]> git.baikalelectronics.ru Git - kernel.git/commit
vfs: fix page locking deadlocks when deduping files
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 11 Aug 2019 22:52:25 +0000 (15:52 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sat, 17 Aug 2019 01:43:24 +0000 (18:43 -0700)
commit533bf1160fe5b31315122ce29491ec873a64f373
treef7150ad9ad44a311987109b39b4532e88db0c819
parent6da194e43d83146636a66266bddda589ba3f44f5
vfs: fix page locking deadlocks when deduping files

When dedupe wants to use the page cache to compare parts of two files
for dedupe, we must be very careful to handle locking correctly.  The
current code doesn't do this.  It must lock and unlock the page only
once if the two pages are the same, since the overlapping range check
doesn't catch this when blocksize < pagesize.  If the pages are distinct
but from the same file, we must observe page locking order and lock them
in order of increasing offset to avoid clashing with writeback locking.

Fixes: 8ff80371f84bf0b ("vfs: refactor clone/dedupe_file_range common functions")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
fs/read_write.c