[pnfs] [PATCH] pnfsd: get a reference on nfs4_file when cloning nfs4_layoutrecall

Marc Eshel eshel at almaden.ibm.com
Thu Jan 24 21:46:26 EST 2008


I tested with this patch and t seems to work now.
Thanks, Marc.

Benny Halevy <bhalevy at panasas.com> wrote on 01/24/2008 12:26:43 PM:

> currently, the reference count is taken at hash_layoutrecall which
> is the wrong time.  When the callback path is down the pending
> nfs4_layoutrecall structure that was previously cloned is released
> and since it points to the nfs4_file without a corresponding reference 
count
> the nfs4_file strucutere is being release prematurely.
> 
> Signed-off-by: Benny Halevy <bhalevy at panasas.com>
> ---
>  fs/nfsd/nfs4state.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index df97a9e..12b432d 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4224,9 +4224,11 @@ alloc_init_layoutrecall(struct 
> nfs4_layoutrecall *clone)
> 
>     dprintk("NFSD %s clr %p clone %p\n", __FUNCTION__, clr, clone);
> 
> -   if (clone)
> +   if (clone) {
>        memcpy(clr, clone, sizeof(*clr));
> -   else
> +      if (clr->clr_file)
> +         get_nfs4_file(clr->clr_file);
> +   } else
>        memset(clr, 0, sizeof(*clr));
>     kref_init(&clr->clr_ref);
>     INIT_LIST_HEAD(&clr->clr_perclnt);
> @@ -4244,8 +4246,6 @@ hash_layoutrecall(struct nfs4_layoutrecall *clr)
>     dprintk("NFSD %s clr %p clp %p fp %p\n", __FUNCTION__, clr, clp, 
fp);
>     list_add(&clr->clr_perclnt, &clp->cl_layoutrecalls);
>     kref_get(&clr->clr_ref);
> -   if (fp)
> -      get_nfs4_file(fp);
>     dprintk("NFSD %s exit\n", __FUNCTION__);
>  }
> 
> -- 
> 1.5.3.3
> 



More information about the pNFS mailing list