From: Josef Bacik Date: Wed, 17 Apr 2013 14:17:05 +0000 (-0400) Subject: Btrfs: don't force pages under writeback to finish when aborting X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b8d7f3ac10a865ca727f9373a796ef8537e3a474;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git Btrfs: don't force pages under writeback to finish when aborting Dave reported a BUG_ON() that happened in end_page_writeback() after an abort. This happened because we unconditionally call end_page_writeback() in the endio case, which is right. However when we abort the transaction we will call end_page_writeback() on any writeback pages we find, which is wrong. We need to lock the page and wait on page writeback to complete if it is. There is nothing unsafe about this since we are discarding the transaction anyway. Thanks, Reported-by: David Sterba Signed-off-by: Josef Bacik --- diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8a7a366267ec..aab7d89f3ff0 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3763,10 +3763,9 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, if (eb) ret = test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags); - if (PageWriteback(page)) - end_page_writeback(page); - lock_page(page); + + wait_on_page_writeback(page); if (PageDirty(page)) { clear_page_dirty_for_io(page); spin_lock_irq(&page->mapping->tree_lock);