This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 61f98981c07a16144a178108e4587f34bb912774
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Mar 22 12:12:10 2021 +0000
libgfs2: Clean up rindex_read()
Nothing calls this function with a valid fd (gfs2_grow does things its
own way) so remove that parameter and the code paths that use it. Fix up
some argument and function names.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 2 +-
gfs2/edit/hexedit.c | 2 +-
gfs2/fsck/initialize.c | 2 +-
gfs2/fsck/rgrepair.c | 2 +-
gfs2/libgfs2/gfs2l.c | 2 +-
gfs2/libgfs2/libgfs2.h | 3 +--
gfs2/libgfs2/super.c | 48 ++++++++++++++++++++-------------------------
7 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index e43c9aa4..142c7d4e 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1560,7 +1560,7 @@ static int gfs1_ri_update(struct gfs2_sbd *sdp, int *rgcount, int quiet)
struct osi_node *n, *next = NULL;
int ok;
- if (rindex_read(sdp, 0, &count1, &ok))
+ if (rindex_read(sdp, &count1, &ok))
goto fail;
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 91313e81..bd3f0abc 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -976,7 +976,7 @@ static int read_rindex(void)
sbd.fssize = sbd.device.length;
if (sbd.md.riinode) /* If we found the rindex */
- rindex_read(&sbd, 0, &count, &sane);
+ rindex_read(&sbd, &count, &sane);
if (!OSI_EMPTY_ROOT(&sbd.rgtree)) {
ri = &((struct rgrp_tree *)osi_last(&sbd.rgtree))->ri;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 04230f2f..5f176dca 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -697,7 +697,7 @@ static int ri_update(struct gfs2_sbd *sdp, int *rgcount, int *ok)
/* Turn off generic readhead */
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_RANDOM);
- if (rindex_read(sdp, 0, &count1, ok))
+ if (rindex_read(sdp, &count1, ok))
goto fail;
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index f9a85887..dd0b1fa5 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -1036,7 +1036,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane)
}
/* Read in the rindex */
sdp->rgtree.osi_node = NULL; /* Just to be safe */
- rindex_read(sdp, 0, &sdp->rgrps, sane);
+ rindex_read(sdp, &sdp->rgrps, sane);
if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex)) {
log_warn( _("WARNING: rindex file has an invalid size.\n"));
if (!query( _("Truncate the rindex size? (y/n)"))) {
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index bc42e888..567b3b89 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -135,7 +135,7 @@ static int openfs(const char *path, struct gfs2_sbd *sdp)
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
sdp->fssize = sdp->device.length;
if (sdp->md.riinode) {
- rindex_read(sdp, 0, &count, &sane);
+ rindex_read(sdp, &count, &sane);
} else {
perror("Failed to look up rindex");
return 1;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 1e8d2313..1427e2a9 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -703,8 +703,7 @@ extern int build_quota_change(struct gfs2_inode *per_node, unsigned int j);
/* super.c */
extern int check_sb(struct gfs2_sb *sb);
extern int read_sb(struct gfs2_sbd *sdp);
-extern int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1,
- int *sane);
+extern int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok);
extern int write_sb(struct gfs2_sbd *sdp);
/* ondisk.c */
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 7a032cd4..bf65b127 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -133,7 +133,7 @@ int read_sb(struct gfs2_sbd *sdp)
return 0;
}
-/* rgd_seems_sane - check some general things about the rindex entry
+/* rgd_seems_ok - check some general things about the rindex entry
*
* If rg lengths are not consistent, it's not sane (or it's converted from
* gfs1). The first RG will be a different length due to space reserved for
@@ -142,7 +142,7 @@ int read_sb(struct gfs2_sbd *sdp)
*
* Returns: 1 if the rgd seems relatively sane
*/
-static int rgd_seems_sane(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
+static int rgd_seems_ok(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
uint32_t most_bitmaps_possible;
@@ -189,14 +189,12 @@ static int good_on_disk(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
/**
* rindex_read - read in the rg index file
* @sdp: the incore superblock pointer
- * fd: optional file handle for rindex file (if meta_fs file system is mounted)
- * (if fd is <= zero, it will read from raw device)
- * @count1: return count of the rgs.
- * @sane: return whether rindex is consistent
+ * @rgcount: return count of the rgs.
+ * @ok: return whether rindex is consistent
*
* Returns: 0 on success, -1 on failure
*/
-int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
+int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
{
unsigned int rg;
int error;
@@ -207,18 +205,14 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
struct rgrp_tree *rgd = NULL, *prev_rgd = NULL;
uint64_t prev_length = 0;
- *sane = 1;
- *count1 = 0;
- if (!fd && sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex))
- *sane = 0; /* rindex file size must be a multiple of 96 */
+ *ok = 1;
+ *rgcount = 0;
+ if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex))
+ *ok = 0; /* rindex file size must be a multiple of 96 */
for (rg = 0; ; rg++) {
- if (fd > 0)
- error = read(fd, &buf, sizeof(struct gfs2_rindex));
- else
- error = gfs2_readi(sdp->md.riinode,
- (char *)&buf.bufgfs2,
- rg * sizeof(struct gfs2_rindex),
- sizeof(struct gfs2_rindex));
+ error = gfs2_readi(sdp->md.riinode, (char *)&buf.bufgfs2,
+ rg * sizeof(struct gfs2_rindex),
+ sizeof(struct gfs2_rindex));
if (!error)
break;
if (error != sizeof(struct gfs2_rindex))
@@ -226,7 +220,7 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
gfs2_rindex_in(&ri, (char *)&buf.bufgfs2);
if (gfs2_check_range(sdp, ri.ri_addr) != 0) {
- *sane = 0;
+ *ok = 0;
if (prev_rgd == NULL)
continue;
ri.ri_addr = prev_rgd->ri.ri_addr + prev_rgd->length;
@@ -240,27 +234,27 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
(or it's converted from gfs1). */
if (!sdp->gfs1) {
if (prev_rgd->start >= rgd->start)
- *sane = 0;
- else if (!rgd_seems_sane(sdp, rgd))
- *sane = 0;
- else if (*sane && rg > 2 && prev_length &&
+ *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)
- *sane = good_on_disk(sdp, rgd);
+ *ok = good_on_disk(sdp, rgd);
}
prev_length = rgd->start - prev_rgd->start;
prev_rgd->length = rgrp_size(prev_rgd);
}
if(gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd))
- *sane = 0;
+ *ok = 0;
- (*count1)++;
+ (*rgcount)++;
prev_rgd = rgd;
}
if (prev_rgd)
prev_rgd->length = rgrp_size(prev_rgd);
- if (*count1 == 0)
+ if (*rgcount == 0)
return -1;
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.