]> 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)
commit5e51c627c5acbcf82bb552e17533a79d2a6a2600
tree87de545c980f1bf2b6d750f64a44923333fef4e3
parent7e043a80b5dae5c2d2cf84031501de7827fd6c00
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: 3d3c95046742 ("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