From: NeilBrown <neilb@suse.de>
To: Matthew Wilcox <matthew.r.wilcox@intel.com>,
Charles Bertsch <cbertsch@cox.net>
Cc: linux-raid@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>
Subject: Problems with bdev_write_page().
Date: Sun, 17 May 2015 17:02:00 +1000 [thread overview]
Message-ID: <20150517170200.0d966434@notabene.brown> (raw)
[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]
Hi Matthew,
I've just been looking at bdev_write_page().
You can read about why here:
http://marc.info/?t=142984068300001&r=1&w=2
it ends with a "git bisect" which points the finger at you.
If I look at bdev_write_page() it says:
* On entry, the page should be locked and not currently under writeback.
* On exit, if the write started successfully, the page will be unlocked and
* under writeback. If the write failed already (eg the driver failed to
* queue the page to the device), the page will still be locked. If the
* caller is a ->writepage implementation, it will need to unlock the page.
So the page is unlocked on success.
In __mpage_writepage() I find
if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9),
page, wbc)) {
clean_buffers(page, first_unmapped);
so if bdev_write_page() succeeds, i.e. if it returns '0', then
clean_buffers() is called. At this point the page is unlocked remember.
clean_buffers may call
try_to_free_buffers(page);
(without first locking the page, so still unlocked)..
try_to_free_buffers starts:
BUG_ON(!PageLocked(page));
Opps.
Can you propose a fix for Charles, who can trigger this bug and nicely
bisected it for us - thanks Charles!!!
Also while looking at the code, I notice that brd_rw_page() unconditionally
calls page_endio() and, in the WRITE case, page_endio unconditionally calls
end_page_writeback(), which has
if (!test_clear_page_writeback(page))
BUG();
and so cannot tolerate being called twice in a row.
So if brd_rw_page() ever returned an error (which seems possible though not
likely), end_page_writeback() would be called once by page_endio() and once
in the error path of bdev_write_page(), and the BUG above would be triggered.
I'll leave that for you to sort out too :-)
Thanks,
NeilBrown
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next reply other threads:[~2015-05-17 7:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-17 7:02 NeilBrown [this message]
[not found] <Uv2G1q00k0LXzhv01v2JnY>
2015-05-25 21:19 ` Problems with bdev_write_page() Charles Bertsch
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=20150517170200.0d966434@notabene.brown \
--to=neilb@suse.de \
--cc=cbertsch@cox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=matthew.r.wilcox@intel.com \
/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