ocfs2: return ENOMEM while sb_getblk failing
PATCH 1/2 ocfs2: return ENOMEM while sb_getblk failing
The only reason for sb_getblk() failing is if it can't allocate the buffer_head. So return ENOMEM instead when it fails.
Signed-off-by Rui Xiang <[email protected]>
--- fs/ocfs2/alloc.c | 2 +- fs/ocfs2/aops.c | 1 + fs/ocfs2/dir.c | 8 ++++---- fs/ocfs2/namei.c | 2 +- fs/ocfs2/refcounttree.c | 6 +++--- fs/ocfs2/suballoc.c | 4 ++-- fs/ocfs2/super.c | 4 ++-- fs/ocfs2/xattr.c | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-)
fs/ocfs2/alloc.c +1 -1
@@ -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; }
fs/ocfs2/aops.c +1 -0
@@ -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;
fs/ocfs2/dir.c +4 -4
@@ -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; }
fs/ocfs2/namei.c +1 -1
@@ -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; }
fs/ocfs2/refcounttree.c +3 -3
@@ -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; }
@@ -3031,7 +3031,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 ; }
fs/ocfs2/suballoc.c +2 -2
@@ -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; }
fs/ocfs2/super.c +2 -2
@@ -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))
fs/ocfs2/xattr.c +1 -1
@@ -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 ; }
Signature · 1 line
1.8.2.2
PATCH 2/2 ocfs2: add necessary check in case sb_getblk fails
Sb_getblk may retrun an err, so add a check for bh.
Signed-off-by Rui Xiang <[email protected]>
--- fs/ocfs2/refcounttree.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ocfs2/refcounttree.c +5 -0
@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode, } new_bh =sb_getblk (inode->i_sb, first_blkno); +if (!new_bh) { + ret = -ENOMEM ; +mlog_errno (ret); + goto out_commit; + }ocfs2_set_new_buffer_uptodate (&new_tree->rf_ci, new_bh); ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh,
Signature · 1 line
1.8.2.2
PATCH 2/2 ocfs2: add necessary check in case sb_getblk fails
Quoted 3 lines · Rui Xiang
Sb_getblkmay retrun an err, so add a check for bh.Signed-off-by Rui Xiang <[email protected]>
Reviewed-by Jie Liu <[email protected]>
Quoted 20 lines
--- fs/ocfs2/refcounttree.c | 5 +++++ 1 file changed, 5 insertions(+)fs/ocfs2/refcounttree.c +5
-0@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode, } new_bh =sb_getblk (inode->i_sb, first_blkno); +if (!new_bh) { + ret = -ENOMEM ; +mlog_errno (ret); + goto out_commit; + }ocfs2_set_new_buffer_uptodate (&new_tree->rf_ci, new_bh); ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh,
PATCH 1/2 ocfs2: return ENOMEM while sb_getblk failing
In reply to Rui XiangQuoted 4 lines · Rui Xiang
The only reason for
sb_getblk()failing is if it can't allocate thebuffer_head. So return ENOMEM instead when it fails.Signed-off-by Rui Xiang <[email protected]>
Looks good, thank you!
Reviewed-by Jie Liu <[email protected]>
Quoted 170 lines
--- fs/ocfs2/alloc.c | 2 +- fs/ocfs2/aops.c | 1 + fs/ocfs2/dir.c | 8 ++++---- fs/ocfs2/namei.c | 2 +- fs/ocfs2/refcounttree.c | 6 +++--- fs/ocfs2/suballoc.c | 4 ++-- fs/ocfs2/super.c | 4 ++-- fs/ocfs2/xattr.c | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-)fs/ocfs2/alloc.c +1
-1@@ -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; }fs/ocfs2/aops.c +1
-0@@ -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;fs/ocfs2/dir.c +4
-4@@ -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; }fs/ocfs2/namei.c +1
-1@@ -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; }fs/ocfs2/refcounttree.c +3
-3@@ -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; }@@ -3031,7 +3031,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 ; }fs/ocfs2/suballoc.c +2
-2@@ -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; }fs/ocfs2/super.c +2
-2@@ -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))fs/ocfs2/xattr.c +1
-1@@ -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 ; }