* [Cluster-devel] [PATCH] GFS2: call gfs2_write_alloc_required for each chunk
@ 2012-03-08 19:16 Benjamin Marzinski
2012-03-09 16:03 ` Steven Whitehouse
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Marzinski @ 2012-03-08 19:16 UTC (permalink / raw)
To: cluster-devel.redhat.com
gfs2_fallocate was calling gfs2_write_alloc_required() once at the start of
the function. This caused problems since gfs2_write_alloc_required used a
long unsigned int for the len, but gfs2_fallocate could allocate a much
larger amount. This patch will move the call into the loop where the
chunks are actually allocated and zeroed out. This will keep the allocation
size under the limit, and also allow gfs2_fallocate to quickly skip over
sections of the file that are already completely allocated.
fallcate_chunk was also not correctly setting the file size. It was using the
len veriable to find the last block written to, but by the time it was setting
the size, the len variable had already been decremented to 0.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
fs/gfs2/file.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
Index: gfs2-3.0-nmw/fs/gfs2/file.c
===================================================================
--- gfs2-3.0-nmw.orig/fs/gfs2/file.c
+++ gfs2-3.0-nmw/fs/gfs2/file.c
@@ -676,6 +676,7 @@ static int fallocate_chunk(struct inode
struct gfs2_inode *ip = GFS2_I(inode);
struct buffer_head *dibh;
int error;
+ loff_t size = len;
unsigned int nr_blks;
sector_t lblock = offset >> inode->i_blkbits;
@@ -709,8 +710,8 @@ static int fallocate_chunk(struct inode
goto out;
}
}
- if (offset + len > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE))
- i_size_write(inode, offset + len);
+ if (offset + size > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE))
+ i_size_write(inode, offset + size);
mark_inode_dirty(inode);
@@ -779,12 +780,14 @@ static long gfs2_fallocate(struct file *
if (unlikely(error))
goto out_uninit;
- if (!gfs2_write_alloc_required(ip, offset, len))
- goto out_unlock;
-
while (len > 0) {
if (len < bytes)
bytes = len;
+ if (!gfs2_write_alloc_required(ip, offset, bytes)) {
+ len -= bytes;
+ offset += bytes;
+ continue;
+ }
qa = gfs2_qadata_get(ip);
if (!qa) {
error = -ENOMEM;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cluster-devel] [PATCH] GFS2: call gfs2_write_alloc_required for each chunk
2012-03-08 19:16 [Cluster-devel] [PATCH] GFS2: call gfs2_write_alloc_required for each chunk Benjamin Marzinski
@ 2012-03-09 16:03 ` Steven Whitehouse
0 siblings, 0 replies; 2+ messages in thread
From: Steven Whitehouse @ 2012-03-09 16:03 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
Now in the -nmw tree. Thanks,
Steve.
On Thu, 2012-03-08 at 13:16 -0600, Benjamin Marzinski wrote:
> gfs2_fallocate was calling gfs2_write_alloc_required() once at the start of
> the function. This caused problems since gfs2_write_alloc_required used a
> long unsigned int for the len, but gfs2_fallocate could allocate a much
> larger amount. This patch will move the call into the loop where the
> chunks are actually allocated and zeroed out. This will keep the allocation
> size under the limit, and also allow gfs2_fallocate to quickly skip over
> sections of the file that are already completely allocated.
>
> fallcate_chunk was also not correctly setting the file size. It was using the
> len veriable to find the last block written to, but by the time it was setting
> the size, the len variable had already been decremented to 0.
>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
> fs/gfs2/file.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> Index: gfs2-3.0-nmw/fs/gfs2/file.c
> ===================================================================
> --- gfs2-3.0-nmw.orig/fs/gfs2/file.c
> +++ gfs2-3.0-nmw/fs/gfs2/file.c
> @@ -676,6 +676,7 @@ static int fallocate_chunk(struct inode
> struct gfs2_inode *ip = GFS2_I(inode);
> struct buffer_head *dibh;
> int error;
> + loff_t size = len;
> unsigned int nr_blks;
> sector_t lblock = offset >> inode->i_blkbits;
>
> @@ -709,8 +710,8 @@ static int fallocate_chunk(struct inode
> goto out;
> }
> }
> - if (offset + len > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE))
> - i_size_write(inode, offset + len);
> + if (offset + size > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE))
> + i_size_write(inode, offset + size);
>
> mark_inode_dirty(inode);
>
> @@ -779,12 +780,14 @@ static long gfs2_fallocate(struct file *
> if (unlikely(error))
> goto out_uninit;
>
> - if (!gfs2_write_alloc_required(ip, offset, len))
> - goto out_unlock;
> -
> while (len > 0) {
> if (len < bytes)
> bytes = len;
> + if (!gfs2_write_alloc_required(ip, offset, bytes)) {
> + len -= bytes;
> + offset += bytes;
> + continue;
> + }
> qa = gfs2_qadata_get(ip);
> if (!qa) {
> error = -ENOMEM;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-09 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08 19:16 [Cluster-devel] [PATCH] GFS2: call gfs2_write_alloc_required for each chunk Benjamin Marzinski
2012-03-09 16:03 ` Steven Whitehouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).