[PVFS2-CVS] commit by neill in pvfs2/src/kernel/linux-2.6: dcache.c dir.c file.c inode.c namei.c pvfs2-cache.c pvfs2-kernel.h pvfs2-utils.c super.c

CVS commit program cvs at parl.clemson.edu
Fri Feb 13 14:37:26 EST 2004


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

Modified Files:
	dcache.c dir.c file.c inode.c namei.c pvfs2-cache.c 
	pvfs2-kernel.h pvfs2-utils.c super.c 
Log Message:
- improve error handling in many failure scenarios
- properly initialize inode private data in cases where we know it's invalid


Index: dcache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/dcache.c,v
diff -p -u -r1.12 -r1.13
--- dcache.c	10 Feb 2004 23:12:36 -0000	1.12
+++ dcache.c	13 Feb 2004 19:37:26 -0000	1.13
@@ -31,6 +31,10 @@ int pvfs2_d_revalidate(
     else if (inode)
     {
 	ret = ((pvfs2_inode_getattr(inode) == 0) ? 1 : 0);
+        if (ret == 0)
+        {
+            make_bad_inode(inode);
+        }
     }
     return ret;
 }

Index: dir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/dir.c,v
diff -p -u -r1.16 -r1.17
--- dir.c	9 Feb 2004 21:58:02 -0000	1.16
+++ dir.c	13 Feb 2004 19:37:26 -0000	1.17
@@ -59,6 +59,8 @@ static int pvfs2_readdir(
 
     pvfs2_print("pvfs2: pvfs2_readdir called on %s (pos = %d)\n",
 		dentry->d_name.name, (int)pos);
+    pvfs2_print("token adjustment is %d\n",
+                pvfs2_inode->readdir_token_adjustment);
 
     switch (pos)
     {

Index: file.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/file.c,v
diff -p -u -r1.51 -r1.52
--- file.c	10 Feb 2004 23:12:36 -0000	1.51
+++ file.c	13 Feb 2004 19:37:26 -0000	1.52
@@ -391,17 +391,24 @@ int pvfs2_fsync(
 
 loff_t pvfs2_file_llseek(struct file *file, loff_t offset, int origin)
 {
+    int ret = -EINVAL;
     struct inode *inode = file->f_dentry->d_inode;
 
-    /* revalidate inode to get the file size */
     if (!inode)
     {
         pvfs2_error("pvfs2_file_llseek: invalid inode (NULL)\n");
-        return -EINVAL;
+        return ret;
     }
-    if ((inode->i_size == 0) && pvfs2_inode_getattr(inode))
+
+    if (inode->i_size == 0)
     {
-        return -EINVAL;
+        /* revalidate the inode's file size */
+        ret = pvfs2_inode_getattr(inode);
+        if (ret)
+        {
+            make_bad_inode(inode);
+            return ret;
+        }
     }
 
     /*

Index: inode.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/inode.c,v
diff -p -u -r1.30 -r1.31
--- inode.c	11 Feb 2004 23:14:47 -0000	1.30
+++ inode.c	13 Feb 2004 19:37:26 -0000	1.31
@@ -373,10 +373,15 @@ int pvfs2_getattr(
     pvfs2_print("pvfs2: pvfs2_getattr called on %s\n",
                 dentry->d_name.name);
 
-    if (pvfs2_inode_getattr(inode) == 0)
+    ret = pvfs2_inode_getattr(inode);
+    if (ret == 0)
     {
         generic_fillattr(inode, kstat);
-        ret = 0;
+    }
+    else
+    {
+        /* assume an I/O error and flag inode as bad */
+        make_bad_inode(inode);
     }
     return ret;
 }

Index: namei.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/namei.c,v
diff -p -u -r1.41 -r1.42
--- namei.c	11 Feb 2004 23:14:49 -0000	1.41
+++ namei.c	13 Feb 2004 19:37:26 -0000	1.42
@@ -146,7 +146,7 @@ struct dentry *pvfs2_lookup(
     {
 	inode = iget(sb, pvfs2_handle_to_ino(
                          new_op->downcall.resp.lookup.refn.handle));
-	if (inode)
+	if (inode && !is_bad_inode(inode))
 	{
 	    found_pvfs2_inode = PVFS2_I(inode);
 
@@ -162,7 +162,10 @@ struct dentry *pvfs2_lookup(
 	}
 	else
 	{
-	    pvfs2_error("FIXME: Invalid pvfs2 private data\n");
+            if (inode)
+            {
+                iput(inode);
+            }
             op_release(new_op);
             return ERR_PTR(-EACCES);
 	}

Index: pvfs2-cache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-cache.c,v
diff -p -u -r1.15 -r1.16
--- pvfs2-cache.c	15 Dec 2003 21:13:58 -0000	1.15
+++ pvfs2-cache.c	13 Feb 2004 19:37:26 -0000	1.16
@@ -26,7 +26,6 @@ extern kmem_cache_t *pvfs2_inode_cache;
 extern int pvfs2_gen_credentials(
     PVFS_credentials *credentials);
 
-
 static void op_cache_ctor(
     void *kernel_op,
     kmem_cache_t *cachep,
@@ -139,16 +138,13 @@ static void pvfs2_inode_cache_ctor(
     kmem_cache_t * cachep,
     unsigned long flags)
 {
-    pvfs2_inode_t *pvfs2_inode = (pvfs2_inode_t *) new_pvfs2_inode;
+    pvfs2_inode_t *pvfs2_inode = (pvfs2_inode_t *)new_pvfs2_inode;
 
     if (flags & SLAB_CTOR_CONSTRUCTOR)
     {
 	memset(pvfs2_inode, 0, sizeof(pvfs2_inode_t));
 
-	pvfs2_inode->refn.handle = 0;
-	pvfs2_inode->refn.fs_id = 0;
-        pvfs2_inode->link_target = NULL;
-        pvfs2_inode->last_failed_block_index_read = 0;
+        pvfs2_inode_initialize(pvfs2_inode);
 
 	/*
 	   inode_init_once is from inode.c;

Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.33 -r1.34
--- pvfs2-kernel.h	11 Feb 2004 23:14:49 -0000	1.33
+++ pvfs2-kernel.h	13 Feb 2004 19:37:26 -0000	1.34
@@ -393,6 +393,8 @@ int pvfs2_kernel_error_code_convert(
 void *pvfs2_kernel_error_code_ptr_convert(
     int pvfs2_error_code);
 
+void pvfs2_inode_initialize(
+    pvfs2_inode_t *pvfs2_inode);
 
 #endif /* __PVFS2KERNEL_H */
 

Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.49 -r1.50
--- pvfs2-utils.c	11 Feb 2004 23:14:49 -0000	1.49
+++ pvfs2-utils.c	13 Feb 2004 19:37:26 -0000	1.50
@@ -337,12 +337,12 @@ static inline int copy_attributes_from_i
   issues a pvfs2 getattr request and fills in the
   appropriate inode attributes if successful.
 
-  returns 0 on success; -1 otherwise
+  returns 0 on success; -errno otherwise
 */
 int pvfs2_inode_getattr(
     struct inode *inode)
 {
-    int ret = -1, retries = PVFS2_OP_RETRY_COUNT, error_exit = 0;
+    int ret = -EINVAL, retries = PVFS2_OP_RETRY_COUNT, error_exit = 0;
     pvfs2_kernel_op_t *new_op = NULL;
     pvfs2_inode_t *pvfs2_inode = NULL;
 
@@ -351,7 +351,7 @@ int pvfs2_inode_getattr(
 	pvfs2_inode = PVFS2_I(inode);
 	if (!pvfs2_inode)
 	{
-	    return ret;
+ 	    return ret;
 	}
 
 	/*
@@ -385,6 +385,7 @@ int pvfs2_inode_getattr(
 	{
 	    pvfs2_error("pvfs2: pvfs2_inode_getattr -- "
                         "kmem_cache_alloc failed!\n");
+            ret = -ENOMEM;
 	    return ret;
 	}
 	new_op->upcall.type = PVFS2_VFS_OP_GETATTR;
@@ -410,7 +411,7 @@ int pvfs2_inode_getattr(
                             "to copy attributes\n");
             }
 	}
-        ret = new_op->downcall.status;
+        ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
 
       error_exit:
         pvfs2_print(error_exit ? "*** warning: getattr error_exit\n" : "");
@@ -490,6 +491,9 @@ static inline struct inode *pvfs2_create
 	new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
 	if (!new_op)
 	{
+	    pvfs2_error("pvfs2: pvfs2_create_file -- "
+                        "kmem_cache_alloc failed!\n");
+            iput(inode);
             *error_code = -ENOMEM;
 	    return NULL;
 	}
@@ -588,6 +592,7 @@ static inline struct inode *pvfs2_create
 	{
 	    pvfs2_error("pvfs2: pvfs2_create_dir -- "
                         "kmem_cache_alloc failed!\n");
+            iput(inode);
             *error_code = -ENOMEM;
 	    return NULL;
 	}
@@ -685,6 +690,9 @@ static inline struct inode *pvfs2_create
 	new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
 	if (!new_op)
 	{
+	    pvfs2_error("pvfs2: pvfs2_create_symlink -- "
+                        "kmem_cache_alloc failed!\n");
+            iput(inode);
             *error_code = -ENOMEM;
 	    return NULL;
 	}
@@ -852,6 +860,9 @@ int pvfs2_remove_entry(
               in the middle of a readdir for this directory
             */
             parent->readdir_token_adjustment++;
+
+            pvfs2_print("token adjustment is %d\n",
+                        parent->readdir_token_adjustment);
         }
         ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
 
@@ -905,21 +916,39 @@ int pvfs2_truncate_inode(
 int pvfs2_kernel_error_code_convert(
     int pvfs2_error_code)
 {
-    int ret = 0;
+    int ret = pvfs2_error_code;
 
     switch(pvfs2_error_code)
     {
+        case -PVFS_EINVAL:
+            ret = -EINVAL;
+            break;
+        case -PVFS_ENOMEM:
+            ret = -ENOMEM;
+            break;
         case -PVFS_ENOTEMPTY:
             ret = -ENOTEMPTY;
             break;
         case -PVFS_ENOSPC:
             ret = -ENOSPC;
             break;
+        case 0:
+            ret = 0;
+            break;
         default:
             pvfs2_print("Got an unknown pvfs2 error code: %d\n",
                         pvfs2_error_code);
     }
     return ret;
+}
+
+void pvfs2_inode_initialize(pvfs2_inode_t *pvfs2_inode)
+{
+    pvfs2_inode->refn.handle = 0;
+    pvfs2_inode->refn.fs_id = 0;
+    pvfs2_inode->link_target = NULL;
+    pvfs2_inode->last_failed_block_index_read = 0;
+    pvfs2_inode->readdir_token_adjustment = 0;
 }
 
 /*

Index: super.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/super.c,v
diff -p -u -r1.23 -r1.24
--- super.c	11 Feb 2004 23:49:32 -0000	1.23
+++ super.c	13 Feb 2004 19:37:26 -0000	1.24
@@ -64,9 +64,20 @@ static void pvfs2_destroy_inode(
 static void pvfs2_read_inode(
     struct inode *inode)
 {
+    pvfs2_inode_t *pvfs2_inode = PVFS2_I(inode);
+
     pvfs2_print("pvfs2: pvfs2_read_inode called (inode = %d | "
                 "ct = %d)\n", (int)inode->i_ino,
                 (int)atomic_read(&inode->i_count));
+
+    /*
+      at this point we know the private inode data handle/fs_id can't
+      be valid because we've never done a pvfs2 lookup/getattr yet.
+      clear it here to allow the pvfs2_inode_getattr to use the inode
+      number as the handle instead of whatever junk the private data
+      may contain.
+    */
+    pvfs2_inode_initialize(pvfs2_inode);
 
     /*
        need to populate the freshly allocated (passed in)



More information about the PVFS2-CVS mailing list