]> granicus.if.org Git - zfs/commit
Fix zfs_putpage() lock inversion
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 19 Dec 2014 20:57:54 +0000 (12:57 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 22 Dec 2014 17:31:56 +0000 (09:31 -0800)
commit74328ee18f94d27f9c802d29fdd311018dab2adf
treee1c45efc24bf65c579832175d193d5c4c18df2d8
parent2d9d57b0fbe17b56a1bdd09505400144778cb189
Fix zfs_putpage() lock inversion

There exists a lock inversions involving the zfs range lock and the
individual page writeback bits which can result in a deadlock.  To
prevent this we must always manipulate the writeback bit while
holding the range lock.  The exact deadlock is as follows:

------ Process A ------        ------ Process B ------
zpl_writepages                 zpl_fallocate
write_cache_pages              zpl_fallocate_common
zpl_putpage                    zfs_space
zfs_putpage (set bit)          zfs_freesp
zfs_range_lock (wait on lock)  zfs_free_range (take lock)
[has not yet initiated I/O,    truncate_inode_pages_range
the bit will not be cleared]   wait_on_page_writeback (wait on bit)

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
Issue #2976
module/zfs/zfs_vnops.c