• Nick Piggin's avatar
    Introduce a new truncate calling sequence into fs/mm subsystems. Rather · 7b9e2af3
    Nick Piggin authored
    than setattr > vmtruncate > truncate, have filesystems call their truncate
    sequence from ->setattr if filesystem specific operations are required. 
    vmtruncate is deprecated, and truncate_pagecache and inode_newsize_ok
    helpers introduced previously should be used.
    
    simple_setattr is introduced for simple in-ram filesystems to implement
    the new truncate sequence.  Eventually all filesystems should be converted
    to implement a setattr, and the default code in notify_change should go
    away.
    
    simple_setsize is also introduced to perform just the ATTR_SIZE portion of
    simple_setattr (ie.  changing i_size and trimming pagecache).
    
    A new attribute is introduced into inode_operations structure;
    .new_truncate is a temporary hack to distinguish filesystems that
    implement the new truncate system.
    
    To implement the new truncate sequence:
    - set .new_truncate = 1
    - filesystem specific manipulations (eg freeing blocks) must be done in
      the setattr method rather than ->truncate.
    - vmtruncate can not be used by core code to trim blocks past i_size in
      the event of write failure after allocation, so this must be performed
      in the fs code.
    - make use of the better opportunity to catch errors with the above 2 changes.
    - inode_setattr should not be used. generic_setattr is a new function
      to be used to copy simple attributes into the generic inode.
    
    Big problem with the previous calling sequence: the filesystem is not
    called until i_size has already changed.  This means it is not allowed to
    fail the call, and also it does not know what the previous i_size was. 
    Also, generic code calling vmtruncate to truncate allocated blocks in case
    of error had no good way to return a meaningful error (or, for example,
    atomically handle block deallocation).
    Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
    Cc: Chris Mason <chris.mason@oracle.com>
    Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
    Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
    Cc: Miklos Szeredi <miklos@szeredi.hu>
    Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
    Cc: Steven French <sfrench@us.ibm.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    7b9e2af3
buffer.c 88.9 KB