diff mbox

[RFC,04/27] pnfs: layoutret_on_setattr

Message ID 1303320401-21106-1-git-send-email-bhalevy@panasas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benny Halevy April 20, 2011, 5:26 p.m. UTC
From: Andy Adamson <andros@netapp.com>

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
---
 fs/nfs/nfs4proc.c |    3 +++
 fs/nfs/pnfs.h     |   22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

Comments

Trond Myklebust April 20, 2011, 8:03 p.m. UTC | #1
On Wed, 2011-04-20 at 20:26 +0300, Benny Halevy wrote:
> From: Andy Adamson <andros@netapp.com>
> 
> Signed-off-by: Andy Adamson <andros@netapp.com>
> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> ---
>  fs/nfs/nfs4proc.c |    3 +++
>  fs/nfs/pnfs.h     |   22 ++++++++++++++++++++++
>  2 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index b03defb..b4df7a6 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -2332,6 +2332,9 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
>  	struct nfs4_state *state = NULL;
>  	int status;
>  
> +	if (pnfs_ld_layoutret_on_setattr(inode))
> +		pnfs_return_layout(inode, NULL, true);

There is nothing that prevents further reads and writes being scheduled
after this, so what is the plan to prevent them from being sent to the
MDS?
Also, why are we doing this in the case of a file time update or a
modebits update? It seems relevant only for the case of a size update.

> +
>  	nfs_fattr_init(fattr);
>  	
>  	/* Search for an existing open(O_WRITE) file */
> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
> index a308f3c..3506ad4 100644
> --- a/fs/nfs/pnfs.h
> +++ b/fs/nfs/pnfs.h
> @@ -64,12 +64,18 @@ enum {
>  	NFS_LAYOUT_DESTROYED,		/* no new use of layout allowed */
>  };
>  
> +enum layoutdriver_policy_flags {
> +	/* Should the pNFS client commit and return the layout upon a setattr */
> +	PNFS_LAYOUTRET_ON_SETATTR	= 1 << 0,
> +};
> +
>  /* Per-layout driver specific registration structure */
>  struct pnfs_layoutdriver_type {
>  	struct list_head pnfs_tblid;
>  	const u32 id;
>  	const char *name;
>  	struct module *owner;
> +	unsigned flags;
>  	struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr);
>  	void (*free_lseg) (struct pnfs_layout_segment *lseg);
>  
> @@ -228,6 +234,16 @@ static inline void pnfs_clear_request_commit(struct nfs_page *req)
>  		put_lseg(req->wb_commit_lseg);
>  }
>  
> +/* Should the pNFS client commit and return the layout upon a setattr */
> +static inline bool
> +pnfs_ld_layoutret_on_setattr(struct inode *inode)
> +{
> +	if (!pnfs_enabled_sb(NFS_SERVER(inode)))
> +		return false;
> +	return NFS_SERVER(inode)->pnfs_curr_ld->flags &
> +		PNFS_LAYOUTRET_ON_SETATTR;
> +}
> +
>  static inline int pnfs_return_layout(struct inode *ino,
>  				     struct pnfs_layout_range *range,
>  				     bool wait)
> @@ -290,6 +306,12 @@ static inline int pnfs_return_layout(struct inode *ino,
>  }
>  
>  static inline bool
> +pnfs_ld_layoutret_on_setattr(struct inode *inode)
> +{
> +	return false;
> +}
> +
> +static inline bool
>  pnfs_roc(struct inode *ino)
>  {
>  	return false;
Benny Halevy April 22, 2011, 8:23 a.m. UTC | #2
On 2011-04-20 23:03, Trond Myklebust wrote:
> On Wed, 2011-04-20 at 20:26 +0300, Benny Halevy wrote:
>> From: Andy Adamson <andros@netapp.com>
>>
>> Signed-off-by: Andy Adamson <andros@netapp.com>
>> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
>> ---
>>  fs/nfs/nfs4proc.c |    3 +++
>>  fs/nfs/pnfs.h     |   22 ++++++++++++++++++++++
>>  2 files changed, 25 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>> index b03defb..b4df7a6 100644
>> --- a/fs/nfs/nfs4proc.c
>> +++ b/fs/nfs/nfs4proc.c
>> @@ -2332,6 +2332,9 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
>>  	struct nfs4_state *state = NULL;
>>  	int status;
>>  
>> +	if (pnfs_ld_layoutret_on_setattr(inode))
>> +		pnfs_return_layout(inode, NULL, true);
> 
> There is nothing that prevents further reads and writes being scheduled
> after this, so what is the plan to prevent them from being sent to the
> MDS?

The idea is that the client will acquire a fresh layout for further
I/Os.  Sending I/Os to the MDS at any time should be fine,
but layoutgets should be synchronized with LAYOUTRETURN+SETATTR.

> Also, why are we doing this in the case of a file time update or a
> modebits update? It seems relevant only for the case of a size update.
> 

I agree regarding file time updates, but in the case of modebits update
the client will lose its layout too as its associated capabilities will
be revoked due to the change in permissions.

Benny

>> +
>>  	nfs_fattr_init(fattr);
>>  	
>>  	/* Search for an existing open(O_WRITE) file */
>> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
>> index a308f3c..3506ad4 100644
>> --- a/fs/nfs/pnfs.h
>> +++ b/fs/nfs/pnfs.h
>> @@ -64,12 +64,18 @@ enum {
>>  	NFS_LAYOUT_DESTROYED,		/* no new use of layout allowed */
>>  };
>>  
>> +enum layoutdriver_policy_flags {
>> +	/* Should the pNFS client commit and return the layout upon a setattr */
>> +	PNFS_LAYOUTRET_ON_SETATTR	= 1 << 0,
>> +};
>> +
>>  /* Per-layout driver specific registration structure */
>>  struct pnfs_layoutdriver_type {
>>  	struct list_head pnfs_tblid;
>>  	const u32 id;
>>  	const char *name;
>>  	struct module *owner;
>> +	unsigned flags;
>>  	struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr);
>>  	void (*free_lseg) (struct pnfs_layout_segment *lseg);
>>  
>> @@ -228,6 +234,16 @@ static inline void pnfs_clear_request_commit(struct nfs_page *req)
>>  		put_lseg(req->wb_commit_lseg);
>>  }
>>  
>> +/* Should the pNFS client commit and return the layout upon a setattr */
>> +static inline bool
>> +pnfs_ld_layoutret_on_setattr(struct inode *inode)
>> +{
>> +	if (!pnfs_enabled_sb(NFS_SERVER(inode)))
>> +		return false;
>> +	return NFS_SERVER(inode)->pnfs_curr_ld->flags &
>> +		PNFS_LAYOUTRET_ON_SETATTR;
>> +}
>> +
>>  static inline int pnfs_return_layout(struct inode *ino,
>>  				     struct pnfs_layout_range *range,
>>  				     bool wait)
>> @@ -290,6 +306,12 @@ static inline int pnfs_return_layout(struct inode *ino,
>>  }
>>  
>>  static inline bool
>> +pnfs_ld_layoutret_on_setattr(struct inode *inode)
>> +{
>> +	return false;
>> +}
>> +
>> +static inline bool
>>  pnfs_roc(struct inode *ino)
>>  {
>>  	return false;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b03defb..b4df7a6 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2332,6 +2332,9 @@  nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
 	struct nfs4_state *state = NULL;
 	int status;
 
+	if (pnfs_ld_layoutret_on_setattr(inode))
+		pnfs_return_layout(inode, NULL, true);
+
 	nfs_fattr_init(fattr);
 	
 	/* Search for an existing open(O_WRITE) file */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a308f3c..3506ad4 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -64,12 +64,18 @@  enum {
 	NFS_LAYOUT_DESTROYED,		/* no new use of layout allowed */
 };
 
+enum layoutdriver_policy_flags {
+	/* Should the pNFS client commit and return the layout upon a setattr */
+	PNFS_LAYOUTRET_ON_SETATTR	= 1 << 0,
+};
+
 /* Per-layout driver specific registration structure */
 struct pnfs_layoutdriver_type {
 	struct list_head pnfs_tblid;
 	const u32 id;
 	const char *name;
 	struct module *owner;
+	unsigned flags;
 	struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr);
 	void (*free_lseg) (struct pnfs_layout_segment *lseg);
 
@@ -228,6 +234,16 @@  static inline void pnfs_clear_request_commit(struct nfs_page *req)
 		put_lseg(req->wb_commit_lseg);
 }
 
+/* Should the pNFS client commit and return the layout upon a setattr */
+static inline bool
+pnfs_ld_layoutret_on_setattr(struct inode *inode)
+{
+	if (!pnfs_enabled_sb(NFS_SERVER(inode)))
+		return false;
+	return NFS_SERVER(inode)->pnfs_curr_ld->flags &
+		PNFS_LAYOUTRET_ON_SETATTR;
+}
+
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct pnfs_layout_range *range,
 				     bool wait)
@@ -290,6 +306,12 @@  static inline int pnfs_return_layout(struct inode *ino,
 }
 
 static inline bool
+pnfs_ld_layoutret_on_setattr(struct inode *inode)
+{
+	return false;
+}
+
+static inline bool
 pnfs_roc(struct inode *ino)
 {
 	return false;