cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Abhi Das <adas@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 4/4] gfs2: allow fallocate to max out quotas/fs efficiently
Date: Thu, 12 Feb 2015 10:54:14 -0600	[thread overview]
Message-ID: <1423760054-63438-5-git-send-email-adas@redhat.com> (raw)
In-Reply-To: <1423760054-63438-1-git-send-email-adas@redhat.com>

With the addition of gfs2_quota_lck_chk_ret_allow() and
gfs2_inpl_rsrv_ret_max_avl(), we can quickly get an estimate of
how many more blocks are available for allocation restricted by
quota and fs size respectively.
By trying to allocate what's available instead of guessing, we
can max out quotas or the filesystem efficiently.

Bear in mind that this applies only when the requested fallocate
operation would otherwise error out with -EDQUOT or -ENOSPC without
utilizing all the blocks that might still be available.

Signed-off-by: Abhi Das <adas@redhat.com>
---
 fs/gfs2/file.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index c9482ae..9d8e03a 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -805,6 +805,7 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
 	loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
 	loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
 	loff_t max_chunk_size = UINT_MAX & bsize_mask;
+	u32 allow;
 
 	next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
 
@@ -828,20 +829,25 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
 			offset += bytes;
 			continue;
 		}
-		error = gfs2_quota_lock_check(ip, bytes >> sdp->sd_sb.sb_bsize_shift);
-		if (error)
+	quota_retry:
+		error = gfs2_quota_lck_chk_ret_allow(ip, 
+						     bytes >> sdp->sd_sb.sb_bsize_shift,
+						     &allow);
+		if (error) {
+			if (error == -EDQUOT && allow) {
+				bytes = allow << sdp->sd_sb.sb_bsize_shift;
+				goto quota_retry;
+			}
 			return error;
-retry:
+		}
+	retry:
 		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
 
 		ap.target = data_blocks + ind_blocks;
-		error = gfs2_inplace_reserve(ip, &ap);
+		error = gfs2_inpl_rsrv_ret_max_avl(ip, &ap, &allow);
 		if (error) {
-			if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) {
-				bytes >>= 1;
-				bytes &= bsize_mask;
-				if (bytes == 0)
-					bytes = sdp->sd_sb.sb_bsize;
+			if (error == -ENOSPC && allow) {
+				bytes = allow << sdp->sd_sb.sb_bsize_shift;
 				goto retry;
 			}
 			goto out_qunlock;
-- 
1.8.1.4



  parent reply	other threads:[~2015-02-12 16:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 16:54 [Cluster-devel] [GFS2 PATCH 0/4] fallocate quota fixes Abhi Das
2015-02-12 16:54 ` [Cluster-devel] [GFS2 PATCH 1/4] gfs2: check quota for blocks we're about to allocate Abhi Das
2015-02-12 18:12   ` Andrew Price
2015-02-12 18:23     ` Abhijith Das
2015-02-12 16:54 ` [Cluster-devel] [GFS2 PATCH 2/4] gfs2: add new quota check functions Abhi Das
2015-02-13 13:34   ` Steven Whitehouse
2015-02-12 16:54 ` [Cluster-devel] [GFS2 PATCH 3/4] gfs2: add new function gfs2_inpl_rsrv_ret_max_avl Abhi Das
2015-02-13 13:36   ` Steven Whitehouse
2015-02-12 16:54 ` Abhi Das [this message]
2015-02-12 17:47 ` [Cluster-devel] [GFS2 PATCH 0/4] fallocate quota fixes Bob Peterson

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=1423760054-63438-5-git-send-email-adas@redhat.com \
    --to=adas@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).