diff options
author | Abhi Das <adas@redhat.com> | 2015-03-18 13:04:37 -0400 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2015-03-18 13:47:10 -0400 |
commit | 25435e5ed611f310dda889940cbc4c45b3ecd9ec (patch) | |
tree | 9610acd909a2a48a01f092a58c163af4cac1aad2 /fs/gfs2/rgrp.c | |
parent | b8fbf471edb3dbf441716fd2a52a7ca76c381381 (diff) |
gfs2: allow quota_check and inplace_reserve to return available blocks
struct gfs2_alloc_parms is passed to gfs2_quota_check() and
gfs2_inplace_reserve() with ap->target containing the number of
blocks being requested for allocation in the current operation.
We add a new field to struct gfs2_alloc_parms called 'allowed'.
gfs2_quota_check() and gfs2_inplace_reserve() return the max
blocks allowed by quota and the max blocks allowed by the chosen
rgrp respectively in 'allowed'.
A new field 'min_target', when non-zero, tells gfs2_quota_check()
and gfs2_inplace_reserve() to not return -EDQUOT/-ENOSPC when
there are atleast 'min_target' blocks allowable/available. The
assumption is that the caller is ok with just 'min_target' blocks
and will likely proceed with allocating them.
Signed-off-by: Abhi Das <adas@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Acked-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r-- | fs/gfs2/rgrp.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 9150207f365c..6af2396a317c 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1946,10 +1946,18 @@ static inline int fast_to_acquire(struct gfs2_rgrpd *rgd) | |||
1946 | * @ip: the inode to reserve space for | 1946 | * @ip: the inode to reserve space for |
1947 | * @ap: the allocation parameters | 1947 | * @ap: the allocation parameters |
1948 | * | 1948 | * |
1949 | * Returns: errno | 1949 | * We try our best to find an rgrp that has at least ap->target blocks |
1950 | * available. After a couple of passes (loops == 2), the prospects of finding | ||
1951 | * such an rgrp diminish. At this stage, we return the first rgrp that has | ||
1952 | * atleast ap->min_target blocks available. Either way, we set ap->allowed to | ||
1953 | * the number of blocks available in the chosen rgrp. | ||
1954 | * | ||
1955 | * Returns: 0 on success, | ||
1956 | * -ENOMEM if a suitable rgrp can't be found | ||
1957 | * errno otherwise | ||
1950 | */ | 1958 | */ |
1951 | 1959 | ||
1952 | int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *ap) | 1960 | int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) |
1953 | { | 1961 | { |
1954 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1962 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1955 | struct gfs2_rgrpd *begin = NULL; | 1963 | struct gfs2_rgrpd *begin = NULL; |
@@ -2012,7 +2020,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *a | |||
2012 | /* Skip unuseable resource groups */ | 2020 | /* Skip unuseable resource groups */ |
2013 | if ((rs->rs_rbm.rgd->rd_flags & (GFS2_RGF_NOALLOC | | 2021 | if ((rs->rs_rbm.rgd->rd_flags & (GFS2_RGF_NOALLOC | |
2014 | GFS2_RDF_ERROR)) || | 2022 | GFS2_RDF_ERROR)) || |
2015 | (ap->target > rs->rs_rbm.rgd->rd_extfail_pt)) | 2023 | (loops == 0 && ap->target > rs->rs_rbm.rgd->rd_extfail_pt)) |
2016 | goto skip_rgrp; | 2024 | goto skip_rgrp; |
2017 | 2025 | ||
2018 | if (sdp->sd_args.ar_rgrplvb) | 2026 | if (sdp->sd_args.ar_rgrplvb) |
@@ -2027,11 +2035,13 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *a | |||
2027 | goto check_rgrp; | 2035 | goto check_rgrp; |
2028 | 2036 | ||
2029 | /* If rgrp has enough free space, use it */ | 2037 | /* If rgrp has enough free space, use it */ |
2030 | if (rs->rs_rbm.rgd->rd_free_clone >= ap->target) { | 2038 | if (rs->rs_rbm.rgd->rd_free_clone >= ap->target || |
2039 | (loops == 2 && ap->min_target && | ||
2040 | rs->rs_rbm.rgd->rd_free_clone >= ap->min_target)) { | ||
2031 | ip->i_rgd = rs->rs_rbm.rgd; | 2041 | ip->i_rgd = rs->rs_rbm.rgd; |
2042 | ap->allowed = ip->i_rgd->rd_free_clone; | ||
2032 | return 0; | 2043 | return 0; |
2033 | } | 2044 | } |
2034 | |||
2035 | check_rgrp: | 2045 | check_rgrp: |
2036 | /* Check for unlinked inodes which can be reclaimed */ | 2046 | /* Check for unlinked inodes which can be reclaimed */ |
2037 | if (rs->rs_rbm.rgd->rd_flags & GFS2_RDF_CHECK) | 2047 | if (rs->rs_rbm.rgd->rd_flags & GFS2_RDF_CHECK) |