]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: fix reflink source file racing with directio writes
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 15 Aug 2019 00:38:09 +0000 (17:38 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 19 Aug 2019 01:53:25 +0000 (18:53 -0700)
commit035c0e1e83b0ade92c8e9c8756c9bd4a1da62d3a
tree902c57ac0fe14c9693ab36bd943de335eb23fc6d
parent533bf1160fe5b31315122ce29491ec873a64f373
xfs: fix reflink source file racing with directio writes

While trawling through the dedupe file comparison code trying to fix
page deadlocking problems, Dave Chinner noticed that the reflink code
only takes shared IOLOCK/MMAPLOCKs on the source file.  Because
page_mkwrite and directio writes do not take the EXCL versions of those
locks, this means that reflink can race with writer processes.

For pure remapping this can lead to undefined behavior and file
corruption; for dedupe this means that we cannot be sure that the
contents are identical when we decide to go ahead with the remapping.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_reflink.c