[PVFS2-CVS] commit by neill in pvfs2-1/src/kernel/linux-2.6: dir.c
pvfs2-kernel.h pvfs2-utils.c
CVS commit program
cvs at parl.clemson.edu
Mon Feb 9 16:58:02 EST 2004
Update of /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6
In directory parlweb:/tmp/cvs-serv29230
Modified Files:
dir.c pvfs2-kernel.h pvfs2-utils.c
Log Message:
- adjust the offset of the issued upcall readdir if files are removed
on the directory we're reading between readdir calls
Index: dir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/dir.c,v
diff -p -u -r1.15 -r1.16
--- dir.c 6 Feb 2004 20:02:20 -0000 1.15
+++ dir.c 9 Feb 2004 21:58:02 -0000 1.16
@@ -48,6 +48,15 @@ static int pvfs2_readdir(
pos = (PVFS_ds_position)file->f_pos;
+ /*
+ reset the token adjustment when starting to read a directory
+ from the beginning
+ */
+ if (pos == 0)
+ {
+ pvfs2_inode->readdir_token_adjustment = 0;
+ }
+
pvfs2_print("pvfs2: pvfs2_readdir called on %s (pos = %d)\n",
dentry->d_name.name, (int)pos);
@@ -106,9 +115,25 @@ static int pvfs2_readdir(
so the proper pvfs2 position is (pos - 2), except where
pos == 0. In that case, pos is PVFS_READDIR_START.
+
+ the token adjustment is for the case where files or
+ directories are being removed between calls to readdir.
+ while we're progressing through the directory, our issued
+ upcall offset needs to be adjusted less the number of
+ objects in this directory that were removed.
*/
new_op->upcall.req.readdir.token =
(pos == 2 ? PVFS_READDIR_START : (pos - 2));
+ if (new_op->upcall.req.readdir.token != PVFS_READDIR_START)
+ {
+ new_op->upcall.req.readdir.token -=
+ pvfs2_inode->readdir_token_adjustment;
+ if (new_op->upcall.req.readdir.token == 0)
+ {
+ new_op->upcall.req.readdir.token =
+ PVFS_READDIR_START;
+ }
+ }
service_operation_with_timeout_retry(
new_op, "pvfs2_readdir", retries);
@@ -122,9 +147,6 @@ static int pvfs2_readdir(
int i = 0, len = 0;
ino_t current_ino = 0;
char *current_entry = NULL;
-
- /* store the position token */
- pvfs2_inode->readdir_token = new_op->downcall.resp.readdir.token;
for (i = 0; i < new_op->downcall.resp.readdir.dirent_count; i++)
{
Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.30 -r1.31
--- pvfs2-kernel.h 5 Feb 2004 16:55:37 -0000 1.30
+++ pvfs2-kernel.h 9 Feb 2004 21:58:02 -0000 1.31
@@ -129,7 +129,7 @@ typedef struct
typedef struct
{
PVFS_pinode_reference refn;
- PVFS_ds_position readdir_token;
+ PVFS_ds_position readdir_token_adjustment;
char *link_target;
struct inode vfs_inode;
sector_t last_failed_block_index_read;
Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.45 -r1.46
--- pvfs2-utils.c 5 Feb 2004 16:55:37 -0000 1.45
+++ pvfs2-utils.c 9 Feb 2004 21:58:02 -0000 1.46
@@ -826,9 +826,18 @@ int pvfs2_remove_entry(
the status value tells us if it went through ok or not
*/
ret = new_op->downcall.status;
- if (ret == -PVFS_ENOTEMPTY)
+ switch(ret)
{
- ret = -ENOTEMPTY;
+ case -PVFS_ENOTEMPTY:
+ ret = -ENOTEMPTY;
+ break;
+ case 0:
+ /*
+ adjust the readdir token if in fact we're
+ in the middle of a readdir for this directory
+ */
+ parent->readdir_token_adjustment++;
+ break;
}
error_exit:
More information about the PVFS2-CVS
mailing list