]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix "BUG: Bad page state" caused by writeback flag
authorChunwei Chen <tuxoko@gmail.com>
Thu, 5 Mar 2015 19:52:26 +0000 (11:52 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 29 Jul 2015 14:38:15 +0000 (07:38 -0700)
commit21a96fb635fb14a59efe44d7ea6767c5f9a586bc
treead2a1724912309480f55e25d9844dc491b06c583
parentc1718e9580b9b6222be19c1691d3d7b61e503754
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
module/zfs/zfs_vnops.c