From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: cmm@us.ibm.com, tytso@mit.edu, sandeen@redhat.com
Cc: linux-ext4@vger.kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH -V2 4/4] ext4: Add WARN_ON on unmapped dirty buffer_heads in writepage
Date: Thu, 4 Jun 2009 11:40:05 +0530 [thread overview]
Message-ID: <1244095805-17015-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1244095805-17015-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Now we have block_lock_hole_extend clearing the dirty flag of
buffer_heads outside i_size we should not find buffer_heads
which are unmapped and dirty in writepage. If we find do a WARN_ON.
We can still continue because block_write_full page look at the mapped
flag only.
Following sequence of events would result in the above condition.
1) truncate(f, 1024)
2) mmap(f, 0, 4096)
3) a[0] = 'a'
4) truncate(f, 4096)
5) writepage(...)
After step 3 we would have unmapped buffer_heads outside i_size.
After step 4 we would have unmapped buffer_heads within i_size.
Now that truncate is calling block_lock_hole_extend which in turn
is clearing the dirty flag, we can safely assume that we won't
find unmapped dirty buffer_heads in write page. If we did find one
we should find out why.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2219daa..9bba474 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2488,6 +2488,10 @@ static int __ext4_journalled_writepage(struct page *page,
return ret;
}
+static int ext4_bh_unmapped_and_dirty(handle_t *handle, struct buffer_head *bh)
+{
+ return !buffer_mapped(bh) && buffer_dirty(bh);
+}
/*
* Note that we don't need to start a transaction unless we're journaling data
@@ -2602,6 +2606,14 @@ static int ext4_writepage(struct page *page,
/* now mark the buffer_heads as dirty and uptodate */
block_commit_write(page, 0, len);
}
+ /*
+ * There should not be any unmapped and dirty
+ * buffer_heads at this point. Look at block_lock_hole_extend
+ * for more info. If we find one print more info
+ */
+ WARN(walk_page_buffers(NULL, page_bufs, 0, len, NULL,
+ ext4_bh_unmapped_and_dirty),
+ "Unmapped dirty buffer_heads found in %s\n", __func__);
if (PageChecked(page) && ext4_should_journal_data(inode)) {
/*
--
1.6.3.1.244.gf9275
next prev parent reply other threads:[~2009-06-04 6:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-04 6:10 [PATCH -V2 1/4] ext4: Check for only delay or unwritten buffer_heads Aneesh Kumar K.V
2009-06-04 6:10 ` [PATCH -V2 2/4] ext4: Add generic writepage callback Aneesh Kumar K.V
2009-06-04 6:10 ` [PATCH -V2 3/4] ext4: Move some static functions around Aneesh Kumar K.V
2009-06-04 6:10 ` Aneesh Kumar K.V [this message]
2009-06-04 13:50 ` [PATCH -V2 4/4] ext4: Add WARN_ON on unmapped dirty buffer_heads in writepage Theodore Tso
2009-06-04 13:47 ` [PATCH -V2 3/4] ext4: Move some static functions around Theodore Tso
2009-06-04 12:05 ` [PATCH -V2 2/4] ext4: Add generic writepage callback Theodore Tso
2009-06-04 13:20 ` Theodore Tso
2009-06-04 13:16 ` [PATCH -V2 1/4] ext4: Check for only delay or unwritten buffer_heads Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244095805-17015-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=cmm@us.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).