Patchwork ext4: fix double unlock buffer mess during fs-resize

login
register
mail settings
Submitter Dmitri Monakho
Date Sept. 7, 2012, 10:14 a.m.
Message ID <1347012884-29484-1-git-send-email-dmonakhov@openvz.org>
Download mbox | patch
Permalink /patch/182351/
State Accepted, archived
Headers show

Comments

Dmitri Monakho - Sept. 7, 2012, 10:14 a.m.
bh_submit_read() is responsible for unlock bh on endio

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/resize.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
Dmitri Monakho - Sept. 25, 2012, 3:25 p.m.
On Fri,  7 Sep 2012 14:14:44 +0400, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> bh_submit_read() is responsible for unlock bh on endio
> 
Hi, are any objections against this fix?
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/ext4/resize.c |   15 +++++----------
>  1 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index 41f6ef6..3b05198 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1076,17 +1076,12 @@ static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
>  	struct buffer_head *bh = sb_getblk(sb, block);
>  	if (!bh)
>  		return NULL;
> -
> -	if (bitmap_uptodate(bh))
> -		return bh;
> -
> -	lock_buffer(bh);
> -	if (bh_submit_read(bh) < 0) {
> -		unlock_buffer(bh);
> -		brelse(bh);
> -		return NULL;
> +	if (!bh_uptodate_or_lock(bh)) {
> +		if (bh_submit_read(bh) < 0) {
> +			brelse(bh);
> +			return NULL;
> +		}
>  	}
> -	unlock_buffer(bh);
>  
>  	return bh;
>  }
> -- 
> 1.7.7.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o - Sept. 26, 2012, 3:26 a.m.
On Fri, Sep 07, 2012 at 02:14:44PM +0400, Dmitry Monakhov wrote:
> bh_submit_read() is responsible for unlock bh on endio
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>

Thanks, applied.  

BTW, I was checking the call sites for ext4_get_bitmap() in
fs/ext/resize.c, and we doing some extra work in
ext4_set_bitmap_checksums(); if the bitmap is uninitialized, then
there's no point in generating a checksum for it.

Something we can fix later, since it's harmless, although it is extra
unnecessary work.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 41f6ef6..3b05198 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1076,17 +1076,12 @@  static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
 	struct buffer_head *bh = sb_getblk(sb, block);
 	if (!bh)
 		return NULL;
-
-	if (bitmap_uptodate(bh))
-		return bh;
-
-	lock_buffer(bh);
-	if (bh_submit_read(bh) < 0) {
-		unlock_buffer(bh);
-		brelse(bh);
-		return NULL;
+	if (!bh_uptodate_or_lock(bh)) {
+		if (bh_submit_read(bh) < 0) {
+			brelse(bh);
+			return NULL;
+		}
 	}
-	unlock_buffer(bh);
 
 	return bh;
 }