[XFS] Interim solution for attribute insertion failure during file
authorYingping Lu <yingping@sgi.com>
Wed, 1 Feb 2006 01:14:34 +0000 (12:14 +1100)
committerNathan Scott <nathans@sgi.com>
Wed, 1 Feb 2006 01:14:34 +0000 (12:14 +1100)
creation due to ENOSPC. The current solution removes the inode when the
attribute insertion fails. Long term solution would be to make the inode
creation and attribute insertion atomic.

SGI-PV: 947610
SGI-Modid: xfs-linux-melb:xfs-kern:205193a

Signed-off-by: Yingping Lu <yingping@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
fs/xfs/linux-2.6/xfs_iops.c

index 76c6df34d0dbda279cfdda97822967d3fac632bb..eda7919b70a18814e82477828eeaa91794ccb8d6 100644 (file)
@@ -262,6 +262,31 @@ has_fs_struct(struct task_struct *task)
        return (task->fs != init_task.fs);
 }
 
+STATIC inline void
+cleanup_inode(
+       vnode_t         *dvp,
+       vnode_t         *vp,
+       struct dentry   *dentry,        
+       int             mode)
+{
+       struct dentry   teardown = {};
+       int             err2;
+
+       /* Oh, the horror.
+        * If we can't add the ACL or we fail in 
+        * linvfs_init_security we must back out.
+        * ENOSPC can hit here, among other things.
+        */
+       teardown.d_inode = LINVFS_GET_IP(vp);
+       teardown.d_name = dentry->d_name;
+
+       if (S_ISDIR(mode))
+               VOP_RMDIR(dvp, &teardown, NULL, err2);
+       else
+               VOP_REMOVE(dvp, &teardown, NULL, err2);
+       VN_RELE(vp);
+}
+
 STATIC int
 linvfs_mknod(
        struct inode    *dir,
@@ -316,30 +341,19 @@ linvfs_mknod(
        }
 
        if (!error)
+       {
                error = linvfs_init_security(vp, dir);
+               if (error)
+                       cleanup_inode(dvp, vp, dentry, mode);
+       }
 
        if (default_acl) {
                if (!error) {
                        error = _ACL_INHERIT(vp, &va, default_acl);
-                       if (!error) {
+                       if (!error) 
                                VMODIFY(vp);
-                       } else {
-                               struct dentry   teardown = {};
-                               int             err2;
-
-                               /* Oh, the horror.
-                                * If we can't add the ACL we must back out.
-                                * ENOSPC can hit here, among other things.
-                                */
-                               teardown.d_inode = ip = LINVFS_GET_IP(vp);
-                               teardown.d_name = dentry->d_name;
-
-                               if (S_ISDIR(mode))
-                                       VOP_RMDIR(dvp, &teardown, NULL, err2);
-                               else
-                                       VOP_REMOVE(dvp, &teardown, NULL, err2);
-                               VN_RELE(vp);
-                       }
+                       else
+                               cleanup_inode(dvp, vp, dentry, mode);
                }
                _ACL_FREE(default_acl);
        }