cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 3/3] gfs2: allow fallocate to max out quotas/fs efficiently
Date: Tue, 17 Feb 2015 09:41:15 +0000	[thread overview]
Message-ID: <54E30CBB.2050401@redhat.com> (raw)
In-Reply-To: <1424109583-42670-4-git-send-email-adas@redhat.com>

Hi,

On 16/02/15 17:59, Abhi Das wrote:
> We can quickly get an estimate of how many more blocks are
> available for allocation restricted by quota and fs size
> respectively using the ap->allowed field in the gfs2_alloc_parms
> structure. gfs2_quota_check() and gfs2_inplace_reserve() provide
> these values.
>
> By re-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 | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 2ea420a..57129fa 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -829,20 +829,24 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
>   			continue;
>   		}
>   		ap.target = bytes >> sdp->sd_sb.sb_bsize_shift;
> +	quota_retry:
>   		error = gfs2_quota_lock_check(ip, &ap);
> -		if (error)
> +		if (error) {
> +			if (error == -EDQUOT && ap.allowed) {
> +				bytes = ap.allowed << sdp->sd_sb.sb_bsize_shift;
> +				ap.target = ap.allowed;
> +				goto quota_retry;
> +			}
>   			return error;
Do you really need to loop here if -EDQUOT is returned and ap.allowed is 
set? Why not just continue after having updated the target value?

Otherwise I think these patches look good,

Steve.

> -retry:
> +		}
> +	retry:
>   		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
>   
>   		ap.target = data_blocks + ind_blocks;
>   		error = gfs2_inplace_reserve(ip, &ap);
>   		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 && ap.allowed) {
> +				bytes = ap.allowed << sdp->sd_sb.sb_bsize_shift;
>   				goto retry;
>   			}
>   			goto out_qunlock;



  reply	other threads:[~2015-02-17  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 17:59 [Cluster-devel] [GFS2 PATCH 0/3] fallocate quota fixes Abhi Das
2015-02-16 17:59 ` [Cluster-devel] [GFS2 PATCH 1/3] gfs2: perform quota checks against allocation parameters Abhi Das
2015-02-17  9:38   ` Steven Whitehouse
2015-02-17 15:00     ` Abhijith Das
2015-02-16 17:59 ` [Cluster-devel] [GFS2 PATCH 2/3] gfs2: allow quota_check and inplace_reserve to return available blocks Abhi Das
2015-02-16 17:59 ` [Cluster-devel] [GFS2 PATCH 3/3] gfs2: allow fallocate to max out quotas/fs efficiently Abhi Das
2015-02-17  9:41   ` Steven Whitehouse [this message]
2015-02-17 15:07     ` Abhijith Das

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=54E30CBB.2050401@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).