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

CVS commit program cvs at parl.clemson.edu
Wed Feb 11 18:14:49 EST 2004


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

Modified Files:
	inode.c namei.c pvfs2-kernel.h pvfs2-utils.c 
Log Message:
- started mapping pvfs2 error codes to kernel error codes
- fix the case of assertion failing when a new file is attempted to be
  created when there is no space left on the server (and make sure it's
  properly reported back to the client)
- cleanups


Index: inode.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/inode.c,v
diff -p -u -r1.29 -r1.30
--- inode.c	9 Jan 2004 19:33:26 -0000	1.29
+++ inode.c	11 Feb 2004 23:14:47 -0000	1.30
@@ -384,11 +384,6 @@ int pvfs2_getattr(
 struct inode_operations pvfs2_file_inode_operations =
 {
     .truncate = pvfs2_truncate,
-/*     .setxattr = pvfs2_setxattr, */
-/*     .getxattr = pvfs2_getxattr, */
-/*     .listxattr = pvfs2_listxattr, */
-/*     .removexattr = pvfs2_removexattr, */
-/*     .permission = pvfs2_permission, */
     .setattr = pvfs2_setattr,
     .getattr = pvfs2_getattr
 };
@@ -411,15 +406,15 @@ struct inode *pvfs2_get_custom_inode(
 	/* initialize pvfs2 specific private data */
 	pvfs2_inode = PVFS2_I(inode);
 	if (!pvfs2_inode)
-	{
-	    panic("pvfs2_get_custom_inode: PRIVATE DATA NOT ALLOCATED\n");
-	    return NULL;
-	}
+        {
+            panic("pvfs2_get_custom_inode: PRIVATE DATA NOT ALLOCATED\n");
+            return NULL;
+        }
 	else
-	{
+        {
 	    pvfs2_inode->refn.handle = 0;
 	    pvfs2_inode->refn.fs_id = 0;
-	}
+        }
 	pvfs2_print("pvfs2_get_custom_inode: inode %p allocated "
 		    "(pvfs2_inode is %p | sb is %p)\n", inode,
 		    pvfs2_inode, inode->i_sb);

Index: namei.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/namei.c,v
diff -p -u -r1.40 -r1.41
--- namei.c	6 Feb 2004 20:02:20 -0000	1.40
+++ namei.c	11 Feb 2004 23:14:49 -0000	1.41
@@ -30,10 +30,15 @@ static int pvfs2_create(
     int mode,
     struct nameidata *nd)
 {
-    struct inode *inode =
-	pvfs2_create_entry(dir, dentry, NULL, mode, PVFS2_VFS_OP_CREATE);
+    int ret = -EINVAL;
+    struct inode *inode = NULL;
+
+    pvfs2_print("pvfs2: pvfs2_create called\n");
+
+    inode = pvfs2_create_entry(
+        dir, dentry, NULL, mode, PVFS2_VFS_OP_CREATE, &ret);
 
-    return (inode ? 0 : -EINVAL);
+    return (inode ? 0 : ret);
 }
 
 struct dentry *pvfs2_lookup(
@@ -216,19 +221,15 @@ static int pvfs2_symlink(
     struct dentry *dentry,
     const char *symname)
 {
-    int ret = -1, mode = 755;
+    int ret = -EINVAL, mode = 755;
     struct inode *inode = NULL;
 
     pvfs2_print("pvfs2: pvfs2_symlink called\n");
 
     inode = pvfs2_create_entry(
-        dir, dentry, symname, mode, PVFS2_VFS_OP_SYMLINK);
+        dir, dentry, symname, mode, PVFS2_VFS_OP_SYMLINK, &ret);
 
-    if (inode)
-    {
-        ret = 0;
-    }
-    return ret;
+    return (inode ? 0 : ret);
 }
 
 static int pvfs2_mknod(
@@ -246,9 +247,11 @@ static int pvfs2_mkdir(
     struct dentry *dentry,
     int mode)
 {
-    int ret = -1;
-    struct inode *inode =
-	pvfs2_create_entry(dir, dentry, NULL, mode, PVFS2_VFS_OP_MKDIR);
+    int ret = -EINVAL;
+    struct inode *inode = NULL;
+
+    inode = pvfs2_create_entry(
+        dir, dentry, NULL, mode, PVFS2_VFS_OP_MKDIR, &ret);
 
     if (inode)
     {
@@ -409,13 +412,6 @@ struct inode_operations pvfs2_dir_inode_
     .mknod = pvfs2_mknod,
     .rename = pvfs2_rename,
     .setattr = pvfs2_setattr
-/*     .follow_link = pvfs2_follow_link */
-/*     .setxattr = pvfs2_setxattr, */
-/*     .getxattr = pvfs2_getxattr, */
-/*     .listxattr = pvfs2_listxattr, */
-/*     .removexattr = pvfs2_removexattr */
-/*     .setattr = pvfs2_setattr, */
-/*     .permission = pvfs2_permission */
 };
 
 /*

Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.32 -r1.33
--- pvfs2-kernel.h	11 Feb 2004 18:23:55 -0000	1.32
+++ pvfs2-kernel.h	11 Feb 2004 23:14:49 -0000	1.33
@@ -376,7 +376,8 @@ struct inode *pvfs2_create_entry(
     struct dentry *dentry,
     const char *symname,
     int mode,
-    int op_type);
+    int op_type,
+    int *error_code);
 
 int pvfs2_remove_entry(
     struct inode *dir,
@@ -385,6 +386,13 @@ int pvfs2_remove_entry(
 int pvfs2_truncate_inode(
     struct inode *inode,
     loff_t size);
+
+int pvfs2_kernel_error_code_convert(
+    int pvfs2_error_code);
+
+void *pvfs2_kernel_error_code_ptr_convert(
+    int pvfs2_error_code);
+
 
 #endif /* __PVFS2KERNEL_H */
 

Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.48 -r1.49
--- pvfs2-utils.c	10 Feb 2004 23:14:24 -0000	1.48
+++ pvfs2-utils.c	11 Feb 2004 23:14:49 -0000	1.49
@@ -475,7 +475,8 @@ int pvfs2_inode_setattr(
 static inline struct inode *pvfs2_create_file(
     struct inode *dir,
     struct dentry *dentry,
-    int mode)
+    int mode,
+    int *error_code)
 {
     int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
     pvfs2_kernel_op_t *new_op = NULL;
@@ -489,6 +490,7 @@ static inline struct inode *pvfs2_create
 	new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
 	if (!new_op)
 	{
+            *error_code = -ENOMEM;
 	    return NULL;
 	}
 	new_op->upcall.type = PVFS2_VFS_OP_CREATE;
@@ -554,7 +556,10 @@ static inline struct inode *pvfs2_create
 	    pvfs2_error("pvfs2_create_file: An error occurred; "
                         "removing created inode\n");
 	    iput(inode);
-	    inode = NULL;
+            inode = NULL;
+
+            *error_code = pvfs2_kernel_error_code_convert(
+                new_op->downcall.status);
 	}
 
 	/* when request is serviced properly, free req op struct */
@@ -566,7 +571,8 @@ static inline struct inode *pvfs2_create
 static inline struct inode *pvfs2_create_dir(
     struct inode *dir,
     struct dentry *dentry,
-    int mode)
+    int mode,
+    int *error_code)
 {
     int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
     pvfs2_kernel_op_t *new_op = NULL;
@@ -582,6 +588,7 @@ static inline struct inode *pvfs2_create
 	{
 	    pvfs2_error("pvfs2: pvfs2_create_dir -- "
                         "kmem_cache_alloc failed!\n");
+            *error_code = -ENOMEM;
 	    return NULL;
 	}
 	new_op->upcall.type = PVFS2_VFS_OP_MKDIR;
@@ -648,6 +655,9 @@ static inline struct inode *pvfs2_create
                         "removing created inode\n");
 	    iput(inode);
 	    inode = NULL;
+
+            *error_code = pvfs2_kernel_error_code_convert(
+                new_op->downcall.status);
 	}
 
 	/* when request is serviced properly, free req op struct */
@@ -660,7 +670,8 @@ static inline struct inode *pvfs2_create
     struct inode *dir,
     struct dentry *dentry,
     const char *symname,
-    int mode)
+    int mode,
+    int *error_code)
 {
     int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
     pvfs2_kernel_op_t *new_op = NULL;
@@ -674,6 +685,7 @@ static inline struct inode *pvfs2_create
 	new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
 	if (!new_op)
 	{
+            *error_code = -ENOMEM;
 	    return NULL;
 	}
 	new_op->upcall.type = PVFS2_VFS_OP_SYMLINK;
@@ -739,6 +751,9 @@ static inline struct inode *pvfs2_create
                         "removing created inode\n");
 	    iput(inode);
 	    inode = NULL;
+
+            *error_code = pvfs2_kernel_error_code_convert(
+                new_op->downcall.status);
 	}
 
 	/* when request is serviced properly, free req op struct */
@@ -749,7 +764,10 @@ static inline struct inode *pvfs2_create
 
 /*
   create a pvfs2 entry; returns a properly populated inode
-  pointer on success; NULL on failure
+  pointer on success; NULL on failure.
+
+  the required error_code value will contain an error code ONLY if an
+  error occurs (i.e. NULL is returned) and is unmodified otherwise.
 
   if op_type is PVFS_VFS_OP_CREATE, a file is created
   if op_type is PVFS_VFS_OP_MKDIR, a directory is created
@@ -762,21 +780,23 @@ struct inode *pvfs2_create_entry(
     struct dentry *dentry,
     const char *symname,
     int mode,
-    int op_type)
+    int op_type,
+    int *error_code)
 {
-    if (dir && dentry)
+    if (dir && dentry && error_code)
     {
 	switch (op_type)
 	{
-	case PVFS2_VFS_OP_CREATE:
-	    return pvfs2_create_file(dir, dentry, mode);
-	case PVFS2_VFS_OP_MKDIR:
-	    return pvfs2_create_dir(dir, dentry, mode);
-        case PVFS2_VFS_OP_SYMLINK:
-            return pvfs2_create_symlink(dir, dentry, symname, mode);
-	default:
-	    pvfs2_error("pvfs2_create_entry got a bad "
-                        "op_type (%d)\n", op_type);
+            case PVFS2_VFS_OP_CREATE:
+                return pvfs2_create_file(dir, dentry, mode, error_code);
+            case PVFS2_VFS_OP_MKDIR:
+                return pvfs2_create_dir(dir, dentry, mode, error_code);
+            case PVFS2_VFS_OP_SYMLINK:
+                return pvfs2_create_symlink(
+                    dir, dentry, symname, mode, error_code);
+            default:
+                pvfs2_error("pvfs2_create_entry got a bad "
+                            "op_type (%d)\n", op_type);
 	}
     }
     return NULL;
@@ -825,20 +845,15 @@ int pvfs2_remove_entry(
 	   the remove has no downcall members to retrieve, but
 	   the status value tells us if it went through ok or not
 	 */
-	ret = new_op->downcall.status;
-        switch(ret)
+        if (new_op->downcall.status == 0)
         {
-            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;
+            /*
+              adjust the readdir token if in fact we're
+              in the middle of a readdir for this directory
+            */
+            parent->readdir_token_adjustment++;
         }
+        ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
 
       error_exit:
 	/* when request is serviced properly, free req op struct */
@@ -884,6 +899,26 @@ int pvfs2_truncate_inode(
     /* when request is serviced properly, free req op struct */
     op_release(new_op);
 
+    return ret;
+}
+
+int pvfs2_kernel_error_code_convert(
+    int pvfs2_error_code)
+{
+    int ret = 0;
+
+    switch(pvfs2_error_code)
+    {
+        case -PVFS_ENOTEMPTY:
+            ret = -ENOTEMPTY;
+            break;
+        case -PVFS_ENOSPC:
+            ret = -ENOSPC;
+            break;
+        default:
+            pvfs2_print("Got an unknown pvfs2 error code: %d\n",
+                        pvfs2_error_code);
+    }
     return ret;
 }
 



More information about the PVFS2-CVS mailing list