This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit ac0aa85c98c66deec9f021b69bf4bcf50f123c05
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Apr 21 18:44:56 2021 +0100
libgfs2: Remove gfs2_statfs_change_{in,out}
Update users to avoid storing cpu-endian data in an on-disk struct and
remove the functions. Replace the gfs2_statfs_change_print() function
with one that expects big-endian data.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 22 ++++++++++------------
gfs2/edit/extended.c | 11 +++++------
gfs2/fsck/initialize.c | 3 ---
gfs2/fsck/main.c | 32 +++++++++++++++-----------------
gfs2/libgfs2/libgfs2.h | 4 +---
gfs2/libgfs2/ondisk.c | 26 +++++---------------------
gfs2/libgfs2/structures.c | 14 ++++++--------
7 files changed, 42 insertions(+), 70 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index ded2589e..cca60598 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1958,27 +1958,25 @@ static void update_inode_file(struct gfs2_sbd *sdp)
log_debug(_("\nNext Inum: %llu\n"), (unsigned long
long)sdp->md.next_inum);
}/* update_inode_file */
-/* ------------------------------------------------------------------------- */
-/* write_statfs_file - write the statfs file */
-/* ------------------------------------------------------------------------- */
+/**
+ * write_statfs_file - write the statfs file
+ */
static void write_statfs_file(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.statfs;
struct gfs2_statfs_change sc;
- char buf[sizeof(struct gfs2_statfs_change)];
int count;
- sc.sc_total = sdp->blks_total;
- sc.sc_free = sdp->blks_total - sdp->blks_alloced;
- sc.sc_dinodes = sdp->dinodes_alloced;
+ sc.sc_total = cpu_to_be64(sdp->blks_total);
+ sc.sc_free = cpu_to_be64(sdp->blks_total - sdp->blks_alloced);
+ sc.sc_dinodes = cpu_to_be64(sdp->dinodes_alloced);
- gfs2_statfs_change_out(&sc, buf);
- count = gfs2_writei(ip, buf, 0, sizeof(struct gfs2_statfs_change));
- if (count != sizeof(struct gfs2_statfs_change)) {
- fprintf(stderr, "do_init (2)\n");
+ count = gfs2_writei(ip, &sc, 0, sizeof(sc));
+ if (count != sizeof(sc)) {
+ fprintf(stderr, "Failed to write statfs file\n");
exit(1);
}
-}/* write_statfs_file */
+}
/* ------------------------------------------------------------------------- */
/* remove_obsolete_gfs1 - remove obsolete gfs1 inodes. */
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 30e227d1..79a5ec86 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -588,24 +588,23 @@ static int print_inum(struct gfs2_inode *dii)
static int print_statfs(struct gfs2_inode *dis)
{
- struct gfs2_statfs_change sfb, sfc;
+ struct gfs2_statfs_change sc;
int rc;
-
- rc = gfs2_readi(dis, (void *)&sfb, 0, sizeof(sfb));
+
+ rc = gfs2_readi(dis, (void *)&sc, 0, sizeof(sc));
if (!rc) {
print_gfs2("The statfs file is empty.");
eol(0);
return 0;
}
- if (rc != sizeof(sfb)) {
+ if (rc != sizeof(sc)) {
print_gfs2("Error reading statfs file.");
eol(0);
return -1;
}
- gfs2_statfs_change_in(&sfc, (char *)&sfb);
print_gfs2("statfs file contents:");
eol(0);
- gfs2_statfs_change_print(&sfc);
+ lgfs2_statfs_change_print(&sc);
return 0;
}
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index e35cf0a9..1a6db6ec 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -808,7 +808,6 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
{
uint64_t inumbuf = 0;
char *buf;
- struct gfs2_statfs_change sc;
int err;
/*******************************************************************
@@ -914,8 +913,6 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
free(buf);
goto fail;
}
- /* call gfs2_inum_range_in() to retrieve range */
- gfs2_statfs_change_in(&sc, buf);
free(buf);
}
}
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index a860f6eb..d424e075 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -168,8 +168,10 @@ static int check_statfs(struct gfs2_sbd *sdp)
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
struct gfs2_rindex *ri;
- struct gfs2_statfs_change sc = {0,};
- char buf[sizeof(struct gfs2_statfs_change)];
+ struct gfs2_statfs_change sc;
+ uint64_t sc_total;
+ uint64_t sc_free;
+ uint64_t sc_dinodes;
int count;
if (sdp->gfs1 && !sdp->md.statfs->i_di.di_size) {
@@ -177,14 +179,17 @@ static int check_statfs(struct gfs2_sbd *sdp)
return 0;
}
/* Read the current statfs values */
- count = gfs2_readi(sdp->md.statfs, buf, 0,
+ count = gfs2_readi(sdp->md.statfs, &sc, 0,
sdp->md.statfs->i_di.di_size);
if (count != sizeof(struct gfs2_statfs_change)) {
log_err(_("Failed to read statfs values (%d of %"PRIu64"
read)\n"),
count, (uint64_t)sdp->md.statfs->i_di.di_size);
return FSCK_ERROR;
}
- gfs2_statfs_change_in(&sc, buf);
+ sc_total = be64_to_cpu(sc.sc_total);
+ sc_free = be64_to_cpu(sc.sc_free);
+ sc_dinodes = be64_to_cpu(sc.sc_dinodes);
+
/* Calculate the real values from the rgrp information */
sdp->blks_total = 0;
sdp->blks_alloced = 0;
@@ -200,24 +205,17 @@ static int check_statfs(struct gfs2_sbd *sdp)
}
/* See if they match */
- if (sc.sc_total == sdp->blks_total &&
- sc.sc_free == (sdp->blks_total - sdp->blks_alloced) &&
- sc.sc_dinodes == sdp->dinodes_alloced) {
+ if (sc_total == sdp->blks_total &&
+ sc_free == (sdp->blks_total - sdp->blks_alloced) &&
+ sc_dinodes == sdp->dinodes_alloced) {
log_info( _("The statfs file is accurate.\n"));
return 0;
}
log_err( _("The statfs file is wrong:\n\n"));
log_err( _("Current statfs values:\n"));
- log_err( _("blocks: %lld (0x%llx)\n"),
- (unsigned long long)sc.sc_total,
- (unsigned long long)sc.sc_total);
- log_err( _("free: %lld (0x%llx)\n"),
- (unsigned long long)sc.sc_free,
- (unsigned long long)sc.sc_free);
- log_err( _("dinodes: %lld (0x%llx)\n\n"),
- (unsigned long long)sc.sc_dinodes,
- (unsigned long long)sc.sc_dinodes);
-
+ log_err( _("blocks: %"PRId64" (0x%"PRIx64")\n"),
sc_total, sc_total);
+ log_err( _("free: %"PRId64" (0x%"PRIx64")\n"), sc_free,
sc_free);
+ log_err( _("dinodes: %"PRId64" (0x%"PRIx64")\n\n"),
sc_dinodes, sc_dinodes);
log_err( _("Calculated statfs values:\n"));
log_err( _("blocks: %lld (0x%llx)\n"),
(unsigned long long)sdp->blks_total,
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d479ade2..20cb11bf 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -716,8 +716,6 @@ extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf);
extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
extern void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf);
-extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf);
-extern void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf);
/* Printing functions */
@@ -731,11 +729,11 @@ extern void gfs2_dinode_print(const struct gfs2_dinode *di);
extern void gfs2_leaf_print(const struct gfs2_leaf *lf);
extern void gfs2_ea_header_print(const struct gfs2_ea_header *ea, char *name);
extern void gfs2_log_header_print(const struct gfs2_log_header *lh);
-extern void gfs2_statfs_change_print(const struct gfs2_statfs_change *sc);
/* These expect on-disk data instead of native-endian structs */
extern void lgfs2_meta_header_print(void *mhp);
extern void lgfs2_log_descriptor_print(void *ldp);
extern void lgfs2_quota_change_print(void *qcp);
+extern void lgfs2_statfs_change_print(void *scp);
__END_DECLS
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 3b72051a..8f28ca6e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -569,29 +569,13 @@ void lgfs2_log_descriptor_print(void *ldp)
printbe32(ld, ld_data2);
}
-void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf)
+void lgfs2_statfs_change_print(void *scp)
{
- struct gfs2_statfs_change *str = (struct gfs2_statfs_change *)buf;
+ struct gfs2_statfs_change *sc = scp;
- CPIN_64(sc, str, sc_total);
- CPIN_64(sc, str, sc_free);
- CPIN_64(sc, str, sc_dinodes);
-}
-
-void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf)
-{
- struct gfs2_statfs_change *str = (struct gfs2_statfs_change *)buf;
-
- CPOUT_64(sc, str, sc_total);
- CPOUT_64(sc, str, sc_free);
- CPOUT_64(sc, str, sc_dinodes);
-}
-
-void gfs2_statfs_change_print(const struct gfs2_statfs_change *sc)
-{
- pv(sc, sc_total, "%"PRId64, "0x%"PRIx64);
- pv(sc, sc_free, "%"PRId64, "0x%"PRIx64);
- pv(sc, sc_dinodes, "%"PRId64, "0x%"PRIx64);
+ print_it(" sc_total", "%"PRId64, "0x%"PRIx64,
be64_to_cpu(sc->sc_total));
+ print_it(" sc_free", "%"PRId64, "0x%"PRIx64,
be64_to_cpu(sc->sc_free));
+ print_it(" sc_dinodes", "%"PRId64, "0x%"PRIx64,
be64_to_cpu(sc->sc_dinodes));
}
void lgfs2_quota_change_print(void *qcp)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index d5d12ef1..4b25f05a 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -635,21 +635,19 @@ int do_init_statfs(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.statfs;
struct gfs2_statfs_change sc;
- char buf[sizeof(struct gfs2_statfs_change)];
int count;
- sc.sc_total = sdp->blks_total;
- sc.sc_free = sdp->blks_total - sdp->blks_alloced;
- sc.sc_dinodes = sdp->dinodes_alloced;
+ sc.sc_total = cpu_to_be64(sdp->blks_total);
+ sc.sc_free = cpu_to_be64(sdp->blks_total - sdp->blks_alloced);
+ sc.sc_dinodes = cpu_to_be64(sdp->dinodes_alloced);
- gfs2_statfs_change_out(&sc, buf);
- count = gfs2_writei(ip, buf, 0, sizeof(struct gfs2_statfs_change));
- if (count != sizeof(struct gfs2_statfs_change))
+ count = gfs2_writei(ip, &sc, 0, sizeof(sc));
+ if (count != sizeof(sc))
return -1;
if (cfg_debug) {
printf("\nStatfs:\n");
- gfs2_statfs_change_print(&sc);
+ lgfs2_statfs_change_print(&sc);
}
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.