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

Benny Halevy bhalevy at panasas.com
Tue Nov 28 03:21:56 EST 2006


- define pnfs_iomode as an enumerated type rather than using FMODE constants
- rename (and retype) argument names accordingly.

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

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
@@ -298,7 +298,7 @@ static int
  get_layout(struct inode* ino,
            struct nfs_open_context* ctx,
            size_t count, loff_t pos,
-          int access_type,
+          enum pnfs_iomode iomode,
            struct nfs4_pnfs_layoutget_arg* arg,
            struct nfs4_pnfs_layoutget_res* res)
  {
@@ -312,8 +312,7 @@ get_layout(struct inode* ino,

         arg->clientid = ctx->state->owner->so_client->cl_clientid;
         arg->type = server->pnfs_curr_ld->id;
-       /* FMODE_WRITE =2= LAYOUTMODE_RW,  FMODE_READ =1= LAYOUTMODE_READ */
-       arg->iomode = access_type;
+       arg->iomode = iomode;
         arg->offset = 0;
         arg->length = (__u64)~0;
         arg->minlength = count;
@@ -347,8 +346,7 @@ pnfs_return_layout(struct inode* ino)
         arg.clientid = server->nfs4_state->cl_clientid;
         arg.reclaim = 0;
         arg.layout_type = server->pnfs_curr_ld->id;
-       /* FMODE_WRITE =2= LAYOUTMODE_RW,  FMODE_READ =1= LAYOUTMODE_READ */
-       arg.iomode = FMODE_WRITE;
+       arg.iomode = IOMODE_ANY /* for now */;
         arg.return_type = LAYOUTRETURN_FILE;
         arg.offset = 0;
         arg.length = ~0;
@@ -409,7 +407,7 @@ virtual_update_layout(struct inode* ino,
                       struct nfs_open_context* ctx,
                       size_t count,
                       loff_t pos,
-                     int access_type)
+                     enum pnfs_iomode iomode)
  {
         struct nfs4_pnfs_layoutget_res res;
         struct nfs4_pnfs_layoutget_arg arg;
@@ -437,7 +435,7 @@ virtual_update_layout(struct inode* ino,
                 return 0; /* Already have layout information */
         }

-       if ((result = get_layout(ino, ctx, count, pos, access_type, 
&arg, &res))) {
+       if ((result = get_layout(ino, ctx, count, pos, iomode, &arg, 
&res))) {
                 printk("\n%s: ERROR retrieving layout 
%d\n",__FUNCTION__,result);
                 result =  -EIO;
                 goto out;
@@ -731,7 +735,7 @@ pnfs_writepages(struct nfs_write_data* w
                                             args->context,
                                             args->count,
                                             args->offset,
-                                           FMODE_WRITE)))
+                                           IOMODE_RW)))
                 goto out;

         if (!nfss->pnfs_curr_ld->ld_io_ops ||
@@ -819,7 +823,7 @@ pnfs_readpages(struct nfs_read_data *rda
                                             args->context,
                                             args->count,
                                             args->offset,
-                                           FMODE_WRITE)))
+                                           IOMODE_RW)))
                 goto out;

         if (!nfss->pnfs_curr_ld->ld_io_ops ||
@@ -907,7 +911,7 @@ pnfs_file_read(struct file* filp,
                                             (struct nfs_open_context 
*)filp->private_data,
                                             count,
                                             *pos,
-                                           FMODE_READ)))
+                                           IOMODE_READ)))
                 goto out;

         /* Step 2: Call I/O device driver's read function */
@@ -991,7 +995,7 @@ pnfs_file_write(struct file* filp,
                                             (struct nfs_open_context 
*)filp->private_data,
                                             count,
                                             *pos,
-                                           FMODE_WRITE)))
+                                           IOMODE_RW)))
                 goto out;

         /* Step 2: Call I/O device driver's write function */
@@ -1118,7 +1122,7 @@ pnfs_fsync(struct file *file, struct den
                                             (struct nfs_open_context 
*)file->private_data,
                                             0,
                                             0,
-                                           FMODE_WRITE)))
+                                           IOMODE_RW)))
                 goto out;

         dprintk("%s: Calling layout driver fsync\n",__FUNCTION__);
diff -x CVS -rup a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
--- a/fs/nfs/pnfs.h     2006-11-16 09:38:24.000000000 +0200
+++ b/fs/nfs/pnfs.h     2006-11-27 19:01:19.000000000 +0200
@@ -13,7 +13,7 @@
  #define FS_NFS_PNFS_H

  int virtual_update_layout(struct inode* ino, struct nfs_open_context* ctx,
-       size_t count, loff_t pos, int access_type);
+       size_t count, loff_t pos, enum pnfs_iomode access_type);

  int pnfs_return_layout(struct inode* ino);
  void set_pnfs_layoutdriver(struct super_block *sb, u32 id);
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
@@ -28,6 +28,12 @@ struct nfs4_pnfs_layout {
         char buf[PNFS_LAYOUT_MAXSIZE];
  };

+enum pnfs_iomode {
+       IOMODE_READ = 1,
+       IOMODE_RW = 2,
+       IOMODE_ANY = 3,
+};
+
  struct nfs4_pnfs_layoutget_arg {
         __u64 clientid;
         __u32 type;


More information about the pNFS mailing list