diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 43 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 25 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 15 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 27 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 28 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 222 |
7 files changed, 162 insertions, 204 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index a0848cdf0c5..fafdb80be1d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -40,6 +40,49 @@ /* Any negative pid to make it special client */ #define QUOTA_CRAWL_PID "-100" +#define GLUSTERFS_GET_QUOTA_LIMIT_MOUNT_PIDFILE(pidfile, volname) \ + { \ + snprintf(pidfile, PATH_MAX - 1, \ + DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_limit.pid", volname); \ + } + +#define GLUSTERFS_GET_QUOTA_LIST_MOUNT_PIDFILE(pidfile, volname) \ + { \ + snprintf(pidfile, PATH_MAX - 1, \ + DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_list.pid", volname); \ + } + +#define GLUSTERD_GET_QUOTA_CRAWL_PIDDIR(piddir, volinfo, type) \ + do { \ + char _volpath[PATH_MAX] = { \ + 0, \ + }; \ + int32_t _crawl_pid_len; \ + GLUSTERD_GET_VOLUME_DIR(_volpath, volinfo, priv); \ + if (type == GF_QUOTA_OPTION_TYPE_ENABLE || \ + type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS) \ + _crawl_pid_len = snprintf(piddir, PATH_MAX, "%s/run/quota/enable", \ + _volpath); \ + else \ + _crawl_pid_len = snprintf(piddir, PATH_MAX, \ + "%s/run/quota/disable", _volpath); \ + if ((_crawl_pid_len < 0) || (_crawl_pid_len >= PATH_MAX)) { \ + piddir[0] = 0; \ + } \ + } while (0) + +#define GLUSTERD_GET_TMP_PATH(abspath, path) \ + do { \ + snprintf(abspath, sizeof(abspath) - 1, \ + DEFAULT_VAR_RUN_DIRECTORY "/tmp%s", path); \ + } while (0) + +#define GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH(abspath, volname, path) \ + do { \ + snprintf(abspath, sizeof(abspath) - 1, \ + DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_list%s", volname, path); \ + } while (0) + const char *gd_quota_op_list[GF_QUOTA_OPTION_TYPE_MAX + 1] = { [GF_QUOTA_OPTION_TYPE_NONE] = "none", [GF_QUOTA_OPTION_TYPE_ENABLE] = "enable", diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index 74105a60df5..ca408856c23 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -34,6 +34,31 @@ #include "cli1-xdr.h" #include "xdr-generic.h" +#define GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(path, volinfo, priv) \ + do { \ + char defrag_path[PATH_MAX]; \ + int32_t _sockfile_old_len; \ + GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ + _sockfile_old_len = snprintf(path, PATH_MAX, "%s/%s.sock", \ + defrag_path, uuid_utoa(MY_UUID)); \ + if ((_sockfile_old_len < 0) || (_sockfile_old_len >= PATH_MAX)) { \ + path[0] = 0; \ + } \ + } while (0) + +#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) \ + do { \ + int32_t _defrag_sockfile_len; \ + _defrag_sockfile_len = snprintf( \ + path, UNIX_PATH_MAX, \ + DEFAULT_VAR_RUN_DIRECTORY "/gluster-%s-%s.sock", "rebalance", \ + uuid_utoa(volinfo->volume_id)); \ + if ((_defrag_sockfile_len < 0) || \ + (_defrag_sockfile_len >= PATH_MAX)) { \ + path[0] = 0; \ + } \ + } while (0) + int32_t glusterd_brick_op_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe); diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index ab0544310db..95b68f0b506 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -27,6 +27,12 @@ #define SERVER_PATH_MAX (16 * 1024) +#define GLUSTERD_STACK_DESTROY(frame) \ + do { \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + } while (0) + extern glusterd_op_info_t opinfo; extern uuid_t global_txn_id; diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index e8e342b6f6c..f1fc06b3500 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -62,6 +62,21 @@ #include <glusterfs/lvm-defaults.h> #include <glusterfs/events.h> +#define GLUSTERD_GET_UUID_NOHYPHEN(ret_string, uuid) \ + do { \ + char *snap_volname_ptr = ret_string; \ + char tmp_uuid[64]; \ + char *snap_volid_ptr = uuid_utoa_r(uuid, tmp_uuid); \ + while (*snap_volid_ptr) { \ + if (*snap_volid_ptr == '-') { \ + snap_volid_ptr++; \ + } else { \ + (*snap_volname_ptr++) = (*snap_volid_ptr++); \ + } \ + } \ + *snap_volname_ptr = '\0'; \ + } while (0) + char snap_mount_dir[VALID_GLUSTERD_PATHMAX]; struct snap_create_args_ { xlator_t *this; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 708b0977900..fc0df1155a9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -48,6 +48,33 @@ #include "mntent_compat.h" #endif +#define GLUSTERD_GET_SNAP_DIR(path, snap, priv) \ + do { \ + int32_t _snap_dir_len; \ + _snap_dir_len = snprintf(path, PATH_MAX, "%s/snaps/%s", priv->workdir, \ + snap->snapname); \ + if ((_snap_dir_len < 0) || (_snap_dir_len >= PATH_MAX)) { \ + path[0] = 0; \ + } \ + } while (0) + +#define GLUSTERD_GET_BRICK_DIR(path, volinfo, priv) \ + do { \ + int32_t _brick_len; \ + if (volinfo->is_snap_volume) { \ + _brick_len = snprintf(path, PATH_MAX, "%s/snaps/%s/%s/%s", \ + priv->workdir, volinfo->snapshot->snapname, \ + volinfo->volname, GLUSTERD_BRICK_INFO_DIR); \ + } else { \ + _brick_len = snprintf(path, PATH_MAX, "%s/%s/%s/%s", \ + priv->workdir, GLUSTERD_VOLUME_DIR_PREFIX, \ + volinfo->volname, GLUSTERD_BRICK_INFO_DIR); \ + } \ + if ((_brick_len < 0) || (_brick_len >= PATH_MAX)) { \ + path[0] = 0; \ + } \ + } while (0) + void glusterd_replace_slash_with_hyphen(char *str) { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 4a8cadee0ab..82a6ca0aaee 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -91,6 +91,26 @@ #define NLMV4_VERSION 4 #define NLMV1_VERSION 1 +#define GLUSTERD_GET_NFS_PIDFILE(pidfile, priv) \ + do { \ + int32_t _nfs_pid_len; \ + _nfs_pid_len = snprintf(pidfile, PATH_MAX, "%s/nfs/nfs.pid", \ + priv->rundir); \ + if ((_nfs_pid_len < 0) || (_nfs_pid_len >= PATH_MAX)) { \ + pidfile[0] = 0; \ + } \ + } while (0) + +#define GLUSTERD_GET_QUOTAD_PIDFILE(pidfile, priv) \ + do { \ + int32_t _quotad_pid_len; \ + _quotad_pid_len = snprintf(pidfile, PATH_MAX, "%s/quotad/quotad.pid", \ + priv->rundir); \ + if ((_quotad_pid_len < 0) || (_quotad_pid_len >= PATH_MAX)) { \ + pidfile[0] = 0; \ + } \ + } while (0) + gf_boolean_t is_brick_mx_enabled(void) { @@ -8443,7 +8463,6 @@ glusterd_nfs_statedump(char *options, int option_cnt, char **op_errstr) xlator_t *this = NULL; glusterd_conf_t *conf = NULL; char pidfile_path[PATH_MAX] = ""; - char path[PATH_MAX] = ""; FILE *pidfile = NULL; pid_t pid = -1; char dumpoptions_path[PATH_MAX] = ""; @@ -8472,8 +8491,7 @@ glusterd_nfs_statedump(char *options, int option_cnt, char **op_errstr) goto out; } - GLUSTERD_GET_NFS_DIR(path, conf); - GLUSTERD_GET_NFS_PIDFILE(pidfile_path, path, conf); + GLUSTERD_GET_NFS_PIDFILE(pidfile_path, conf); pidfile = fopen(pidfile_path, "r"); if (!pidfile) { @@ -8574,7 +8592,6 @@ glusterd_quotad_statedump(char *options, int option_cnt, char **op_errstr) xlator_t *this = NULL; glusterd_conf_t *conf = NULL; char pidfile_path[PATH_MAX] = ""; - char path[PATH_MAX] = ""; FILE *pidfile = NULL; pid_t pid = -1; char dumpoptions_path[PATH_MAX] = ""; @@ -8602,8 +8619,7 @@ glusterd_quotad_statedump(char *options, int option_cnt, char **op_errstr) goto out; } - GLUSTERD_GET_QUOTAD_DIR(path, conf); - GLUSTERD_GET_QUOTAD_PIDFILE(pidfile_path, path, conf); + GLUSTERD_GET_QUOTAD_PIDFILE(pidfile_path, conf); pidfile = fopen(pidfile_path, "r"); if (!pidfile) { diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index cf8d0395aa5..575f8c5c1dd 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -656,22 +656,36 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); } \ } while (0) -#define GLUSTERD_GET_SHD_RUNDIR(path, volinfo, priv) \ +#define GLUSTERD_GET_DEFRAG_DIR(path, volinfo, priv) \ do { \ - int32_t _shd_dir_len; \ - _shd_dir_len = snprintf(path, PATH_MAX, "%s/shd/%s", priv->rundir, \ - volinfo->volname); \ - if ((_shd_dir_len < 0) || (_shd_dir_len >= PATH_MAX)) { \ + char vol_path[PATH_MAX]; \ + int32_t _defrag_dir_len; \ + GLUSTERD_GET_VOLUME_DIR(vol_path, volinfo, priv); \ + _defrag_dir_len = snprintf(path, PATH_MAX, "%s/%s", vol_path, \ + "rebalance"); \ + if ((_defrag_dir_len < 0) || (_defrag_dir_len >= PATH_MAX)) { \ path[0] = 0; \ } \ } while (0) -#define GLUSTERD_GET_SHD_PID_FILE(path, volinfo, priv) \ +#define GLUSTERD_GET_DEFRAG_PID_FILE(path, volinfo, priv) \ do { \ - int32_t _shd_pid_len; \ - _shd_pid_len = snprintf(path, PATH_MAX, "%s/shd/%s-shd.pid", \ - priv->rundir, volinfo->volname); \ - if ((_shd_pid_len < 0) || (_shd_pid_len >= PATH_MAX)) { \ + char defrag_path[PATH_MAX]; \ + int32_t _defrag_pidfile_len; \ + GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ + _defrag_pidfile_len = snprintf(path, PATH_MAX, "%s/%s.pid", \ + defrag_path, uuid_utoa(MY_UUID)); \ + if ((_defrag_pidfile_len < 0) || (_defrag_pidfile_len >= PATH_MAX)) { \ + path[0] = 0; \ + } \ + } while (0) + +#define GLUSTERD_GET_SHD_RUNDIR(path, volinfo, priv) \ + do { \ + int32_t _shd_dir_len; \ + _shd_dir_len = snprintf(path, PATH_MAX, "%s/shd/%s", priv->rundir, \ + volinfo->volname); \ + if ((_shd_dir_len < 0) || (_shd_dir_len >= PATH_MAX)) { \ path[0] = 0; \ } \ } while (0) @@ -692,16 +706,6 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); } \ } while (0) -#define GLUSTERD_GET_SNAP_DIR(path, snap, priv) \ - do { \ - int32_t _snap_dir_len; \ - _snap_dir_len = snprintf(path, PATH_MAX, "%s/snaps/%s", priv->workdir, \ - snap->snapname); \ - if ((_snap_dir_len < 0) || (_snap_dir_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - #define GLUSTERD_GET_SNAP_GEO_REP_DIR(path, snap, priv) \ do { \ int32_t _snap_geo_len; \ @@ -712,42 +716,6 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); } \ } while (0) -#define GLUSTERD_GET_BRICK_DIR(path, volinfo, priv) \ - do { \ - int32_t _brick_len; \ - if (volinfo->is_snap_volume) { \ - _brick_len = snprintf(path, PATH_MAX, "%s/snaps/%s/%s/%s", \ - priv->workdir, volinfo->snapshot->snapname, \ - volinfo->volname, GLUSTERD_BRICK_INFO_DIR); \ - } else { \ - _brick_len = snprintf(path, PATH_MAX, "%s/%s/%s/%s", \ - priv->workdir, GLUSTERD_VOLUME_DIR_PREFIX, \ - volinfo->volname, GLUSTERD_BRICK_INFO_DIR); \ - } \ - if ((_brick_len < 0) || (_brick_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_NFS_DIR(path, priv) \ - do { \ - int32_t _nfs_dir_len; \ - _nfs_dir_len = snprintf(path, PATH_MAX, "%s/nfs", priv->workdir); \ - if ((_nfs_dir_len < 0) || (_nfs_dir_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_QUOTAD_DIR(path, priv) \ - do { \ - int32_t _quotad_dir_len; \ - _quotad_dir_len = snprintf(path, PATH_MAX, "%s/quotad", \ - priv->workdir); \ - if ((_quotad_dir_len < 0) || (_quotad_dir_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - #define GLUSTERD_GET_QUOTA_LIMIT_MOUNT_PATH(abspath, volname, path) \ do { \ snprintf(abspath, sizeof(abspath) - 1, \ @@ -755,18 +723,6 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); path); \ } while (0) -#define GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH(abspath, volname, path) \ - do { \ - snprintf(abspath, sizeof(abspath) - 1, \ - DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_list%s", volname, path); \ - } while (0) - -#define GLUSTERD_GET_TMP_PATH(abspath, path) \ - do { \ - snprintf(abspath, sizeof(abspath) - 1, \ - DEFAULT_VAR_RUN_DIRECTORY "/tmp%s", path); \ - } while (0) - #define GLUSTERD_REMOVE_SLASH_FROM_PATH(path, string) \ do { \ int i = 0; \ @@ -795,136 +751,6 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); } \ } while (0) -#define GLUSTERD_GET_NFS_PIDFILE(pidfile, nfspath, priv) \ - do { \ - int32_t _nfs_pid_len; \ - _nfs_pid_len = snprintf(pidfile, PATH_MAX, "%s/nfs/nfs.pid", \ - priv->rundir); \ - if ((_nfs_pid_len < 0) || (_nfs_pid_len >= PATH_MAX)) { \ - pidfile[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_QUOTAD_PIDFILE(pidfile, quotadpath, priv) \ - do { \ - int32_t _quotad_pid_len; \ - _quotad_pid_len = snprintf(pidfile, PATH_MAX, "%s/quotad/quotad.pid", \ - priv->rundir); \ - if ((_quotad_pid_len < 0) || (_quotad_pid_len >= PATH_MAX)) { \ - pidfile[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_QUOTA_CRAWL_PIDDIR(piddir, volinfo, type) \ - do { \ - char _volpath[PATH_MAX] = { \ - 0, \ - }; \ - int32_t _crawl_pid_len; \ - GLUSTERD_GET_VOLUME_DIR(_volpath, volinfo, priv); \ - if (type == GF_QUOTA_OPTION_TYPE_ENABLE || \ - type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS) \ - _crawl_pid_len = snprintf(piddir, PATH_MAX, "%s/run/quota/enable", \ - _volpath); \ - else \ - _crawl_pid_len = snprintf(piddir, PATH_MAX, \ - "%s/run/quota/disable", _volpath); \ - if ((_crawl_pid_len < 0) || (_crawl_pid_len >= PATH_MAX)) { \ - piddir[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_STACK_DESTROY(frame) \ - do { \ - frame->local = NULL; \ - STACK_DESTROY(frame->root); \ - } while (0) - -#define GLUSTERD_GET_DEFRAG_PROCESS(path, volinfo) \ - do { \ - snprintf(path, NAME_MAX, "rebalance"); \ - } while (0) - -#define GLUSTERD_GET_DEFRAG_DIR(path, volinfo, priv) \ - do { \ - char vol_path[PATH_MAX]; \ - char operation[NAME_MAX]; \ - int32_t _defrag_dir_len; \ - GLUSTERD_GET_VOLUME_DIR(vol_path, volinfo, priv); \ - GLUSTERD_GET_DEFRAG_PROCESS(operation, volinfo); \ - _defrag_dir_len = snprintf(path, PATH_MAX, "%s/%s", vol_path, \ - operation); \ - if ((_defrag_dir_len < 0) || (_defrag_dir_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(path, volinfo, priv) \ - do { \ - char defrag_path[PATH_MAX]; \ - int32_t _sockfile_old_len; \ - GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ - _sockfile_old_len = snprintf(path, PATH_MAX, "%s/%s.sock", \ - defrag_path, uuid_utoa(MY_UUID)); \ - if ((_sockfile_old_len < 0) || (_sockfile_old_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) \ - do { \ - char operation[NAME_MAX]; \ - int32_t _defrag_sockfile_len; \ - GLUSTERD_GET_DEFRAG_PROCESS(operation, volinfo); \ - _defrag_sockfile_len = snprintf( \ - path, UNIX_PATH_MAX, \ - DEFAULT_VAR_RUN_DIRECTORY "/gluster-%s-%s.sock", operation, \ - uuid_utoa(volinfo->volume_id)); \ - if ((_defrag_sockfile_len < 0) || \ - (_defrag_sockfile_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERD_GET_DEFRAG_PID_FILE(path, volinfo, priv) \ - do { \ - char defrag_path[PATH_MAX]; \ - int32_t _defrag_pidfile_len; \ - GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ - _defrag_pidfile_len = snprintf(path, PATH_MAX, "%s/%s.pid", \ - defrag_path, uuid_utoa(MY_UUID)); \ - if ((_defrag_pidfile_len < 0) || (_defrag_pidfile_len >= PATH_MAX)) { \ - path[0] = 0; \ - } \ - } while (0) - -#define GLUSTERFS_GET_QUOTA_LIMIT_MOUNT_PIDFILE(pidfile, volname) \ - { \ - snprintf(pidfile, PATH_MAX - 1, \ - DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_limit.pid", volname); \ - } - -#define GLUSTERFS_GET_QUOTA_LIST_MOUNT_PIDFILE(pidfile, volname) \ - { \ - snprintf(pidfile, PATH_MAX - 1, \ - DEFAULT_VAR_RUN_DIRECTORY "/%s_quota_list.pid", volname); \ - } - -#define GLUSTERD_GET_UUID_NOHYPHEN(ret_string, uuid) \ - do { \ - char *snap_volname_ptr = ret_string; \ - char tmp_uuid[64]; \ - char *snap_volid_ptr = uuid_utoa_r(uuid, tmp_uuid); \ - while (*snap_volid_ptr) { \ - if (*snap_volid_ptr == '-') { \ - snap_volid_ptr++; \ - } else { \ - (*snap_volname_ptr++) = (*snap_volid_ptr++); \ - } \ - } \ - *snap_volname_ptr = '\0'; \ - } while (0) - #define RCU_READ_LOCK \ pthread_mutex_lock(&(THIS->ctx)->cleanup_lock); \ { \ |