]> www.infradead.org Git - users/hch/xfs.git/commit
netfs: Fix trimming of streaming-write folios in netfs_inval_folio()
authorDavid Howells <dhowells@redhat.com>
Fri, 23 Aug 2024 20:08:12 +0000 (21:08 +0100)
committerChristian Brauner <brauner@kernel.org>
Sat, 24 Aug 2024 14:09:16 +0000 (16:09 +0200)
commitcce6bfa6ca0e30af9927b0074c97fe6a92f28092
tree689a3d4b63f876eb722de435b0807537f901d76d
parent7dfc8f0c6144c290dbeb01835a67e81b34dda8cd
netfs: Fix trimming of streaming-write folios in netfs_inval_folio()

When netfslib writes to a folio that it doesn't have data for, but that
data exists on the server, it will make a 'streaming write' whereby it
stores data in a folio that is marked dirty, but not uptodate.  When it
does this, it attaches a record to folio->private to track the dirty
region.

When truncate() or fallocate() wants to invalidate part of such a folio, it
will call into ->invalidate_folio(), specifying the part of the folio that
is to be invalidated.  netfs_invalidate_folio(), on behalf of the
filesystem, must then determine how to trim the streaming write record.  In
a couple of cases, however, it does this incorrectly (the reduce-length and
move-start cases are switched over and don't, in any case, calculate the
value correctly).

Fix this by making the logic tree more obvious and fixing the cases.

Fixes: 9ebff83e6481 ("netfs: Prep to use folio->private for write grouping and streaming write")
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20240823200819.532106-5-dhowells@redhat.com
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Pankaj Raghav <p.raghav@samsung.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: netfs@lists.linux.dev
cc: linux-mm@kvack.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/misc.c