All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing
@ 2013-09-05  8:28 Rui Xiang
  2013-09-05  8:28 ` [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails Rui Xiang
  2013-09-06 16:44 ` [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Mark Fasheh
  0 siblings, 2 replies; 7+ messages in thread
From: Rui Xiang @ 2013-09-05  8:28 UTC (permalink / raw)
  To: ocfs2-devel

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 <rui.xiang@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/ocfs2/alloc.c        | 2 +-
 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 +-
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 17e6bdd..dc7411f 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -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;
 			}
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 30544ce..5354743 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -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;
 	}
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index be3f867..4f791f6 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -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;
 	}
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index a70d604..50c1796 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -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;
 		}
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 5397c07..2c91452 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -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;
 	}
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 121da2d..cac4987 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -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))
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 317ef0a..e8b41e1 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -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;
 		}
-- 
1.8.2.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails
  2013-09-05  8:28 [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Rui Xiang
@ 2013-09-05  8:28 ` Rui Xiang
  2013-09-06 16:45   ` Mark Fasheh
  2013-09-06 16:44 ` [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Mark Fasheh
  1 sibling, 1 reply; 7+ messages in thread
From: Rui Xiang @ 2013-09-05  8:28 UTC (permalink / raw)
  To: ocfs2-devel

Sb_getblk may retrun an err, so add a check for bh.

Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/ocfs2/refcounttree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 50c1796..22f3f19 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -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,
-- 
1.8.2.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing
  2013-09-05  8:28 [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Rui Xiang
  2013-09-05  8:28 ` [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails Rui Xiang
@ 2013-09-06 16:44 ` Mark Fasheh
  2013-09-16 11:42   ` Joseph Qi
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Fasheh @ 2013-09-06 16:44 UTC (permalink / raw)
  To: ocfs2-devel

This looks great, thank you.

Reviewed-by: Mark Fasheh <mfasheh@suse.de>

On Thu, Sep 05, 2013 at 04:28:54PM +0800, Rui Xiang wrote:
> 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 <rui.xiang@huawei.com>
> Reviewed-by: Jie Liu <jeff.liu@oracle.com>
> ---
>  fs/ocfs2/alloc.c        | 2 +-
>  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 +-
>  7 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 17e6bdd..dc7411f 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -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;
>  			}
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index 30544ce..5354743 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -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;
>  	}
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index be3f867..4f791f6 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -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;
>  	}
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index a70d604..50c1796 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -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;
>  		}
> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
> index 5397c07..2c91452 100644
> --- a/fs/ocfs2/suballoc.c
> +++ b/fs/ocfs2/suballoc.c
> @@ -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;
>  	}
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 121da2d..cac4987 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -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))
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 317ef0a..e8b41e1 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -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;
>  		}
> -- 
> 1.8.2.2
> 
> 
--
Mark Fasheh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails
  2013-09-05  8:28 ` [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails Rui Xiang
@ 2013-09-06 16:45   ` Mark Fasheh
  2013-09-16 11:49     ` Joseph Qi
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Fasheh @ 2013-09-06 16:45 UTC (permalink / raw)
  To: ocfs2-devel

Reviewed-by: Mark Fasheh <mfasheh@suse.de>

On Thu, Sep 05, 2013 at 04:28:55PM +0800, Rui Xiang wrote:
> Sb_getblk may retrun an err, so add a check for bh.
> 
> Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
> Reviewed-by: Jie Liu <jeff.liu@oracle.com>
> ---
>  fs/ocfs2/refcounttree.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 50c1796..22f3f19 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -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,
> -- 
> 1.8.2.2
> 
> 
--
Mark Fasheh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing
  2013-09-06 16:44 ` [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Mark Fasheh
@ 2013-09-16 11:42   ` Joseph Qi
  2013-09-16 12:31     ` Rui Xiang
  0 siblings, 1 reply; 7+ messages in thread
From: Joseph Qi @ 2013-09-16 11:42 UTC (permalink / raw)
  To: ocfs2-devel

On 2013/9/7 0:44, Mark Fasheh wrote:
> This looks great, thank you.
> 
> Reviewed-by: Mark Fasheh <mfasheh@suse.de>
> 
> On Thu, Sep 05, 2013 at 04:28:54PM +0800, Rui Xiang wrote:
>> 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 <rui.xiang@huawei.com>
>> Reviewed-by: Jie Liu <jeff.liu@oracle.com>
>> ---
>>  fs/ocfs2/alloc.c        | 2 +-
>>  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 +-
>>  7 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
>> index 17e6bdd..dc7411f 100644
>> --- a/fs/ocfs2/alloc.c
>> +++ b/fs/ocfs2/alloc.c
>> @@ -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;
>>  			}
>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>> index 30544ce..5354743 100644
>> --- a/fs/ocfs2/dir.c
>> +++ b/fs/ocfs2/dir.c
>> @@ -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;
>>  	}
>> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
>> index be3f867..4f791f6 100644
>> --- a/fs/ocfs2/namei.c
>> +++ b/fs/ocfs2/namei.c
>> @@ -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;
>>  	}
>> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
>> index a70d604..50c1796 100644
>> --- a/fs/ocfs2/refcounttree.c
>> +++ b/fs/ocfs2/refcounttree.c
>> @@ -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;
>>  		}
>> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
>> index 5397c07..2c91452 100644
>> --- a/fs/ocfs2/suballoc.c
>> +++ b/fs/ocfs2/suballoc.c
>> @@ -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;
>>  	}
>> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
>> index 121da2d..cac4987 100644
>> --- a/fs/ocfs2/super.c
>> +++ b/fs/ocfs2/super.c
>> @@ -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))
>> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
>> index 317ef0a..e8b41e1 100644
>> --- a/fs/ocfs2/xattr.c
>> +++ b/fs/ocfs2/xattr.c
>> @@ -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;
>>  		}
>> -- 
>> 1.8.2.2
>>
>>
> --
> Mark Fasheh
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
> 
> .
> 

ocfs2_symlink_get_block in aops.c, and ocfs2_read_blocks_sync and
ocfs2_read_blocks in buffer_head_io.c need do the same change for
consistency.

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 20dfec7..b9ed571 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -92,6 +92,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;
 		}
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index 5d18ad1..5b704c6 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -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;
 			}

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails
  2013-09-06 16:45   ` Mark Fasheh
@ 2013-09-16 11:49     ` Joseph Qi
  0 siblings, 0 replies; 7+ messages in thread
From: Joseph Qi @ 2013-09-16 11:49 UTC (permalink / raw)
  To: ocfs2-devel

On 2013/9/7 0:45, Mark Fasheh wrote:
> Reviewed-by: Mark Fasheh <mfasheh@suse.de>
> 
> On Thu, Sep 05, 2013 at 04:28:55PM +0800, Rui Xiang wrote:
>> Sb_getblk may retrun an err, so add a check for bh.
>>
>> Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
>> Reviewed-by: Jie Liu <jeff.liu@oracle.com>
>> ---
>>  fs/ocfs2/refcounttree.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
>> index 50c1796..22f3f19 100644
>> --- a/fs/ocfs2/refcounttree.c
>> +++ b/fs/ocfs2/refcounttree.c
>> @@ -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,
>> -- 
>> 1.8.2.2
>>
>>
> --
> Mark Fasheh
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
> 
> 
Need also add a check after calling sb_getblk in
ocfs2_create_xattr_block.

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index bd2a1f0..8d61105 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2873,6 +2873,12 @@ static int ocfs2_create_xattr_block(struct inode *inode,
 	}
 
 	new_bh = sb_getblk(inode->i_sb, first_blkno);
+	if (!new_bh) {
+		ret = -ENOMEM;
+		mlog_errno(ret);
+		goto end;
+	}
+
 	ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
 
 	ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing
  2013-09-16 11:42   ` Joseph Qi
@ 2013-09-16 12:31     ` Rui Xiang
  0 siblings, 0 replies; 7+ messages in thread
From: Rui Xiang @ 2013-09-16 12:31 UTC (permalink / raw)
  To: ocfs2-devel

Hi Joseph,

Thank you for pointing the negligence. I will resend the patches later.

On 2013/9/16 19:42, Joseph Qi wrote:
> On 2013/9/7 0:44, Mark Fasheh wrote:
>> This looks great, thank you.
>>
>> Reviewed-by: Mark Fasheh <mfasheh@suse.de>
>>
>> On Thu, Sep 05, 2013 at 04:28:54PM +0800, Rui Xiang wrote:
>>> 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 <rui.xiang@huawei.com>
>>> Reviewed-by: Jie Liu <jeff.liu@oracle.com>
>>> ---
>>>  fs/ocfs2/alloc.c        | 2 +-
>>>  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 +-
>>>  7 files changed, 14 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
>>> index 17e6bdd..dc7411f 100644
>>> --- a/fs/ocfs2/alloc.c
>>> +++ b/fs/ocfs2/alloc.c
>>> @@ -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;
>>>  			}
>>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>>> index 30544ce..5354743 100644
>>> --- a/fs/ocfs2/dir.c
>>> +++ b/fs/ocfs2/dir.c
>>> @@ -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;
>>>  	}
>>> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
>>> index be3f867..4f791f6 100644
>>> --- a/fs/ocfs2/namei.c
>>> +++ b/fs/ocfs2/namei.c
>>> @@ -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;
>>>  	}
>>> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
>>> index a70d604..50c1796 100644
>>> --- a/fs/ocfs2/refcounttree.c
>>> +++ b/fs/ocfs2/refcounttree.c
>>> @@ -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;
>>>  		}
>>> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
>>> index 5397c07..2c91452 100644
>>> --- a/fs/ocfs2/suballoc.c
>>> +++ b/fs/ocfs2/suballoc.c
>>> @@ -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;
>>>  	}
>>> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
>>> index 121da2d..cac4987 100644
>>> --- a/fs/ocfs2/super.c
>>> +++ b/fs/ocfs2/super.c
>>> @@ -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))
>>> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
>>> index 317ef0a..e8b41e1 100644
>>> --- a/fs/ocfs2/xattr.c
>>> +++ b/fs/ocfs2/xattr.c
>>> @@ -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;
>>>  		}
>>> -- 
>>> 1.8.2.2
>>>
>>>
>> --
>> Mark Fasheh
>>
>> _______________________________________________
>> Ocfs2-devel mailing list
>> Ocfs2-devel at oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
>>
>> .
>>
> 
> ocfs2_symlink_get_block in aops.c, and ocfs2_read_blocks_sync and
> ocfs2_read_blocks in buffer_head_io.c need do the same change for
> consistency.
> 
> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> index 20dfec7..b9ed571 100644
> --- a/fs/ocfs2/aops.c
> +++ b/fs/ocfs2/aops.c
> @@ -92,6 +92,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;
>  		}
> diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
> index 5d18ad1..5b704c6 100644
> --- a/fs/ocfs2/buffer_head_io.c
> +++ b/fs/ocfs2/buffer_head_io.c
> @@ -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;
>  			}
> 
> 
> .

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-16 12:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05  8:28 [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Rui Xiang
2013-09-05  8:28 ` [Ocfs2-devel] [PATCH RESEND 2/2] ocfs2: add necessary check in case sb_getblk fails Rui Xiang
2013-09-06 16:45   ` Mark Fasheh
2013-09-16 11:49     ` Joseph Qi
2013-09-06 16:44 ` [Ocfs2-devel] [PATCH RESEND 1/2] ocfs2: return ENOMEM while sb_getblk failing Mark Fasheh
2013-09-16 11:42   ` Joseph Qi
2013-09-16 12:31     ` Rui Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.