From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 3/4] gfs2: add new function gfs2_inpl_rsrv_ret_max_avl
Date: Fri, 13 Feb 2015 13:36:06 +0000 [thread overview]
Message-ID: <54DDFDC6.2070402@redhat.com> (raw)
In-Reply-To: <1423760054-63438-4-git-send-email-adas@redhat.com>
Hi,
Likewise here, if the available blocks was added to the allocation
parms, then this would help to neaten up the code a bit. Otherwise all
four patches look good to me,
Steve.
On 12/02/15 16:54, Abhi Das wrote:
> This is a variant of the existing gfs2_inplace_reserve() function.
>
> If the requested number of blocks are not available to be reserved
> from any of the rgrps, gfs2_inplace_reserve() return -ENOSPC.
> gfs2_inpl_rsrv_ret_max_val() will also return the maximum blocks
> available in an extra parameter 'max_avail'.
>
> If acceptable to the caller logic, either of these inplace resreve
> functions may be called again requesting 'max_avail' blocks to
> avoid the -ENOSPC error.
>
> Signed-off-by: Abhi Das <adas@redhat.com>
> ---
> fs/gfs2/rgrp.c | 13 +++++++++++--
> fs/gfs2/rgrp.h | 10 +++++++++-
> 2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index 9150207..0fa9ae3 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -1942,14 +1942,17 @@ static inline int fast_to_acquire(struct gfs2_rgrpd *rgd)
> }
>
> /**
> - * gfs2_inplace_reserve - Reserve space in the filesystem
> + * gfs2_inpl_rsrv_ret_max_avl - Reserve space in the filesystem
> * @ip: the inode to reserve space for
> * @ap: the allocation parameters
> + * @max_avail: If non-NULL, return the max available extent if -ENOSPC
> *
> * Returns: errno
> */
>
> -int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *ap)
> +int gfs2_inpl_rsrv_ret_max_avl(struct gfs2_inode *ip,
> + const struct gfs2_alloc_parms *ap,
> + u32 *max_avail)
> {
> struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
> struct gfs2_rgrpd *begin = NULL;
> @@ -1958,6 +1961,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *a
> u64 last_unlinked = NO_BLOCK;
> int loops = 0;
> u32 skip = 0;
> + u32 max_avlbl = 0;
>
> if (sdp->sd_args.ar_rgrplvb)
> flags |= GL_SKIP;
> @@ -2030,6 +2034,8 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *a
> if (rs->rs_rbm.rgd->rd_free_clone >= ap->target) {
> ip->i_rgd = rs->rs_rbm.rgd;
> return 0;
> + } else if (rs->rs_rbm.rgd->rd_free_clone > max_avlbl) {
> + max_avlbl = rs->rs_rbm.rgd->rd_free_clone;
> }
>
> check_rgrp:
> @@ -2068,6 +2074,9 @@ next_rgrp:
> gfs2_log_flush(sdp, NULL, NORMAL_FLUSH);
> }
>
> + if (max_avail)
> + *max_avail = max_avlbl;
> +
> return -ENOSPC;
> }
>
> diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
> index b104f4a..2adffca 100644
> --- a/fs/gfs2/rgrp.h
> +++ b/fs/gfs2/rgrp.h
> @@ -41,7 +41,15 @@ extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh);
> extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
>
> #define GFS2_AF_ORLOV 1
> -extern int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *ap);
> +extern int gfs2_inpl_rsrv_ret_max_avl(struct gfs2_inode *ip,
> + const struct gfs2_alloc_parms *ap,
> + u32 *max_avail);
> +static inline int gfs2_inplace_reserve(struct gfs2_inode *ip,
> + const struct gfs2_alloc_parms *ap)
> +{
> + return gfs2_inpl_rsrv_ret_max_avl(ip, ap, NULL);
> +}
> +
> extern void gfs2_inplace_release(struct gfs2_inode *ip);
>
> extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
next prev parent reply other threads:[~2015-02-13 13:36 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 [this message]
2015-02-12 16:54 ` [Cluster-devel] [GFS2 PATCH 4/4] gfs2: allow fallocate to max out quotas/fs efficiently Abhi Das
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=54DDFDC6.2070402@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).