linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
@ 2011-10-24  3:25 Peng Tao
  2011-10-31 12:58 ` Benny Halevy
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Tao @ 2011-10-24  3:25 UTC (permalink / raw)
  To: linux-nfs; +Cc: Trond.Myklebust, bhalevy, Peng Tao

Hi, Trond and Benny,

The patch depends on the pnfs private workqueue for now. So I want to consult
you about where to put the work. Is pnfs private workqueue dropped? If yes, where
should I put this kind of work?

Thanks,
Tao

For blocklayout, we want to issue layoutreturn to return layouts when
handling CB_RECALL_ANY.

Signed-off-by: Peng Tao <peng_tao@emc.com>
---
 fs/nfs/callback_proc.c |   55 +++++++++++++++++++++++++++++++++++++++++-------
 include/linux/nfs4.h   |    3 +-
 2 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 43926ad..6bb005c 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -160,7 +160,8 @@ static u32 initiate_file_draining(struct nfs_client *clp,
 }
 
 static u32 initiate_bulk_draining(struct nfs_client *clp,
-				  struct cb_layoutrecallargs *args)
+				  struct cb_layoutrecallargs *args,
+				  int sendreturn)
 {
 	struct nfs_server *server;
 	struct pnfs_layout_hdr *lo;
@@ -204,12 +205,47 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
 		list_del_init(&lo->plh_bulk_recall);
 		spin_unlock(&ino->i_lock);
 		pnfs_free_lseg_list(&free_me_list);
+		if (sendreturn && list_empty(&lo->plh_segs))
+			pnfs_return_layout(ino);
 		put_layout_hdr(lo);
 		iput(ino);
 	}
 	return rv;
 }
 
+struct recallany_data {
+	struct nfs_client *clp;
+	struct work_struct ra_work;
+};
+
+static void layout_recallany_draining(struct work_struct *work)
+{
+	struct recallany_data *ra;
+	struct cb_layoutrecallargs args;
+
+	memset(&args, 0, sizeof(args));
+	ra = container_of(work, struct recallany_data, ra_work);
+	/* Ignore draining error. Per RFC, if layoutreturns are not sent, it is up
+	 * to server to handle the situation (e.g., send specific layoutrecalls).
+	 */
+	initiate_bulk_draining(ra->clp, &args, 1);
+	kfree(ra);
+}
+
+static u32 init_recallany_draining(struct nfs_client *clp)
+{
+	struct recallany_data *ra;
+
+	ra = kmalloc(sizeof(*ra), GFP_NOFS);
+	if (ra) {
+		ra->clp = clp;
+		INIT_WORK(&ra->ra_work, layout_recallany_draining);
+		pnfsiod_queue_work(&ra->ra_work);
+		return NFS4_OK;
+	}
+	return NFS4ERR_DELAY;
+}
+
 static u32 do_callback_layoutrecall(struct nfs_client *clp,
 				    struct cb_layoutrecallargs *args)
 {
@@ -220,8 +256,10 @@ static u32 do_callback_layoutrecall(struct nfs_client *clp,
 		goto out;
 	if (args->cbl_recall_type == RETURN_FILE)
 		res = initiate_file_draining(clp, args);
+	if (args->cbl_recall_type == RETURN_ANY)
+		res = init_recallany_draining(clp);
 	else
-		res = initiate_bulk_draining(clp, args);
+		res = initiate_bulk_draining(clp, args, 0);
 	clear_bit(NFS4CLNT_LAYOUTRECALL, &clp->cl_state);
 out:
 	dprintk("%s returning %i\n", __func__, res);
@@ -245,15 +283,13 @@ __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,
 	return cpu_to_be32(res);
 }
 
-static void pnfs_recall_all_layouts(struct nfs_client *clp)
+static __be32 pnfs_recall_all_layouts(struct nfs_client *clp, uint32_t type)
 {
 	struct cb_layoutrecallargs args;
 
-	/* Pretend we got a CB_LAYOUTRECALL(ALL) */
 	memset(&args, 0, sizeof(args));
-	args.cbl_recall_type = RETURN_ALL;
-	/* FIXME we ignore errors, what should we do? */
-	do_callback_layoutrecall(clp, &args);
+	args.cbl_recall_type = type;
+	return cpu_to_be32(do_callback_layoutrecall(clp, &args));
 }
 
 __be32 nfs4_callback_devicenotify(struct cb_devicenotifyargs *args,
@@ -533,7 +569,10 @@ __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
 		flags |= FMODE_WRITE;
 	if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *)
 		     &args->craa_type_mask))
-		pnfs_recall_all_layouts(cps->clp);
+		pnfs_recall_all_layouts(cps->clp, RETURN_ALL);
+	if (test_bit(RCA4_TYPE_MASK_BLK_LAYOUT, (const unsigned long *)
+		     &args->craa_type_mask))
+		status = pnfs_recall_all_layouts(cps->clp, RETURN_ANY);
 	if (flags)
 		nfs_expire_all_delegation_types(cps->clp, flags);
 out:
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 76f99e8..1f71a9e 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -597,7 +597,8 @@ enum pnfs_layouttype {
 enum pnfs_layoutreturn_type {
 	RETURN_FILE = 1,
 	RETURN_FSID = 2,
-	RETURN_ALL  = 3
+	RETURN_ALL  = 3,
+	RETURN_ANY  = 4
 };
 
 enum pnfs_iomode {
-- 
1.7.1.262.g5ef3d


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
  2011-10-24  3:25 [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY Peng Tao
@ 2011-10-31 12:58 ` Benny Halevy
  2011-10-31 13:54   ` Myklebust, Trond
  0 siblings, 1 reply; 4+ messages in thread
From: Benny Halevy @ 2011-10-31 12:58 UTC (permalink / raw)
  To: Peng Tao; +Cc: linux-nfs, Trond.Myklebust, Peng Tao

On 2011-10-24 05:25, Peng Tao wrote:
> Hi, Trond and Benny,
> 
> The patch depends on the pnfs private workqueue for now. So I want to consult
> you about where to put the work. Is pnfs private workqueue dropped? If yes, where
> should I put this kind of work?

I'll defer this to Trond.
I'm OK with having a workqueue for pnfs.

Benny

> 
> Thanks,
> Tao
> 
> For blocklayout, we want to issue layoutreturn to return layouts when
> handling CB_RECALL_ANY.
> 
> Signed-off-by: Peng Tao <peng_tao@emc.com>
> ---
>  fs/nfs/callback_proc.c |   55 +++++++++++++++++++++++++++++++++++++++++-------
>  include/linux/nfs4.h   |    3 +-
>  2 files changed, 49 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
> index 43926ad..6bb005c 100644
> --- a/fs/nfs/callback_proc.c
> +++ b/fs/nfs/callback_proc.c
> @@ -160,7 +160,8 @@ static u32 initiate_file_draining(struct nfs_client *clp,
>  }
>  
>  static u32 initiate_bulk_draining(struct nfs_client *clp,
> -				  struct cb_layoutrecallargs *args)
> +				  struct cb_layoutrecallargs *args,
> +				  int sendreturn)
>  {
>  	struct nfs_server *server;
>  	struct pnfs_layout_hdr *lo;
> @@ -204,12 +205,47 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
>  		list_del_init(&lo->plh_bulk_recall);
>  		spin_unlock(&ino->i_lock);
>  		pnfs_free_lseg_list(&free_me_list);
> +		if (sendreturn && list_empty(&lo->plh_segs))
> +			pnfs_return_layout(ino);
>  		put_layout_hdr(lo);
>  		iput(ino);
>  	}
>  	return rv;
>  }
>  
> +struct recallany_data {
> +	struct nfs_client *clp;
> +	struct work_struct ra_work;
> +};
> +
> +static void layout_recallany_draining(struct work_struct *work)
> +{
> +	struct recallany_data *ra;
> +	struct cb_layoutrecallargs args;
> +
> +	memset(&args, 0, sizeof(args));
> +	ra = container_of(work, struct recallany_data, ra_work);
> +	/* Ignore draining error. Per RFC, if layoutreturns are not sent, it is up
> +	 * to server to handle the situation (e.g., send specific layoutrecalls).
> +	 */
> +	initiate_bulk_draining(ra->clp, &args, 1);
> +	kfree(ra);
> +}
> +
> +static u32 init_recallany_draining(struct nfs_client *clp)
> +{
> +	struct recallany_data *ra;
> +
> +	ra = kmalloc(sizeof(*ra), GFP_NOFS);
> +	if (ra) {
> +		ra->clp = clp;
> +		INIT_WORK(&ra->ra_work, layout_recallany_draining);
> +		pnfsiod_queue_work(&ra->ra_work);
> +		return NFS4_OK;
> +	}
> +	return NFS4ERR_DELAY;
> +}
> +
>  static u32 do_callback_layoutrecall(struct nfs_client *clp,
>  				    struct cb_layoutrecallargs *args)
>  {
> @@ -220,8 +256,10 @@ static u32 do_callback_layoutrecall(struct nfs_client *clp,
>  		goto out;
>  	if (args->cbl_recall_type == RETURN_FILE)
>  		res = initiate_file_draining(clp, args);
> +	if (args->cbl_recall_type == RETURN_ANY)
> +		res = init_recallany_draining(clp);
>  	else
> -		res = initiate_bulk_draining(clp, args);
> +		res = initiate_bulk_draining(clp, args, 0);
>  	clear_bit(NFS4CLNT_LAYOUTRECALL, &clp->cl_state);
>  out:
>  	dprintk("%s returning %i\n", __func__, res);
> @@ -245,15 +283,13 @@ __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,
>  	return cpu_to_be32(res);
>  }
>  
> -static void pnfs_recall_all_layouts(struct nfs_client *clp)
> +static __be32 pnfs_recall_all_layouts(struct nfs_client *clp, uint32_t type)
>  {
>  	struct cb_layoutrecallargs args;
>  
> -	/* Pretend we got a CB_LAYOUTRECALL(ALL) */
>  	memset(&args, 0, sizeof(args));
> -	args.cbl_recall_type = RETURN_ALL;
> -	/* FIXME we ignore errors, what should we do? */
> -	do_callback_layoutrecall(clp, &args);
> +	args.cbl_recall_type = type;
> +	return cpu_to_be32(do_callback_layoutrecall(clp, &args));
>  }
>  
>  __be32 nfs4_callback_devicenotify(struct cb_devicenotifyargs *args,
> @@ -533,7 +569,10 @@ __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
>  		flags |= FMODE_WRITE;
>  	if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *)
>  		     &args->craa_type_mask))
> -		pnfs_recall_all_layouts(cps->clp);
> +		pnfs_recall_all_layouts(cps->clp, RETURN_ALL);
> +	if (test_bit(RCA4_TYPE_MASK_BLK_LAYOUT, (const unsigned long *)
> +		     &args->craa_type_mask))
> +		status = pnfs_recall_all_layouts(cps->clp, RETURN_ANY);
>  	if (flags)
>  		nfs_expire_all_delegation_types(cps->clp, flags);
>  out:
> diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
> index 76f99e8..1f71a9e 100644
> --- a/include/linux/nfs4.h
> +++ b/include/linux/nfs4.h
> @@ -597,7 +597,8 @@ enum pnfs_layouttype {
>  enum pnfs_layoutreturn_type {
>  	RETURN_FILE = 1,
>  	RETURN_FSID = 2,
> -	RETURN_ALL  = 3
> +	RETURN_ALL  = 3,
> +	RETURN_ANY  = 4
>  };
>  
>  enum pnfs_iomode {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
  2011-10-31 12:58 ` Benny Halevy
@ 2011-10-31 13:54   ` Myklebust, Trond
  2011-10-31 14:31     ` Peng Tao
  0 siblings, 1 reply; 4+ messages in thread
From: Myklebust, Trond @ 2011-10-31 13:54 UTC (permalink / raw)
  To: Benny Halevy, Peng Tao; +Cc: linux-nfs, Peng Tao



> -----Original Message-----
> From: Benny Halevy [mailto:bhalevy@tonian.com]
> Sent: Monday, October 31, 2011 8:58 AM
> To: Peng Tao
> Cc: linux-nfs@vger.kernel.org; Myklebust, Trond; Peng Tao
> Subject: Re: [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
> 
> On 2011-10-24 05:25, Peng Tao wrote:
> > Hi, Trond and Benny,
> >
> > The patch depends on the pnfs private workqueue for now. So I want
to
> > consult you about where to put the work. Is pnfs private workqueue
> > dropped? If yes, where should I put this kind of work?
> 
> I'll defer this to Trond.
> I'm OK with having a workqueue for pnfs.

I've already commented on this: I see no justification whatsoever for a
private pnfs workqueue.

Cheers
   Trond

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
  2011-10-31 13:54   ` Myklebust, Trond
@ 2011-10-31 14:31     ` Peng Tao
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Tao @ 2011-10-31 14:31 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: Benny Halevy, linux-nfs, Peng Tao

Hi, Trond,

On Mon, Oct 31, 2011 at 9:54 PM, Myklebust, Trond
<Trond.Myklebust@netapp.com> wrote:
>
>
>> -----Original Message-----
>> From: Benny Halevy [mailto:bhalevy@tonian.com]
>> Sent: Monday, October 31, 2011 8:58 AM
>> To: Peng Tao
>> Cc: linux-nfs@vger.kernel.org; Myklebust, Trond; Peng Tao
>> Subject: Re: [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY
>>
>> On 2011-10-24 05:25, Peng Tao wrote:
>> > Hi, Trond and Benny,
>> >
>> > The patch depends on the pnfs private workqueue for now. So I want
> to
>> > consult you about where to put the work. Is pnfs private workqueue
>> > dropped? If yes, where should I put this kind of work?
>>
>> I'll defer this to Trond.
>> I'm OK with having a workqueue for pnfs.
>
> I've already commented on this: I see no justification whatsoever for a
> private pnfs workqueue.
OK. Thanks a lot for confirming it. I think I can just change this one
to use the system wq. Will send an updated patch.


-- 
Thanks,
Tao

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-31 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24  3:25 [PATCH-RFC] nfs41: handle BLK_LAYOUT CB_RECALL_ANY Peng Tao
2011-10-31 12:58 ` Benny Halevy
2011-10-31 13:54   ` Myklebust, Trond
2011-10-31 14:31     ` Peng Tao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).