[PATCH] JFS: return correct error when i-node allocation failed
authorAkinobu Mita <mita@miraclelinux.com>
Thu, 14 Sep 2006 14:22:38 +0000 (09:22 -0500)
committerDave Kleikamp <shaggy@austin.ibm.com>
Mon, 2 Oct 2006 14:51:01 +0000 (09:51 -0500)
I have seen confusing behavior on JFS when I injected many intentional
slab allocation errors. The cp command failed with no disk space error
with enough disk space.

This patch makes:

- change the return value in case slab allocation failures happen
  from -ENOSPC to -ENOMEM

- ialloc() return error code so that the caller can know the reason
  of failures

Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
(cherry picked from 2b46f77976f798f3fe800809a1d0ed38763c71c8 commit)

fs/jfs/jfs_dtree.c
fs/jfs/jfs_inode.c
fs/jfs/jfs_unicode.c
fs/jfs/namei.c
fs/jfs/super.c

index 6c3f083198468a686af3ed7c4dcc6bcbaf782dd8..a9f2604f28cf3635b7c85c1f406fcab988a7cd4b 100644 (file)
@@ -3780,13 +3780,13 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
        lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
                                        GFP_KERNEL);
        if (lkey.name == NULL)
-               return -ENOSPC;
+               return -ENOMEM;
 
        rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
                                        GFP_KERNEL);
        if (rkey.name == NULL) {
                kfree(lkey.name);
-               return -ENOSPC;
+               return -ENOMEM;
        }
 
        /* get left and right key */
index bffaca9ae3a20ef31e737485230b0836d666887a..dbf0f77c7a4a0aecf336ee2bbe80701623c870b3 100644 (file)
@@ -61,7 +61,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
        inode = new_inode(sb);
        if (!inode) {
                jfs_warn("ialloc: new_inode returned NULL!");
-               return inode;
+               return ERR_PTR(-ENOMEM);
        }
 
        jfs_inode = JFS_IP(inode);
@@ -69,9 +69,10 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
        rc = diAlloc(parent, S_ISDIR(mode), inode);
        if (rc) {
                jfs_warn("ialloc: diAlloc returned %d!", rc);
-               make_bad_inode(inode);
+               if (rc == -EIO)
+                       make_bad_inode(inode);
                iput(inode);
-               return NULL;
+               return ERR_PTR(rc);
        }
 
        inode->i_uid = current->fsuid;
@@ -97,7 +98,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
                inode->i_flags |= S_NOQUOTA;
                inode->i_nlink = 0;
                iput(inode);
-               return NULL;
+               return ERR_PTR(-EDQUOT);
        }
 
        inode->i_mode = mode;
index f327decfb1556c5abb146e999bf1bd1cb94b4a6b..0543f7fd436486d489875ee56bbd661539b31dd9 100644 (file)
@@ -124,7 +124,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry)
            kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS);
 
        if (uniName->name == NULL)
-               return -ENOSPC;
+               return -ENOMEM;
 
        uniName->namlen = jfs_strtoUCS(uniName->name, dentry->d_name.name,
                                       length, nls_tab);
index b8d16a6aa88f0c7c11f4bb741f671bba40ac51c6..5d4ef6e4b7e9f817a4bac0459a4780d2ef358098 100644 (file)
@@ -97,8 +97,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
         * begin the transaction before we search the directory.
         */
        ip = ialloc(dip, mode);
-       if (ip == NULL) {
-               rc = -ENOSPC;
+       if (IS_ERR(ip)) {
+               rc = PTR_ERR(ip);
                goto out2;
        }
 
@@ -231,8 +231,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
         * begin the transaction before we search the directory.
         */
        ip = ialloc(dip, S_IFDIR | mode);
-       if (ip == NULL) {
-               rc = -ENOSPC;
+       if (IS_ERR(ip)) {
+               rc = PTR_ERR(ip);
                goto out2;
        }
 
@@ -906,8 +906,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
         * (iAlloc() returns new, locked inode)
         */
        ip = ialloc(dip, S_IFLNK | 0777);
-       if (ip == NULL) {
-               rc = -ENOSPC;
+       if (IS_ERR(ip)) {
+               rc = PTR_ERR(ip);
                goto out2;
        }
 
@@ -978,7 +978,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
                xlen = xsize >> JFS_SBI(sb)->l2bsize;
                if ((rc = xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) {
                        txAbort(tid, 0);
-                       rc = -ENOSPC;
                        goto out3;
                }
                extent = xaddr;
@@ -1350,8 +1349,8 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
                goto out;
 
        ip = ialloc(dir, mode);
-       if (ip == NULL) {
-               rc = -ENOSPC;
+       if (IS_ERR(ip)) {
+               rc = PTR_ERR(ip);
                goto out1;
        }
        jfs_ip = JFS_IP(ip);
index 143bcd1d5eaa42f0529596676c85c16304a3e995..fc6951587c6bcb50d9b07880a11a1643f0539f97 100644 (file)
@@ -422,7 +422,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
 
        sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL);
        if (!sbi)
-               return -ENOSPC;
+               return -ENOMEM;
        sb->s_fs_info = sbi;
        sbi->sb = sb;
        sbi->uid = sbi->gid = sbi->umask = -1;