* [Ocfs2-devel] [-mm PATCH] ocfs2: ->fallocate() support
@ 2007-06-21 19:01 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-06-21 12:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-fsdevel, Amit Arora, ocfs2-devel
Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
now - FA_DEALLOCATE will come later.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
---
fs/ocfs2/file.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 53 insertions(+), 14 deletions(-)
f1281cd91f406365d417efbb7418f7b644300d5c
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index c3e01e0..35b5a3f 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1264,26 +1264,19 @@ out:
/*
* Parts of this function taken from xfs_change_file_space()
*/
-int ocfs2_change_file_space(struct file *file, unsigned int cmd,
- struct ocfs2_space_resv *sr)
+static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
+ loff_t f_pos, unsigned int cmd,
+ struct ocfs2_space_resv *sr,
+ int allow_past_eof)
{
int ret;
s64 llen;
- struct inode *inode = file->f_path.dentry->d_inode;
+ loff_t size;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct buffer_head *di_bh = NULL;
handle_t *handle;
unsigned long long max_off = ocfs2_max_file_offset(inode->i_sb->s_blocksize_bits);
- if (!ocfs2_writes_unwritten_extents(osb))
- return -ENOTTY;
-
- if (!S_ISREG(inode->i_mode))
- return -EINVAL;
-
- if (!(file->f_mode & FMODE_WRITE))
- return -EBADF;
-
if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
return -EROFS;
@@ -1313,7 +1306,7 @@ int ocfs2_change_file_space(struct file
case 0: /*SEEK_SET*/
break;
case 1: /*SEEK_CUR*/
- sr->l_start += file->f_pos;
+ sr->l_start += f_pos;
break;
case 2: /*SEEK_END*/
sr->l_start += i_size_read(inode);
@@ -1334,6 +1327,8 @@ int ocfs2_change_file_space(struct file
goto out_meta_unlock;
}
+ size = sr->l_start + sr->l_len;
+
if (cmd == OCFS2_IOC_RESVSP || cmd == OCFS2_IOC_RESVSP64) {
if (sr->l_len <= 0) {
ret = -EINVAL;
@@ -1341,7 +1336,7 @@ int ocfs2_change_file_space(struct file
}
}
- if (should_remove_suid(file->f_path.dentry)) {
+ if (file && should_remove_suid(file->f_path.dentry)) {
ret = __ocfs2_write_remove_suid(inode, di_bh);
if (ret) {
mlog_errno(ret);
@@ -1371,6 +1366,9 @@ int ocfs2_change_file_space(struct file
goto out_meta_unlock;
}
+ if (!allow_past_eof && i_size_read(inode) < size)
+ i_size_write(inode, size);
+
inode->i_ctime = inode->i_mtime = CURRENT_TIME;
ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
if (ret < 0)
@@ -1389,6 +1387,46 @@ out:
return ret;
}
+int ocfs2_change_file_space(struct file *file, unsigned int cmd,
+ struct ocfs2_space_resv *sr)
+{
+ struct inode *inode = file->f_path.dentry->d_inode;
+
+ if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb)))
+ return -ENOTTY;
+
+ if (!S_ISREG(inode->i_mode))
+ return -EINVAL;
+
+ if (!(file->f_mode & FMODE_WRITE))
+ return -EBADF;
+
+ return __ocfs2_change_file_space(file, inode, file->f_pos, cmd, sr, 1);
+}
+
+static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
+ loff_t len)
+{
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+ struct ocfs2_space_resv sr;
+
+ /*
+ * Currently only allocation is supported and on regular files
+ */
+ if (mode != FA_ALLOCATE || !ocfs2_writes_unwritten_extents(osb))
+ return -EOPNOTSUPP;
+
+ if (S_ISDIR(inode->i_mode))
+ return -ENODEV;
+
+ 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, 0);
+}
+
static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
loff_t *ppos,
size_t count,
@@ -1817,6 +1855,7 @@ const struct inode_operations ocfs2_file
.setattr = ocfs2_setattr,
.getattr = ocfs2_getattr,
.permission = ocfs2_permission,
+ .fallocate = ocfs2_fallocate,
};
const struct inode_operations ocfs2_special_file_iops = {
--
1.3.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [-mm PATCH] ocfs2: ->fallocate() support
@ 2007-06-21 19:01 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-06-21 19:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-fsdevel, Amit Arora, ocfs2-devel
Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
now - FA_DEALLOCATE will come later.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
---
fs/ocfs2/file.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 53 insertions(+), 14 deletions(-)
f1281cd91f406365d417efbb7418f7b644300d5c
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index c3e01e0..35b5a3f 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1264,26 +1264,19 @@ out:
/*
* Parts of this function taken from xfs_change_file_space()
*/
-int ocfs2_change_file_space(struct file *file, unsigned int cmd,
- struct ocfs2_space_resv *sr)
+static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
+ loff_t f_pos, unsigned int cmd,
+ struct ocfs2_space_resv *sr,
+ int allow_past_eof)
{
int ret;
s64 llen;
- struct inode *inode = file->f_path.dentry->d_inode;
+ loff_t size;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct buffer_head *di_bh = NULL;
handle_t *handle;
unsigned long long max_off = ocfs2_max_file_offset(inode->i_sb->s_blocksize_bits);
- if (!ocfs2_writes_unwritten_extents(osb))
- return -ENOTTY;
-
- if (!S_ISREG(inode->i_mode))
- return -EINVAL;
-
- if (!(file->f_mode & FMODE_WRITE))
- return -EBADF;
-
if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
return -EROFS;
@@ -1313,7 +1306,7 @@ int ocfs2_change_file_space(struct file
case 0: /*SEEK_SET*/
break;
case 1: /*SEEK_CUR*/
- sr->l_start += file->f_pos;
+ sr->l_start += f_pos;
break;
case 2: /*SEEK_END*/
sr->l_start += i_size_read(inode);
@@ -1334,6 +1327,8 @@ int ocfs2_change_file_space(struct file
goto out_meta_unlock;
}
+ size = sr->l_start + sr->l_len;
+
if (cmd == OCFS2_IOC_RESVSP || cmd == OCFS2_IOC_RESVSP64) {
if (sr->l_len <= 0) {
ret = -EINVAL;
@@ -1341,7 +1336,7 @@ int ocfs2_change_file_space(struct file
}
}
- if (should_remove_suid(file->f_path.dentry)) {
+ if (file && should_remove_suid(file->f_path.dentry)) {
ret = __ocfs2_write_remove_suid(inode, di_bh);
if (ret) {
mlog_errno(ret);
@@ -1371,6 +1366,9 @@ int ocfs2_change_file_space(struct file
goto out_meta_unlock;
}
+ if (!allow_past_eof && i_size_read(inode) < size)
+ i_size_write(inode, size);
+
inode->i_ctime = inode->i_mtime = CURRENT_TIME;
ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
if (ret < 0)
@@ -1389,6 +1387,46 @@ out:
return ret;
}
+int ocfs2_change_file_space(struct file *file, unsigned int cmd,
+ struct ocfs2_space_resv *sr)
+{
+ struct inode *inode = file->f_path.dentry->d_inode;
+
+ if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb)))
+ return -ENOTTY;
+
+ if (!S_ISREG(inode->i_mode))
+ return -EINVAL;
+
+ if (!(file->f_mode & FMODE_WRITE))
+ return -EBADF;
+
+ return __ocfs2_change_file_space(file, inode, file->f_pos, cmd, sr, 1);
+}
+
+static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
+ loff_t len)
+{
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+ struct ocfs2_space_resv sr;
+
+ /*
+ * Currently only allocation is supported and on regular files
+ */
+ if (mode != FA_ALLOCATE || !ocfs2_writes_unwritten_extents(osb))
+ return -EOPNOTSUPP;
+
+ if (S_ISDIR(inode->i_mode))
+ return -ENODEV;
+
+ 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, 0);
+}
+
static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
loff_t *ppos,
size_t count,
@@ -1817,6 +1855,7 @@ const struct inode_operations ocfs2_file
.setattr = ocfs2_setattr,
.getattr = ocfs2_getattr,
.permission = ocfs2_permission,
+ .fallocate = ocfs2_fallocate,
};
const struct inode_operations ocfs2_special_file_iops = {
--
1.3.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Ocfs2-devel] Re: [-mm PATCH] ocfs2: ->fallocate() support
2007-06-23 16:54 ` Andrew Morton
@ 2007-06-23 17:24 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-06-23 10:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: aarora, linux-fsdevel, ocfs2-devel
On Sat, Jun 23, 2007 at 09:54:15AM -0700, Andrew Morton wrote:
> > On Thu, 21 Jun 2007 12:01:43 -0700 Mark Fasheh <mark.fasheh@oracle.com> wrote:
> > Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
> > now - FA_DEALLOCATE will come later.
>
> I get a healthy reject when applying this against your own tree. Perhaps
> because my copy of it is a few days old, dunno.
Eek, yeah I based it on a pretty recent version of my stuff.
> I think I'll duck it, allow you to merge this in the normal fashion once
> fallocate hits mainline, OK?
Sounds good to me. Could I trouble you to add me to the CC for one of the
patches that add ->fallocate() so I know when it gets sent upstream?
Thanks,
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [-mm PATCH] ocfs2: ->fallocate() support
2007-06-21 19:01 ` Mark Fasheh
(?)
@ 2007-06-23 16:54 ` Andrew Morton
2007-06-23 17:24 ` Mark Fasheh
-1 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2007-06-23 16:54 UTC (permalink / raw)
To: Mark Fasheh; +Cc: aarora, linux-fsdevel, ocfs2-devel
> On Thu, 21 Jun 2007 12:01:43 -0700 Mark Fasheh <mark.fasheh@oracle.com> wrote:
> Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
> now - FA_DEALLOCATE will come later.
I get a healthy reject when applying this against your own tree. Perhaps
because my copy of it is a few days old, dunno.
I think I'll duck it, allow you to merge this in the normal fashion once
fallocate hits mainline, OK?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [-mm PATCH] ocfs2: ->fallocate() support
@ 2007-06-23 17:24 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-06-23 17:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: aarora, linux-fsdevel, ocfs2-devel
On Sat, Jun 23, 2007 at 09:54:15AM -0700, Andrew Morton wrote:
> > On Thu, 21 Jun 2007 12:01:43 -0700 Mark Fasheh <mark.fasheh@oracle.com> wrote:
> > Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
> > now - FA_DEALLOCATE will come later.
>
> I get a healthy reject when applying this against your own tree. Perhaps
> because my copy of it is a few days old, dunno.
Eek, yeah I based it on a pretty recent version of my stuff.
> I think I'll duck it, allow you to merge this in the normal fashion once
> fallocate hits mainline, OK?
Sounds good to me. Could I trouble you to add me to the CC for one of the
patches that add ->fallocate() so I know when it gets sent upstream?
Thanks,
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [-mm PATCH] ocfs2: ->fallocate() support
2007-06-21 19:01 ` Mark Fasheh
(?)
(?)
@ 2007-06-30 9:34 ` Christoph Hellwig
2007-07-02 23:18 ` Mark Fasheh
-1 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2007-06-30 9:34 UTC (permalink / raw)
To: Mark Fasheh; +Cc: Andrew Morton, Amit Arora, linux-fsdevel, ocfs2-devel, xfs
On Thu, Jun 21, 2007 at 12:01:43PM -0700, Mark Fasheh wrote:
> Plug ocfs2 into the ->fallocate() callback. We only support FA_ALLOCATE for
> now - FA_DEALLOCATE will come later.
Btw, it seems like ocfs implements the xfs preallocation ioctls. What
would people thing about moving those up to work over ->fallocate so they
can be used on all filesystems that support preallocation? While the
ABI is quite ugly it has a huge userbase because it's the only existing
preallocation mechanism on Linux.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Ocfs2-devel] Re: [-mm PATCH] ocfs2: ->fallocate() support
2007-06-30 9:34 ` Christoph Hellwig
2007-07-02 23:18 ` Mark Fasheh
@ 2007-07-02 23:18 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-07-02 16:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-fsdevel, Andrew Morton, Amit Arora, ocfs2-devel, xfs
On Sat, Jun 30, 2007 at 10:34:13AM +0100, Christoph Hellwig wrote:
> Btw, it seems like ocfs implements the xfs preallocation ioctls. What
> would people thing about moving those up to work over ->fallocate so they
> can be used on all filesystems that support preallocation?
That sounds like a good idea. We've already got a very good match on
RESVP/UNRESVP with the various ->fallocate flags.
I'm not sure whether we want to do this for ALLOCSP/FREESP - as far as I've
heard those are hardly used.
> While the ABI is quite ugly it has a huge userbase because it's the only
> existing preallocation mechanism on Linux.
Yeah, that was the primary reason I chose to implement the ioctl (along with
the ->fallocate patch)
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [-mm PATCH] ocfs2: ->fallocate() support
@ 2007-07-02 23:18 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-07-02 23:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-fsdevel, Andrew Morton, Amit Arora, ocfs2-devel, xfs
On Sat, Jun 30, 2007 at 10:34:13AM +0100, Christoph Hellwig wrote:
> Btw, it seems like ocfs implements the xfs preallocation ioctls. What
> would people thing about moving those up to work over ->fallocate so they
> can be used on all filesystems that support preallocation?
That sounds like a good idea. We've already got a very good match on
RESVP/UNRESVP with the various ->fallocate flags.
I'm not sure whether we want to do this for ALLOCSP/FREESP - as far as I've
heard those are hardly used.
> While the ABI is quite ugly it has a huge userbase because it's the only
> existing preallocation mechanism on Linux.
Yeah, that was the primary reason I chose to implement the ioctl (along with
the ->fallocate patch)
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [-mm PATCH] ocfs2: ->fallocate() support
@ 2007-07-02 23:18 ` Mark Fasheh
0 siblings, 0 replies; 9+ messages in thread
From: Mark Fasheh @ 2007-07-02 23:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Amit Arora, linux-fsdevel, ocfs2-devel, xfs
On Sat, Jun 30, 2007 at 10:34:13AM +0100, Christoph Hellwig wrote:
> Btw, it seems like ocfs implements the xfs preallocation ioctls. What
> would people thing about moving those up to work over ->fallocate so they
> can be used on all filesystems that support preallocation?
That sounds like a good idea. We've already got a very good match on
RESVP/UNRESVP with the various ->fallocate flags.
I'm not sure whether we want to do this for ALLOCSP/FREESP - as far as I've
heard those are hardly used.
> While the ABI is quite ugly it has a huge userbase because it's the only
> existing preallocation mechanism on Linux.
Yeah, that was the primary reason I chose to implement the ioctl (along with
the ->fallocate patch)
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-07-03 0:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-21 12:01 [Ocfs2-devel] [-mm PATCH] ocfs2: ->fallocate() support Mark Fasheh
2007-06-21 19:01 ` Mark Fasheh
2007-06-23 16:54 ` Andrew Morton
2007-06-23 10:24 ` [Ocfs2-devel] " Mark Fasheh
2007-06-23 17:24 ` Mark Fasheh
2007-06-30 9:34 ` Christoph Hellwig
2007-07-02 16:18 ` [Ocfs2-devel] " Mark Fasheh
2007-07-02 23:18 ` Mark Fasheh
2007-07-02 23:18 ` Mark Fasheh
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.