[pnfs] CVS: nfsv4
Benny Halevy Panasas
bhalevy at citi.umich.edu
Tue Dec 12 04:03:52 EST 2006
CVSROOT: /cvs
Module name: nfsv4
Changes by: bhalevy at citi. 2006/12/12 04:03:52
Modified files:
cvs/pnfs/fs/nfs: nfs4state.c pnfs.c write.c
cvs/pnfs/fs/nfsd: nfs4proc.c
cvs/pnfs/include/linux: fs.h
Log message:
The following patche implements changes we need for
layout commit. The first patch one adds logic on the client
side to mark the inode for layout commit on the sync and async
write paths and to send the layoutcommit before close.
The second patch adds a layout_commit export op and
calls it rather than notify_change if the file system
implemented it (we need it in order to avoid blocking
indefinitely in the setattr patch)
- commit layout before close if needed
- mark inode for layout commit after successful synchronous writes
and in the async writeback path (always for non-nfsv4 layout types).
- Add a layout_commit export op
If implemented, invoke it rather than notify_change() in nfsd4_layoutcommit()
so that the filesystem can decide how to apply new attributes
Index: fs/nfs/nfs4state.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/nfs4state.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 nfs4state.c
--- fs/nfs/nfs4state.c 16 Mar 2006 17:58:32 -0000 1.1.1.2
+++ fs/nfs/nfs4state.c 12 Dec 2006 08:50:53 -0000
@@ -51,6 +51,7 @@
#include "nfs4_fs.h"
#include "callback.h"
#include "delegation.h"
+#include "pnfs.h"
#define OPENOWNER_POOL_SIZE 8
@@ -510,8 +511,15 @@ void nfs4_close_state(struct nfs4_state
spin_unlock(&inode->i_lock);
spin_unlock(&owner->so_lock);
- if (oldstate != newstate && nfs4_do_close(inode, state) == 0)
- return;
+ if (oldstate != newstate) {
+ if (pnfs_enabled_sb(NFS_SERVER(inode))) {
+ if (NFS_I(inode)->layoutcommit_ctx) {
+ pnfs_layoutcommit_inode(inode, 0);
+ }
+ }
+ if (nfs4_do_close(inode, state) == 0)
+ return;
+ }
nfs4_put_open_state(state);
nfs4_put_state_owner(owner);
}
Index: fs/nfs/pnfs.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/pnfs.c,v
retrieving revision 1.45
diff -u -p -r1.45 pnfs.c
--- fs/nfs/pnfs.c 30 Nov 2006 16:51:07 -0000 1.45
+++ fs/nfs/pnfs.c 12 Dec 2006 08:50:54 -0000
@@ -162,10 +162,12 @@ find_pnfs(int id, struct pnfs_module **m
void
pnfs_need_layoutcommit(struct nfs_inode* nfsi, struct nfs_open_context *ctx)
{
+ dprintk("%s: current_layout=%p layoutcommit_ctx=%p ctx=%p\n",__FUNCTION__,
+ nfsi->current_layout, nfsi->layoutcommit_ctx, ctx);
spin_lock(&pnfs_spinlock);
if (nfsi->current_layout && !nfsi->layoutcommit_ctx) {
- dprintk("%s: Setting layoutcommit flag\n",__FUNCTION__);
nfsi->layoutcommit_ctx = get_nfs_open_context(ctx);
+ dprintk("%s: Set layoutcommit_ctx=%p\n",__FUNCTION__, nfsi->layoutcommit_ctx);
}
spin_unlock(&pnfs_spinlock);
}
@@ -760,7 +762,12 @@ pnfs_writepages(struct nfs_write_data* w
how,
wdata);
- out:
+ if (status > 0) {
+ pnfs_update_last_write(nfsi, args->offset, status);
+ pnfs_need_layoutcommit(nfsi, wdata->args.context);
+ }
+
+out:
dprintk("%s: End Status %d\n",__FUNCTION__, status);
return status;
}
@@ -1216,6 +1223,7 @@ pnfs_layoutcommit_setup(struct pnfs_layo
struct nfs_server *nfss = NFS_SERVER(data->inode);
struct nfs4_client *clp = nfss->nfs4_state;
+ dprintk("%s Begin (sync:%d)\n", __FUNCTION__, sync);
data->args.fh = NFS_FH(data->inode);
data->args.clientid = clp->cl_clientid;
data->args.layout_type = nfss->pnfs_curr_ld->id;
@@ -1278,7 +1286,7 @@ pnfs_layoutcommit_inode(struct inode *in
struct nfs_inode *nfsi = NFS_I(inode);
int status = 0;
- dprintk("%s Begin\n", __FUNCTION__);
+ dprintk("%s Begin (sync:%d)\n", __FUNCTION__, sync);
data = pnfs_layoutcommit_alloc();
if (!data)
@@ -1315,6 +1323,7 @@ pnfs_layoutcommit_inode(struct inode *in
pnfs_execute_layoutcommit(data);
}
out:
+ dprintk("%s end (err:%d)\n", __FUNCTION__, status);
return status;
out_unlock:
spin_unlock(&pnfs_spinlock);
Index: fs/nfs/write.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/write.c,v
retrieving revision 1.30
diff -u -p -r1.30 write.c
--- fs/nfs/write.c 13 Oct 2006 05:54:30 -0000 1.30
+++ fs/nfs/write.c 12 Dec 2006 08:50:55 -0000
@@ -1356,10 +1356,11 @@ void pnfs_writeback_done_update(struct n
struct nfs_writeres *resp = &data->res;
struct nfs_inode *nfsi = NFS_I(data->inode);
+ dprintk("%s: (count:%d)\n", __FUNCTION__, resp->count);
if(resp->count > 0 && pnfs_use_write(data->inode, argp->count)) {
pnfs_update_last_write(nfsi, argp->offset, resp->count);
- if (pnfs_use_nfsv4_wproto(data->inode, argp->count) &&
+ if (!pnfs_use_nfsv4_wproto(data->inode, argp->count) ||
((resp->verf->committed == NFS_FILE_SYNC) ||
(data->how == FLUSH_STABLE && data->call_ops == NULL)))
pnfs_need_layoutcommit(nfsi, argp->context);
Index: fs/nfsd/nfs4proc.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfsd/nfs4proc.c,v
retrieving revision 1.22
diff -u -p -r1.22 nfs4proc.c
--- fs/nfsd/nfs4proc.c 4 Dec 2006 18:10:59 -0000 1.22
+++ fs/nfsd/nfs4proc.c 12 Dec 2006 08:50:57 -0000
@@ -827,6 +827,7 @@ nfsd4_layoutcommit( struct svc_rqst *rqs
int status;
struct inode* ino = NULL;
struct iattr ia;
+ struct super_block *sb;
dprintk("NFSD: nfsd4_layoutcommit \n");
status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
@@ -857,8 +858,14 @@ nfsd4_layoutcommit( struct svc_rqst *rqs
dprintk("%s: Modifying file size\n", __FUNCTION__);
ia.ia_valid = ATTR_SIZE;
ia.ia_size = lcp->lc_last_wr + 1;
- status = notify_change(current_fh->fh_dentry, &ia);
- dprintk("%s:notify_change result %d\n", __FUNCTION__, status);
+ sb = current_fh->fh_dentry->d_inode->i_sb;
+ if (sb->s_export_op->layout_commit) {
+ status = sb->s_export_op->layout_commit(ino, lcp);
+ dprintk("%s:layout_commit result %d\n", __FUNCTION__, status);
+ } else {
+ status = notify_change(current_fh->fh_dentry, &ia);
+ dprintk("%s:notify_change result %d\n", __FUNCTION__, status);
+ }
fh_unlock(current_fh);
Index: include/linux/fs.h
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/include/linux/fs.h,v
retrieving revision 1.12
diff -u -p -r1.12 fs.h
--- include/linux/fs.h 19 Sep 2006 23:23:33 -0000 1.12
+++ include/linux/fs.h 12 Dec 2006 08:51:00 -0000
@@ -1285,6 +1285,8 @@ struct export_operations {
int (*layout_get) (struct inode *inode, void *buf);
/* pNFS: returns the opaque device */
int (*get_deviceinfo) (struct super_block *sb, void *p);
+ /* pNFS: commit changes to layout */
+ int (*layout_commit) (struct inode *inode, void *p);
/* pNFS: returns the layout */
int (*layout_return) (struct inode *inode, void *p);
More information about the pNFS
mailing list