diff options
author | Anand Avati <avati@gluster.com> | 2012-01-13 13:27:15 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2012-01-20 05:03:42 -0800 |
commit | 7e1f8e3bac201f88e2d9ef62fc69a044716dfced (patch) | |
tree | 77540dbf1def2c864f8ae55f2293dba4a1d47488 /xlators/protocol/server/src/server3_1-fops.c | |
parent | 33c568ce1a28c1739f095611b40b7acf40e4e6df (diff) |
core: GFID filehandle based backend and anonymous FDs
1. What
--------
This change introduces an infrastructure change in the filesystem
which lets filesystem operation address objects (inodes) just by its
GFID. Thus far GFID has been a unique identifier of a user-visible
inode. But in terms of addressability the only mechanism thus far has
been the backend filesystem path, which could be derived from the
GFID only if it was cached in the inode table along with the entire set
of dentry ancestry leading up to the root.
This change essentially decouples addressability from the namespace. It
is no more necessary to be aware of the parent directory to address a
file or directory.
2. Why
-------
The biggest use case for such a feature is NFS for generating
persistent filehandles. So far the technique for generating filehandles
in NFS has been to encode path components so that the appropriate
inode_t can be repopulated into the inode table by means of a recursive
lookup of each component top-down.
Another use case is the ability to perform more intelligent self-healing
and rebalancing of inodes with hardlinks and also to detect renames.
A derived feature from GFID filehandles is anonymous FDs. An anonymous FD
is an internal USABLE "fd_t" which does not map to a user opened file
descriptor or to an internal ->open()'d fd. The ability to address a file
by the GFID eliminates the need to have a persistent ->open()'d fd for the
purpose of avoiding the namespace. This improves NFS read/write performance
significantly eliminating open/close calls and also fixes some of today's
limitations (like keeping an FD open longer than necessary resulting
in disk space leakage)
3. How
-------
At each storage/posix translator level, every file is hardlinked inside
a hidden .glusterfs directory (under the top level export) with the name
as the ascii-encoded standard UUID format string. For reasons of performance
and scalability there is a two-tier classification of those hardlinks
under directories with the initial parts of the UUID string as the directory
names.
For directories (which cannot be hardlinked), the approach is to use a symlink
which dereferences the parent GFID path along with basename of the directory.
The parent GFID dereference will in turn be a dereference of the grandparent
with the parent's basename, and so on recursively up to the root export.
4. Development
---------------
4a. To leverage the ability to address an inode by its GFID, the technique is
to perform a "nameless lookup". This means, to populate a loc_t structure as:
loc_t {
pargfid: NULL
parent: NULL
name: NULL
path: NULL
gfid: GFID to be looked up [out parameter]
inode: inode_new () result [in parameter]
}
and performing such lookup will return in its callback an inode_t
populated with the right contexts and a struct iatt which can be
used to perform an inode_link () on the inode (without a parent and
basename). The inode will now be hashed and linked in the inode table
and findable via inode_find().
A fundamental change moving forward is that the primary fields in a
loc_t structure are now going to be (pargfid, name) and (gfid) depending
on the kind of FOP. So far path had been the primary field for operations.
The remaining fields only serve as hints/helpers.
4b. If read/write is to be performed on an inode_t, the approach so far
has been to: fd_create(), STACK_WIND(open, fd), fd_bind (in callback) and
then perform STACK_WIND(read, fd) etc. With anonymous fds now you can do
fd_anonymous (inode), STACK_WIND (read, fd). This results in great boost
in performance in the inbuilt NFS server.
5. Misc
-------
The inode_ctx_put[2] has been renamed to inode_ctx_set[2] to be consistent
with the rest of the codebase.
Change-Id: Ie4629edf6bd32a595f4d7f01e90c0a01f16fb12f
BUG: 781318
Reviewed-on: http://review.gluster.com/669
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/protocol/server/src/server3_1-fops.c')
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 85 |
1 files changed, 27 insertions, 58 deletions
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 60444061d86..8df517be30a 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -2690,7 +2690,6 @@ server_stat (rpcsvc_request_t *req) return 0; /* Initialize args first, then decode */ - args.path = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_stat_req)) { //failed to decode msg; @@ -2715,7 +2714,6 @@ server_stat (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); ret = 0; resolve_and_resume (frame, server_stat_resume); @@ -2735,8 +2733,6 @@ server_setattr (rpcsvc_request_t *req) if (!req) return 0; - args.path = alloca (req->msg[0].iov_len); - if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_setattr_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -2760,7 +2756,6 @@ server_setattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); gf_stat_to_iatt (&args.stbuf, &state->stbuf); state->valid = args.valid; @@ -2828,8 +2823,6 @@ server_readlink (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_readlink_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -2853,7 +2846,6 @@ server_readlink (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); state->size = args.size; @@ -2877,7 +2869,6 @@ server_create (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_create_req)) { @@ -2927,7 +2918,6 @@ server_create (rpcsvc_request_t *req) buf = NULL; } - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); state->mode = args.mode; state->flags = gf_flags_to_flags (args.flags); @@ -2976,8 +2966,6 @@ server_open (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_open_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -3001,7 +2989,6 @@ server_open (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); state->flags = gf_flags_to_flags (args.flags); @@ -3048,6 +3035,7 @@ server_readv (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; state->size = args.size; state->offset = args.offset; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_readv_resume); @@ -3095,6 +3083,7 @@ server_writev (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; state->offset = args.offset; state->iobref = iobref_ref (req->iobref); + memcpy (state->resolve.gfid, args.gfid, 16); if (len < req->msg[0].iov_len) { state->payload_vector[0].iov_base @@ -3236,6 +3225,7 @@ server_fsync (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->flags = args.data; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_fsync_resume); @@ -3279,6 +3269,7 @@ server_flush (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_flush_resume); @@ -3323,6 +3314,7 @@ server_ftruncate (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->offset = args.offset; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_ftruncate_resume); @@ -3365,6 +3357,7 @@ server_fstat (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_fstat_resume); @@ -3384,7 +3377,6 @@ server_truncate (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_truncate_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -3407,7 +3399,6 @@ server_truncate (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); memcpy (state->resolve.gfid, args.gfid, 16); state->offset = args.offset; @@ -3430,7 +3421,6 @@ server_unlink (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_unlink_req)) { @@ -3455,7 +3445,6 @@ server_unlink (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); memcpy (state->resolve.pargfid, args.pargfid, 16); @@ -3482,7 +3471,6 @@ server_setxattr (rpcsvc_request_t *req) conn = req->trans->xl_private; - args.path = alloca (req->msg[0].iov_len); args.dict.dict_val = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_setxattr_req)) { @@ -3507,7 +3495,6 @@ server_setxattr (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); @@ -3595,6 +3582,7 @@ server_fsetxattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->flags = args.flags; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.dict.dict_len) { dict = dict_new (); @@ -3732,7 +3720,6 @@ server_xattrop (rpcsvc_request_t *req) conn = req->trans->xl_private; args.dict.dict_val = alloca (req->msg[0].iov_len); - args.path = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_xattrop_req)) { //failed to decode msg; @@ -3756,7 +3743,6 @@ server_xattrop (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); state->flags = args.flags; memcpy (state->resolve.gfid, args.gfid, 16); @@ -3808,8 +3794,7 @@ server_getxattr (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - args.name = alloca (4096); + args.name = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_getxattr_req)) { //failed to decode msg; @@ -3833,7 +3818,6 @@ server_getxattr (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) { @@ -3860,7 +3844,7 @@ server_fgetxattr (rpcsvc_request_t *req) if (!req) return ret; - args.name = alloca (4096); + args.name = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_fgetxattr_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -3884,6 +3868,7 @@ server_fgetxattr (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) state->name = gf_strdup (args.name); @@ -3907,8 +3892,7 @@ server_removexattr (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - args.name = alloca (4096); + args.name = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_removexattr_req)) { //failed to decode msg; @@ -3932,7 +3916,6 @@ server_removexattr (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); memcpy (state->resolve.gfid, args.gfid, 16); state->name = gf_strdup (args.name); @@ -3956,8 +3939,6 @@ server_opendir (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_opendir_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -3980,7 +3961,6 @@ server_opendir (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_MUST; - state->resolve.path = gf_strdup (args.path); memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; @@ -4037,6 +4017,7 @@ server_readdirp (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->offset = args.offset; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_readdirp_resume); @@ -4091,6 +4072,7 @@ server_readdir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->offset = args.offset; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_readdir_resume); @@ -4133,6 +4115,7 @@ server_fsyncdir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->flags = args.data; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; resolve_and_resume (frame, server_fsyncdir_resume); @@ -4155,7 +4138,6 @@ server_mknod (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_mknod_req)) { @@ -4208,7 +4190,6 @@ server_mknod (rpcsvc_request_t *req) state->resolve.type = RESOLVE_NOT; memcpy (state->resolve.pargfid, args.pargfid, 16); - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); state->mode = args.mode; @@ -4254,7 +4235,6 @@ server_mkdir (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_mkdir_req)) { @@ -4306,7 +4286,6 @@ server_mkdir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_NOT; memcpy (state->resolve.pargfid, args.pargfid, 16); - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); state->mode = args.mode; @@ -4348,7 +4327,6 @@ server_rmdir (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_rmdir_req)) { @@ -4374,7 +4352,6 @@ server_rmdir (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.pargfid, args.pargfid, 16); - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); state->flags = args.flags; @@ -4399,8 +4376,7 @@ server_inodelk (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - args.volume = alloca (4096); + args.volume = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_inodelk_req)) { //failed to decode msg; @@ -4425,7 +4401,6 @@ server_inodelk (rpcsvc_request_t *req) state->resolve.type = RESOLVE_EXACT; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); cmd = args.cmd; switch (cmd) { @@ -4474,7 +4449,7 @@ server_finodelk (rpcsvc_request_t *req) if (!req) return ret; - args.volume = alloca (4096); + args.volume = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_finodelk_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -4500,6 +4475,7 @@ server_finodelk (rpcsvc_request_t *req) state->volume = gf_strdup (args.volume); state->resolve.fd_no = args.fd; state->cmd = args.cmd; + memcpy (state->resolve.gfid, args.gfid, 16); switch (state->cmd) { case GF_LK_GETLK: @@ -4547,9 +4523,8 @@ server_entrylk (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); - args.volume = alloca (4096); - args.name = alloca (4096); + args.volume = alloca (256); + args.name = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_entrylk_req)) { //failed to decode msg; @@ -4573,7 +4548,6 @@ server_entrylk (rpcsvc_request_t *req) } state->resolve.type = RESOLVE_EXACT; - state->resolve.path = gf_strdup (args.path); memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) @@ -4600,8 +4574,8 @@ server_fentrylk (rpcsvc_request_t *req) if (!req) return ret; - args.name = alloca (4096); - args.volume = alloca (4096); + args.name = alloca (256); + args.volume = alloca (256); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_fentrylk_req)) { //failed to decode msg; @@ -4628,6 +4602,7 @@ server_fentrylk (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; state->cmd = args.cmd; state->type = args.type; + memcpy (state->resolve.gfid, args.gfid, 16); if (args.namelen) state->name = gf_strdup (args.name); @@ -4650,7 +4625,6 @@ server_access (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_access_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -4674,7 +4648,6 @@ server_access (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); state->mask = args.mask; ret = 0; @@ -4698,7 +4671,6 @@ server_symlink (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); args.linkname = alloca (4096); @@ -4752,7 +4724,6 @@ server_symlink (rpcsvc_request_t *req) state->resolve.type = RESOLVE_NOT; memcpy (state->resolve.pargfid, args.pargfid, 16); - state->resolve.path = gf_strdup (args.path); state->resolve.bname = gf_strdup (args.bname); state->name = gf_strdup (args.linkname); @@ -4925,6 +4896,7 @@ server_lk (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; state->cmd = args.cmd; state->type = args.type; + memcpy (state->resolve.gfid, args.gfid, 16); switch (state->cmd) { case GF_LK_GETLK: @@ -5052,7 +5024,6 @@ server_lookup (rpcsvc_request_t *req) conn = req->trans->xl_private; - args.path = alloca (req->msg[0].iov_len); args.bname = alloca (req->msg[0].iov_len); args.dict.dict_val = alloca (req->msg[0].iov_len); @@ -5080,14 +5051,14 @@ server_lookup (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto out; } - memcpy (state->resolve.gfid, args.gfid, 16); state->resolve.type = RESOLVE_DONTCARE; - memcpy (state->resolve.pargfid, args.pargfid, 16); - state->resolve.path = gf_strdup (args.path); - if (IS_NOT_ROOT (STRLEN_0 (args.path))) { + if (args.bname && strcmp (args.bname, "")) { + memcpy (state->resolve.pargfid, args.pargfid, 16); state->resolve.bname = gf_strdup (args.bname); + } else { + memcpy (state->resolve.gfid, args.gfid, 16); } if (args.dict.dict_len) { @@ -5147,7 +5118,6 @@ server_statfs (rpcsvc_request_t *req) if (!req) return ret; - args.path = alloca (req->msg[0].iov_len); if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gfs3_statfs_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -5171,7 +5141,6 @@ server_statfs (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; memcpy (state->resolve.gfid, args.gfid, 16); - state->resolve.path = gf_strdup (args.path); ret = 0; resolve_and_resume (frame, server_statfs_resume); |