[pnfs] [PATCH] when nfsd is stopped tell fs when layout is destroyed.

Benny Halevy bhalevy at panasas.com
Thu Jul 26 10:46:40 EDT 2007


Marc,

I have a few issues with this patch.
Please consider the attached patch instead.

1. In our case, we need to distinguish between the normal return case
and the expire/revocation case since we handle it differently internally.
I added a LR_FLAG_EXPIRE flag to indicate that.

2. the added argument is barely a boolean flag to destroy_layout and
is not really used.

3. I rather not add more functionality to destroy_layout which will
just take care of unhashing the structure and freeing it and instead,
add a new function 'expire_layout' to forcibly return the layout
(with the new flag) to the file system.  This will do what you
want from the expire_client call site with changing the existing
function and its interface.

4. some other nits I fixed:
> +			lr.lr_seg.clientid = 0;

need to specify clientid. can be taken from the returned layout lp->lo_seg.clientid;

> +			lr.lr_seg.layout_type = LAYOUT_NFSV4_FILES;

well, not everybody use LAYOUT_NFSV4_FILES :)
this too should be taken from the returned layout lp->lo_seg.layout_type;

> +			lr.lr_seg.length = -1;

please use NFS4_LENGTH_EOF rather than -1 to indicate end of file

The attached patch compiles but I haven't tested it yet.
I'd appreciate if you could test it in your environment too.

Thanks,

Benny

Marc Eshel wrote:
> From: Marc Eshel <eshel at almaden.ibm.com>
> 
> 
> ---
> 
>  fs/nfsd/nfs4state.c |   28 +++++++++++++++++++++++-----
>  1 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index b73c928..a5b03bf 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -91,7 +91,7 @@ #if defined(CONFIG_PNFS)
>   */
>  static kmem_cache_t *pnfs_layout_slab = NULL;
>  static kmem_cache_t *pnfs_layoutrecall_slab = NULL;
> -static void destroy_layout(struct nfs4_layout *lp);
> +static void destroy_layout(struct nfs4_layout *lp, struct nfsd4_pnfs_layoutreturn *lrp);
>  static inline void layoutrecall_done(struct nfs4_layoutrecall *clr);
>  static void release_pnfs_ds_dev_list(struct nfs4_stateid *stp);
>  #endif /* CONFIG_PNFS */
> @@ -627,7 +627,7 @@ #if defined(CONFIG_PNFS)
>  		dprintk("NFSD: expire client. lp %p, fp %p\n", lp,
>  				lp->lo_file);
>  		BUG_ON(lp->lo_client != clp);
> -		destroy_layout(lp);
> +		destroy_layout(lp, NULL);
>  	}
>  	while (!list_empty(&clp->cl_layoutrecalls)) {
>  		lrp = list_entry(clp->cl_layoutrecalls.next,
> @@ -4051,8 +4051,9 @@ alloc_init_layout(struct nfs4_layout *lp
>  }
>  
>  static void
> -destroy_layout(struct nfs4_layout *lp)
> +destroy_layout(struct nfs4_layout *lp, struct nfsd4_pnfs_layoutreturn *lrp)
>  {
> +	struct nfsd4_pnfs_layoutreturn lr;
>  	struct nfs4_client *clp;
>  	struct nfs4_file *fp;
>  
> @@ -4063,6 +4064,20 @@ destroy_layout(struct nfs4_layout *lp)
>  	dprintk("pNFS %s: lp %p clp %p fp %p ino %p\n", __FUNCTION__,
>  	        lp, clp, fp, fp->fi_inode);
>  
> +	/* call exported filesystem layout_return */
> +	if (!lrp) {
> +		if (fp->fi_inode->i_sb->s_export_op->layout_return) {
> +			lr.lr_return_type = RETURN_FILE;
> +			lr.lr_reclaim = 0;
> +			lr.lr_flags = 0;
> +			lr.lr_seg.clientid = 0;

= lp->lo_seg.clientid;

> +			lr.lr_seg.layout_type = LAYOUT_NFSV4_FILES;

= lp->lo_seg.layout_type;

> +			lr.lr_seg.iomode = IOMODE_ANY;
> +			lr.lr_seg.offset = 0;
> +			lr.lr_seg.length = -1;

please use NFS4_LENGTH_EOF rather than -1 to indicate end of file

> +			fp->fi_inode->i_sb->s_export_op->layout_return(fp->fi_inode, &lr);
> +		}
> +	}
>  	kmem_cache_free(pnfs_layout_slab, lp);
>  	put_nfs4_file(fp);
>  }
> @@ -4502,7 +4517,7 @@ int nfs4_pnfs_return_layout(struct super
>  			layouts_found++;
>  			trim_layout(&lp->lo_seg, &lrp->lr_seg);
>  			if (!lp->lo_seg.length)
> -				destroy_layout(lp);
> +				destroy_layout(lp, lrp);
>  		}
>  	} else list_for_each_entry_safe (lp, nextlp, &clp->cl_layouts, lo_perclnt) {
>  		if (lrp->lr_seg.layout_type != lp->lo_seg.layout_type ||
> @@ -4515,7 +4530,7 @@ int nfs4_pnfs_return_layout(struct super
>  			continue;
>  
>  		layouts_found++;
> -		destroy_layout(lp);
> +		destroy_layout(lp, lrp);
>  	}
>  
>  	/* update layoutrecalls */
> @@ -4810,6 +4825,9 @@ int nfsd_layout_recall_cb(struct inode *
>  	       cbl->cbl_seg.iomode != IOMODE_RW &&
>  	       cbl->cbl_seg.iomode != IOMODE_ANY);
>  
> +	if (nfsd_serv == NULL)
> +		return -ENOENT;
> +
>  	clr = alloc_init_layoutrecall(NULL);
>  	if (!clr)
>  		return -ENOMEM;
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs

-------------- next part --------------
A non-text attachment was scrubbed...
Name: expire-layout.patch
Type: text/x-patch
Size: 2467 bytes
Desc: not available
Url : http://linux-nfs.org/pipermail/pnfs/attachments/20070726/1d142be4/attachment.bin 


More information about the pNFS mailing list