Re: [PATCH 1/6] fs: add hole punching to fallocate

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andreas Dilger
Date: Wednesday, November 17, 2010 - 2:19 am

On 2010-11-16, at 20:11, Dave Chinner wrote:

It makes the API usage from applications more consistent.  It would be inconvenient, for example, if applications had to use a different system call if they were writing in the middle of the file vs. at the end, wouldn't it?

Similarly, if multiple threads are appending vs. punching (let's assume non-overlapping regions, for sanity, like a producer/consumer model punching out completed records) then using ftruncate() to remove the last record and shrink the file would require locking the whole file from userspace (unlike the append, which does this in the kernel), or risk discarding unprocessed data beyond the record that was punched out.


I would think it natural that the new size is the start of the region, like an "anti-write" (where write sets the size at the end of the added bytes).


I definitely think they should be left as is.  If they were in the punched-out range, they would be deallocated, and if they are beyond EOF they will remain as they are - we didn't ask to remove them unless the punched-out range went to ~0ULL (which would make it equivalent to an ftruncate()).


I'm not sure I understand what a "written block beyond EOF" means.  How can there be data beyond EOF?  I think the KEEP_SIZE flag is only relevant if the punch is spanning EOF, like the opposite of a write that is spanning EOF.  If KEEP_SIZE is set, then it leaves the size unchanged, and if unset and punch spans EOF it reduces the file size.  If the punch is not at EOF it doesn't change the file size, just like a write that is not at EOF.


Even if the effects were the same, it makes sense because applications may be using fallocate(PUNCH_HOLE) to punch out records, and having them special case the use of ftruncate() to get certain semantics at the end of the file adds needless complexity.

Cheers, Andreas





--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Hole Punching V2, Josef Bacik, (Mon Nov 15, 10:05 am)
[PATCH 1/6] fs: add hole punching to fallocate, Josef Bacik, (Mon Nov 15, 10:05 am)
[PATCH 4/6] Ext4: fail if we try to use hole punch, Josef Bacik, (Mon Nov 15, 10:05 am)
[PATCH 5/6] Btrfs: fail if we try to use hole punch, Josef Bacik, (Mon Nov 15, 10:05 am)
[PATCH 6/6] Gfs2: fail if we try to use hole punch, Josef Bacik, (Mon Nov 15, 10:05 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Josef Bacik, (Tue Nov 16, 5:50 am)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Josef Bacik, (Tue Nov 16, 5:52 am)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Josef Bacik, (Tue Nov 16, 5:53 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Josef Bacik, (Tue Nov 16, 9:05 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Pádraig Brady, (Tue Nov 16, 9:20 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Josef Bacik, (Tue Nov 16, 9:33 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Pádraig Brady, (Tue Nov 16, 9:56 am)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Greg Freemyer, (Tue Nov 16, 1:47 pm)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Andreas Dilger, (Tue Nov 16, 5:22 pm)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Dave Chinner, (Tue Nov 16, 7:11 pm)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Josef Bacik, (Tue Nov 16, 7:28 pm)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Josef Bacik, (Tue Nov 16, 7:34 pm)
Re: [PATCH 4/6] Ext4: fail if we try to use hole punch, Josef Bacik, (Tue Nov 16, 11:31 pm)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Andreas Dilger, (Wed Nov 17, 2:19 am)
Re: [PATCH 1/6] fs: add hole punching to fallocate, Andreas Dilger, (Wed Nov 17, 2:30 am)