From a8ef67630c48dfec336cc2088ac78cb29074022c Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 15 Jun 2010 00:39:25 +0000 Subject: nfs: Support directory level exports nfsx has followed traditional approach of exporting whole volumes as NFS exports. The Platform requires and some users have approached us for introducing exports of only specific directories instead of full Gluster volumes. This commit introduces this support through two nfsx options: Option 1: ========= option nfs3..export-dir ,,.. export-dir will allow the export of a particular dir as a single export by itself. For eg.: volume posix type storage/posix option directory /export/ end-volume volume posix-ac type features/access-control subvolumes posix end-volume volume nfs type nfs/server subvolumes posix-ac option rpc-auth.addr.allow * option nfs3.posix-ac.export-dir /homes/shehjart end-volume A comma separate list of sub-directories will set up those dirs as separated exports. At the nfs client, the mount command will be: $ mount :/posix-ac/homes/shehjart /mnt Option 2: ========= option nfs3..export-volumes There can be situations where users only want the directory level exports and require that volume exports be completely disabled. The above option allows us to do this. By default, volume exports are enabled. From the earlier example, replacing with posix-ac, will disable mounting of the posix-ac volume as a whole. Signed-off-by: Shehjar Tikoo Signed-off-by: Anand V. Avati BUG: 989 (Support directory exports in nfsx) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=989 --- xlators/nfs/server/src/mount3.h | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'xlators/nfs/server/src/mount3.h') diff --git a/xlators/nfs/server/src/mount3.h b/xlators/nfs/server/src/mount3.h index 7cfd2b0cb84..f555bc7f18a 100644 --- a/xlators/nfs/server/src/mount3.h +++ b/xlators/nfs/server/src/mount3.h @@ -33,6 +33,7 @@ #include "list.h" #include "xdr-nfs3.h" #include "locking.h" +#include "nfs3-fh.h" /* Registered with portmap */ #define GF_MOUNTV3_PORT 38465 @@ -60,12 +61,28 @@ struct mountentry { char hostname[MNTPATHLEN]; }; +#define MNT3_EXPTYPE_VOLUME 1 +#define MNT3_EXPTYPE_DIR 2 + +struct mnt3_export { + struct list_head explist; + + /* The string that may contain either the volume name if the full volume + * is exported or the subdirectory in the volume. + */ + char *expname; + xlator_t *vol; + int exptype; +}; + struct mount3_state { xlator_t *nfsx; /* The buffers for all network IO are got from this pool. */ struct iobuf_pool *iobpool; - xlator_list_t *exports; + + /* List of exports, can be volumes or directories in those volumes. */ + struct list_head exportlist; /* List of current mount points over all the exports from this * server. @@ -74,5 +91,22 @@ struct mount3_state { /* Used to protect the mountlist. */ gf_lock_t mountlock; + + /* Set to 0 if exporting full volumes is disabled. On by default. */ + int export_volumes; }; + + +struct mount3_resolve_state { + struct mnt3_export *exp; + struct mount3_state *mstate; + rpcsvc_request_t *req; + + char remainingdir[MNTPATHLEN]; + loc_t resolveloc; + struct nfs3_fh parentfh; +}; + +typedef struct mount3_resolve_state mnt3_resolve_t; + #endif -- cgit