This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit fdfbbb85719983734c447cd81c18f4229c229bc4
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Nov 24 14:23:14 2021 +0000
fsck.gfs2: Simplify how_many_rgrps()
This function used to be in libgfs2 but now that it's only used in a
couple of places in fsck.gfs2 it can be simplified to just do what
fsck.gfs2 needs it to do.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index b9ef0c82..7f9b0c70 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -706,11 +706,10 @@ out:
*
* Returns: the number of RGs
*/
-static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int
rgsize_specified)
+static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev)
{
uint64_t nrgrp;
uint32_t rgblocks1, rgblocksn, bitblocks1, bitblocksn;
- int bitmap_overflow = 0;
while (1) {
nrgrp = DIV_RU(dev->length, (sdp->rgsize << 20) / sdp->sd_bsize);
@@ -720,25 +719,16 @@ static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device
*dev, int rgs
/* calculate size of the first rgrp */
bitblocks1 = rgblocks2bitblocks(sdp->sd_bsize, dev->length - (nrgrp - 1) *
(dev->length / nrgrp),
&rgblocks1);
- if (bitblocks1 > 2149 || bitblocksn > 2149) {
- bitmap_overflow = 1;
- if (sdp->rgsize <= GFS2_DEFAULT_RGSIZE) {
- fprintf(stderr, "error: It is not possible "
- "to use the entire device with "
- "block size %u bytes.\n",
- sdp->sd_bsize);
- exit(-1);
- }
- sdp->rgsize -= GFS2_DEFAULT_RGSIZE; /* smaller rgs */
- continue;
- }
- if (bitmap_overflow ||
- rgsize_specified || /* If user specified an rg size or */
- nrgrp <= GFS2_EXCESSIVE_RGS || /* not an excessive # or */
- sdp->rgsize >= 2048) /* we reached the max rg size */
+ if (bitblocks1 <= 2149 && bitblocksn <= 2149)
break;
- sdp->rgsize += GFS2_DEFAULT_RGSIZE; /* bigger rgs */
+ sdp->rgsize -= GFS2_DEFAULT_RGSIZE; /* smaller rgs */
+
+ if (sdp->rgsize < GFS2_DEFAULT_RGSIZE) {
+ log_err(_("Cannot use the entire device with block size %u bytes.\n"),
+ sdp->sd_bsize);
+ return 0;
+ }
}
log_debug(" rg sz = %"PRIu32"\n nrgrp = %"PRIu64"\n",
sdp->rgsize,
@@ -761,7 +751,9 @@ static struct osi_root compute_rgrp_layout(struct gfs2_sbd *sdp)
dev = &sdp->device;
dev->length -= LGFS2_SB_ADDR(sdp) + 1;
- nrgrp = how_many_rgrps(sdp, dev, 1);
+ nrgrp = how_many_rgrps(sdp, dev);
+ if (nrgrp == 0)
+ return (struct osi_root){NULL};
rglength = dev->length / nrgrp;
for (; rgrp < nrgrp; rgrp++) {
@@ -841,7 +833,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
/* Try all possible rgrp sizes: 2048, 1024, 512, 256, 128, 64, 32 */
for (sdp->rgsize = GFS2_DEFAULT_RGSIZE; sdp->rgsize >= 32;
sdp->rgsize /= 2) {
- num_rgrps = how_many_rgrps(sdp, &sdp->device, 1);
+ num_rgrps = how_many_rgrps(sdp, &sdp->device);
if (num_rgrps == *num_rgs) {
log_info(_("rgsize must be: %lld (0x%llx)\n"),
(unsigned long long)sdp->rgsize,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date