• David Howells's avatar
    afs: Fix truncation issues and mmap writeback size · 793fe82e
    David Howells authored
    Fix the following issues:
    
     (1) Fix writeback to reduce the size of a store operation to i_size,
         effectively discarding the extra data.
    
         The problem comes when afs_page_mkwrite() records that a page is about
         to be modified by mmap().  It doesn't know what bits of the page are
         going to be modified, so it records the whole page as being dirty
         (this is stored in page->private as start and end offsets).
    
         Without this, the marshalling for the store to the server extends the
         size of the file to the end of the page (in afs_fs_store_data() and
         yfs_fs_store_data()).
    
     (2) Fix setattr to actually truncate the pagecache, thereby clearing
         the discarded part of a file.
    
     (3) Fix setattr to check that the new size is okay and to disable
         ATTR_SIZE if i_size wouldn't change.
    
     (4) Force i_size to be updated as the result of a truncate.
    
     (5) Don't truncate if ATTR_SIZE is not set.
    
     (6) Call pagecache_isize_extended() if the file was enlarged.
    
    Note that truncate_set_size() isn't used because the setting of i_size is
    done inside afs_vnode_commit_status() under the vnode->cb_lock.
    
    Found with the generic/029 and generic/393 xfstests.
    
    Fixes: 31143d5d ("AFS: implement basic file write support")
    Fixes: 4343d008 ("afs: Get rid of the afs_writeback record")
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    793fe82e
write.c 21.6 KB