ocfs2: return ENOMEM when sb_getblk() fails
authorRui Xiang <rui.xiang@huawei.com>
Tue, 12 Nov 2013 23:06:54 +0000 (15:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 13 Nov 2013 03:09:00 +0000 (12:09 +0900)
The only reason for sb_getblk() failing is if it can't allocate the
buffer_head.  So return ENOMEM instead when it fails.

[joseph.qi@huawei.com: ocfs2_symlink_get_block() and ocfs2_read_blocks_sync() and ocfs2_read_blocks() need the same change]
Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/alloc.c
fs/ocfs2/aops.c
fs/ocfs2/buffer_head_io.c
fs/ocfs2/dir.c
fs/ocfs2/namei.c
fs/ocfs2/refcounttree.c
fs/ocfs2/suballoc.c
fs/ocfs2/super.c
fs/ocfs2/xattr.c

index 17e6bdde96c5e4707a29906e207e981761ca49c8..dc7411fe185d99652cc98f93436e1b46bdfd380d 100644 (file)
@@ -1025,7 +1025,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle,
                for(i = count;  i < (num_got + count); i++) {
                        bhs[i] = sb_getblk(osb->sb, first_blkno);
                        if (bhs[i] == NULL) {
-                               status = -EIO;
+                               status = -ENOMEM;
                                mlog_errno(status);
                                goto bail;
                        }
index c0d4797618ef4e1c2d14caf03a5f6b44ea0ecaa1..c20360002f291b22d7cb72761316aff2797a85c3 100644 (file)
@@ -80,6 +80,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
 
        if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb,
                                                    le32_to_cpu(fe->i_clusters))) {
+               err = -ENOMEM;
                mlog(ML_ERROR, "block offset is outside the allocated size: "
                     "%llu\n", (unsigned long long)iblock);
                goto bail;
@@ -92,6 +93,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
                            iblock;
                buffer_cache_bh = sb_getblk(osb->sb, blkno);
                if (!buffer_cache_bh) {
+                       err = -ENOMEM;
                        mlog(ML_ERROR, "couldn't getblock for symlink!\n");
                        goto bail;
                }
index 5d18ad10c27fc044ae240a5c147c8f3e0b146ae5..5b704c63a103018ddb8a56663e42edd09d6d40ff 100644 (file)
@@ -115,7 +115,7 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
                if (bhs[i] == NULL) {
                        bhs[i] = sb_getblk(osb->sb, block++);
                        if (bhs[i] == NULL) {
-                               status = -EIO;
+                               status = -ENOMEM;
                                mlog_errno(status);
                                goto bail;
                        }
@@ -214,7 +214,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
                        bhs[i] = sb_getblk(sb, block++);
                        if (bhs[i] == NULL) {
                                ocfs2_metadata_cache_io_unlock(ci);
-                               status = -EIO;
+                               status = -ENOMEM;
                                mlog_errno(status);
                                goto bail;
                        }
index 93b079115edcf2e5c119311620aba53a4f7f3c92..91a7e85ac8fdc8f6d25944d5b3552a39e20ab86b 100644 (file)
@@ -2349,7 +2349,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
 
        dx_root_bh = sb_getblk(osb->sb, dr_blkno);
        if (dx_root_bh == NULL) {
-               ret = -EIO;
+               ret = -ENOMEM;
                goto out;
        }
        ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh);
@@ -2422,7 +2422,7 @@ static int ocfs2_dx_dir_format_cluster(struct ocfs2_super *osb,
        for (i = 0; i < num_dx_leaves; i++) {
                bh = sb_getblk(osb->sb, start_blk + i);
                if (bh == NULL) {
-                       ret = -EIO;
+                       ret = -ENOMEM;
                        goto out;
                }
                dx_leaves[i] = bh;
@@ -2929,7 +2929,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
        blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
        dirdata_bh = sb_getblk(sb, blkno);
        if (!dirdata_bh) {
-               ret = -EIO;
+               ret = -ENOMEM;
                mlog_errno(ret);
                goto out_commit;
        }
@@ -3159,7 +3159,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
 
        *new_bh = sb_getblk(sb, p_blkno);
        if (!*new_bh) {
-               status = -EIO;
+               status = -ENOMEM;
                mlog_errno(status);
                goto bail;
        }
index be3f8676a4385970f0edc92fff291c997c3d2823..4f791f6d27d0463f8bef77dc20a5f5274df8ddea 100644 (file)
@@ -489,7 +489,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
 
        *new_fe_bh = sb_getblk(osb->sb, fe_blkno);
        if (!*new_fe_bh) {
-               status = -EIO;
+               status = -ENOMEM;
                mlog_errno(status);
                goto leave;
        }
index 0022192e7ac86499910c7b5a09e36b2b73758371..70d083e60d4076a46d782905c50f6653b76c3e0b 100644 (file)
@@ -1310,7 +1310,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle,
 
        new_bh = sb_getblk(sb, blkno);
        if (new_bh == NULL) {
-               ret = -EIO;
+               ret = -ENOMEM;
                mlog_errno(ret);
                goto out;
        }
@@ -1561,7 +1561,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
 
        new_bh = sb_getblk(sb, blkno);
        if (new_bh == NULL) {
-               ret = -EIO;
+               ret = -ENOMEM;
                mlog_errno(ret);
                goto out;
        }
@@ -3029,7 +3029,7 @@ int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
        for (i = 0; i < blocks; i++, old_block++, new_block++) {
                new_bh = sb_getblk(osb->sb, new_block);
                if (new_bh == NULL) {
-                       ret = -EIO;
+                       ret = -ENOMEM;
                        mlog_errno(ret);
                        break;
                }
index 5397c07ce6080b8f6e3c5917225eba98a070a4ba..2c91452c4047bc3a9ff324a3ba5e2e0fbfd7d09f 100644 (file)
@@ -481,7 +481,7 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
 
        bg_bh = sb_getblk(osb->sb, bg_blkno);
        if (!bg_bh) {
-               status = -EIO;
+               status = -ENOMEM;
                mlog_errno(status);
                goto bail;
        }
@@ -661,7 +661,7 @@ ocfs2_block_group_alloc_discontig(handle_t *handle,
 
        bg_bh = sb_getblk(osb->sb, bg_blkno);
        if (!bg_bh) {
-               status = -EIO;
+               status = -ENOMEM;
                mlog_errno(status);
                goto bail;
        }
index d4e81e4a9b0489de2eb66899eb23b9d87ea81ae5..c41492957aa5f4ab4f7aa7a056ac2715a352c2b7 100644 (file)
@@ -1848,8 +1848,8 @@ static int ocfs2_get_sector(struct super_block *sb,
 
        *bh = sb_getblk(sb, block);
        if (!*bh) {
-               mlog_errno(-EIO);
-               return -EIO;
+               mlog_errno(-ENOMEM);
+               return -ENOMEM;
        }
        lock_buffer(*bh);
        if (!buffer_dirty(*bh))
index aaaab8ba82aba36a55411ddeffdba1c99ff8c465..82257299d5eacb2604e902d2fab39d7d33cbc717 100644 (file)
@@ -377,7 +377,7 @@ static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
                bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb,
                                              xb_blkno + i);
                if (!bucket->bu_bhs[i]) {
-                       rc = -EIO;
+                       rc = -ENOMEM;
                        mlog_errno(rc);
                        break;
                }