[pnfs] [PATCH 3/3] layout_return and return_on_close

Benny Halevy bhalevy at panasas.com
Tue Nov 28 03:22:04 EST 2006


- Add the return_on_close flag to the layout_get results structure
- Save a return_on_close iomode in the pnfs_layout_type structure
- Return the layout before sending a close operation (currently for any 
iomode)

Signed-off-by: Benny Halevy bhalevy at panasas.com

diff -x CVS -rup a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
--- a/fs/nfs/nfs4state.c        2006-11-27 11:36:09.000000000 +0200
+++ b/fs/nfs/nfs4state.c        2006-11-27 19:01:19.000000000 +0200
@@ -42,6 +42,7 @@
  #include <linux/slab.h>
  #include <linux/smp_lock.h>
  #include <linux/nfs_fs.h>
+#include <linux/nfs4_pnfs.h>
  #include <linux/nfs_idmap.h>
  #include <linux/kthread.h>
  #include <linux/module.h>
@@ -516,6 +517,11 @@ void nfs4_close_state(struct nfs4_state
                         if (NFS_I(inode)->layoutcommit_ctx) {
                                 pnfs_layoutcommit_inode(inode, 0);
                         }
+                       /* TODO: make finer grained returns here */
+                       if (NFS_I(inode)->current_layout &&
+                           NFS_I(inode)->current_layout->roc_iomode) {
+                               pnfs_return_layout(inode);
+                       }
                 }
                 if (nfs4_do_close(inode, state) == 0)
                         return;
diff -x CVS -rup a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
--- a/fs/nfs/nfs4xdr.c  2006-11-27 18:19:46.000000000 +0200
+++ b/fs/nfs/nfs4xdr.c  2006-11-27 19:01:19.000000000 +0200
@@ -4642,7 +4642,8 @@ static int decode_pnfs_layoutget(struct
         status = decode_op_hdr(xdr, OP_LAYOUTGET);
         if (status)
                 return status;
-       READ_BUF(28);
+       READ_BUF(32);
+       READ32(res->return_on_close);
         READ64(res->offset);
         READ64(res->length);
         READ32(res->iomode);
diff -x CVS -rup a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
--- a/fs/nfs/pnfs.c     2006-11-27 18:19:46.000000000 +0200
+++ b/fs/nfs/pnfs.c     2006-11-27 19:01:19.000000000 +0200
@@ -455,10 +455,16 @@ virtual_update_layout(struct inode* ino,
                 printk("%s: ERROR!  Could not inject layout 
(%d)\n",__FUNCTION__,result);
                 result =  -EIO;
                 goto out;
-       } else {
-               nfsi->current_layout = layout_new;
         }

+       if (res.return_on_close) {
+               layout_new->roc_iomode = res.iomode;
+               if (!layout_new->roc_iomode) {
+                       layout_new->roc_iomode = IOMODE_ANY;
+               }
+       }
+       nfsi->current_layout = layout_new;
+
         result = 0;
  out:
         dprintk("%s end (err:%d)\n",__FUNCTION__,result);
diff -x CVS -rup a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
--- a/fs/nfsd/nfs4xdr.c 2006-11-27 18:19:46.000000000 +0200
+++ b/fs/nfsd/nfs4xdr.c 2006-11-27 19:01:20.000000000 +0200
@@ -2781,7 +2781,8 @@ nfsd4_encode_getdevinfo(struct nfsd4_com
         }
  }

-/* LAYOUTGET: minorversion1-01.txt
+/* LAYOUTGET: minorversion1-08.txt
+u32            bool                    logr_return_on_close;
  u64            offset4                 offset;
  u64            length4                 length;
  u32            pnfs_layoutiomode4      iomode;
@@ -2795,7 +2796,8 @@ nfsd4_encode_layoutget(struct nfsd4_comp
         ENCODE_HEAD;

         if (!nfserr) {
-               RESERVE_SPACE(28);
+               RESERVE_SPACE(32);
+               WRITE32(lgp->lg_return_on_close);
                 WRITE64(lgp->lg_offset);
                 WRITE64(lgp->lg_length);
                 WRITE32(lgp->lg_iomode);
diff -x CVS -rup a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
--- a/include/linux/nfs4_pnfs.h 2006-08-24 20:34:51.000000000 +0300
+++ b/include/linux/nfs4_pnfs.h 2006-11-27 19:01:20.000000000 +0200
@@ -29,6 +29,7 @@ struct pnfs_mount_type {
  struct pnfs_layout_type {
         struct pnfs_mount_type* mountid;
         void* layoutid;
+       int roc_iomode; /* iomode to return on close, 0=none */
  };

  /* Layout driver I/O operations.
diff -x CVS -rup a/include/linux/nfsd/nfsd4_pnfs.h 
b/include/linux/nfsd/nfsd4_pnfs.h
--- a/include/linux/nfsd/nfsd4_pnfs.h   2006-11-27 18:19:46.000000000 +0200
+++ b/include/linux/nfsd/nfsd4_pnfs.h   2006-11-27 19:01:20.000000000 +0200
@@ -83,6 +83,7 @@ struct nfsd4_pnfs_layoutget {
          /* only for cluster fs file layout 'struct knfsd_fh' */
         unsigned char                   lg_fh[NFS_MAXFHSIZE];

+       u32                             lg_return_on_close; /* response */
         void                            *lg_layout;     /* response 
callback encoded */
  };

diff -x CVS -rup a/include/linux/pnfs_xdr.h b/include/linux/pnfs_xdr.h
--- a/include/linux/pnfs_xdr.h  2006-11-27 18:19:46.000000000 +0200
+++ b/include/linux/pnfs_xdr.h  2006-11-27 19:01:20.000000000 +0200
@@ -47,6 +47,7 @@ struct nfs4_pnfs_layoutget_arg {
  };

  struct nfs4_pnfs_layoutget_res {
+       __u32 return_on_close;
         __u64 offset;
         __u64 length;
         __u32 iomode;


More information about the pNFS mailing list