On Jun 25, 2007 20:33 +0530, Amit K. Arora wrote:
> I have not implemented FA_FL_FREE_ENOSPC and FA_ZERO_SPACE flags yet, as
> *suggested* by Andreas in http://lkml.org/lkml/2007/6/14/323 post.
> If it is decided that these flags are also needed, I will update this
> patch. Thanks!
Can you clarify - what is the current behaviour when ENOSPC (or some other
error) is hit? Does it keep the current fallocate() or does it free it?
For FA_ZERO_SPACE - I'd think this would (IMHO) be the default - we
don't want to expose uninitialized disk blocks to userspace. I'm not
sure if this makes sense at all.
> On Mon, Jun 25, 2007 at 07:15:00PM +0530, Amit K. Arora wrote:
> > Implement new flags and values for mode argument.
> >
> > This patch implements the new flags and values for the "mode" argument
> > of the fallocate system call. It is based on the discussion between
> > Andreas Dilger and David Chinner on the man page proposed (by the later)
> > on fallocate.
> >
> > Signed-off-by: Amit Arora <[email protected]>
> >
> > Index: linux-2.6.22-rc4/include/linux/fs.h
> > ===================================================================
> > --- linux-2.6.22-rc4.orig/include/linux/fs.h
> > +++ linux-2.6.22-rc4/include/linux/fs.h
> > @@ -267,15 +267,16 @@ extern int dir_notify_enable;
> > #define SYNC_FILE_RANGE_WAIT_AFTER 4
> >
> > /*
> > - * sys_fallocate modes
> > - * Currently sys_fallocate supports two modes:
> > - * FA_ALLOCATE : This is the preallocate mode, using which an application/user
> > - * may request (pre)allocation of blocks.
> > - * FA_DEALLOCATE: This is the deallocate mode, which can be used to free
> > - * the preallocated blocks.
> > + * sys_fallocate mode flags and values
> > */
> > -#define FA_ALLOCATE 0x1
> > -#define FA_DEALLOCATE 0x2
> > +#define FA_FL_DEALLOC 0x01 /* default is allocate */
> > +#define FA_FL_KEEP_SIZE 0x02 /* default is extend/shrink size */
> > +#define FA_FL_DEL_DATA 0x04 /* default is keep written data on DEALLOC */
> > +
> > +#define FA_ALLOCATE 0
> > +#define FA_DEALLOCATE FA_FL_DEALLOC
> > +#define FA_RESV_SPACE FA_FL_KEEP_SIZE
> > +#define FA_UNRESV_SPACE (FA_FL_DEALLOC | FA_FL_KEEP_SIZE | FA_FL_DEL_DATA)
> >
> > #ifdef __KERNEL__
> >
> > Index: linux-2.6.22-rc4/fs/open.c
> > ===================================================================
> > --- linux-2.6.22-rc4.orig/fs/open.c
> > +++ linux-2.6.22-rc4/fs/open.c
> > @@ -356,23 +356,26 @@ asmlinkage long sys_ftruncate64(unsigned
> > * sys_fallocate - preallocate blocks or free preallocated blocks
> > * @fd: the file descriptor
> > * @mode: mode specifies if fallocate should preallocate blocks OR free
> > - * (unallocate) preallocated blocks. Currently only FA_ALLOCATE and
> > - * FA_DEALLOCATE modes are supported.
> > + * (unallocate) preallocated blocks.
> > * @offset: The offset within file, from where (un)allocation is being
> > * requested. It should not have a negative value.
> > * @len: The amount (in bytes) of space to be (un)allocated, from the offset.
> > *
> > * This system call, depending on the mode, preallocates or unallocates blocks
> > * for a file. The range of blocks depends on the value of offset and len
> > - * arguments provided by the user/application. For FA_ALLOCATE mode, if this
> > + * arguments provided by the user/application. For FA_ALLOCATE and
> > + * FA_RESV_SPACE modes, if the sys_fallocate()
> > * system call succeeds, subsequent writes to the file in the given range
> > * (specified by offset & len) should not fail - even if the file system
> > * later becomes full. Hence the preallocation done is persistent (valid
> > - * even after reopen of the file and remount/reboot).
> > + * even after reopen of the file and remount/reboot). If FA_RESV_SPACE mode
> > + * is passed, the file size will not be changed even if the preallocation
> > + * is beyond EOF.
> > *
> > * It is expected that the ->fallocate() inode operation implemented by the
> > * individual file systems will update the file size and/or ctime/mtime
> > - * depending on the mode and also on the success of the operation.
> > + * depending on the mode (change is visible to user or not - say file size)
> > + * and obviously, on the success of the operation.
> > *
> > * Note: Incase the file system does not support preallocation,
> > * posix_fallocate() should fall back to the library implementation (i.e.
> > @@ -398,7 +401,8 @@ asmlinkage long sys_fallocate(int fd, in
> >
> > /* Return error if mode is not supported */
> > ret = -EOPNOTSUPP;
> > - if (mode != FA_ALLOCATE && mode != FA_DEALLOCATE)
> > + if (!(mode == FA_ALLOCATE || mode == FA_DEALLOCATE ||
> > + mode == FA_RESV_SPACE || mode == FA_UNRESV_SPACE))
> > goto out;
> >
> > ret = -EBADF;
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]