[pnfs] [PATCH] return layout on setattr
Benny Halevy
bhalevy at panasas.com
Tue Nov 28 07:19:29 EST 2006
I propose to add this to the pnfs client as we need to always
return the layout on setattr. Having the client commit and return
the layout before sending the setattr is more efficient than
having to always recall it, hence adding a client layout_type
policy makes sense...
Benny
Commit and return layout on setattr, based on layout_type policy
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
diff -x CVS -rup a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
--- a/fs/nfs/nfs4proc.c 2006-11-16 09:38:24.000000000 +0200
+++ b/fs/nfs/nfs4proc.c 2006-11-28 14:12:59.000000000 +0200
@@ -1594,6 +1594,33 @@ nfs4_proc_setattr(struct dentry *dentry,
return status;
}
+/*
+ * Return layout before issuing a setattr
+ */
+static int
+pnfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
+ struct iattr *sattr)
+{
+ struct inode *inode = dentry->d_inode;
+
+ if (pnfs_enabled_sb(NFS_SERVER(inode)) &&
NFS_I(inode)->current_layout) {
+ struct pnfs_layoutdriver_type *ld;
+ struct layoutdriver_policy_operations *policy_ops;
+
+ ld = NFS_SERVER(inode)->pnfs_curr_ld;
+ policy_ops = ld->ld_policy_ops;
+
+ if (policy_ops && policy_ops->layoutret_on_setattr) {
+ if (NFS_I(inode)->layoutcommit_ctx) {
+ pnfs_layoutcommit_inode(inode, 0);
+ }
+ pnfs_return_layout(inode);
+ }
+ }
+
+ return nfs4_proc_setattr(dentry, fattr, sattr);
+}
+
static int _nfs4_proc_lookup(struct inode *dir, struct qstr *name,
struct nfs_fh *fhandle, struct nfs_fattr *fattr)
{
@@ -4150,7 +4177,7 @@ struct nfs_rpc_ops pnfs_v4_clientops = {
.file_inode_ops = &nfs4_file_inode_operations,
.getroot = nfs4_proc_get_root,
.getattr = nfs4_proc_getattr,
- .setattr = nfs4_proc_setattr,
+ .setattr = pnfs4_proc_setattr,
.lookup = nfs4_proc_lookup,
.access = nfs4_proc_access,
.readlink = nfs4_proc_readlink,
diff -x CVS -rup a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
--- a/include/linux/nfs4_pnfs.h 2006-11-28 11:12:08.000000000 +0200
+++ b/include/linux/nfs4_pnfs.h 2006-11-28 14:13:01.000000000 +0200
@@ -105,6 +105,10 @@ struct layoutdriver_policy_operations {
* same compound as the OPEN operation?
*/
int (*layoutget_on_open) (struct pnfs_mount_type *);
+
+ /* Should the pNFS client commit and return the layout upon a
setattr
+ */
+ int (*layoutret_on_setattr) (struct pnfs_mount_type *);
};
/* Per-layout driver specific registration structure */
More information about the pNFS
mailing list