[gfs2-utils] 09/09: gfs2_edit: Don't free buf in save_leaf_chain()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 4485127e4eb02c55a4bdebbd36239c9a5a58d577
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Nov 26 18:14:14 2021 +0000
gfs2_edit: Don't free buf in save_leaf_chain()
Each buffer passed to this function is an offset in a larger allocation
so freeing them can be left until later.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5ccc46a8..0b0b7963 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -811,16 +811,13 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
if (r != sdp->sd_bsize) {
fprintf(stderr, "Failed to read leaf block %"PRIx64": %s\n",
blk, strerror(errno));
- free(buf);
return 1;
}
report_progress(blk, 0);
if (gfs2_check_meta(buf, GFS2_METATYPE_LF) == 0) {
int ret = save_buf(mfd, buf, blk, sdp->sd_bsize);
- if (ret != 0) {
- free(buf);
+ if (ret != 0)
return ret;
- }
}
leaf = (struct gfs2_leaf *)buf;
}
@@ -838,8 +835,7 @@ static void save_leaf_blocks(struct metafd *mfd, struct block_range_queue *q)
save_leaf_chain(mfd, &sbd, buf);
}
q->tail = br->next;
- free(br->buf);
- free(br);
+ block_range_free(&br);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 08/09: libgfs2: Remove unnecessary cast from
gfs2_lookupi()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit af42ad6175c25e4d37d7980f963f1ef32e9a2549
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Nov 26 17:28:29 2021 +0000
libgfs2: Remove unnecessary cast from gfs2_lookupi()
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 449873b9..886496f7 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1882,7 +1882,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
if (!len || len > GFS2_FNAMESIZE)
return -ENAMETOOLONG;
- if (gfs2_filecmp(filename, (char *)".", 1)) {
+ if (gfs2_filecmp(filename, ".", 1)) {
*ipp = dip;
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 07/09: libgfs2: Fix leak of bh in read_sb()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 034e8816cd45e598f4408345b070cf8248078d2c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Nov 26 17:15:42 2021 +0000
libgfs2: Fix leak of bh in read_sb()
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/super.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 1bdfe254..c3c59e7e 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -68,8 +68,10 @@ int read_sb(struct gfs2_sbd *sdp)
bh = bread(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift);
ret = check_sb(bh->b_data);
- if (ret < 0)
+ if (ret < 0) {
+ brelse(bh);
return ret;
+ }
if (ret == 1)
sdp->gfs1 = 1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 06/09: gfs2_edit: Fix NULL check in print_block_type()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 53ddc29cc4ff538030de044ffb3b548d19f21e5a
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Nov 25 16:03:09 2021 +0000
gfs2_edit: Fix NULL check in print_block_type()
'type' is dereferenced in both cases of the if statement so check it
separately.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 88ee3e5f..e3794290 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1592,7 +1592,9 @@ static void jump(void)
static void print_block_type(uint64_t tblock, const struct lgfs2_metadata *type)
{
- if (type != NULL && type->nfields > 0)
+ if (type == NULL)
+ return;
+ if (type->nfields > 0)
printf("%d (Block %"PRIu64" is type %d: %s)\n", type->mh_type,
tblock, type->mh_type, type->display);
else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 05/09: fsck.gfs2: Rename rg_repair() to rindex_repair()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 1c1060b5595dbd77f85e5a6d77bbc8749fdef714
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Nov 25 12:58:11 2021 +0000
fsck.gfs2: Rename rg_repair() to rindex_repair()
To be more consistent with what it does and to differentiate it from the
rg_repair() function in gfs2_edit.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/fsck.h | 2 +-
gfs2/fsck/initialize.c | 2 +-
gfs2/fsck/rgrepair.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 91ef23d1..f6c7d1dd 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -124,7 +124,7 @@ extern int pass2(struct gfs2_sbd *sdp);
extern int pass3(struct gfs2_sbd *sdp);
extern int pass4(struct gfs2_sbd *sdp);
extern int pass5(struct gfs2_sbd *sdp, struct gfs2_bmap *bl);
-extern int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok);
+extern int rindex_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok);
extern int fsck_query(const char *format, ...)
__attribute__((format(printf,1,2)));
extern struct dir_info *dirtree_find(uint64_t block);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 9ba4bc89..86f032e7 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -730,7 +730,7 @@ static int fetch_rgrps_level(struct gfs2_sbd *sdp, enum rgindex_trust_level lvl,
log_notice(_("Level %d resource group check: %s.\n"), lvl + 1, level_desc[lvl]);
- if (rg_repair(sdp, lvl, ok) != 0)
+ if (rindex_repair(sdp, lvl, ok) != 0)
goto fail;
if (rindex_read(sdp, count, ok) != 0 || !*ok)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index c9384ac8..3163f17f 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -946,7 +946,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
}
/*
- * rg_repair - try to repair a damaged rg index (rindex)
+ * rindex_repair - try to repair a damaged rg index (rindex)
* trust_lvl - This is how much we trust the rindex file.
* BLIND_FAITH means we take the rindex at face value.
* OPEN_MINDED means it might be okay, but we should verify it.
@@ -956,7 +956,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
* was converted from GFS via gfs2_convert, and its rgrps are
* not on nice boundaries thanks to previous gfs_grow ops. Lovely.
*/
-int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
+int rindex_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
{
struct osi_node *n, *next = NULL, *e, *enext;
int error, discrepancies, percent;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 04/09: libgfs2: Remove rgcalc from struct gfs2_sbd
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 804f7587119bd105887e67c62c38a26f7711e0ea
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Nov 24 16:45:03 2021 +0000
libgfs2: Remove rgcalc from struct gfs2_sbd
It's only used in fsck/rgrepair.c so move it into that file.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 35 ++++++++++++++++++-----------------
gfs2/libgfs2/libgfs2.h | 1 -
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 7f9b0c70..c9384ac8 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -18,6 +18,7 @@
static int rindex_modified = 0;
static struct special_blocks false_rgrps;
+static struct osi_root rgcalc;
#define BAD_RG_PERCENT_TOLERANCE 11
#define AWAY_FROM_BITMAPS 0x1000
@@ -544,7 +545,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
return -1;
}
- sdp->rgcalc.osi_node = NULL;
+ rgcalc.osi_node = NULL;
grow_segments = find_shortest_rgdist(sdp, &rg_dist[0], &rg_dcnt[0]);
for (i = 0; i < grow_segments; i++)
log_info(_("Segment %d: rgrp distance: 0x%llx, count: %d\n"),
@@ -563,7 +564,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
rg_was_fnd = (!gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG));
brelse(bh);
/* Allocate a new RG and index. */
- calc_rgd = rgrp_insert(&sdp->rgcalc, blk);
+ calc_rgd = rgrp_insert(&rgcalc, blk);
if (!calc_rgd) {
log_crit( _("Can't allocate memory for rgrp repair.\n"));
goto out;
@@ -679,7 +680,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
/* Now dump out the information (if verbose mode) */
/* ---------------------------------------------- */
log_debug( _("rindex rebuilt as follows:\n"));
- for (n = osi_first(&sdp->rgcalc), rgi = 0; n; n = next, rgi++) {
+ for (n = osi_first(&rgcalc), rgi = 0; n; n = next, rgi++) {
next = osi_next(n);
calc_rgd = (struct rgrp_tree *)n;
log_debug("%d: 0x%"PRIx64"/%"PRIx32"/0x%"PRIx64"/0x%"PRIx32"/0x%"PRIx32"\n",
@@ -780,7 +781,7 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
struct rgrp_tree *rl;
uint32_t rgblocks, bitblocks;
- for (n = osi_first(&sdp->rgcalc); n; n = next) {
+ for (n = osi_first(&rgcalc); n; n = next) {
next = osi_next(n);
rl = (struct rgrp_tree *)n;
@@ -827,7 +828,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
/* ----------------------------------------------------------------- */
*num_rgs = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex);
- sdp->rgcalc.osi_node = NULL;
+ rgcalc.osi_node = NULL;
fix_device_geometry(sdp);
/* Try all possible rgrp sizes: 2048, 1024, 512, 256, 128, 64, 32 */
@@ -842,7 +843,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
}
}
/* Compute the default resource group layout as mkfs would have done */
- sdp->rgcalc = compute_rgrp_layout(sdp);
+ rgcalc = compute_rgrp_layout(sdp);
if (calc_rgrps(sdp)) { /* Calculate but don't write to disk. */
fprintf(stderr, _("Failed to build resource groups\n"));
exit(-1);
@@ -923,7 +924,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- exp = rgrp_insert(&sdp->rgcalc, rgd->rt_addr);
+ exp = rgrp_insert(&rgcalc, rgd->rt_addr);
if (exp == NULL) {
fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
exit(-1);
@@ -975,7 +976,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
}
error = expect_rindex_sanity(sdp, &calc_rg_count);
if (error) {
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
return error;
}
} else if (trust_lvl == OPEN_MINDED) { /* If we can't trust RG index */
@@ -985,7 +986,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
/* Calculate our own RG index for comparison */
error = gfs2_rindex_calculate(sdp, &calc_rg_count);
if (error) { /* If calculated RGs don't match the fs */
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
return -1;
}
} else if (trust_lvl == DISTRUST) { /* If we can't trust RG index */
@@ -995,7 +996,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
error = rindex_rebuild(sdp, &calc_rg_count, 0);
if (error) {
log_crit( _("Error rebuilding rgrp list.\n"));
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
return -1;
}
} else if (trust_lvl == INDIGNATION) { /* If we can't trust anything */
@@ -1005,7 +1006,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
error = rindex_rebuild(sdp, &calc_rg_count, 1);
if (error) {
log_crit( _("Error rebuilding rgrp list.\n"));
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
return -1;
}
}
@@ -1016,7 +1017,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
log_warn( _("WARNING: rindex file has an invalid size.\n"));
if (!query( _("Truncate the rindex size? (y/n)"))) {
log_err(_("The rindex was not repaired.\n"));
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
return -1;
}
@@ -1040,7 +1041,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
then try again with a little more DISTRUST. */
if ((trust_lvl < DISTRUST) ||
!query( _("Attempt to use what rgrps we can? (y/n)"))) {
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
log_err(_("The rindex was not repaired.\n"));
return -1;
@@ -1064,7 +1065,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
/* abandon this method of recovery and try a better one. */
/* ------------------------------------------------------------- */
discrepancies = 0;
- for (rg = 0, n = osi_first(&sdp->rgtree), e = osi_first(&sdp->rgcalc);
+ for (rg = 0, n = osi_first(&sdp->rgtree), e = osi_first(&rgcalc);
n && e && !fsck_abort && rg < calc_rg_count; rg++) {
struct rgrp_tree *expected, *actual;
@@ -1106,7 +1107,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
log_warn( _("%d out of %d rgrps (%d percent) did not "
"match what was expected.\n"),
discrepancies, rg, percent);
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
return -1;
}
@@ -1118,7 +1119,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
/* Our rindex should be pretty predictable unless we've grown */
/* so look for index problems first before looking at the rgs. */
/* ------------------------------------------------------------- */
- for (rg = 0, n = osi_first(&sdp->rgtree), e = osi_first(&sdp->rgcalc);
+ for (rg = 0, n = osi_first(&sdp->rgtree), e = osi_first(&rgcalc);
e && !fsck_abort && rg < calc_rg_count; rg++) {
struct rgrp_tree *expected, *actual;
@@ -1211,7 +1212,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
i++;
} while (i < rgd->rt_length);
}
- gfs2_rgrp_free(sdp, &sdp->rgcalc);
+ gfs2_rgrp_free(sdp, &rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
/* We shouldn't need to worry about getting the user's permission to
make changes here. If b_modified is true, they already gave their
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e37f5c57..171128d7 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -375,7 +375,6 @@ struct gfs2_sbd {
uint64_t orig_rgrps;
uint64_t rgrps;
struct osi_root rgtree;
- struct osi_root rgcalc;
struct gfs2_inode *master_dir;
struct master_dir md;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 03/09: fsck.gfs2: Simplify how_many_rgrps()
by pagure@pagure.io
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.
2 years, 4 months
[gfs2-utils] 02/09: fsck.gfs2: Simplify compute_rgrp_layout()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 8b6fb562f3c18731272520b46f59e48563564afc
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Nov 24 12:47:54 2021 +0000
fsck.gfs2: Simplify compute_rgrp_layout()
This function used to be in libgfs2 but now that it's only called from
one place 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 | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index eec59681..b9ef0c82 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -750,47 +750,28 @@ static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgs
/**
* compute_rgrp_layout - figure out where the RG in a FS are
*/
-static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, int rgsize_specified)
+static struct osi_root compute_rgrp_layout(struct gfs2_sbd *sdp)
{
struct device *dev;
struct rgrp_tree *rl, *rlast = NULL;
unsigned int rgrp = 0, nrgrp, rglength;
+ struct osi_root rgtree = {NULL};
uint64_t rgaddr;
dev = &sdp->device;
- /* If this is a new file system, compute the length and number */
- /* of rgs based on the size of the device. */
- /* If we have existing RGs (i.e. gfs2_grow) find the last one. */
- if (!rgtree->osi_node) {
- dev->length -= LGFS2_SB_ADDR(sdp) + 1;
- nrgrp = how_many_rgrps(sdp, dev, rgsize_specified);
- rglength = dev->length / nrgrp;
- } else {
- uint64_t old_length, new_chunk;
- unsigned new_rgrps;
-
- for (struct osi_node *n = osi_first(rgtree); n; n = osi_next(n))
- rlast = (struct rgrp_tree *)n;
-
- rglength = rgrp_size(rlast);
- rlast->rt_skip = rglength;
- old_length = rlast->rt_addr + rglength;
- new_chunk = dev->length - old_length;
- new_rgrps = new_chunk / rglength;
- nrgrp = rgrp + new_rgrps;
- }
+ dev->length -= LGFS2_SB_ADDR(sdp) + 1;
+ nrgrp = how_many_rgrps(sdp, dev, 1);
+ rglength = dev->length / nrgrp;
- if (rgrp < nrgrp)
- printf("\nNew resource groups:\n");
for (; rgrp < nrgrp; rgrp++) {
if (rgrp) {
rgaddr = rlast->rt_addr + rlast->rt_skip;
- rl = rgrp_insert(rgtree, rgaddr);
+ rl = rgrp_insert(&rgtree, rgaddr);
rl->rt_skip = rglength;
} else {
rgaddr = LGFS2_SB_ADDR(sdp) + 1;
- rl = rgrp_insert(rgtree, rgaddr);
+ rl = rgrp_insert(&rgtree, rgaddr);
rl->rt_skip = dev->length -
(nrgrp - 1) * (dev->length / nrgrp);
}
@@ -798,6 +779,7 @@ static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, i
}
sdp->rgrps = nrgrp;
+ return rgtree;
}
static int calc_rgrps(struct gfs2_sbd *sdp)
@@ -868,7 +850,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
}
}
/* Compute the default resource group layout as mkfs would have done */
- compute_rgrp_layout(sdp, &sdp->rgcalc, 1);
+ sdp->rgcalc = compute_rgrp_layout(sdp);
if (calc_rgrps(sdp)) { /* Calculate but don't write to disk. */
fprintf(stderr, _("Failed to build resource groups\n"));
exit(-1);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] 01/09: libgfs2: Remove start and length from struct
rgrp_tree
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 61b3351f9bcf2b5451fb9f620442a8a7130fb439
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Nov 12 21:52:28 2021 +0000
libgfs2: Remove start and length from struct rgrp_tree
These are essentially duplicates of rt_addr and rt_skip.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 34 ++++++++--------------------------
gfs2/libgfs2/libgfs2.h | 2 --
gfs2/libgfs2/super.c | 13 ++++---------
3 files changed, 12 insertions(+), 37 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 129e3e5c..eec59681 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -754,7 +754,6 @@ static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, i
{
struct device *dev;
struct rgrp_tree *rl, *rlast = NULL;
- struct osi_node *n, *next = NULL;
unsigned int rgrp = 0, nrgrp, rglength;
uint64_t rgaddr;
@@ -771,20 +770,11 @@ static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, i
uint64_t old_length, new_chunk;
unsigned new_rgrps;
- printf("Existing resource groups:\n");
- for (rgrp = 0, n = osi_first(rgtree); n; n = next, rgrp++) {
- next = osi_next(n);
- rl = (struct rgrp_tree *)n;
+ for (struct osi_node *n = osi_first(rgtree); n; n = osi_next(n))
+ rlast = (struct rgrp_tree *)n;
- printf("%d: start: %" PRIu64 " (0x%"
- PRIx64 "), length = %"PRIu64" (0x%"
- PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
- rl->length, rl->length);
- rlast = rl;
- }
- rlast->start = rlast->rt_addr;
rglength = rgrp_size(rlast);
- rlast->length = rglength;
+ rlast->rt_skip = rglength;
old_length = rlast->rt_addr + rglength;
new_chunk = dev->length - old_length;
new_rgrps = new_chunk / rglength;
@@ -795,20 +785,15 @@ static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, i
printf("\nNew resource groups:\n");
for (; rgrp < nrgrp; rgrp++) {
if (rgrp) {
- rgaddr = rlast->start + rlast->length;
+ rgaddr = rlast->rt_addr + rlast->rt_skip;
rl = rgrp_insert(rgtree, rgaddr);
- rl->length = rglength;
+ rl->rt_skip = rglength;
} else {
rgaddr = LGFS2_SB_ADDR(sdp) + 1;
rl = rgrp_insert(rgtree, rgaddr);
- rl->length = dev->length -
+ rl->rt_skip = dev->length -
(nrgrp - 1) * (dev->length / nrgrp);
}
- rl->start = rgaddr;
- /* printf("%d: start: %" PRIu64 " (0x%"
- PRIx64 "), length = %"PRIu64" (0x%"
- PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
- rl->length, rl->length);*/
rlast = rl;
}
@@ -825,11 +810,10 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- bitblocks = rgblocks2bitblocks(sdp->sd_bsize, rl->length, &rgblocks);
+ bitblocks = rgblocks2bitblocks(sdp->sd_bsize, rl->rt_skip, &rgblocks);
- rl->rt_addr = rl->start;
rl->rt_length = bitblocks;
- rl->rt_data0 = rl->start + bitblocks;
+ rl->rt_data0 = rl->rt_addr + bitblocks;
rl->rt_data = rgblocks;
rl->rt_bitbytes = rgblocks / GFS2_NBBY;
rl->rt_free = rgblocks;
@@ -970,8 +954,6 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
exit(-1);
}
- exp->start = rgd->start;
- exp->length = rgd->length;
exp->rt_data0 = rgd->rt_data0;
exp->rt_data = rgd->rt_data;
exp->rt_length = rgd->rt_length;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index dd97441f..e37f5c57 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -175,8 +175,6 @@ typedef struct _lgfs2_rgrps *lgfs2_rgrps_t;
struct rgrp_tree {
struct osi_node node;
- uint64_t start; /* The offset of the beginning of this resource group */
- uint64_t length; /* The length of this resource group */
struct gfs2_bitmap *bits;
lgfs2_rgrps_t rgrps;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index cd2a2ecf..1bdfe254 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -224,29 +224,26 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
*ok = 0;
if (prev_rgd == NULL)
continue;
- addr = prev_rgd->rt_addr + prev_rgd->length;
+ addr = prev_rgd->rt_data0 + prev_rgd->rt_data;
}
rgd = rgrp_insert(&sdp->rgtree, addr);
rgd->rt_length = be32_to_cpu(ri.ri_length);
rgd->rt_data0 = be64_to_cpu(ri.ri_data0);
rgd->rt_data = be32_to_cpu(ri.ri_data);
rgd->rt_bitbytes = be32_to_cpu(ri.ri_bitbytes);
- rgd->start = addr;
if (prev_rgd) {
/* If rg addresses go backwards, it's not sane
(or it's converted from gfs1). */
if (!sdp->gfs1) {
- if (prev_rgd->start >= rgd->start)
+ if (prev_rgd->rt_addr >= rgd->rt_addr)
*ok = 0;
else if (!rgd_seems_ok(sdp, rgd))
*ok = 0;
else if (*ok && rg > 2 && prev_length &&
- prev_length != rgd->start -
- prev_rgd->start)
+ prev_length != rgd->rt_addr - prev_rgd->rt_addr)
*ok = good_on_disk(sdp, rgd);
}
- prev_length = rgd->start - prev_rgd->start;
- prev_rgd->length = rgrp_size(prev_rgd);
+ prev_length = rgd->rt_addr - prev_rgd->rt_addr;
}
if(gfs2_compute_bitstructs(sdp->sd_bsize, rgd))
@@ -255,8 +252,6 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
(*rgcount)++;
prev_rgd = rgd;
}
- if (prev_rgd)
- prev_rgd->length = rgrp_size(prev_rgd);
if (*rgcount == 0)
return -1;
return 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months
[gfs2-utils] branch master updated (c0ea1bc4 -> 4485127e)
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a change to branch master
in repository gfs2-utils.
from c0ea1bc4 libgfs2: Remove new_rgrps from struct gfs2_sbd
new 61b3351f libgfs2: Remove start and length from struct rgrp_tree
new 8b6fb562 fsck.gfs2: Simplify compute_rgrp_layout()
new fdfbbb85 fsck.gfs2: Simplify how_many_rgrps()
new 804f7587 libgfs2: Remove rgcalc from struct gfs2_sbd
new 1c1060b5 fsck.gfs2: Rename rg_repair() to rindex_repair()
new 53ddc29c gfs2_edit: Fix NULL check in print_block_type()
new 034e8816 libgfs2: Fix leak of bh in read_sb()
new af42ad61 libgfs2: Remove unnecessary cast from gfs2_lookupi()
new 4485127e gfs2_edit: Don't free buf in save_leaf_chain()
The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
gfs2/edit/hexedit.c | 4 +-
gfs2/edit/savemeta.c | 8 +--
gfs2/fsck/fsck.h | 2 +-
gfs2/fsck/initialize.c | 2 +-
gfs2/fsck/rgrepair.c | 133 +++++++++++++++++--------------------------------
gfs2/libgfs2/fs_ops.c | 2 +-
gfs2/libgfs2/libgfs2.h | 3 --
gfs2/libgfs2/super.c | 17 +++----
8 files changed, 60 insertions(+), 111 deletions(-)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 4 months