diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2016-05-03 05:54:08 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2016-10-07 12:36:29 -0800 |
commit | 36b75937684e92b9b35d7bcb88784c9e57c4598a (patch) | |
tree | d71badd16775549fcf63211038b39179c4d80963 | |
parent | 4fcd6c6e08787ae73d28ef08d4beb2fdeb4a34c5 (diff) |
bcachefs: fix a writepage race
set_page_dirty() can happen again while a page is undergoing writeback, so we
if we're doing a compressed write we need to mark pages as unallocated before
unlocking
-rw-r--r-- | drivers/md/bcache/fs-io.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/md/bcache/fs-io.c b/drivers/md/bcache/fs-io.c index 4585ba74a637..0f0a9e04c959 100644 --- a/drivers/md/bcache/fs-io.c +++ b/drivers/md/bcache/fs-io.c @@ -799,11 +799,6 @@ static void bch_writepage_io_done(struct closure *cl) struct bch_page_state old, new; old = page_state_cmpxchg(page_state(page), new, { - new.alloc_state = - (io->op.op.compression_type == - BCH_COMPRESSION_NONE) - ? BCH_PAGE_ALLOCATED - : BCH_PAGE_UNALLOCATED; new.sectors = PAGE_SECTORS; new.dirty_sectors = 0; }); @@ -935,7 +930,10 @@ do_io: (new.sectors != PAGE_SECTORS || new.alloc_state != BCH_PAGE_ALLOCATED)); - if (!new.reserved) + if (new.alloc_state == BCH_PAGE_ALLOCATED && + w->io->op.op.compression_type != BCH_COMPRESSION_NONE) + new.alloc_state = BCH_PAGE_UNALLOCATED; + else if (!new.reserved) goto out; new.reserved = 0; }); |