Skip to content
  • Lukas Czerner's avatar
    fs: Add FITRIM ioctl · 367a51a3
    Lukas Czerner authored
    
    
    Adds an filesystem independent ioctl to allow implementation of file
    system batched discard support. I takes fstrim_range structure as an
    argument. fstrim_range is definec in the include/fs.h and its
    definition is as follows.
    
    struct fstrim_range {
    	start;
    	len;
    	minlen;
    }
    
    start	- first Byte to trim
    len	- number of Bytes to trim from start
    minlen	- minimum extent length to trim, free extents shorter than this
    	  number of Bytes will be ignored. This will be rounded up to fs
    	  block size.
    
    It is also possible to specify NULL as an argument. In this case the
    arguments will set itself as follows:
    
    start = 0;
    len = ULLONG_MAX;
    minlen = 0;
    
    So it will trim the whole file system at one run.
    
    After the FITRIM is done, the number of actually discarded Bytes is stored
    in fstrim_range.len to give the user better insight on how much storage
    space has been really released for wear-leveling.
    
    Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
    Reviewed-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
    Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
    367a51a3