HomeFreeBSD

Fix "BUG: Bad page state" caused by writeback flag

Description

Fix "BUG: Bad page state" caused by writeback flag

Commit d958324 fixed the deadlock between page lock and range lock by
unlocking the page lock before acquiring the range lock. However,
this created a new issue #3075.

The problem is that if we can't set the write back bit before releasing
the page lock. Then other processes will be unaware that the page is
under active write back. They may therefore truncate the page,
invalidate the page, or not honor the sync semantics.

To workaround this problem we re-dirty the page before dropping the
page lock. While this doesn't prevent the page from being truncated
it does ensure it won't be invalidated. Then the range lock and the
page lock are reacquired in the correct deadlock-free order.

Once both locks are safely held the page state can be rechecked. If
all is well and the page is in the expect state the dirty bit can be
removed, the write back bit set, and the page removed from the skip
count. If not the page will be handled as appropriate.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3075

Details

Provenance
Chunwei Chen <tuxoko@gmail.com>Authored on Mar 5 2015, 7:52 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Jul 29 2015, 2:38 PM
Parents
rGc1718e9580b9: Fix build failure with Linux 4.1 and FTRACE
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG21a96fb635fb: Fix "BUG: Bad page state" caused by writeback flag (authored by Chunwei Chen <tuxoko@gmail.com>).Jul 29 2015, 2:38 PM