From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 06/18] libgfs2: Return the inode from build_statfs_change()
Date: Wed, 12 Jan 2022 19:26:38 +0000 [thread overview]
Message-ID: <20220112192650.1426415-7-anprice@redhat.com> (raw)
In-Reply-To: <20220112192650.1426415-1-anprice@redhat.com>
This allows the caller to call inode_put() when it's convenient and also
allows the debug message printing to be moved out of the function.
fsck.gfs2 passes the function by reference so it needs a shim until the
other builder functions can be given the same signature.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/convert/gfs2_convert.c | 8 +++++---
gfs2/fsck/pass1.c | 8 +++++---
gfs2/fsck/pass2.c | 12 +++++++++++-
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/structures.c | 16 +++++-----------
gfs2/mkfs/main_mkfs.c | 12 +++++++++---
6 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index dd809e48..1cb2d6fa 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2122,12 +2122,14 @@ static int build_per_node(struct gfs2_sbd *sdp)
}
inode_put(&ip);
- err = build_statfs_change(per_node, j);
- if (err) {
+ ip = build_statfs_change(per_node, j);
+ if (ip == NULL) {
log_crit(_("Error building '%s': %s\n"), "statfs_change",
strerror(errno));
- return err;
+ return 1;
}
+ inode_put(&ip);
+
err = build_quota_change(per_node, j);
if (err) {
log_crit(_("Error building '%s': %s\n"), "quota_change",
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 8f576fe2..3df64de7 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1600,12 +1600,14 @@ int build_per_node(struct gfs2_sbd *sdp)
}
inode_put(&ip);
- err = build_statfs_change(per_node, j);
- if (err) {
+ ip = build_statfs_change(per_node, j);
+ if (ip == NULL) {
log_err(_("Error building '%s': %s\n"), "statfs_change",
strerror(errno));
- return err;
+ return 1;
}
+ inode_put(&ip);
+
err = build_quota_change(per_node, j);
if (err) {
log_err(_("Error building '%s': %s\n"), "quota_change",
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 229667fb..2e0c1bb7 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1885,6 +1885,16 @@ static int fsck_build_inum_range(struct gfs2_inode *per_node, unsigned int n)
return 0;
}
+static int fsck_build_statfs_change(struct gfs2_inode *per_node, unsigned int n)
+{
+ struct gfs2_inode *ip = build_statfs_change(per_node, n);
+
+ if (ip == NULL)
+ return 1;
+ inode_put(&ip);
+ return 0;
+}
+
/* Check system directory inode */
/* Should work for all system directories: root, master, jindex, per_node */
static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1972,7 +1982,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
NULL, fsck_build_inum_range);
sprintf(fn, "statfs_change%d", j);
error += check_pernode_for(j, sysinode, fn, 24, 0,
- NULL, build_statfs_change);
+ NULL, fsck_build_statfs_change);
sprintf(fn, "quota_change%d", j);
error += check_pernode_for(j, sysinode, fn, 1048576, 1,
"a_change_fxns,
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e9c51054..0c702df0 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -788,7 +788,7 @@ extern int gfs2_check_meta(const char *buf, int type);
extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx,
uint64_t *buf, uint8_t state);
extern struct gfs2_inode *build_inum_range(struct gfs2_inode *per_node, unsigned int n);
-extern int build_statfs_change(struct gfs2_inode *per_node, unsigned int j);
+extern struct gfs2_inode *build_statfs_change(struct gfs2_inode *per_node, unsigned int j);
extern int build_quota_change(struct gfs2_inode *per_node, unsigned int j);
/* super.c */
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 96a62475..bd226e6d 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -296,7 +296,7 @@ struct gfs2_inode *build_inum_range(struct gfs2_inode *per_node, unsigned int j)
return ip;
}
-int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
+struct gfs2_inode *build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
{
char name[256];
struct gfs2_inode *ip;
@@ -304,19 +304,13 @@ int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
sprintf(name, "statfs_change%u", j);
ip = createi(per_node, name, S_IFREG | 0600,
GFS2_DIF_SYSTEM | GFS2_DIF_JDATA);
- if (ip == NULL) {
- return errno;
- }
+ if (ip == NULL)
+ return NULL;
+
ip->i_size = sizeof(struct gfs2_statfs_change);
lgfs2_dinode_out(ip, ip->i_bh->b_data);
bmodified(ip->i_bh);
- if (cfg_debug) {
- printf("\nStatFS Change %u:\n", j);
- lgfs2_dinode_print(ip->i_bh->b_data);
- }
-
- inode_put(&ip);
- return 0;
+ return ip;
}
int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index ea4a653f..e0f42c5a 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -708,12 +708,18 @@ static int build_per_node(struct gfs2_sbd *sdp, struct mkfs_opts *opts)
}
inode_put(&ip);
- err = build_statfs_change(per_node, j);
- if (err) {
+ ip = build_statfs_change(per_node, j);
+ if (ip == NULL) {
fprintf(stderr, _("Error building '%s': %s\n"), "statfs_change",
strerror(errno));
- return err;
+ return 1;
}
+ if (opts->debug) {
+ printf("\nStatFS Change %u:\n", j);
+ lgfs2_dinode_print(ip->i_bh->b_data);
+ }
+ inode_put(&ip);
+
err = build_quota_change(per_node, j);
if (err) {
fprintf(stderr, _("Error building '%s': %s\n"), "quota_change",
--
2.34.1
next prev parent reply other threads:[~2022-01-12 19:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 19:26 [Cluster-devel] [PATCH 00/18] gfs2-utils: Don't require an external print_it() in libgfs2 Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 01/18] libgfs2: Move debugging printf out of build_master() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 02/18] libgfs2: Rework lgfs2_build_jindex() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 03/18] libgfs2: Move build_jindex() into fsck.gfs2 Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 04/18] libgfs2: Push down build_per_node() into the utils Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 05/18] libgfs2: Return the inode from build_inum_range() Andrew Price
2022-01-12 19:26 ` Andrew Price [this message]
2022-01-12 19:26 ` [Cluster-devel] [PATCH 07/18] libgfs2: Return the inode from build_quota_change() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 08/18] libgfs2: Return the inode from build_inum() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 09/18] libgfs2: Return the inode from build_statfs() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 10/18] libgfs2: Return the inode from build_rindex() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 11/18] libgfs2: Return the inode from build_quota() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 12/18] libgfs2: Move debugging printf out of build_root() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 13/18] libgfs2: Remove debugging printf from do_init_statfs() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 14/18] libgfs2: Move debugging output out of do_init_inum() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 15/18] libgfs2: Remove debugging printfs from fix_device_geometry() Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 16/18] libgfs2: Remove config.[ch] Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 17/18] libgfs2: Move struct printing functions out of libgfs2 Andrew Price
2022-01-12 19:26 ` [Cluster-devel] [PATCH 18/18] libgfs2: Remove print_it extern requirement Andrew Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112192650.1426415-7-anprice@redhat.com \
--to=anprice@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).