All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] gfs2: Fix fallocate chunk size
@ 2018-02-19 22:51 Andreas Gruenbacher
  2018-02-20 15:36 ` Bob Peterson
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Gruenbacher @ 2018-02-19 22:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The chunk size of allocations in __gfs2_fallocate is calculated
incorrectly.  The size can collapse, causing __gfs2_fallocate to
allocate one block at a time, which is very inefficient.  This needs
fixing in two places:

In gfs2_quota_lock_check, always set ap->allowed to UINT_MAX to indicate
that there is no quota limit.  This fixes callers that rely on
ap->allowed to be set even when quotas are off.

In __gfs2_fallocate, reset max_blks to UINT_MAX in each iteration of the
loop to make sure that allocation limits from one resource group won't
spill over into another resource group.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/file.c  | 5 +++--
 fs/gfs2/quota.h | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 4f88e20..2edd3a9 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -809,7 +809,7 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
 	struct gfs2_inode *ip = GFS2_I(inode);
 	struct gfs2_alloc_parms ap = { .aflags = 0, };
 	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
-	loff_t bytes, max_bytes, max_blks = UINT_MAX;
+	loff_t bytes, max_bytes, max_blks;
 	int error;
 	const loff_t pos = offset;
 	const loff_t count = len;
@@ -861,7 +861,8 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
 			return error;
 		/* ap.allowed tells us how many blocks quota will allow
 		 * us to write. Check if this reduces max_blks */
-		if (ap.allowed && ap.allowed < max_blks)
+		max_blks = UINT_MAX;
+		if (ap.allowed)
 			max_blks = ap.allowed;
 
 		error = gfs2_inplace_reserve(ip, &ap);
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
index 5e47c93..836f294 100644
--- a/fs/gfs2/quota.h
+++ b/fs/gfs2/quota.h
@@ -45,6 +45,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
 {
 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
 	int ret;
+
+	ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
 	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
 		return 0;
 	ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] gfs2: Fix fallocate chunk size
  2018-02-19 22:51 [Cluster-devel] [PATCH] gfs2: Fix fallocate chunk size Andreas Gruenbacher
@ 2018-02-20 15:36 ` Bob Peterson
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Peterson @ 2018-02-20 15:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
| The chunk size of allocations in __gfs2_fallocate is calculated
| incorrectly.  The size can collapse, causing __gfs2_fallocate to
| allocate one block at a time, which is very inefficient.  This needs
| fixing in two places:
| 
| In gfs2_quota_lock_check, always set ap->allowed to UINT_MAX to indicate
| that there is no quota limit.  This fixes callers that rely on
| ap->allowed to be set even when quotas are off.
| 
| In __gfs2_fallocate, reset max_blks to UINT_MAX in each iteration of the
| loop to make sure that allocation limits from one resource group won't
| spill over into another resource group.
| 
| Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

Hi,

Thanks. This is now pushed to the for-next branch of the linux-gfs2 tree:

https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=3fc7c7e1cfaac17cb7b0bfd54e5abf9b1ef2b819

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-20 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 22:51 [Cluster-devel] [PATCH] gfs2: Fix fallocate chunk size Andreas Gruenbacher
2018-02-20 15:36 ` Bob Peterson

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.