* [Cluster-devel] [PATCH 1/6] fs: add hole punching to fallocate
2010-11-09 21:41 ` Ted Ts'o
@ 2010-11-09 21:53 ` Jan Kara
0 siblings, 0 replies; 30+ messages in thread
From: Jan Kara @ 2010-11-09 21:53 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Tue 09-11-10 16:41:47, Ted Ts'o wrote:
> On Tue, Nov 09, 2010 at 03:42:42PM +1100, Dave Chinner wrote:
> > Implementation is up to the filesystem. However, XFS does (b)
> > because:
> >
> > 1) it was extremely simple to implement (one of the
> > advantages of having an exceedingly complex allocation
> > interface to begin with :P)
> > 2) conversion is atomic, fast and reliable
> > 3) it is independent of the underlying storage; and
> > 4) reads of unwritten extents operate at memory speed,
> > not disk speed.
>
> Yeah, I was thinking that using a device-style TRIM might be better
> since future attempts to write to it won't require a separate seek to
> modify the extent tree. But yeah, there are a bunch of advantages of
> simply mutating the extent tree.
>
> While we're on the subject of changes to fallocate, what do people
> think of FALLOC_FL_EXPOSE_OLD_DATA, which requires either root
> privileges or (if capabilities are in use) CAP_DAC_OVERRIDE &&
> CAP_MAC_OVERRIDE && CAP_SYS_ADMIN. This would allow a trusted process
> to fallocate blocks with the extent already marked initialized. I've
> had two requests for such functionality for ext4 already.
>
> (Take for example a trusted cluster filesystem backend that checks the
> object checksum before returning any data to the user; and if the
> check fails the cluster file system will try to use some other replica
> stored on some other server.)
Hum, could you elaborate a bit? I fail to see how above fallocate() flag
could be used to help solving this problem... Just curious...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Cluster-devel] [PATCH 1/6] fs: add hole punching to fallocate
2010-11-15 17:05 ` [PATCH 1/6] fs: add hole punching to fallocate Josef Bacik
@ 2010-11-16 11:16 ` Jan Kara
2010-11-16 11:43 ` Jan Kara
0 siblings, 1 reply; 30+ messages in thread
From: Jan Kara @ 2010-11-16 11:16 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Mon 15-11-10 12:05:18, Josef Bacik wrote:
> diff --git a/fs/open.c b/fs/open.c
> index 4197b9e..ab8dedf 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -223,7 +223,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> return -EINVAL;
>
> /* Return error if mode is not supported */
> - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> + if (mode && (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)))
Why not just:
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) ?
> diff --git a/include/linux/falloc.h b/include/linux/falloc.h
> index 3c15510..851cba2 100644
> --- a/include/linux/falloc.h
> +++ b/include/linux/falloc.h
> @@ -2,6 +2,7 @@
> #define _FALLOC_H_
>
> #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
> +#define FALLOC_FL_PUNCH_HOLE 0X02 /* de-allocates range */
^ use lowercase 'x' please...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Cluster-devel] [PATCH 1/6] fs: add hole punching to fallocate
2010-11-16 11:16 ` [Cluster-devel] " Jan Kara
@ 2010-11-16 11:43 ` Jan Kara
2010-11-16 12:52 ` Josef Bacik
0 siblings, 1 reply; 30+ messages in thread
From: Jan Kara @ 2010-11-16 11:43 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Tue 16-11-10 12:16:11, Jan Kara wrote:
> On Mon 15-11-10 12:05:18, Josef Bacik wrote:
> > diff --git a/fs/open.c b/fs/open.c
> > index 4197b9e..ab8dedf 100644
> > --- a/fs/open.c
> > +++ b/fs/open.c
> > @@ -223,7 +223,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> > return -EINVAL;
> >
> > /* Return error if mode is not supported */
> > - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> > + if (mode && (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)))
> Why not just:
> if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) ?
And BTW, since FALLOC_FL_PUNCH_HOLE does not change the file size, should
not we enforce that FALLOC_FL_KEEP_SIZE is / is not set? I don't mind too
much which way but keeping it ambiguous (ignored) in the interface usually
proves as a bad idea in future when we want to further extend the interface...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Cluster-devel] [PATCH 1/6] fs: add hole punching to fallocate
2010-11-16 12:52 ` Josef Bacik
@ 2010-11-16 13:14 ` Jan Kara
0 siblings, 0 replies; 30+ messages in thread
From: Jan Kara @ 2010-11-16 13:14 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Tue 16-11-10 07:52:50, Josef Bacik wrote:
> On Tue, Nov 16, 2010 at 12:43:46PM +0100, Jan Kara wrote:
> > On Tue 16-11-10 12:16:11, Jan Kara wrote:
> > > On Mon 15-11-10 12:05:18, Josef Bacik wrote:
> > > > diff --git a/fs/open.c b/fs/open.c
> > > > index 4197b9e..ab8dedf 100644
> > > > --- a/fs/open.c
> > > > +++ b/fs/open.c
> > > > @@ -223,7 +223,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> > > > return -EINVAL;
> > > >
> > > > /* Return error if mode is not supported */
> > > > - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> > > > + if (mode && (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)))
> > > Why not just:
> > > if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) ?
> > And BTW, since FALLOC_FL_PUNCH_HOLE does not change the file size, should
> > not we enforce that FALLOC_FL_KEEP_SIZE is / is not set? I don't mind too
> > much which way but keeping it ambiguous (ignored) in the interface usually
> > proves as a bad idea in future when we want to further extend the interface...
> >
>
> Yeah I went back and forth on this. KEEP_SIZE won't change the behavior of
> PUNCH_HOLE since PUNCH_HOLE implicitly means keep the size. I figured since its
> "mode" and not "flags" it would be ok to make either way accepted, but if you
> prefer PUNCH_HOLE means you have to have KEEP_SIZE set then I'm cool with that,
> just let me know one way or the other. Thanks,
I was wondering about 'mode' vs 'flags' as well. The manpage says:
The mode argument determines the operation to be performed on the given
range. Currently only one flag is supported for mode...
So we call it "mode" but speak about "flags"? Seems a bit inconsistent.
I'd maybe lean a bit at the "flags" side and just make sure that
only one of FALLOC_FL_KEEP_SIZE, FALLOC_FL_PUNCH_HOLE is set (interpreting
FALLOC_FL_KEEP_SIZE as allocate blocks beyond i_size). But I'm not sure
what others think.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* Hole Punching V3
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
This is version 3 of the hole punching series I've been posting. Not much has
changed, the history is below
V2->V3
-FALLOC_FL_PUNCH_HOLE must also have FALLOC_FL_KEEP_SIZE in order to work
-formatting fixes
V1->V2
-Hole punching doesn't change file size
-Fixed the mode checks in ext4/btrfs/gfs2 so they do what they are supposed to
I've updated my local copies of the xfsprogs patches I have to test this to use
KEEP_SIZE and PUNCH_HOLE together, I'll post them after it looks like these
patches are good to go, including the manpage update. The xfstest I wrote ran
fine both on xfs and btrfs (failing on btrfs obviously). Thanks,
Josef
^ permalink raw reply [flat|nested] 30+ messages in thread
* Hole Punching V3
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This is version 3 of the hole punching series I've been posting. Not much has
changed, the history is below
V2->V3
-FALLOC_FL_PUNCH_HOLE must also have FALLOC_FL_KEEP_SIZE in order to work
-formatting fixes
V1->V2
-Hole punching doesn't change file size
-Fixed the mode checks in ext4/btrfs/gfs2 so they do what they are supposed to
I've updated my local copies of the xfsprogs patches I have to test this to use
KEEP_SIZE and PUNCH_HOLE together, I'll post them after it looks like these
patches are good to go, including the manpage update. The xfstest I wrote ran
fine both on xfs and btrfs (failing on btrfs obviously). Thanks,
Josef
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 30+ messages in thread
* Hole Punching V3
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This is version 3 of the hole punching series I've been posting. Not much has
changed, the history is below
V2->V3
-FALLOC_FL_PUNCH_HOLE must also have FALLOC_FL_KEEP_SIZE in order to work
-formatting fixes
V1->V2
-Hole punching doesn't change file size
-Fixed the mode checks in ext4/btrfs/gfs2 so they do what they are supposed to
I've updated my local copies of the xfsprogs patches I have to test this to use
KEEP_SIZE and PUNCH_HOLE together, I'll post them after it looks like these
patches are good to go, including the manpage update. The xfstest I wrote ran
fine both on xfs and btrfs (failing on btrfs obviously). Thanks,
Josef
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 1/6] fs: add hole punching to fallocate
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
Hole punching has already been implemented by XFS and OCFS2, and has the
potential to be implemented on both BTRFS and EXT4 so we need a generic way to
get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
to fallocate() since it already looks like the normal fallocate() operation.
I've tested this patch with XFS and BTRFS to make sure XFS did what it's
supposed to do and that BTRFS failed like it was supposed to. Thank you,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/open.c | 7 ++++++-
include/linux/falloc.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index 4197b9e..5b6ef7e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return -EINVAL;
/* Return error if mode is not supported */
- if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
+ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+ return -EOPNOTSUPP;
+
+ /* Punch hole must have keep size set */
+ if ((mode & FALLOC_FL_PUNCH_HOLE) &&
+ !(mode & FALLOC_FL_KEEP_SIZE))
return -EOPNOTSUPP;
if (!(file->f_mode & FMODE_WRITE))
diff --git a/include/linux/falloc.h b/include/linux/falloc.h
index 3c15510..73e0b62 100644
--- a/include/linux/falloc.h
+++ b/include/linux/falloc.h
@@ -2,6 +2,7 @@
#define _FALLOC_H_
#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#ifdef __KERNEL__
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/6] fs: add hole punching to fallocate
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Hole punching has already been implemented by XFS and OCFS2, and has the
potential to be implemented on both BTRFS and EXT4 so we need a generic way to
get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
to fallocate() since it already looks like the normal fallocate() operation.
I've tested this patch with XFS and BTRFS to make sure XFS did what it's
supposed to do and that BTRFS failed like it was supposed to. Thank you,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/open.c | 7 ++++++-
include/linux/falloc.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index 4197b9e..5b6ef7e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return -EINVAL;
/* Return error if mode is not supported */
- if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
+ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+ return -EOPNOTSUPP;
+
+ /* Punch hole must have keep size set */
+ if ((mode & FALLOC_FL_PUNCH_HOLE) &&
+ !(mode & FALLOC_FL_KEEP_SIZE))
return -EOPNOTSUPP;
if (!(file->f_mode & FMODE_WRITE))
diff --git a/include/linux/falloc.h b/include/linux/falloc.h
index 3c15510..73e0b62 100644
--- a/include/linux/falloc.h
+++ b/include/linux/falloc.h
@@ -2,6 +2,7 @@
#define _FALLOC_H_
#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#ifdef __KERNEL__
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/6] fs: add hole punching to fallocate
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Hole punching has already been implemented by XFS and OCFS2, and has the
potential to be implemented on both BTRFS and EXT4 so we need a generic way to
get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
to fallocate() since it already looks like the normal fallocate() operation.
I've tested this patch with XFS and BTRFS to make sure XFS did what it's
supposed to do and that BTRFS failed like it was supposed to. Thank you,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/open.c | 7 ++++++-
include/linux/falloc.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index 4197b9e..5b6ef7e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return -EINVAL;
/* Return error if mode is not supported */
- if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
+ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+ return -EOPNOTSUPP;
+
+ /* Punch hole must have keep size set */
+ if ((mode & FALLOC_FL_PUNCH_HOLE) &&
+ !(mode & FALLOC_FL_KEEP_SIZE))
return -EOPNOTSUPP;
if (!(file->f_mode & FMODE_WRITE))
diff --git a/include/linux/falloc.h b/include/linux/falloc.h
index 3c15510..73e0b62 100644
--- a/include/linux/falloc.h
+++ b/include/linux/falloc.h
@@ -2,6 +2,7 @@
#define _FALLOC_H_
#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#ifdef __KERNEL__
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/6] XFS: handle hole punching via fallocate properly
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
This patch simply allows XFS to handle the hole punching flag in fallocate
properly. I've tested this with a little program that does a bunch of random
hole punching with FL_KEEP_SIZE and without it to make sure it does the right
thing. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/xfs/linux-2.6/xfs_iops.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 96107ef..07d2164 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -516,6 +516,7 @@ xfs_vn_fallocate(
loff_t new_size = 0;
xfs_flock64_t bf;
xfs_inode_t *ip = XFS_I(inode);
+ int cmd = XFS_IOC_RESVSP;
/* preallocation on directories not yet supported */
error = -ENODEV;
@@ -528,6 +529,9 @@ xfs_vn_fallocate(
xfs_ilock(ip, XFS_IOLOCK_EXCL);
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = XFS_IOC_UNRESVSP;
+
/* check the new inode size is valid before allocating */
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
offset + len > i_size_read(inode)) {
@@ -537,8 +541,7 @@ xfs_vn_fallocate(
goto out_unlock;
}
- error = -xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf,
- 0, XFS_ATTR_NOLOCK);
+ error = -xfs_change_file_space(ip, cmd, &bf, 0, XFS_ATTR_NOLOCK);
if (error)
goto out_unlock;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/6] XFS: handle hole punching via fallocate properly
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This patch simply allows XFS to handle the hole punching flag in fallocate
properly. I've tested this with a little program that does a bunch of random
hole punching with FL_KEEP_SIZE and without it to make sure it does the right
thing. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/xfs/linux-2.6/xfs_iops.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 96107ef..07d2164 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -516,6 +516,7 @@ xfs_vn_fallocate(
loff_t new_size = 0;
xfs_flock64_t bf;
xfs_inode_t *ip = XFS_I(inode);
+ int cmd = XFS_IOC_RESVSP;
/* preallocation on directories not yet supported */
error = -ENODEV;
@@ -528,6 +529,9 @@ xfs_vn_fallocate(
xfs_ilock(ip, XFS_IOLOCK_EXCL);
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = XFS_IOC_UNRESVSP;
+
/* check the new inode size is valid before allocating */
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
offset + len > i_size_read(inode)) {
@@ -537,8 +541,7 @@ xfs_vn_fallocate(
goto out_unlock;
}
- error = -xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf,
- 0, XFS_ATTR_NOLOCK);
+ error = -xfs_change_file_space(ip, cmd, &bf, 0, XFS_ATTR_NOLOCK);
if (error)
goto out_unlock;
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/6] XFS: handle hole punching via fallocate properly
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This patch simply allows XFS to handle the hole punching flag in fallocate
properly. I've tested this with a little program that does a bunch of random
hole punching with FL_KEEP_SIZE and without it to make sure it does the right
thing. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/xfs/linux-2.6/xfs_iops.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 96107ef..07d2164 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -516,6 +516,7 @@ xfs_vn_fallocate(
loff_t new_size = 0;
xfs_flock64_t bf;
xfs_inode_t *ip = XFS_I(inode);
+ int cmd = XFS_IOC_RESVSP;
/* preallocation on directories not yet supported */
error = -ENODEV;
@@ -528,6 +529,9 @@ xfs_vn_fallocate(
xfs_ilock(ip, XFS_IOLOCK_EXCL);
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = XFS_IOC_UNRESVSP;
+
/* check the new inode size is valid before allocating */
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
offset + len > i_size_read(inode)) {
@@ -537,8 +541,7 @@ xfs_vn_fallocate(
goto out_unlock;
}
- error = -xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf,
- 0, XFS_ATTR_NOLOCK);
+ error = -xfs_change_file_space(ip, cmd, &bf, 0, XFS_ATTR_NOLOCK);
if (error)
goto out_unlock;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/6] Ocfs2: handle hole punching via fallocate properly
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
This patch just makes ocfs2 use its UNRESERVP ioctl when we get the hole punch
flag in fallocate. I didn't test it, but it seems simple enough. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ocfs2/file.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 77b4c04..ad23a18 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1992,6 +1992,7 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct ocfs2_space_resv sr;
int change_size = 1;
+ int cmd = OCFS2_IOC_RESVSP64;
if (!ocfs2_writes_unwritten_extents(osb))
return -EOPNOTSUPP;
@@ -2002,12 +2003,15 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
if (mode & FALLOC_FL_KEEP_SIZE)
change_size = 0;
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = OCFS2_IOC_UNRESVSP64;
+
sr.l_whence = 0;
sr.l_start = (s64)offset;
sr.l_len = (s64)len;
- return __ocfs2_change_file_space(NULL, inode, offset,
- OCFS2_IOC_RESVSP64, &sr, change_size);
+ return __ocfs2_change_file_space(NULL, inode, offset, cmd, &sr,
+ change_size);
}
int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos,
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/6] Ocfs2: handle hole punching via fallocate properly
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This patch just makes ocfs2 use its UNRESERVP ioctl when we get the hole punch
flag in fallocate. I didn't test it, but it seems simple enough. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ocfs2/file.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 77b4c04..ad23a18 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1992,6 +1992,7 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct ocfs2_space_resv sr;
int change_size = 1;
+ int cmd = OCFS2_IOC_RESVSP64;
if (!ocfs2_writes_unwritten_extents(osb))
return -EOPNOTSUPP;
@@ -2002,12 +2003,15 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
if (mode & FALLOC_FL_KEEP_SIZE)
change_size = 0;
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = OCFS2_IOC_UNRESVSP64;
+
sr.l_whence = 0;
sr.l_start = (s64)offset;
sr.l_len = (s64)len;
- return __ocfs2_change_file_space(NULL, inode, offset,
- OCFS2_IOC_RESVSP64, &sr, change_size);
+ return __ocfs2_change_file_space(NULL, inode, offset, cmd, &sr,
+ change_size);
}
int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos,
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/6] Ocfs2: handle hole punching via fallocate properly
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
This patch just makes ocfs2 use its UNRESERVP ioctl when we get the hole punch
flag in fallocate. I didn't test it, but it seems simple enough. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ocfs2/file.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 77b4c04..ad23a18 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1992,6 +1992,7 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct ocfs2_space_resv sr;
int change_size = 1;
+ int cmd = OCFS2_IOC_RESVSP64;
if (!ocfs2_writes_unwritten_extents(osb))
return -EOPNOTSUPP;
@@ -2002,12 +2003,15 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
if (mode & FALLOC_FL_KEEP_SIZE)
change_size = 0;
+ if (mode & FALLOC_FL_PUNCH_HOLE)
+ cmd = OCFS2_IOC_UNRESVSP64;
+
sr.l_whence = 0;
sr.l_start = (s64)offset;
sr.l_len = (s64)len;
- return __ocfs2_change_file_space(NULL, inode, offset,
- OCFS2_IOC_RESVSP64, &sr, change_size);
+ return __ocfs2_change_file_space(NULL, inode, offset, cmd, &sr,
+ change_size);
}
int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos,
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/6] Ext4: fail if we try to use hole punch
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
Ext4 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ext4/extents.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0554c48..35bca73 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3622,6 +3622,10 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
struct ext4_map_blocks map;
unsigned int credits, blkbits = inode->i_blkbits;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* currently supporting (pre)allocate mode for extent-based
* files _only_
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/6] Ext4: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Ext4 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ext4/extents.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0554c48..35bca73 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3622,6 +3622,10 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
struct ext4_map_blocks map;
unsigned int credits, blkbits = inode->i_blkbits;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* currently supporting (pre)allocate mode for extent-based
* files _only_
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/6] Ext4: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Ext4 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/ext4/extents.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0554c48..35bca73 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3622,6 +3622,10 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
struct ext4_map_blocks map;
unsigned int credits, blkbits = inode->i_blkbits;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* currently supporting (pre)allocate mode for extent-based
* files _only_
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/6] Btrfs: fail if we try to use hole punch
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
Btrfs doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/btrfs/inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 78877d7..6f08892 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6936,6 +6936,10 @@ static long btrfs_fallocate(struct inode *inode, int mode,
alloc_start = offset & ~mask;
alloc_end = (offset + len + mask) & ~mask;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* wait for ordered IO before we have any locks. We'll loop again
* below with the locks held.
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/6] Btrfs: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Btrfs doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/btrfs/inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 78877d7..6f08892 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6936,6 +6936,10 @@ static long btrfs_fallocate(struct inode *inode, int mode,
alloc_start = offset & ~mask;
alloc_end = (offset + len + mask) & ~mask;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* wait for ordered IO before we have any locks. We'll loop again
* below with the locks held.
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/6] Btrfs: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Btrfs doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/btrfs/inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 78877d7..6f08892 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6936,6 +6936,10 @@ static long btrfs_fallocate(struct inode *inode, int mode,
alloc_start = offset & ~mask;
alloc_end = (offset + len + mask) & ~mask;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
/*
* wait for ordered IO before we have any locks. We'll loop again
* below with the locks held.
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/6] Gfs2: fail if we try to use hole punch
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 1:46 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-dev
Gfs2 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/gfs2/ops_inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 12cbea7..65cb5f6 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -1439,6 +1439,10 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset,
loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
sdp->sd_sb.sb_bsize_shift;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/6] Gfs2: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Gfs2 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/gfs2/ops_inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 12cbea7..65cb5f6 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -1439,6 +1439,10 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset,
loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
sdp->sd_sb.sb_bsize_shift;
--
1.6.6.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/6] Gfs2: fail if we try to use hole punch
@ 2010-11-18 1:46 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2010-11-18 1:46 UTC (permalink / raw)
To: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
Gfs2 doesn't have the ability to punch holes yet, so make sure we return
EOPNOTSUPP if we try to use hole punching through fallocate. This support can
be added later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
---
fs/gfs2/ops_inode.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 12cbea7..65cb5f6 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -1439,6 +1439,10 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset,
loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
+ /* We only support the FALLOC_FL_KEEP_SIZE mode */
+ if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+ return -EOPNOTSUPP;
+
offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
sdp->sd_sb.sb_bsize_shift;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [Cluster-devel] [PATCH 1/6] fs: add hole punching to fallocate
2010-11-18 1:46 ` Josef Bacik
(?)
@ 2010-11-18 23:43 ` Jan Kara
-1 siblings, 0 replies; 30+ messages in thread
From: Jan Kara @ 2010-11-18 23:43 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Wed 17-11-10 20:46:15, Josef Bacik wrote:
> Hole punching has already been implemented by XFS and OCFS2, and has the
> potential to be implemented on both BTRFS and EXT4 so we need a generic way to
> get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
> to fallocate() since it already looks like the normal fallocate() operation.
> I've tested this patch with XFS and BTRFS to make sure XFS did what it's
> supposed to do and that BTRFS failed like it was supposed to. Thank you,
Looks nice now. Acked-by: Jan Kara <jack@suse.cz>
Honza
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
> fs/open.c | 7 ++++++-
> include/linux/falloc.h | 1 +
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index 4197b9e..5b6ef7e 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> return -EINVAL;
>
> /* Return error if mode is not supported */
> - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> + if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
> + return -EOPNOTSUPP;
> +
> + /* Punch hole must have keep size set */
> + if ((mode & FALLOC_FL_PUNCH_HOLE) &&
> + !(mode & FALLOC_FL_KEEP_SIZE))
> return -EOPNOTSUPP;
>
> if (!(file->f_mode & FMODE_WRITE))
> diff --git a/include/linux/falloc.h b/include/linux/falloc.h
> index 3c15510..73e0b62 100644
> --- a/include/linux/falloc.h
> +++ b/include/linux/falloc.h
> @@ -2,6 +2,7 @@
> #define _FALLOC_H_
>
> #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
> +#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
>
> #ifdef __KERNEL__
>
> --
> 1.6.6.1
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/6] fs: add hole punching to fallocate
@ 2010-11-18 23:43 ` Jan Kara
0 siblings, 0 replies; 30+ messages in thread
From: Jan Kara @ 2010-11-18 23:43 UTC (permalink / raw)
To: Josef Bacik
Cc: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack
On Wed 17-11-10 20:46:15, Josef Bacik wrote:
> Hole punching has already been implemented by XFS and OCFS2, and has the
> potential to be implemented on both BTRFS and EXT4 so we need a generic way to
> get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
> to fallocate() since it already looks like the normal fallocate() operation.
> I've tested this patch with XFS and BTRFS to make sure XFS did what it's
> supposed to do and that BTRFS failed like it was supposed to. Thank you,
Looks nice now. Acked-by: Jan Kara <jack@suse.cz>
Honza
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
> fs/open.c | 7 ++++++-
> include/linux/falloc.h | 1 +
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index 4197b9e..5b6ef7e 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> return -EINVAL;
>
> /* Return error if mode is not supported */
> - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> + if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
> + return -EOPNOTSUPP;
> +
> + /* Punch hole must have keep size set */
> + if ((mode & FALLOC_FL_PUNCH_HOLE) &&
> + !(mode & FALLOC_FL_KEEP_SIZE))
> return -EOPNOTSUPP;
>
> if (!(file->f_mode & FMODE_WRITE))
> diff --git a/include/linux/falloc.h b/include/linux/falloc.h
> index 3c15510..73e0b62 100644
> --- a/include/linux/falloc.h
> +++ b/include/linux/falloc.h
> @@ -2,6 +2,7 @@
> #define _FALLOC_H_
>
> #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
> +#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
>
> #ifdef __KERNEL__
>
> --
> 1.6.6.1
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/6] fs: add hole punching to fallocate
@ 2010-11-18 23:43 ` Jan Kara
0 siblings, 0 replies; 30+ messages in thread
From: Jan Kara @ 2010-11-18 23:43 UTC (permalink / raw)
To: Josef Bacik
Cc: jack, linux-kernel, xfs, cluster-devel, cmm, joel.becker,
linux-fsdevel, linux-ext4, linux-btrfs
On Wed 17-11-10 20:46:15, Josef Bacik wrote:
> Hole punching has already been implemented by XFS and OCFS2, and has the
> potential to be implemented on both BTRFS and EXT4 so we need a generic way to
> get to this feature. The simplest way in my mind is to add FALLOC_FL_PUNCH_HOLE
> to fallocate() since it already looks like the normal fallocate() operation.
> I've tested this patch with XFS and BTRFS to make sure XFS did what it's
> supposed to do and that BTRFS failed like it was supposed to. Thank you,
Looks nice now. Acked-by: Jan Kara <jack@suse.cz>
Honza
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
> fs/open.c | 7 ++++++-
> include/linux/falloc.h | 1 +
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index 4197b9e..5b6ef7e 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> return -EINVAL;
>
> /* Return error if mode is not supported */
> - if (mode && !(mode & FALLOC_FL_KEEP_SIZE))
> + if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
> + return -EOPNOTSUPP;
> +
> + /* Punch hole must have keep size set */
> + if ((mode & FALLOC_FL_PUNCH_HOLE) &&
> + !(mode & FALLOC_FL_KEEP_SIZE))
> return -EOPNOTSUPP;
>
> if (!(file->f_mode & FMODE_WRITE))
> diff --git a/include/linux/falloc.h b/include/linux/falloc.h
> index 3c15510..73e0b62 100644
> --- a/include/linux/falloc.h
> +++ b/include/linux/falloc.h
> @@ -2,6 +2,7 @@
> #define _FALLOC_H_
>
> #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
> +#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
>
> #ifdef __KERNEL__
>
> --
> 1.6.6.1
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Hole Punching V3
2010-11-18 1:46 ` Josef Bacik
@ 2011-01-03 21:57 ` Josef Bacik
-1 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2011-01-03 21:57 UTC (permalink / raw)
To: Josef Bacik
Cc: david, linux-kernel, linux-btrfs, linux-ext4, linux-fsdevel, xfs,
cmm, cluster-devel, joel.becker, jack, akpm, torvalds
On Wed, Nov 17, 2010 at 08:46:14PM -0500, Josef Bacik wrote:
> This is version 3 of the hole punching series I've been posting. Not much has
> changed, the history is below
>
> V2->V3
> -FALLOC_FL_PUNCH_HOLE must also have FALLOC_FL_KEEP_SIZE in order to work
> -formatting fixes
>
> V1->V2
> -Hole punching doesn't change file size
> -Fixed the mode checks in ext4/btrfs/gfs2 so they do what they are supposed to
>
> I've updated my local copies of the xfsprogs patches I have to test this to use
> KEEP_SIZE and PUNCH_HOLE together, I'll post them after it looks like these
> patches are good to go, including the manpage update. The xfstest I wrote ran
> fine both on xfs and btrfs (failing on btrfs obviously). Thanks,
>
I'd like to try and get this into the next merge window, it seems everybody is
happy with it so far, any other comments? Provided everybody is ok with it, how
would you like me to send it to you Linus? Would you prefer a pull request or
will you just pull the patches off the mailinglist? Thanks,
Josef
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Hole Punching V3
@ 2011-01-03 21:57 ` Josef Bacik
0 siblings, 0 replies; 30+ messages in thread
From: Josef Bacik @ 2011-01-03 21:57 UTC (permalink / raw)
To: Josef Bacik
Cc: jack, linux-kernel, xfs, cluster-devel, cmm, joel.becker,
linux-fsdevel, akpm, linux-ext4, torvalds, linux-btrfs
On Wed, Nov 17, 2010 at 08:46:14PM -0500, Josef Bacik wrote:
> This is version 3 of the hole punching series I've been posting. Not much has
> changed, the history is below
>
> V2->V3
> -FALLOC_FL_PUNCH_HOLE must also have FALLOC_FL_KEEP_SIZE in order to work
> -formatting fixes
>
> V1->V2
> -Hole punching doesn't change file size
> -Fixed the mode checks in ext4/btrfs/gfs2 so they do what they are supposed to
>
> I've updated my local copies of the xfsprogs patches I have to test this to use
> KEEP_SIZE and PUNCH_HOLE together, I'll post them after it looks like these
> patches are good to go, including the manpage update. The xfstest I wrote ran
> fine both on xfs and btrfs (failing on btrfs obviously). Thanks,
>
I'd like to try and get this into the next merge window, it seems everybody is
happy with it so far, any other comments? Provided everybody is ok with it, how
would you like me to send it to you Linus? Would you prefer a pull request or
will you just pull the patches off the mailinglist? Thanks,
Josef
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2011-01-03 21:57 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 1:46 Hole Punching V3 Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` [PATCH 1/6] fs: add hole punching to fallocate Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 23:43 ` [Cluster-devel] " Jan Kara
2010-11-18 23:43 ` Jan Kara
2010-11-18 23:43 ` Jan Kara
2010-11-18 1:46 ` [PATCH 2/6] XFS: handle hole punching via fallocate properly Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` [PATCH 3/6] Ocfs2: " Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` [PATCH 4/6] Ext4: fail if we try to use hole punch Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` [PATCH 5/6] Btrfs: " Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` [PATCH 6/6] Gfs2: " Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2010-11-18 1:46 ` Josef Bacik
2011-01-03 21:57 ` Hole Punching V3 Josef Bacik
2011-01-03 21:57 ` Josef Bacik
-- strict thread matches above, loose matches on Subject: below --
2010-11-15 17:05 Hole Punching V2 Josef Bacik
2010-11-15 17:05 ` [PATCH 1/6] fs: add hole punching to fallocate Josef Bacik
2010-11-16 11:16 ` [Cluster-devel] " Jan Kara
2010-11-16 11:43 ` Jan Kara
2010-11-16 12:52 ` Josef Bacik
2010-11-16 13:14 ` [Cluster-devel] " Jan Kara
2010-11-08 20:32 Josef Bacik
2010-11-09 1:12 ` Dave Chinner
2010-11-09 3:30 ` Ted Ts'o
2010-11-09 4:42 ` Dave Chinner
2010-11-09 21:41 ` Ted Ts'o
2010-11-09 21:53 ` [Cluster-devel] " Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.