[PVFS2-CVS] commit by neill in pvfs2/src/kernel/linux-2.6: dir.c downcall.h pvfs2-kernel.h pvfs2-utils.c

CVS commit program cvs at parl.clemson.edu
Thu Oct 28 18:04:30 EDT 2004


Update of /projects/cvsroot/pvfs2/src/kernel/linux-2.6
In directory parlweb:/tmp/cvs-serv14662/src/kernel/linux-2.6

Modified Files:
	dir.c downcall.h pvfs2-kernel.h pvfs2-utils.c 
Log Message:
- some more experimentation with the readdir stuff from the vfs standpoint.
  shouldn't be any more broken than before, but it needs more work
- fixed vfs directory version type mismatch


Index: dir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/dir.c,v
diff -p -u -r1.30 -r1.31
--- dir.c	20 Oct 2004 14:20:29 -0000	1.30
+++ dir.c	28 Oct 2004 21:04:29 -0000	1.31
@@ -40,9 +40,7 @@ static int pvfs2_readdir(
     pvfs2_kernel_op_t *new_op = NULL;
     pvfs2_inode_t *pvfs2_inode = PVFS2_I(dentry->d_inode);
 
-#if 0
   restart_readdir:
-#endif
 
     pos = (PVFS_ds_position)file->f_pos;
     if (pos == 0)
@@ -50,7 +48,7 @@ static int pvfs2_readdir(
         pvfs2_inode->readdir_token_adjustment = 0;
     }
 
-    pvfs2_print("pvfs2: pvfs2_readdir called on %s (pos=%d, tadj=%d, "
+    pvfs2_print("pvfs2_readdir called on %s (pos=%d, tadj=%d, "
                 "retry=%d, v=%Lu)\n", dentry->d_name.name, (int)pos,
                 (int)pvfs2_inode->readdir_token_adjustment,
                 (int)pvfs2_inode->num_readdir_retries,
@@ -157,13 +155,7 @@ static int pvfs2_readdir(
             {
                 goto graceful_termination_path;
             }
-#if 0
-            /*
-              NOTE: we can't do the retries with the token_adjustment
-              in use because an rm -rf will cause all kinds of
-              problems since the dir is changing as it's being read
-              and we don't want retries in that case.
-            */
+
             if (pvfs2_inode->directory_version == 0)
             {
                 pvfs2_inode->directory_version =
@@ -175,17 +167,50 @@ static int pvfs2_readdir(
                 if (pvfs2_inode->directory_version !=
                     new_op->downcall.resp.readdir.directory_version)
                 {
+                    /*
+                      if the token adjustment is moving rapidly, do
+                      not attempt any retries
+                    */
+                    if ((pvfs2_inode->readdir_token_adjustment) &&
+                        (pvfs2_inode->readdir_token_adjustment %
+                         MAX_DIRENT_COUNT) == 0)
+                    {
+                        pvfs2_inode->last_version_changed = 1;
+                    }
+
+                    /*
+                      don't bother to restart if the directory is
+                      changing too rapidly.  either someone is
+                      creating or removing (as in the case of a
+                      typical rm -rf operation) too quickly and we
+                      have no guarantee of the listing
+                    */
+                    if (pvfs2_inode->last_version_changed)
+                    {
+                        /* once set, do not clear until finished */
+                        goto continue_listing;
+                    }
+
                     pvfs2_print("detected directory change on listing; "
                                 "starting over\n");
 
                     file->f_pos = 0;
                     pvfs2_inode->directory_version =
                         new_op->downcall.resp.readdir.directory_version;
+                    pvfs2_inode->last_version_changed = 1;
 
                     op_release(new_op);
                     pvfs2_inode->num_readdir_retries--;
                     goto restart_readdir;
                 }
+                else
+                {
+                    /*
+                      version hasn't changed between two consecutive
+                      calls; clear the flag here
+                    */
+                    pvfs2_inode->last_version_changed = 0;
+                }
             }
             else
             {
@@ -193,11 +218,13 @@ static int pvfs2_readdir(
                             "possible livelock (%d tries attempted)\n",
                             PVFS2_NUM_READDIR_RETRIES);
             }
-#endif
+
+          continue_listing:
 	    for (i = 0; i < new_op->downcall.resp.readdir.dirent_count; i++)
 	    {
                 len = new_op->downcall.resp.readdir.d_name_len[i];
-                current_entry = &new_op->downcall.resp.readdir.d_name[i][0];
+                current_entry =
+                    &new_op->downcall.resp.readdir.d_name[i][0];
                 current_ino =
                     pvfs2_handle_to_ino(
                         new_op->downcall.resp.readdir.refn[i].handle);
@@ -210,6 +237,7 @@ static int pvfs2_readdir(
                     pvfs2_inode->directory_version = 0;
                     pvfs2_inode->num_readdir_retries =
                         PVFS2_NUM_READDIR_RETRIES;
+                    pvfs2_inode->last_version_changed = 0;
 
                     ret = 0;
                     break;

Index: downcall.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/downcall.h,v
diff -p -u -r1.20 -r1.21
--- downcall.h	25 Oct 2004 14:56:36 -0000	1.20
+++ downcall.h	28 Oct 2004 21:04:29 -0000	1.21
@@ -55,7 +55,7 @@ typedef struct
 typedef struct
 {
     int dirent_count;
-    unsigned long directory_version;
+    uint64_t directory_version;
     PVFS_object_ref refn[MAX_DIRENT_COUNT];
     char d_name[MAX_DIRENT_COUNT][PVFS2_NAME_LEN];
     int d_name_len[MAX_DIRENT_COUNT];

Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.79 -r1.80
--- pvfs2-kernel.h	25 Oct 2004 14:56:36 -0000	1.79
+++ pvfs2-kernel.h	28 Oct 2004 21:04:29 -0000	1.80
@@ -197,7 +197,8 @@ typedef struct
     PVFS_object_ref refn;
     PVFS_ds_position readdir_token_adjustment;
     int num_readdir_retries;
-    uint64_t directory_version;
+    int last_version_changed; 
+   uint64_t directory_version;
     char *link_target;
 #ifdef PVFS2_LINUX_KERNEL_2_4
     struct inode *vfs_inode;

Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.93 -r1.94
--- pvfs2-utils.c	25 Oct 2004 14:56:36 -0000	1.93
+++ pvfs2-utils.c	28 Oct 2004 21:04:29 -0000	1.94
@@ -1004,7 +1004,9 @@ void pvfs2_inode_initialize(pvfs2_inode_
     pvfs2_inode->last_failed_block_index_read = 0;
     pvfs2_inode->link_target = NULL;
     pvfs2_inode->readdir_token_adjustment = 0;
+    pvfs2_inode->last_version_changed = 0;
     pvfs2_inode->num_readdir_retries = PVFS2_NUM_READDIR_RETRIES;
+    pvfs2_inode->directory_version = 0;
 }
 
 /*
@@ -1017,7 +1019,9 @@ void pvfs2_inode_finalize(pvfs2_inode_t 
     pvfs2_inode->refn.fs_id = PVFS_FS_ID_NULL;
     pvfs2_inode->last_failed_block_index_read = 0;
     pvfs2_inode->readdir_token_adjustment = 0;
+    pvfs2_inode->last_version_changed = 0;
     pvfs2_inode->num_readdir_retries = PVFS2_NUM_READDIR_RETRIES;
+    pvfs2_inode->directory_version = 0;
 }
 
 void pvfs2_op_initialize(pvfs2_kernel_op_t *op)



More information about the PVFS2-CVS mailing list