• J
    Btrfs: allow partial ordered extent completion · 77cef2ec
    Josef Bacik 提交于
    We currently have this problem where you can truncate pages that have not yet
    been written for an ordered extent.  We do this because the truncate will be
    coming behind to clean us up anyway so what's the harm right?  Well if truncate
    fails for whatever reason we leave an orphan item around for the file to be
    cleaned up later.  But if the user goes and truncates up the file and tries to
    read from the area that had been discarded previously they will get a csum error
    because we never actually wrote that data out.
    
    This patch fixes this by allowing us to either discard the ordered extent
    completely, by which I mean we just free up the space we had allocated and not
    add the file extent, or adjust the length of the file extent we write.  We do
    this by setting the length we truncated down to in the ordered extent, and then
    we set the file extent length and ram bytes to this length.  The total disk
    space stays unchanged since we may be compressed and we can't just chop off the
    disk space, but at least this way the file extent only points to the valid data.
    Then when the file extent is free'd the extent and csums will be freed normally.
    
    This patch is needed for the next series which will give us more graceful
    recovery of failed truncates.  Thanks,
    Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
    Signed-off-by: NChris Mason <chris.mason@fusionio.com>
    77cef2ec
inode.c 229.2 KB