• David Howells's avatar
    netfs: Fix trimming of streaming-write folios in netfs_inval_folio() · cce6bfa6
    David Howells authored
    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: 9ebff83e ("netfs: Prep to use folio->private for write grouping and streaming write")
    Signed-off-by: default avatarDavid 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: default avatarChristian Brauner <brauner@kernel.org>
    cce6bfa6
misc.c 5.53 KB