From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 12/12] GFS2: call gfs2_write_alloc_required for each chunk
Date: Mon, 19 Mar 2012 10:25:28 +0000 [thread overview]
Message-ID: <1332152728-4027-13-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1332152728-4027-1-git-send-email-swhiteho@redhat.com>
From: Benjamin Marzinski <bmarzins@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>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 310f2fb..7683458 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -676,6 +676,7 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
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 *inode, loff_t offset, loff_t len,
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 *file, int mode, loff_t offset,
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;
--
1.7.4
next prev parent reply other threads:[~2012-03-19 10:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 10:25 [Cluster-devel] GFS2: Pre-pull patch posting (merge window) Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 01/12] GFS2: glock statistics gathering Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 02/12] GFS2: Move two functions from log.c to lops.c Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 03/12] GFS2: FITRIM ioctl support Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 04/12] GFS2: Sort the ordered write list Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 05/12] GFS2: Make bd_cmp() static Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 06/12] GFS2: Unlock rindex mutex on glock error Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 07/12] GFS2: Eliminate sd_rindex_mutex Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 08/12] GFS2: make sure rgrps are up to date in func gfs2_blk2rgrpd Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 09/12] GFS2: Flush pending glock work when evicting an inode Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 10/12] GFS2: Remove a __GFP_NOFAIL allocation Steven Whitehouse
2012-03-19 10:25 ` [Cluster-devel] [PATCH 11/12] GFS2: Clean up log flush header writing Steven Whitehouse
2012-03-19 10:25 ` Steven Whitehouse [this message]
[not found] ` <4F674696.7030602@xenotime.net>
2012-03-19 14:59 ` [Cluster-devel] GFS2: Pre-pull patch posting (merge window) Steven Whitehouse
[not found] ` <4F674E4F.5080904@xenotime.net>
2012-03-19 15:34 ` Steven Whitehouse
2012-03-23 19:41 ` David Teigland
2012-03-23 19:46 ` David Miller
[not found] ` <4F6CD7AD.9030306@xenotime.net>
2012-03-23 20:09 ` Steven Whitehouse
2012-03-23 20:18 ` David Teigland
[not found] ` <20120323220618.GA30906@d2.synalogic.ca>
2012-03-26 10:44 ` Steven Whitehouse
[not found] ` <4F79C733.60604@xenotime.net>
2012-04-02 15:47 ` Steven Whitehouse
2012-03-20 9:47 ` Steven Whitehouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332152728-4027-13-git-send-email-swhiteho@redhat.com \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).