Skip to content

Commit 7391a29

Browse files
Rui Xiangtorvalds
authored andcommitted
ocfs2: return ENOMEM when sb_getblk() fails
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>
1 parent f0cb0f0 commit 7391a29

9 files changed

Lines changed: 18 additions & 16 deletions

File tree

‎fs/ocfs2/alloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle,
10251025
for(i = count; i < (num_got + count); i++) {
10261026
bhs[i] = sb_getblk(osb->sb, first_blkno);
10271027
if (bhs[i] == NULL) {
1028-
status = -EIO;
1028+
status = -ENOMEM;
10291029
mlog_errno(status);
10301030
goto bail;
10311031
}

‎fs/ocfs2/aops.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
8080

8181
if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb,
8282
le32_to_cpu(fe->i_clusters))) {
83+
err = -ENOMEM;
8384
mlog(ML_ERROR, "block offset is outside the allocated size: "
8485
"%llu\n", (unsigned long long)iblock);
8586
goto bail;
@@ -92,6 +93,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
9293
iblock;
9394
buffer_cache_bh = sb_getblk(osb->sb, blkno);
9495
if (!buffer_cache_bh) {
96+
err = -ENOMEM;
9597
mlog(ML_ERROR, "couldn't getblock for symlink!\n");
9698
goto bail;
9799
}

‎fs/ocfs2/buffer_head_io.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
115115
if (bhs[i] == NULL) {
116116
bhs[i] = sb_getblk(osb->sb, block++);
117117
if (bhs[i] == NULL) {
118-
status = -EIO;
118+
status = -ENOMEM;
119119
mlog_errno(status);
120120
goto bail;
121121
}
@@ -214,7 +214,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
214214
bhs[i] = sb_getblk(sb, block++);
215215
if (bhs[i] == NULL) {
216216
ocfs2_metadata_cache_io_unlock(ci);
217-
status = -EIO;
217+
status = -ENOMEM;
218218
mlog_errno(status);
219219
goto bail;
220220
}

‎fs/ocfs2/dir.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
23492349

23502350
dx_root_bh = sb_getblk(osb->sb, dr_blkno);
23512351
if (dx_root_bh == NULL) {
2352-
ret = -EIO;
2352+
ret = -ENOMEM;
23532353
goto out;
23542354
}
23552355
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,
24222422
for (i = 0; i < num_dx_leaves; i++) {
24232423
bh = sb_getblk(osb->sb, start_blk + i);
24242424
if (bh == NULL) {
2425-
ret = -EIO;
2425+
ret = -ENOMEM;
24262426
goto out;
24272427
}
24282428
dx_leaves[i] = bh;
@@ -2929,7 +2929,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
29292929
blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
29302930
dirdata_bh = sb_getblk(sb, blkno);
29312931
if (!dirdata_bh) {
2932-
ret = -EIO;
2932+
ret = -ENOMEM;
29332933
mlog_errno(ret);
29342934
goto out_commit;
29352935
}
@@ -3159,7 +3159,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
31593159

31603160
*new_bh = sb_getblk(sb, p_blkno);
31613161
if (!*new_bh) {
3162-
status = -EIO;
3162+
status = -ENOMEM;
31633163
mlog_errno(status);
31643164
goto bail;
31653165
}

‎fs/ocfs2/namei.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
489489

490490
*new_fe_bh = sb_getblk(osb->sb, fe_blkno);
491491
if (!*new_fe_bh) {
492-
status = -EIO;
492+
status = -ENOMEM;
493493
mlog_errno(status);
494494
goto leave;
495495
}

‎fs/ocfs2/refcounttree.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle,
13101310

13111311
new_bh = sb_getblk(sb, blkno);
13121312
if (new_bh == NULL) {
1313-
ret = -EIO;
1313+
ret = -ENOMEM;
13141314
mlog_errno(ret);
13151315
goto out;
13161316
}
@@ -1561,7 +1561,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
15611561

15621562
new_bh = sb_getblk(sb, blkno);
15631563
if (new_bh == NULL) {
1564-
ret = -EIO;
1564+
ret = -ENOMEM;
15651565
mlog_errno(ret);
15661566
goto out;
15671567
}
@@ -3029,7 +3029,7 @@ int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
30293029
for (i = 0; i < blocks; i++, old_block++, new_block++) {
30303030
new_bh = sb_getblk(osb->sb, new_block);
30313031
if (new_bh == NULL) {
3032-
ret = -EIO;
3032+
ret = -ENOMEM;
30333033
mlog_errno(ret);
30343034
break;
30353035
}

‎fs/ocfs2/suballoc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
481481

482482
bg_bh = sb_getblk(osb->sb, bg_blkno);
483483
if (!bg_bh) {
484-
status = -EIO;
484+
status = -ENOMEM;
485485
mlog_errno(status);
486486
goto bail;
487487
}
@@ -661,7 +661,7 @@ ocfs2_block_group_alloc_discontig(handle_t *handle,
661661

662662
bg_bh = sb_getblk(osb->sb, bg_blkno);
663663
if (!bg_bh) {
664-
status = -EIO;
664+
status = -ENOMEM;
665665
mlog_errno(status);
666666
goto bail;
667667
}

‎fs/ocfs2/super.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,8 +1848,8 @@ static int ocfs2_get_sector(struct super_block *sb,
18481848

18491849
*bh = sb_getblk(sb, block);
18501850
if (!*bh) {
1851-
mlog_errno(-EIO);
1852-
return -EIO;
1851+
mlog_errno(-ENOMEM);
1852+
return -ENOMEM;
18531853
}
18541854
lock_buffer(*bh);
18551855
if (!buffer_dirty(*bh))

‎fs/ocfs2/xattr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
377377
bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb,
378378
xb_blkno + i);
379379
if (!bucket->bu_bhs[i]) {
380-
rc = -EIO;
380+
rc = -ENOMEM;
381381
mlog_errno(rc);
382382
break;
383383
}

0 commit comments

Comments
 (0)