This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch main
in repository gfs2-utils.
commit 82f6758138d08c1bae350a93eeb724e36712c603
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 12 13:22:02 2022 +0000
libgfs2: Push down build_per_node() into the utils
The trouble with having this function in libgfs2 is that it creates
per_node and everything inside it, which means that it's difficult to
know where an error occurred and we don't have any control over how
debug/error messages are printed. It's also not necessarily the order
that we want to create the inodes in all utilities. Move
build_per_node() down into the utils and add error reporting to match.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 36 +++++++++++++++++++++++++++++++++
gfs2/fsck/fsck.h | 1 +
gfs2/fsck/pass1.c | 36 +++++++++++++++++++++++++++++++++
gfs2/libgfs2/libgfs2.h | 1 -
gfs2/libgfs2/structures.c | 36 ---------------------------------
gfs2/mkfs/main_mkfs.c | 49 ++++++++++++++++++++++++++++++++++++++++-----
6 files changed, 117 insertions(+), 42 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 237160af..9a326e7f 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2099,6 +2099,42 @@ static int check_fit(struct gfs2_sbd *sdp)
return blks_avail > blks_need;
}
+static int build_per_node(struct gfs2_sbd *sdp)
+{
+ struct gfs2_inode *per_node;
+ unsigned int j;
+ int err;
+
+ per_node = createi(sdp->master_dir, "per_node", S_IFDIR | 0700,
+ GFS2_DIF_SYSTEM);
+ if (per_node == NULL) {
+ log_crit(_("Error building '%s': %s\n"), "per_node",
strerror(errno));
+ return -1;
+ }
+ for (j = 0; j < sdp->md.journals; j++) {
+ err = build_inum_range(per_node, j);
+ if (err) {
+ log_crit(_("Error building '%s': %s\n"), "inum_range",
+ strerror(errno));
+ return err;
+ }
+ err = build_statfs_change(per_node, j);
+ if (err) {
+ log_crit(_("Error building '%s': %s\n"), "statfs_change",
+ strerror(errno));
+ return err;
+ }
+ err = build_quota_change(per_node, j);
+ if (err) {
+ log_crit(_("Error building '%s': %s\n"), "quota_change",
+ strerror(errno));
+ return err;
+ }
+ }
+ inode_put(&per_node);
+ return 0;
+}
+
/* We fetch the old quota inode block and copy the contents of the block
* (minus the struct gfs2_dinode) into the new quota block. We update the
* inode height/size of the new quota file to that of the old one and set the
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index f6c7d1dd..7b991614 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -200,5 +200,6 @@ extern struct special_blocks *blockfind(struct special_blocks *blist,
uint64_t n
extern void gfs2_special_set(struct special_blocks *blocklist, uint64_t block);
extern void gfs2_special_free(struct special_blocks *blist);
extern int sb_fixed;
+extern int build_per_node(struct gfs2_sbd *sdp);
#endif /* _FSCK_H */
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index e976149c..38da46a6 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1577,6 +1577,42 @@ static int build_a_journal(struct gfs2_sbd *sdp)
return 0;
}
+int build_per_node(struct gfs2_sbd *sdp)
+{
+ struct gfs2_inode *per_node;
+ unsigned int j;
+ int err;
+
+ per_node = createi(sdp->master_dir, "per_node", S_IFDIR | 0700,
+ GFS2_DIF_SYSTEM);
+ if (per_node == NULL) {
+ log_err(_("Error building '%s': %s\n"), "per_node",
strerror(errno));
+ return -1;
+ }
+ for (j = 0; j < sdp->md.journals; j++) {
+ err = build_inum_range(per_node, j);
+ if (err) {
+ log_err(_("Error building '%s': %s\n"), "inum_range",
+ strerror(errno));
+ return err;
+ }
+ err = build_statfs_change(per_node, j);
+ if (err) {
+ log_err(_("Error building '%s': %s\n"), "statfs_change",
+ strerror(errno));
+ return err;
+ }
+ err = build_quota_change(per_node, j);
+ if (err) {
+ log_err(_("Error building '%s': %s\n"), "quota_change",
+ strerror(errno));
+ return err;
+ }
+ }
+ inode_put(&per_node);
+ return 0;
+}
+
static int check_system_inodes(struct gfs2_sbd *sdp)
{
int journal_count;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 9a66b5b3..863b84e6 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -777,7 +777,6 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern struct gfs2_inode *lgfs2_build_jindex(struct gfs2_inode *metafs, struct lgfs2_inum
*jnls, size_t nmemb);
-extern int build_per_node(struct gfs2_sbd *sdp);
extern int build_inum(struct gfs2_sbd *sdp);
extern int build_statfs(struct gfs2_sbd *sdp);
extern int build_rindex(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 09d7041e..c9c31dd2 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -370,42 +370,6 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
return 0;
}
-int build_per_node(struct gfs2_sbd *sdp)
-{
- struct gfs2_inode *per_node;
- unsigned int j;
- int err;
-
- per_node = createi(sdp->master_dir, "per_node", S_IFDIR | 0700,
- GFS2_DIF_SYSTEM);
- if (per_node == NULL) {
- return errno;
- }
-
- for (j = 0; j < sdp->md.journals; j++) {
- err = build_inum_range(per_node, j);
- if (err) {
- return err;
- }
- err = build_statfs_change(per_node, j);
- if (err) {
- return err;
- }
- err = build_quota_change(per_node, j);
- if (err) {
- return err;
- }
- }
-
- if (cfg_debug) {
- printf("\nper_node:\n");
- lgfs2_dinode_print(per_node->i_bh->b_data);
- }
-
- inode_put(&per_node);
- return 0;
-}
-
int build_inum(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 17284976..9c9c3752 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -681,6 +681,46 @@ static int warn_of_destruction(const char *path)
return 0;
}
+static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts)
+{
+ struct gfs2_inode *per_node;
+ unsigned int j;
+ int err;
+
+ per_node = createi(sdp->master_dir, "per_node", S_IFDIR | 0700,
+ GFS2_DIF_SYSTEM);
+ if (per_node == NULL) {
+ fprintf(stderr, _("Error building '%s': %s\n"), "per_node",
strerror(errno));
+ return -1;
+ }
+ for (j = 0; j < sdp->md.journals; j++) {
+ err = build_inum_range(per_node, j);
+ if (err) {
+ fprintf(stderr, _("Error building '%s': %s\n"),
"inum_range",
+ strerror(errno));
+ return err;
+ }
+ err = build_statfs_change(per_node, j);
+ if (err) {
+ fprintf(stderr, _("Error building '%s': %s\n"),
"statfs_change",
+ strerror(errno));
+ return err;
+ }
+ err = build_quota_change(per_node, j);
+ if (err) {
+ fprintf(stderr, _("Error building '%s': %s\n"),
"quota_change",
+ strerror(errno));
+ return err;
+ }
+ }
+ if (opts->debug) {
+ printf("\nper_node:\n");
+ lgfs2_dinode_print(per_node->i_bh->b_data);
+ }
+ inode_put(&per_node);
+ return 0;
+}
+
static int zero_gap(struct gfs2_sbd *sdp, uint64_t addr, size_t blocks)
{
struct iovec *iov;
@@ -1234,11 +1274,10 @@ int main(int argc, char *argv[])
if (error != 0)
exit(1);
- error = build_per_node(&sbd);
- if (error) {
- fprintf(stderr, _("Error building '%s': %s\n"), "per_node",
strerror(errno));
- exit(EXIT_FAILURE);
- }
+ error = build_per_node(&sbd, &opts);
+ if (error != 0)
+ exit(1);
+
error = build_inum(&sbd);
if (error) {
fprintf(stderr, _("Error building '%s': %s\n"), "inum",
strerror(errno));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.