diff mbox

[03/12,linux-next] udf: merge bh free

Message ID 1483736037-25111-4-git-send-email-fabf@skynet.be (mailing list archive)
State New, archived
Headers show

Commit Message

Fabian Frederick Jan. 6, 2017, 8:53 p.m. UTC
Merge all bh free at one place.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/udf/inode.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

Comments

Jan Kara Jan. 10, 2017, 10:36 a.m. UTC | #1
On Fri 06-01-17 21:53:51, Fabian Frederick wrote:
> Merge all bh free at one place.
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

Thanks. Applied.

								Honza

> ---
>  fs/udf/inode.c | 28 ++++++++++------------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 4a7813b..5cac1c3 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -745,11 +745,8 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  				 ~(inode->i_sb->s_blocksize - 1));
>  			udf_write_aext(inode, &cur_epos, &eloc, elen, 1);
>  		}
> -		brelse(prev_epos.bh);
> -		brelse(cur_epos.bh);
> -		brelse(next_epos.bh);
>  		newblock = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
> -		return newblock;
> +		goto out_free;
>  	}
>  
>  	/* Are we beyond EOF? */
> @@ -772,11 +769,9 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  		/* Create extents for the hole between EOF and offset */
>  		ret = udf_do_extend_file(inode, &prev_epos, laarr, offset);
>  		if (ret < 0) {
> -			brelse(prev_epos.bh);
> -			brelse(cur_epos.bh);
> -			brelse(next_epos.bh);
>  			*err = ret;
> -			return 0;
> +			newblock = 0;
> +			goto out_free;
>  		}
>  		c = 0;
>  		offset = 0;
> @@ -839,11 +834,9 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  				iinfo->i_location.partitionReferenceNum,
>  				goal, err);
>  		if (!newblocknum) {
> -			brelse(prev_epos.bh);
> -			brelse(cur_epos.bh);
> -			brelse(next_epos.bh);
>  			*err = -ENOSPC;
> -			return 0;
> +			newblock = 0;
> +			goto out_free;
>  		}
>  		if (isBeyondEOF)
>  			iinfo->i_lenExtents += inode->i_sb->s_blocksize;
> @@ -870,15 +863,11 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  	 * the new number of extents is less than the old number */
>  	udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
>  
> -	brelse(prev_epos.bh);
> -	brelse(cur_epos.bh);
> -	brelse(next_epos.bh);
> -
>  	newblock = udf_get_pblock(inode->i_sb, newblocknum,
>  				iinfo->i_location.partitionReferenceNum, 0);
>  	if (!newblock) {
>  		*err = -EIO;
> -		return 0;
> +		goto out_free;
>  	}
>  	*new = 1;
>  	iinfo->i_next_alloc_block = block;
> @@ -889,7 +878,10 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  		udf_sync_inode(inode);
>  	else
>  		mark_inode_dirty(inode);
> -
> +out_free:
> +	brelse(prev_epos.bh);
> +	brelse(cur_epos.bh);
> +	brelse(next_epos.bh);
>  	return newblock;
>  }
>  
> -- 
> 2.7.4
> 
>
diff mbox

Patch

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 4a7813b..5cac1c3 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -745,11 +745,8 @@  static sector_t inode_getblk(struct inode *inode, sector_t block,
 				 ~(inode->i_sb->s_blocksize - 1));
 			udf_write_aext(inode, &cur_epos, &eloc, elen, 1);
 		}
-		brelse(prev_epos.bh);
-		brelse(cur_epos.bh);
-		brelse(next_epos.bh);
 		newblock = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
-		return newblock;
+		goto out_free;
 	}
 
 	/* Are we beyond EOF? */
@@ -772,11 +769,9 @@  static sector_t inode_getblk(struct inode *inode, sector_t block,
 		/* Create extents for the hole between EOF and offset */
 		ret = udf_do_extend_file(inode, &prev_epos, laarr, offset);
 		if (ret < 0) {
-			brelse(prev_epos.bh);
-			brelse(cur_epos.bh);
-			brelse(next_epos.bh);
 			*err = ret;
-			return 0;
+			newblock = 0;
+			goto out_free;
 		}
 		c = 0;
 		offset = 0;
@@ -839,11 +834,9 @@  static sector_t inode_getblk(struct inode *inode, sector_t block,
 				iinfo->i_location.partitionReferenceNum,
 				goal, err);
 		if (!newblocknum) {
-			brelse(prev_epos.bh);
-			brelse(cur_epos.bh);
-			brelse(next_epos.bh);
 			*err = -ENOSPC;
-			return 0;
+			newblock = 0;
+			goto out_free;
 		}
 		if (isBeyondEOF)
 			iinfo->i_lenExtents += inode->i_sb->s_blocksize;
@@ -870,15 +863,11 @@  static sector_t inode_getblk(struct inode *inode, sector_t block,
 	 * the new number of extents is less than the old number */
 	udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
 
-	brelse(prev_epos.bh);
-	brelse(cur_epos.bh);
-	brelse(next_epos.bh);
-
 	newblock = udf_get_pblock(inode->i_sb, newblocknum,
 				iinfo->i_location.partitionReferenceNum, 0);
 	if (!newblock) {
 		*err = -EIO;
-		return 0;
+		goto out_free;
 	}
 	*new = 1;
 	iinfo->i_next_alloc_block = block;
@@ -889,7 +878,10 @@  static sector_t inode_getblk(struct inode *inode, sector_t block,
 		udf_sync_inode(inode);
 	else
 		mark_inode_dirty(inode);
-
+out_free:
+	brelse(prev_epos.bh);
+	brelse(cur_epos.bh);
+	brelse(next_epos.bh);
 	return newblock;
 }