• David Howells's avatar
    netfs: Optimise away reads above the point at which there can be no data · 100ccd18
    David Howells authored
    Track the file position above which the server is not expected to have any
    data (the "zero point") and preemptively assume that we can satisfy
    requests by filling them with zeroes locally rather than attempting to
    download them if they're over that line - even if we've written data back
    to the server.  Assume that any data that was written back above that
    position is held in the local cache.  Note that we have to split requests
    that straddle the line.
    
    Make use of this to optimise away some reads from the server.  We need to
    set the zero point in the following circumstances:
    
     (1) When we see an extant remote inode and have no cache for it, we set
         the zero_point to i_size.
    
     (2) On local inode creation, we set zero_point to 0.
    
     (3) On local truncation down, we reduce zero_point to the new i_size if
         the new i_size is lower.
    
     (4) On local truncation up, we don't change zero_point.
    
     (5) On local modification, we don't change zero_point.
    
     (6) On remote invalidation, we set zero_point to the new i_size.
    
     (7) If stored data is discarded from the pagecache or culled from fscache,
         we must set zero_point above that if the data also got written to the
         server.
    
     (8) If dirty data is written back to the server, but not fscache, we must
         set zero_point above that.
    
     (9) If a direct I/O write is made, set zero_point above that.
    
    Assuming the above, any read from the server at or above the zero_point
    position will return all zeroes.
    
    The zero_point value can be stored in the cache, provided the above rules
    are applied to it by any code that culls part of the local cache.
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    cc: Jeff Layton <jlayton@kernel.org>
    cc: linux-cachefs@redhat.com
    cc: linux-fsdevel@vger.kernel.org
    cc: linux-mm@kvack.org
    100ccd18
cifsfs.c 54.4 KB