linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfs: treat open-associated setattr like write otc purposes
@ 2011-12-07 16:40 J. Bruce Fields
  0 siblings, 0 replies; only message in thread
From: J. Bruce Fields @ 2011-12-07 16:40 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Bryan Schumaker, linux-nfs

From: "J. Bruce Fields" <bfields@redhat.com>

For the purposes of open-to-close cache consistency, I don't see why a
setattr (if it's something like "ftruncate", that's associated with an
open) should be treated any differently than a write.

In the v4 case (in the absence of pre-op attributes) that means we
should fake up pre-op attributes as we do for write.

This allows us to handle reads from cache in more cases.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/nfs/inode.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

We discussed this a few weeks ago and you seemed amenable to the basic
idea, but I have doubts about my implementation:

	- Is this really the right place to do this?
	- I'm changing v2/v3 behavior here too, where in the write case
	  I think it's only v4 that does the
	  nfs_post_op_update_inode_force_wcc().

Also cc'ing Bryan since I think you suggested he might be interested.

--b.

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index fe12037..b84748e 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -438,8 +438,13 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
 	if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
 		nfs_inode_return_delegation(inode);
 	error = NFS_PROTO(inode)->setattr(dentry, fattr, attr);
-	if (error == 0)
+	if (error)
+		goto out_free;
+	if (attr->ia_valid & ATTR_FILE)
+		nfs_post_op_update_inode_force_wcc(inode, fattr);
+	else
 		nfs_refresh_inode(inode, fattr);
+out_free:
 	nfs_free_fattr(fattr);
 out:
 	return error;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-07 16:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07 16:40 [PATCH] nfs: treat open-associated setattr like write otc purposes J. Bruce Fields

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).