]> git.baikalelectronics.ru Git - kernel.git/commit
netfs: Fix dodgy maths
authorDavid Howells <dhowells@redhat.com>
Fri, 4 Nov 2022 15:36:49 +0000 (15:36 +0000)
committerDavid Howells <dhowells@redhat.com>
Tue, 15 Nov 2022 16:56:07 +0000 (16:56 +0000)
commit31176c0794f81b8846f607b5c5238ad4f9db85f6
tree87de545c980f1bf2b6d750f64a44923333fef4e3
parenta6aec89d013c4dc85effa390fa6afbe783cbe875
netfs: Fix dodgy maths

Fix the dodgy maths in netfs_rreq_unlock_folios().  start_page could be
inside the folio, in which case the calculation of pgpos will be come up
with a negative number (though for the moment rreq->start is rounded down
earlier and folios would have to get merged whilst locked)

Alter how this works to just frame the tracking in terms of absolute file
positions, rather than offsets from the start of the I/O request.  This
simplifies the maths and makes it easier to follow.

Fix the issue by using folio_pos() and folio_size() to calculate the end
position of the page.

Fixes: f04d087afe94 ("netfs: Provide readahead and readpage netfs helpers")
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/Y2SJw7w1IsIik3nb@casper.infradead.org/
Link: https://lore.kernel.org/r/166757988611.950645.7626959069846893164.stgit@warthog.procyon.org.uk/
fs/netfs/buffered_read.c