cli: Cleanup the maintainence mount points used by quota.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2704 (Stale mount-points seen after execting quota list command) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2704
This commit is contained in:
parent
11c2526e04
commit
0a05984fd9
@ -32,7 +32,8 @@
|
|||||||
#include "compat-errno.h"
|
#include "compat-errno.h"
|
||||||
#include "cli-cmd.h"
|
#include "cli-cmd.h"
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include "cli1-xdr.h"
|
#include "cli1-xdr.h"
|
||||||
#include "cli1.h"
|
#include "cli1.h"
|
||||||
#include "protocol-common.h"
|
#include "protocol-common.h"
|
||||||
@ -1308,46 +1309,43 @@ out:
|
|||||||
int32_t
|
int32_t
|
||||||
print_limit_list (char *volname, char *limit_list)
|
print_limit_list (char *volname, char *limit_list)
|
||||||
{
|
{
|
||||||
char mount [1024] = {0, };
|
int64_t size = 0;
|
||||||
char cmd_str [1024] = {0, };
|
int64_t limit_value = 0;
|
||||||
char path [1024] = {0, };
|
int32_t i, j, k;
|
||||||
char ret_str [1024] = {0, };
|
int32_t len = 0, ret = -1;
|
||||||
char value [1024] = {0, };
|
char path [PATH_MAX] = {0, };
|
||||||
char umount_str [1024] = {0, };
|
char ret_str [1024] = {0, };
|
||||||
int64_t size = 0;
|
char value [1024] = {0, };
|
||||||
int64_t limit_value = 0;
|
char mountdir [] = "/tmp/mntXXXXXX";
|
||||||
int32_t i, j, k, len, ret;
|
char cmd_str [PATH_MAX + 1024] = {0, };
|
||||||
|
|
||||||
if (volname == NULL || limit_list == NULL)
|
GF_VALIDATE_OR_GOTO ("cli", volname, out);
|
||||||
return -1;
|
GF_VALIDATE_OR_GOTO ("cli", limit_list, out);
|
||||||
|
|
||||||
snprintf (mount, sizeof (mount), "/etc/glusterd/mountlist/%s", volname);
|
if (mkdtemp (mountdir) == NULL) {
|
||||||
|
gf_log ("cli", GF_LOG_WARNING, "failed to create a temporary "
|
||||||
snprintf (cmd_str, sizeof (cmd_str), "mkdir -p %s", mount);
|
"mount directory");
|
||||||
|
|
||||||
snprintf (umount_str, sizeof (umount_str), "umount %s>>/dev/null 2>&1", mount);
|
|
||||||
system (umount_str);
|
|
||||||
|
|
||||||
ret = system (cmd_str);
|
|
||||||
if (ret) {
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mount a temporary client to fetch the disk usage
|
||||||
|
* of the directory on which the limit is set.
|
||||||
|
*/
|
||||||
snprintf (cmd_str, sizeof (cmd_str), GFS_PREFIX "/sbin/glusterfs -s localhost "
|
snprintf (cmd_str, sizeof (cmd_str), GFS_PREFIX "/sbin/glusterfs -s localhost "
|
||||||
"--volfile-id %s %s", volname, mount);
|
"--volfile-id %s %s", volname, mountdir);
|
||||||
|
|
||||||
ret = system (cmd_str);
|
ret = system (cmd_str);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
gf_log ("cli", GF_LOG_WARNING, "failed to mount glusterfs client");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto rm_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen (limit_list);
|
len = strlen (limit_list);
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
cli_out ("quota limit not set ");
|
cli_out ("quota limit not set ");
|
||||||
goto out;
|
goto unmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -1371,8 +1369,8 @@ print_limit_list (char *volname, char *limit_list)
|
|||||||
}
|
}
|
||||||
value [j] = '\0';
|
value [j] = '\0';
|
||||||
|
|
||||||
memset (&cmd_str, 0, 1024);
|
memset (&cmd_str, 0, sizeof (cmd_str));
|
||||||
snprintf (cmd_str, sizeof (cmd_str), "%s%s", mount, path);
|
snprintf (cmd_str, sizeof (cmd_str), "%s/%s", mountdir, path);
|
||||||
|
|
||||||
ret = getxattr (cmd_str, "trusted.limit.list", (void *) ret_str, 4096);
|
ret = getxattr (cmd_str, "trusted.limit.list", (void *) ret_str, 4096);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1385,9 +1383,18 @@ print_limit_list (char *volname, char *limit_list)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
system (umount_str);
|
|
||||||
|
|
||||||
|
unmount:
|
||||||
|
memset (&cmd_str, 0, sizeof (cmd_str));
|
||||||
|
#if GF_LINUX_HOST_OS
|
||||||
|
snprintf (cmd_str, sizeof (cmd_str), "umount -l %s", mountdir);
|
||||||
|
#else
|
||||||
|
snprintf (cmd_str, sizeof (cmd_str), "umount %s", mountdir);
|
||||||
|
#endif
|
||||||
|
system (cmd_str);
|
||||||
|
rm_dir:
|
||||||
|
rmdir (mountdir);
|
||||||
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user