linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix xfstest generic/269 double revoked buffer bug
@ 2015-10-15  0:23 Daeho Jeong
  2015-10-18  2:30 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Daeho Jeong @ 2015-10-15  0:23 UTC (permalink / raw)
  To: tytso, linux-ext4; +Cc: Daeho Jeong

When you repeatly execute xfstest generic/269 with bigalloc_1k option
enabled using the below command:

"./kvm-xfstests -c bigalloc_1k -m nodelalloc -C 1000 generic/269"

you can easily see the below bug message.

"JBD2 unexpected failure: jbd2_journal_revoke: !buffer_revoked(bh);"

This means that an already revoked buffer is erroneously revoked again
and it is caused by doing revoke for the buffer at the wrong position
in ext4_free_blocks(). We need to re-position the buffer revoke
procedure for an unspecified buffer after checking the cluster boundary
for bigalloc option. If not, some part of the cluster can be doubly
revoked.

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
---
 fs/ext4/mballoc.c |   33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 34b610e..abea276 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4682,22 +4682,11 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 	ext4_debug("freeing block %llu\n", block);
 	trace_ext4_free_blocks(inode, block, count, flags);
 
-	if (flags & EXT4_FREE_BLOCKS_FORGET) {
-		struct buffer_head *tbh = bh;
-		int i;
-
-		BUG_ON(bh && (count > 1));
+	if (bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {
+		BUG_ON(count > 1);
 
-		for (i = 0; i < count; i++) {
-			cond_resched();
-			if (!bh)
-				tbh = sb_find_get_block(inode->i_sb,
-							block + i);
-			if (!tbh)
-				continue;
-			ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
-				    inode, tbh, block + i);
-		}
+		ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
+			    inode, bh, block);
 	}
 
 	/*
@@ -4742,6 +4731,20 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 			count += sbi->s_cluster_ratio - overflow;
 	}
 
+	if (!bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {
+		int i;
+
+		for (i = 0; i < count; i++) {
+			cond_resched();
+			bh = sb_find_get_block(inode->i_sb,
+					       block + i);
+			if (!bh)
+				continue;
+			ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
+				    inode, bh, block + i);
+		}
+	}
+
 do_more:
 	overflow = 0;
 	ext4_get_group_no_and_offset(sb, block, &block_group, &bit);
-- 
1.7.9.5


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

* Re: [PATCH] ext4: fix xfstest generic/269 double revoked buffer bug
  2015-10-15  0:23 [PATCH] ext4: fix xfstest generic/269 double revoked buffer bug Daeho Jeong
@ 2015-10-18  2:30 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2015-10-18  2:30 UTC (permalink / raw)
  To: Daeho Jeong; +Cc: linux-ext4

On Thu, Oct 15, 2015 at 09:23:18AM +0900, Daeho Jeong wrote:
> When you repeatly execute xfstest generic/269 with bigalloc_1k option
> enabled using the below command:
> 
> "./kvm-xfstests -c bigalloc_1k -m nodelalloc -C 1000 generic/269"
> 
> you can easily see the below bug message.
> 
> "JBD2 unexpected failure: jbd2_journal_revoke: !buffer_revoked(bh);"
> 
> This means that an already revoked buffer is erroneously revoked again
> and it is caused by doing revoke for the buffer at the wrong position
> in ext4_free_blocks(). We need to re-position the buffer revoke
> procedure for an unspecified buffer after checking the cluster boundary
> for bigalloc option. If not, some part of the cluster can be doubly
> revoked.
> 
> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>

Thanks, applied.

						- Ted

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

end of thread, other threads:[~2015-10-18  2:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15  0:23 [PATCH] ext4: fix xfstest generic/269 double revoked buffer bug Daeho Jeong
2015-10-18  2:30 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).