Whamcloud - gitweb
LU-16412 llite: check truncated page in ->readpage()
authorQian Yingjin <qian@ddn.com>
Mon, 19 Dec 2022 06:57:39 +0000 (01:57 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 4 Jan 2023 20:39:03 +0000 (20:39 +0000)
commita7cc29ebb3bd95ecd1a9705d96e76aee7037ce1e
tree46cd4941d444fe1e2b590f67de0a4606315abba1
parent89ff7dd43bd271933125dfde67170a031908a16c
LU-16412 llite: check truncated page in ->readpage()

The page end offset calculation in filemap_get_read_batch() was
off by one. This bug was introduced in commit v5.11-10234-gcbd59c48ae
("mm/filemap: use head pages in generic_file_buffered_read")

When a read is submitted with end offset 1048575, it calculates
the end page index for read of 256 where it should be 255. This
results in the readpage() call for the page with index 256 is over
stripe boundary and may not be covered by a DLM extent lock.

This happens in a corner race case: filemap_get_read_batch()
batches the page with index 256 for read, but later this page is
removed from page cache due to the lock protected it being revoked,
but has a reference count due to the batch.  This results in this
page in the read path is not covered by any DLM lock.

The solution is simple. We can check whether the page was
truncated and was removed from page cache in ->readpage() by the
address_sapce pointer of the page. If it was truncated, return
AOP_TRUNCATED_PAGE to the upper caller.  This will cause the
kernel to retry to batch pages and the truncated page will not
be added as it was already removed from page cache of the file.

Add sanityn/test_95 to verify it.

Lustre-change: https://review.whamcloud.com/49433
Lustre-commit: TBD (from 02fe613db9517875c03e8a919e1b42cb1ba7c619)

Test-Parameters: testlist=sanityn env=ONLY=95 clientdistro=ubuntu2204
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I192df92b1d1b79057055430cc81cb7cc760cc9ed
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49434
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/obd_support.h
lustre/llite/rw.c
lustre/llite/rw26.c
lustre/tests/sanityn.sh