]> git.hungrycats.org Git - linux/commit
Btrfs: check prepare_uptodate_page() error code earlier
authorChris Mason <clm@fb.com>
Mon, 14 Dec 2015 23:40:44 +0000 (15:40 -0800)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Tue, 19 Jan 2016 05:20:36 +0000 (00:20 -0500)
commitd2cbdbda072decf67065b7d70d4d82792f1f2f62
tree15cce720c4223111027aad6ac58c5fbd93e2f35f
parenta77ac788eb1c03a51cf0f41f9d7a809de20a6764
Btrfs: check prepare_uptodate_page() error code earlier

prepare_pages() may end up calling prepare_uptodate_page() twice if our
write only spans a single page.  But if the first call returns an error,
our page will be unlocked and its not safe to call it again.

This bug goes all the way back to 2011, and it's not something commonly
hit.

While we're here, add a more explicit check for the page being truncated
away.  The bare lock_page() alone is protected only by good thoughts and
i_mutex, which we're sure to regret eventually.

Reported-by: Dave Jones <dsj@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit bb1591b4ea1a1485ebc79be4e4748e94f96c670b)
(cherry picked from commit 3684e859ba549093a662b89fcae2bb7b89e87a73)
fs/btrfs/file.c