summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/nfs/server')
-rw-r--r--xlators/nfs/server/src/acl3.c32
-rw-r--r--xlators/nfs/server/src/acl3.h2
-rw-r--r--xlators/nfs/server/src/auth-cache.c13
-rw-r--r--xlators/nfs/server/src/exports.c9
-rw-r--r--xlators/nfs/server/src/mount3.c72
-rw-r--r--xlators/nfs/server/src/mount3udp_svc.c6
-rw-r--r--xlators/nfs/server/src/nfs-common.c5
-rw-r--r--xlators/nfs/server/src/nfs-fops.c2
-rw-r--r--xlators/nfs/server/src/nfs.c34
-rw-r--r--xlators/nfs/server/src/nfs3-fh.c6
-rw-r--r--xlators/nfs/server/src/nfs3-helpers.c4
-rw-r--r--xlators/nfs/server/src/nfs3.c54
-rw-r--r--xlators/nfs/server/src/nlm4.c84
-rw-r--r--xlators/nfs/server/src/nlmcbk_svc.c5
14 files changed, 196 insertions, 132 deletions
diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c
index 0eca45d8a3e..7e3bbf16086 100644
--- a/xlators/nfs/server/src/acl3.c
+++ b/xlators/nfs/server/src/acl3.c
@@ -571,6 +571,12 @@ acl3_setacl_resume(void *carg)
acl3_check_fh_resolve_status(cs, stat, acl3err);
nfs_request_user_init(&nfu, cs->req);
xattr = dict_new();
+ if (xattr == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto acl3err;
+ }
+
if (cs->aclcount)
ret = dict_set_static_bin(xattr, POSIX_ACL_ACCESS_XATTR, cs->aclxattr,
posix_acl_xattr_size(cs->aclcount));
@@ -701,13 +707,13 @@ rpcerr:
return ret;
}
-rpcsvc_actor_t acl3svc_actors[ACL3_PROC_COUNT] = {
- {"NULL", ACL3_NULL, acl3svc_null, NULL, 0, DRC_NA},
- {"GETACL", ACL3_GETACL, acl3svc_getacl, NULL, 0, DRC_NA},
- {"SETACL", ACL3_SETACL, acl3svc_setacl, NULL, 0, DRC_NA},
+static rpcsvc_actor_t acl3svc_actors[ACL3_PROC_COUNT] = {
+ {"NULL", acl3svc_null, NULL, ACL3_NULL, DRC_NA, 0},
+ {"GETACL", acl3svc_getacl, NULL, ACL3_GETACL, DRC_NA, 0},
+ {"SETACL", acl3svc_setacl, NULL, ACL3_SETACL, DRC_NA, 0},
};
-rpcsvc_program_t acl3prog = {
+static rpcsvc_program_t acl3prog = {
.progname = "ACL3",
.prognum = ACL_PROGRAM,
.progver = ACLV3_VERSION,
@@ -724,7 +730,6 @@ acl3svc_init(xlator_t *nfsx)
struct nfs_state *nfs = NULL;
dict_t *options = NULL;
int ret = -1;
- char *portstr = NULL;
static gf_boolean_t acl3_inited = _gf_false;
/* Already inited */
@@ -742,12 +747,13 @@ acl3svc_init(xlator_t *nfsx)
acl3prog.private = ns;
options = dict_new();
-
- ret = gf_asprintf(&portstr, "%d", GF_ACL3_PORT);
- if (ret == -1)
+ if (options == NULL) {
+ gf_msg(GF_ACL, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
goto err;
+ }
- ret = dict_set_dynstr(options, "transport.socket.listen-port", portstr);
+ ret = dict_set_str(options, "transport.socket.listen-port", GF_ACL3_PORT);
if (ret == -1)
goto err;
ret = dict_set_str(options, "transport-type", "socket");
@@ -783,13 +789,17 @@ acl3svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
+ if (options)
+ dict_unref(options);
+
acl3_inited = _gf_true;
return &acl3prog;
err:
+ if (options)
+ dict_unref(options);
return NULL;
}
diff --git a/xlators/nfs/server/src/acl3.h b/xlators/nfs/server/src/acl3.h
index dead04b4273..762fbb04a0f 100644
--- a/xlators/nfs/server/src/acl3.h
+++ b/xlators/nfs/server/src/acl3.h
@@ -18,7 +18,7 @@
#define ACL3_SETACL 2
#define ACL3_PROC_COUNT 3
-#define GF_ACL3_PORT 38469
+#define GF_ACL3_PORT "38469"
#define GF_ACL GF_NFS "-ACL"
/* Flags for the getacl/setacl mode */
diff --git a/xlators/nfs/server/src/auth-cache.c b/xlators/nfs/server/src/auth-cache.c
index f8e5061dc54..ffbf5b6cad6 100644
--- a/xlators/nfs/server/src/auth-cache.c
+++ b/xlators/nfs/server/src/auth-cache.c
@@ -40,16 +40,12 @@ make_hashkey(struct nfs3_fh *fh, const char *host)
char exportid[256] = {
0,
};
- char gfid[256] = {
- 0,
- };
char mountid[256] = {
0,
};
size_t nbytes = 0;
gf_uuid_unparse(fh->exportid, exportid);
- gf_uuid_unparse(fh->gfid, gfid);
gf_uuid_unparse(fh->mountid, mountid);
nbytes = strlen(exportid) + strlen(host) + strlen(mountid) + 3;
@@ -145,7 +141,7 @@ auth_cache_add(struct auth_cache *cache, char *hashkey,
{
int ret = -1;
data_t *entry_data = NULL;
-
+ int hashkey_len;
GF_VALIDATE_OR_GOTO(GF_NFS, cache, out);
GF_VALIDATE_OR_GOTO(GF_NFS, cache->cache_dict, out);
@@ -168,9 +164,10 @@ auth_cache_add(struct auth_cache *cache, char *hashkey,
* auth_cache_entry is released */
entry->data = data_ref(entry_data);
+ hashkey_len = strlen(hashkey);
LOCK(&cache->lock);
{
- ret = dict_set(cache->cache_dict, hashkey, entry_data);
+ ret = dict_setn(cache->cache_dict, hashkey, hashkey_len, entry_data);
}
UNLOCK(&cache->lock);
@@ -192,7 +189,7 @@ out:
static int
_auth_cache_expired(struct auth_cache *cache, struct auth_cache_entry *entry)
{
- return ((time(NULL) - entry->timestamp) > cache->ttl_sec);
+ return ((gf_time() - entry->timestamp) > cache->ttl_sec);
}
/**
@@ -477,7 +474,7 @@ cache_nfs_fh(struct auth_cache *cache, struct nfs3_fh *fh,
goto out;
}
- entry->timestamp = time(NULL);
+ entry->timestamp = gf_time();
/* Update entry->item if it is pointing to a different export_item */
if (entry->item && entry->item != export_item) {
GF_REF_PUT(entry->item);
diff --git a/xlators/nfs/server/src/exports.c b/xlators/nfs/server/src/exports.c
index c62e2d9a625..d7e39934851 100644
--- a/xlators/nfs/server/src/exports.c
+++ b/xlators/nfs/server/src/exports.c
@@ -647,6 +647,7 @@ __exp_line_opt_parse(const char *opt_str, struct export_options **exp_opts)
if (!opts) {
ret = -ENOMEM;
parser_unset_string(options_parser);
+ GF_FREE(strmatch);
goto out;
}
}
@@ -677,7 +678,7 @@ __exp_line_opt_parse(const char *opt_str, struct export_options **exp_opts)
_export_options_deinit(opts);
goto out;
}
- } else
+ } else {
/* Cannot change to gf_msg.
* gf_msg not giving output to STDOUT
* Bug id : BZ1215017
@@ -686,6 +687,7 @@ __exp_line_opt_parse(const char *opt_str, struct export_options **exp_opts)
"Could not find any valid options for "
"string: %s",
strmatch);
+ }
GF_FREE(strmatch);
}
@@ -1448,7 +1450,7 @@ exp_file_parse(const char *filepath, struct exports_file **expfile,
GF_CHECK_ALLOC_AND_LOG(GF_EXP, file, ret,
"Allocation error while "
"allocating file struct",
- parse_done);
+ free_and_done);
file->filename = gf_strdup(filepath);
GF_CHECK_ALLOC_AND_LOG(GF_EXP, file, ret,
@@ -1470,7 +1472,8 @@ exp_file_parse(const char *filepath, struct exports_file **expfile,
goto parse_done;
free_and_done:
- exp_file_deinit(file);
+ if (file)
+ exp_file_deinit(file);
_export_dir_deinit(expdir);
parse_done:
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 726dc293af6..a34d9104c17 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -920,14 +920,11 @@ mnt3svc_volume_mount(rpcsvc_request_t *req, struct mount3_state *ms,
{
inode_t *exportinode = NULL;
int ret = -EFAULT;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if ((!req) || (!exp) || (!ms))
return ret;
- rootgfid[15] = 1;
exportinode = inode_find(exp->vol->itable, rootgfid);
if (!exportinode) {
gf_msg(GF_MNT, GF_LOG_ERROR, ENOENT, NFS_MSG_GET_ROOT_INODE_FAIL,
@@ -1372,9 +1369,7 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres)
nfs_user_t nfu = {
0,
};
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if (!mres)
return ret;
@@ -1385,7 +1380,6 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres)
if (!firstcomp)
goto err;
- rootgfid[15] = 1;
ret = nfs_entry_loc_fill(mres->mstate->nfsx, mres->exp->vol->itable,
rootgfid, firstcomp, &mres->resolveloc,
NFS_RESOLVE_CREATE, NULL);
@@ -2337,7 +2331,7 @@ __build_mountlist(struct mount3_state *ms, int *count)
goto free_list;
}
- strcat(mlist->ml_hostname, me->hostname);
+ strcpy(mlist->ml_hostname, me->hostname);
gf_msg_debug(GF_MNT, 0, "mount entry: dir: %s, host: %s",
mlist->ml_directory, mlist->ml_hostname);
@@ -3205,6 +3199,12 @@ mnt3_export_parse_auth_param(struct mnt3_export *exp, char *exportpath)
struct host_auth_spec *host = NULL;
int ret = 0;
+ if (exportpath == NULL) {
+ gf_msg(GF_MNT, GF_LOG_ERROR, EINVAL, NFS_MSG_PARSE_HOSTSPEC_FAIL,
+ "Export path is NULL");
+ return -1;
+ }
+
/* Using exportpath directly in strtok_r because we want
* to strip off AUTH parameter from exportpath. */
token = strtok_r(exportpath, "(", &savPtr);
@@ -3656,20 +3656,26 @@ out:
return ret;
}
-rpcsvc_actor_t mnt3svc_actors[MOUNT3_PROC_COUNT] = {
- {"NULL", MOUNT3_NULL, mnt3svc_null, NULL, 0, DRC_NA},
- {"MNT", MOUNT3_MNT, mnt3svc_mnt, NULL, 0, DRC_NA},
- {"DUMP", MOUNT3_DUMP, mnt3svc_dump, NULL, 0, DRC_NA},
- {"UMNT", MOUNT3_UMNT, mnt3svc_umnt, NULL, 0, DRC_NA},
- {"UMNTALL", MOUNT3_UMNTALL, mnt3svc_umntall, NULL, 0, DRC_NA},
- {"EXPORT", MOUNT3_EXPORT, mnt3svc_export, NULL, 0, DRC_NA}};
+static rpcsvc_actor_t mnt3svc_actors[MOUNT3_PROC_COUNT] = {
+ {
+ "NULL",
+ mnt3svc_null,
+ NULL,
+ MOUNT3_NULL,
+ DRC_NA,
+ },
+ {"MNT", mnt3svc_mnt, NULL, MOUNT3_MNT, DRC_NA, 0},
+ {"DUMP", mnt3svc_dump, NULL, MOUNT3_DUMP, DRC_NA, 0},
+ {"UMNT", mnt3svc_umnt, NULL, MOUNT3_UMNT, DRC_NA, 0},
+ {"UMNTALL", mnt3svc_umntall, NULL, MOUNT3_UMNTALL, DRC_NA, 0},
+ {"EXPORT", mnt3svc_export, NULL, MOUNT3_EXPORT, DRC_NA, 0}};
/* Static init parts are assigned here, dynamic ones are done in
* mnt3svc_init and mnt3_init_state.
* Making MOUNT3 a synctask so that the blocking DNS calls during rpc auth
* gets offloaded to syncenv, keeping the main/poll thread unblocked
*/
-rpcsvc_program_t mnt3prog = {
+static rpcsvc_program_t mnt3prog = {
.progname = "MOUNT3",
.prognum = MOUNT_PROGRAM,
.progver = MOUNT_V3,
@@ -4056,6 +4062,11 @@ mnt3svc_init(xlator_t *nfsx)
mnt3prog.private = mstate;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_MOUNTV3_PORT);
if (ret == -1)
@@ -4091,7 +4102,6 @@ mnt3svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
@@ -4102,20 +4112,25 @@ mnt3svc_init(xlator_t *nfsx)
gf_msg_debug(GF_MNT, GF_LOG_DEBUG, "Thread creation failed");
}
}
+ if (options)
+ dict_unref(options);
+
return &mnt3prog;
err:
+ if (options)
+ dict_unref(options);
return NULL;
}
-rpcsvc_actor_t mnt1svc_actors[MOUNT1_PROC_COUNT] = {
- {"NULL", MOUNT1_NULL, mnt3svc_null, NULL, 0, DRC_NA},
- {"MNT", MOUNT1_MNT, NULL, NULL, 0, DRC_NA},
- {"DUMP", MOUNT1_DUMP, mnt3svc_dump, NULL, 0, DRC_NA},
- {"UMNT", MOUNT1_UMNT, mnt3svc_umnt, NULL, 0, DRC_NA},
- {"UMNTALL", MOUNT1_UMNTALL, NULL, NULL, 0, DRC_NA},
- {"EXPORT", MOUNT1_EXPORT, mnt3svc_export, NULL, 0, DRC_NA}};
+static rpcsvc_actor_t mnt1svc_actors[MOUNT1_PROC_COUNT] = {
+ {"NULL", mnt3svc_null, NULL, MOUNT1_NULL, DRC_NA, 0},
+ {"MNT", NULL, NULL, MOUNT1_MNT, DRC_NA, 0},
+ {"DUMP", mnt3svc_dump, NULL, MOUNT1_DUMP, DRC_NA, 0},
+ {"UMNT", mnt3svc_umnt, NULL, MOUNT1_UMNT, DRC_NA, 0},
+ {"UMNTALL", NULL, NULL, MOUNT1_UMNTALL, DRC_NA, 0},
+ {"EXPORT", mnt3svc_export, NULL, MOUNT1_EXPORT, DRC_NA, 0}};
-rpcsvc_program_t mnt1prog = {
+static rpcsvc_program_t mnt1prog = {
.progname = "MOUNT1",
.prognum = MOUNT_PROGRAM,
.progver = MOUNT_V1,
@@ -4151,6 +4166,11 @@ mnt1svc_init(xlator_t *nfsx)
mnt1prog.private = mstate;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_MOUNTV1_PORT);
if (ret == -1)
diff --git a/xlators/nfs/server/src/mount3udp_svc.c b/xlators/nfs/server/src/mount3udp_svc.c
index d5e41691f3d..1a2b0f85453 100644
--- a/xlators/nfs/server/src/mount3udp_svc.c
+++ b/xlators/nfs/server/src/mount3udp_svc.c
@@ -216,11 +216,7 @@ mount3udp_thread(void *argv)
GF_ASSERT(nfsx);
- if (glusterfs_this_set(nfsx)) {
- gf_msg(GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_XLATOR_SET_FAIL,
- "Failed to set xlator, nfs.mount-udp will not work");
- return NULL;
- }
+ THIS = nfsx;
transp = svcudp_create(RPC_ANYSOCK);
if (transp == NULL) {
diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c
index 5b3ee976e37..b8f6b6f318e 100644
--- a/xlators/nfs/server/src/nfs-common.c
+++ b/xlators/nfs/server/src/nfs-common.c
@@ -272,11 +272,8 @@ err:
int
nfs_root_loc_fill(inode_table_t *itable, loc_t *loc)
{
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- rootgfid[15] = 1;
return nfs_gfid_loc_fill(itable, rootgfid, loc, NFS_RESOLVE_EXIST);
}
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index 896c67c9305..4d8540c2c3e 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -327,7 +327,7 @@ nfs_gfid_dict(inode_t *inode)
unsigned char *dyngfid = NULL;
dict_t *dictgfid = NULL;
int ret = -1;
- uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
dyngfid = GF_MALLOC(sizeof(uuid_t), gf_common_mt_char);
if (dyngfid == NULL)
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index ebded415c38..39b73f88ac3 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -31,6 +31,7 @@
#include <glusterfs/syscall.h>
#include "rpcsvc.h"
#include "nfs-messages.h"
+#include "glusterfs/statedump.h"
#define OPT_SERVER_AUX_GIDS "nfs.server-aux-gids"
#define OPT_SERVER_GID_CACHE_TIMEOUT "nfs.server.aux-gid-timeout"
@@ -1114,7 +1115,7 @@ nfs_init_state(xlator_t *this)
GF_OPTION_INIT("nfs.event-threads", nfs->event_threads, uint32,
free_foppool);
- event_reconfigure_threads(this->ctx->event_pool, nfs->event_threads);
+ gf_event_reconfigure_threads(this->ctx->event_pool, nfs->event_threads);
this->private = (void *)nfs;
INIT_LIST_HEAD(&nfs->versions);
@@ -1156,7 +1157,7 @@ out:
return ret;
}
-int
+static int
nfs_reconfigure_state(xlator_t *this, dict_t *options)
{
int ret = 0;
@@ -1166,8 +1167,8 @@ nfs_reconfigure_state(xlator_t *this, dict_t *options)
gf_boolean_t optbool;
uint32_t optuint32;
struct nfs_state *nfs = NULL;
- char *blacklist_keys[] = {"nfs.port", "nfs.transport-type",
- "nfs.mem-factor", NULL};
+ static char *options_require_restart[] = {"nfs.port", "nfs.transport-type",
+ "nfs.mem-factor", NULL};
GF_VALIDATE_OR_GOTO(GF_NFS, this, out);
GF_VALIDATE_OR_GOTO(GF_NFS, this->private, out);
@@ -1175,14 +1176,14 @@ nfs_reconfigure_state(xlator_t *this, dict_t *options)
nfs = (struct nfs_state *)this->private;
- /* Black listed options can't be reconfigured, they need
+ /* Some listed options can't be reconfigured, they need
* NFS to be restarted. There are two cases 1. SET 2. UNSET.
* 1. SET */
- while (blacklist_keys[keyindx]) {
- if (dict_get(options, blacklist_keys[keyindx])) {
+ while (options_require_restart[keyindx]) {
+ if (dict_get(options, options_require_restart[keyindx])) {
gf_msg(GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL,
"Reconfiguring %s needs NFS restart",
- blacklist_keys[keyindx]);
+ options_require_restart[keyindx]);
goto out;
}
keyindx++;
@@ -1337,7 +1338,7 @@ nfs_reconfigure_state(xlator_t *this, dict_t *options)
GF_OPTION_RECONF("nfs.event-threads", nfs->event_threads, options, uint32,
out);
- event_reconfigure_threads(this->ctx->event_pool, nfs->event_threads);
+ gf_event_reconfigure_threads(this->ctx->event_pool, nfs->event_threads);
ret = 0;
out:
@@ -1667,6 +1668,20 @@ out:
return ret;
}
+int32_t
+nfs_itable_dump(xlator_t *this)
+{
+ if (!this)
+ return -1;
+
+ if (this->next && this->next->itable) {
+ gf_proc_dump_add_section("xlator.nfs.itable");
+ inode_table_dump(this->next->itable, "xlator.nfs.itable");
+ }
+
+ return 0;
+}
+
struct xlator_cbks cbks = {
.forget = nfs_forget,
};
@@ -1676,6 +1691,7 @@ struct xlator_fops fops;
struct xlator_dumpops dumpops = {
.priv = nfs_priv,
.priv_to_dict = nfs_priv_to_dict,
+ .inode = nfs_itable_dump,
};
/* TODO: If needed, per-volume options below can be extended to be export
diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c
index d0c0a2f55b2..caa3cfa6995 100644
--- a/xlators/nfs/server/src/nfs3-fh.c
+++ b/xlators/nfs/server/src/nfs3-fh.c
@@ -64,7 +64,7 @@ nfs3_fh_build_indexed_root_fh(xlator_list_t *cl, xlator_t *xl)
struct iatt buf = {
0,
};
- uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if ((!cl) || (!xl))
return fh;
@@ -85,7 +85,7 @@ nfs3_fh_build_uuid_root_fh(uuid_t volumeid, uuid_t mountid)
struct iatt buf = {
0,
};
- uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
gf_uuid_copy(buf.ia_gfid, root);
nfs3_fh_init(&fh, &buf);
@@ -98,7 +98,7 @@ nfs3_fh_build_uuid_root_fh(uuid_t volumeid, uuid_t mountid)
int
nfs3_fh_is_root_fh(struct nfs3_fh *fh)
{
- uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if (!fh)
return 0;
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 8a58977b53c..897fb42b071 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -1072,7 +1072,7 @@ nfs3_sattr3_to_setattr_valid(sattr3 *sattr, struct iatt *buf, mode_t *omode)
if (sattr->atime.set_it == SET_TO_SERVER_TIME) {
valid |= GF_SET_ATTR_ATIME;
if (buf)
- buf->ia_atime = time(NULL);
+ buf->ia_atime = gf_time();
}
if (sattr->mtime.set_it == SET_TO_CLIENT_TIME) {
@@ -1084,7 +1084,7 @@ nfs3_sattr3_to_setattr_valid(sattr3 *sattr, struct iatt *buf, mode_t *omode)
if (sattr->mtime.set_it == SET_TO_SERVER_TIME) {
valid |= GF_SET_ATTR_MTIME;
if (buf)
- buf->ia_mtime = time(NULL);
+ buf->ia_mtime = gf_time();
}
return valid;
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index e2dd5f4bfe8..f9042bc3b3f 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -5192,32 +5192,32 @@ rpcerr:
return ret;
}
-rpcsvc_actor_t nfs3svc_actors[NFS3_PROC_COUNT] = {
- {"NULL", NFS3_NULL, nfs3svc_null, NULL, 0, DRC_IDEMPOTENT},
- {"GETATTR", NFS3_GETATTR, nfs3svc_getattr, NULL, 0, DRC_IDEMPOTENT},
- {"SETATTR", NFS3_SETATTR, nfs3svc_setattr, NULL, 0, DRC_NON_IDEMPOTENT},
- {"LOOKUP", NFS3_LOOKUP, nfs3svc_lookup, NULL, 0, DRC_IDEMPOTENT},
- {"ACCESS", NFS3_ACCESS, nfs3svc_access, NULL, 0, DRC_IDEMPOTENT},
- {"READLINK", NFS3_READLINK, nfs3svc_readlink, NULL, 0, DRC_IDEMPOTENT},
- {"READ", NFS3_READ, nfs3svc_read, NULL, 0, DRC_IDEMPOTENT},
- {"WRITE", NFS3_WRITE, nfs3svc_write, nfs3svc_write_vecsizer, 0,
- DRC_NON_IDEMPOTENT},
- {"CREATE", NFS3_CREATE, nfs3svc_create, NULL, 0, DRC_NON_IDEMPOTENT},
- {"MKDIR", NFS3_MKDIR, nfs3svc_mkdir, NULL, 0, DRC_NON_IDEMPOTENT},
- {"SYMLINK", NFS3_SYMLINK, nfs3svc_symlink, NULL, 0, DRC_NON_IDEMPOTENT},
- {"MKNOD", NFS3_MKNOD, nfs3svc_mknod, NULL, 0, DRC_NON_IDEMPOTENT},
- {"REMOVE", NFS3_REMOVE, nfs3svc_remove, NULL, 0, DRC_NON_IDEMPOTENT},
- {"RMDIR", NFS3_RMDIR, nfs3svc_rmdir, NULL, 0, DRC_NON_IDEMPOTENT},
- {"RENAME", NFS3_RENAME, nfs3svc_rename, NULL, 0, DRC_NON_IDEMPOTENT},
- {"LINK", NFS3_LINK, nfs3svc_link, NULL, 0, DRC_NON_IDEMPOTENT},
- {"READDIR", NFS3_READDIR, nfs3svc_readdir, NULL, 0, DRC_IDEMPOTENT},
- {"READDIRPLUS", NFS3_READDIRP, nfs3svc_readdirp, NULL, 0, DRC_IDEMPOTENT},
- {"FSSTAT", NFS3_FSSTAT, nfs3svc_fsstat, NULL, 0, DRC_IDEMPOTENT},
- {"FSINFO", NFS3_FSINFO, nfs3svc_fsinfo, NULL, 0, DRC_IDEMPOTENT},
- {"PATHCONF", NFS3_PATHCONF, nfs3svc_pathconf, NULL, 0, DRC_IDEMPOTENT},
- {"COMMIT", NFS3_COMMIT, nfs3svc_commit, NULL, 0, DRC_IDEMPOTENT}};
-
-rpcsvc_program_t nfs3prog = {
+static rpcsvc_actor_t nfs3svc_actors[NFS3_PROC_COUNT] = {
+ {"NULL", nfs3svc_null, NULL, NFS3_NULL, DRC_IDEMPOTENT, 0},
+ {"GETATTR", nfs3svc_getattr, NULL, NFS3_GETATTR, DRC_IDEMPOTENT, 0},
+ {"SETATTR", nfs3svc_setattr, NULL, NFS3_SETATTR, DRC_NON_IDEMPOTENT, 0},
+ {"LOOKUP", nfs3svc_lookup, NULL, NFS3_LOOKUP, DRC_IDEMPOTENT, 0},
+ {"ACCESS", nfs3svc_access, NULL, NFS3_ACCESS, DRC_IDEMPOTENT, 0},
+ {"READLINK", nfs3svc_readlink, NULL, NFS3_READLINK, DRC_IDEMPOTENT, 0},
+ {"READ", nfs3svc_read, NULL, NFS3_READ, DRC_IDEMPOTENT, 0},
+ {"WRITE", nfs3svc_write, nfs3svc_write_vecsizer, NFS3_WRITE, DRC_IDEMPOTENT,
+ 0},
+ {"CREATE", nfs3svc_create, NULL, NFS3_CREATE, DRC_NON_IDEMPOTENT, 0},
+ {"MKDIR", nfs3svc_mkdir, NULL, NFS3_MKDIR, DRC_NON_IDEMPOTENT, 0},
+ {"SYMLINK", nfs3svc_symlink, NULL, NFS3_SYMLINK, DRC_NON_IDEMPOTENT, 0},
+ {"MKNOD", nfs3svc_mknod, NULL, NFS3_MKNOD, DRC_NON_IDEMPOTENT, 0},
+ {"REMOVE", nfs3svc_remove, NULL, NFS3_REMOVE, DRC_NON_IDEMPOTENT, 0},
+ {"RMDIR", nfs3svc_rmdir, NULL, NFS3_RMDIR, DRC_NON_IDEMPOTENT, 0},
+ {"RENAME", nfs3svc_rename, NULL, NFS3_RENAME, DRC_NON_IDEMPOTENT, 0},
+ {"LINK", nfs3svc_link, NULL, NFS3_LINK, DRC_NON_IDEMPOTENT, 0},
+ {"READDIR", nfs3svc_readdir, NULL, NFS3_READDIR, DRC_IDEMPOTENT, 0},
+ {"READDIRPLUS", nfs3svc_readdirp, NULL, NFS3_READDIRP, DRC_IDEMPOTENT, 0},
+ {"FSSTAT", nfs3svc_fsstat, NULL, NFS3_FSSTAT, DRC_IDEMPOTENT, 0},
+ {"FSINFO", nfs3svc_fsinfo, NULL, NFS3_FSINFO, DRC_IDEMPOTENT, 0},
+ {"PATHCONF", nfs3svc_pathconf, NULL, NFS3_PATHCONF, DRC_IDEMPOTENT, 0},
+ {"COMMIT", nfs3svc_commit, NULL, NFS3_COMMIT, DRC_IDEMPOTENT, 0}};
+
+static rpcsvc_program_t nfs3prog = {
.progname = "NFS3",
.prognum = NFS_PROGRAM,
.progver = NFS_V3,
@@ -5651,7 +5651,7 @@ nfs3_init_state(xlator_t *nfsx)
goto free_localpool;
}
- nfs3->serverstart = (uint64_t)time(NULL);
+ nfs3->serverstart = (uint64_t)gf_time();
INIT_LIST_HEAD(&nfs3->fdlru);
LOCK_INIT(&nfs3->fdlrulock);
nfs3->fdcount = 0;
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index a341ebd6638..577e8543966 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -57,6 +57,8 @@ gf_lock_t nlm_client_list_lk;
/* race on this is harmless */
int nlm_grace_period = 50;
+static gf_boolean_t nlm4_inited = _gf_false;
+
#define nlm4_validate_nfs3_state(request, state, status, label, retval) \
do { \
state = rpcsvc_request_program_private(request); \
@@ -1009,7 +1011,8 @@ nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame)
int port = -1;
struct nlm4_notify_args *ncf = NULL;
- glusterfs_this_set(cs->nfsx);
+ GF_ASSERT(cs->nfsx);
+ THIS = cs->nfsx;
rpc_transport_get_peeraddr(cs->trans, NULL, 0, &sock_union.storage,
sizeof(sock_union.storage));
@@ -1052,6 +1055,12 @@ nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame)
}
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
+
ret = dict_set_str(options, "transport-type", "socket");
if (ret == -1) {
gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_DICT_SET_FAILED,
@@ -1121,6 +1130,8 @@ nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame)
ret = 0;
err:
+ if (options)
+ dict_unref(options);
if (ret == -1) {
if (rpc_clnt)
rpc_clnt_unref(rpc_clnt);
@@ -2501,39 +2512,39 @@ out:
return ret;
}
-rpcsvc_actor_t nlm4svc_actors[NLM4_PROC_COUNT] = {
+static rpcsvc_actor_t nlm4svc_actors[NLM4_PROC_COUNT] = {
/* 0 */
- {"NULL", NLM4_NULL, nlm4svc_null, NULL, 0, DRC_IDEMPOTENT},
- {"TEST", NLM4_TEST, nlm4svc_test, NULL, 0, DRC_IDEMPOTENT},
- {"LOCK", NLM4_LOCK, nlm4svc_lock, NULL, 0, DRC_NON_IDEMPOTENT},
- {"CANCEL", NLM4_CANCEL, nlm4svc_cancel, NULL, 0, DRC_NON_IDEMPOTENT},
- {"UNLOCK", NLM4_UNLOCK, nlm4svc_unlock, NULL, 0, DRC_NON_IDEMPOTENT},
+ {"NULL", nlm4svc_null, NULL, NLM4_NULL, DRC_IDEMPOTENT, 0},
+ {"TEST", nlm4svc_test, NULL, NLM4_TEST, DRC_IDEMPOTENT, 0},
+ {"LOCK", nlm4svc_lock, NULL, NLM4_LOCK, DRC_IDEMPOTENT, 0},
+ {"CANCEL", nlm4svc_cancel, NULL, NLM4_CANCEL, DRC_NON_IDEMPOTENT, 0},
+ {"UNLOCK", nlm4svc_unlock, NULL, NLM4_UNLOCK, DRC_NON_IDEMPOTENT, 0},
/* 5 */
- {"GRANTED", NLM4_GRANTED, NULL, NULL, 0, DRC_NA},
- {"TEST", NLM4_TEST_MSG, NULL, NULL, 0, DRC_NA},
- {"LOCK", NLM4_LOCK_MSG, NULL, NULL, 0, DRC_NA},
- {"CANCEL", NLM4_CANCEL_MSG, NULL, NULL, 0, DRC_NA},
- {"UNLOCK", NLM4_UNLOCK_MSG, NULL, NULL, 0, DRC_NA},
+ {"GRANTED", NULL, NULL, NLM4_GRANTED, DRC_NA, 0},
+ {"TEST", NULL, NULL, NLM4_TEST_MSG, DRC_NA, 0},
+ {"LOCK", NULL, NULL, NLM4_LOCK_MSG, DRC_NA, 0},
+ {"CANCEL", NULL, NULL, NLM4_CANCEL_MSG, DRC_NA, 0},
+ {"UNLOCK", NULL, NULL, NLM4_UNLOCK_MSG, DRC_NA, 0},
/* 10 */
- {"GRANTED", NLM4_GRANTED_MSG, NULL, NULL, 0, DRC_NA},
- {"TEST", NLM4_TEST_RES, NULL, NULL, 0, DRC_NA},
- {"LOCK", NLM4_LOCK_RES, NULL, NULL, 0, DRC_NA},
- {"CANCEL", NLM4_CANCEL_RES, NULL, NULL, 0, DRC_NA},
- {"UNLOCK", NLM4_UNLOCK_RES, NULL, NULL, 0, DRC_NA},
+ {"GRANTED", NULL, NULL, NLM4_GRANTED_MSG, DRC_NA, 0},
+ {"TEST", NULL, NULL, NLM4_TEST_RES, DRC_NA, 0},
+ {"LOCK", NULL, NULL, NLM4_LOCK_RES, DRC_NA, 0},
+ {"CANCEL", NULL, NULL, NLM4_CANCEL_RES, DRC_NA, 0},
+ {"UNLOCK", NULL, NULL, NLM4_UNLOCK_RES, DRC_NA, 0},
/* 15 ; procedures 17,18,19 are not defined by nlm */
- {"GRANTED", NLM4_GRANTED_RES, NULL, NULL, 0, DRC_NA},
- {"SM_NOTIFY", NLM4_SM_NOTIFY, NULL, NULL, 0, DRC_NA},
- {"SEVENTEEN", NLM4_SEVENTEEN, NULL, NULL, 0, DRC_NA},
- {"EIGHTEEN", NLM4_EIGHTEEN, NULL, NULL, 0, DRC_NA},
- {"NINETEEN", NLM4_NINETEEN, NULL, NULL, 0, DRC_NA},
+ {"GRANTED", NULL, NULL, NLM4_GRANTED_RES, DRC_NA, 0},
+ {"SM_NOTIFY", NULL, NULL, NLM4_SM_NOTIFY, DRC_NA, 0},
+ {"SEVENTEEN", NULL, NULL, NLM4_SEVENTEEN, DRC_NA, 0},
+ {"EIGHTEEN", NULL, NULL, NLM4_EIGHTEEN, DRC_NA, 0},
+ {"NINETEEN", NULL, NULL, NLM4_NINETEEN, DRC_NA, 0},
/* 20 */
- {"SHARE", NLM4_SHARE, nlm4svc_share, NULL, 0, DRC_NON_IDEMPOTENT},
- {"UNSHARE", NLM4_UNSHARE, nlm4svc_unshare, NULL, 0, DRC_NON_IDEMPOTENT},
- {"NM_LOCK", NLM4_NM_LOCK, nlm4svc_nm_lock, NULL, 0, DRC_NON_IDEMPOTENT},
- {"FREE_ALL", NLM4_FREE_ALL, nlm4svc_free_all, NULL, 0, DRC_IDEMPOTENT},
+ {"SHARE", nlm4svc_share, NULL, NLM4_SHARE, DRC_NON_IDEMPOTENT, 0},
+ {"UNSHARE", nlm4svc_unshare, NULL, NLM4_UNSHARE, DRC_NON_IDEMPOTENT, 0},
+ {"NM_LOCK", nlm4svc_nm_lock, NULL, NLM4_NM_LOCK, DRC_NON_IDEMPOTENT, 0},
+ {"FREE_ALL", nlm4svc_free_all, NULL, NLM4_FREE_ALL, DRC_IDEMPOTENT, 0},
};
-rpcsvc_program_t nlm4prog = {
+static rpcsvc_program_t nlm4prog = {
.progname = "NLM4",
.prognum = NLM_PROGRAM,
.progver = NLM_V4,
@@ -2572,7 +2583,6 @@ nlm4svc_init(xlator_t *nfsx)
};
FILE *pidfile = NULL;
pid_t pid = -1;
- static gf_boolean_t nlm4_inited = _gf_false;
/* Already inited */
if (nlm4_inited)
@@ -2589,6 +2599,11 @@ nlm4svc_init(xlator_t *nfsx)
nlm4prog.private = ns;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_NLM4_PORT);
if (ret == -1)
@@ -2630,7 +2645,6 @@ nlm4svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
INIT_LIST_HEAD(&nlm_client_list);
@@ -2701,15 +2715,20 @@ nlm4svc_init(xlator_t *nfsx)
goto err;
}
- (void)gf_thread_create(&thr, NULL, nsm_thread, (void *)NULL, "nfsnsm");
+ (void)gf_thread_create(&thr, NULL, nsm_thread, nfsx, "nfsnsm");
timeout.tv_sec = nlm_grace_period;
timeout.tv_nsec = 0;
gf_timer_call_after(nfsx->ctx, timeout, nlm_grace_period_over, NULL);
nlm4_inited = _gf_true;
+
+ if (options)
+ dict_unref(options);
return &nlm4prog;
err:
+ if (options)
+ dict_unref(options);
return NULL;
}
@@ -2726,7 +2745,7 @@ nlm_priv(xlator_t *this)
gf_proc_dump_add_section("nfs.nlm");
- if (TRY_LOCK(&nlm_client_list_lk))
+ if ((nlm4_inited == _gf_false) || TRY_LOCK(&nlm_client_list_lk))
goto out;
list_for_each_entry(client, &nlm_client_list, nlm_clients)
@@ -2759,7 +2778,8 @@ out:
gf_proc_dump_build_key(key, "nlm", "statedump_error");
gf_proc_dump_write(key,
"Unable to dump nlm state because "
- "nlm_client_list_lk lock couldn't be acquired");
+ "nlm is not initialised or nlm_client_list_lk "
+ "lock couldn't be acquired");
}
return ret;
diff --git a/xlators/nfs/server/src/nlmcbk_svc.c b/xlators/nfs/server/src/nlmcbk_svc.c
index d18b86ce8db..eaa7b916190 100644
--- a/xlators/nfs/server/src/nlmcbk_svc.c
+++ b/xlators/nfs/server/src/nlmcbk_svc.c
@@ -84,9 +84,14 @@ nlmcbk_program_0(struct svc_req *rqstp, register SVCXPRT *transp)
void *
nsm_thread(void *argv)
{
+ xlator_t *nfsx = argv;
register SVCXPRT *transp;
int ret = 0;
+ GF_ASSERT(nfsx);
+
+ THIS = nfsx;
+
ret = pmap_unset(NLMCBK_PROGRAM, NLMCBK_V1);
if (ret == 0) {
gf_msg(GF_NLM, GF_LOG_ERROR, 0, NFS_MSG_PMAP_UNSET_FAIL,