This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-fsck_cx
in repository gfs2-utils.
commit 005df252b702f61e710bb0d67b8b00331f4cda1d
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Aug 1 10:02:05 2022 +0100
fsck.gfs2: Add an options pointer to fsck_cx
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/fs_recovery.c | 8 ++++----
gfs2/fsck/fs_recovery.h | 2 +-
gfs2/fsck/fsck.h | 5 +++--
gfs2/fsck/initialize.c | 28 ++++++++++++++--------------
gfs2/fsck/main.c | 9 +++++----
5 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 78c2b591..0fd92442 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -675,7 +675,7 @@ static struct metawalk_fxns rangecheck_journal = {
*
* Returns: 0 on success, -1 on failure
*/
-int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int
*clean_journals)
+int replay_journals(struct fsck_cx *cx, int *clean_journals)
{
struct lgfs2_sbd *sdp = cx->sdp;
int dirty_journals = 0;
@@ -710,11 +710,11 @@ int replay_journals(struct fsck_cx *cx, const struct fsck_options *
const _opts,
if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize &&
jsize != sdp->jsize)
sdp->jsize = jsize;
- error = recover_journal(sdp->md.journal[i], i, _opts, &clean);
+ error = recover_journal(sdp->md.journal[i], i, cx->opts, &clean);
if (!clean)
dirty_journals++;
- if (!gave_msg && dirty_journals == 1 && !_opts->no &&
- preen_is_safe(sdp, _opts)) {
+ if (!gave_msg && dirty_journals == 1 && !cx->opts->no
&&
+ preen_is_safe(sdp, cx->opts)) {
gave_msg = 1;
log_notice( _("Recovering journals (this may "
"take a while)\n"));
diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h
index df37dc41..eda8fce9 100644
--- a/gfs2/fsck/fs_recovery.h
+++ b/gfs2/fsck/fs_recovery.h
@@ -3,7 +3,7 @@
#include "libgfs2.h"
-extern int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts,
int *clean_journals);
+extern int replay_journals(struct fsck_cx *cx, int *clean_journals);
extern int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const
_opts);
extern int ji_update(struct lgfs2_sbd *sdp);
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 70ca1231..b854997e 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -121,6 +121,7 @@ struct fsck_cx {
struct osi_root dup_blocks;
struct osi_root dirtree;
struct osi_root inodetree;
+ const struct fsck_options * const opts;
};
extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block);
@@ -129,8 +130,8 @@ extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp,
struct lgfs2_buffer_head *bh);
extern void fsck_inode_put(struct lgfs2_inode **ip);
-extern int initialize(struct fsck_cx *cx, const struct fsck_options * const opts, int
*all_clean);
-extern void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts);
+extern int initialize(struct fsck_cx *cx, int *all_clean);
+extern void destroy(struct fsck_cx *cx);
extern int pass1(struct fsck_cx *cx);
extern int pass1b(struct fsck_cx *cx);
extern int pass1c(struct fsck_cx *cx);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 165ff43f..b9fb425f 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1545,7 +1545,7 @@ static int init_rindex(struct lgfs2_sbd *sdp)
* initialize - initialize superblock pointer
*
*/
-int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int
*all_clean)
+int initialize(struct fsck_cx *cx, int *all_clean)
{
struct lgfs2_sbd *sdp = cx->sdp;
int clean_journals = 0, open_flag;
@@ -1553,17 +1553,17 @@ int initialize(struct fsck_cx *cx, const struct fsck_options *
const _opts, int
*all_clean = 0;
- if (opts.no)
+ if (cx->opts->no)
open_flag = O_RDONLY;
else
open_flag = O_RDWR | O_EXCL;
- sdp->device_fd = open(opts.device, open_flag);
+ sdp->device_fd = open(cx->opts->device, open_flag);
if (sdp->device_fd < 0) {
struct mntent *mnt;
if (open_flag == O_RDONLY || errno != EBUSY) {
log_crit( _("Unable to open device: %s\n"),
- opts.device);
+ cx->opts->device);
return FSCK_USAGE;
}
/* We can't open it EXCL. It may be already open rw (in which
@@ -1574,7 +1574,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const
_opts, int
This protects against cases where the file system is LVM
and perhaps mounted on a different node.
Try opening without O_EXCL. */
- sdp->device_fd = lgfs2_open_mnt_dev(opts.device, O_RDWR, &mnt);
+ sdp->device_fd = lgfs2_open_mnt_dev(cx->opts->device, O_RDWR, &mnt);
if (sdp->device_fd < 0)
goto mount_fail;
/* If the device is mounted, but not mounted RO, fail. This
@@ -1590,7 +1590,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const
_opts, int
}
if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo)) {
- perror(opts.device);
+ perror(cx->opts->device);
return FSCK_ERROR;
}
@@ -1600,7 +1600,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const
_opts, int
return err;
/* Change lock protocol to be fsck_* instead of lock_* */
- if (!opts.no && preen_is_safe(sdp, _opts)) {
+ if (!cx->opts->no && preen_is_safe(sdp, cx->opts)) {
if (block_mounters(sdp, 1)) {
log_err( _("Unable to block other mounters\n"));
return FSCK_USAGE;
@@ -1652,18 +1652,18 @@ int initialize(struct fsck_cx *cx, const struct fsck_options *
const _opts, int
if (sdp->gfs1) {
if (reconstruct_journals(sdp))
return FSCK_ERROR;
- } else if (replay_journals(cx, _opts, &clean_journals)) {
- if (!opts.no && preen_is_safe(sdp, _opts))
+ } else if (replay_journals(cx, &clean_journals)) {
+ if (!cx->opts->no && preen_is_safe(sdp, cx->opts))
block_mounters(sdp, 0);
stack;
return FSCK_ERROR;
}
if (sdp->md.journals == clean_journals)
*all_clean = 1;
- else if (_opts->force || !_opts->preen)
+ else if (cx->opts->force || !cx->opts->preen)
log_notice( _("\nJournal recovery complete.\n"));
- if (!_opts->force && *all_clean && _opts->preen)
+ if (!cx->opts->force && *all_clean && cx->opts->preen)
return FSCK_OK;
}
@@ -1675,15 +1675,15 @@ int initialize(struct fsck_cx *cx, const struct fsck_options *
const _opts, int
close_fail:
close(sdp->device_fd);
mount_fail:
- log_crit( _("Device %s is busy.\n"), opts.device);
+ log_crit( _("Device %s is busy.\n"), cx->opts->device);
return FSCK_USAGE;
}
-void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts)
+void destroy(struct fsck_cx *cx)
{
struct lgfs2_sbd *sdp = cx->sdp;
- if (!_opts->no) {
+ if (!cx->opts->no) {
if (block_mounters(sdp, 0)) {
log_warn( _("Unable to unblock other mounters - manual intervention
required\n"));
log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n"));
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 9a74b365..b070ec9b 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -300,7 +300,8 @@ int main(int argc, char **argv)
{
struct lgfs2_sbd sb;
struct fsck_cx cx = {
- .sdp = &sb
+ .sdp = &sb,
+ .opts = &opts,
};
int j;
int i;
@@ -325,12 +326,12 @@ int main(int argc, char **argv)
exit(error);
setbuf(stdout, NULL);
log_notice( _("Initializing fsck\n"));
- if ((error = initialize(&cx, &opts, &all_clean)))
+ if ((error = initialize(&cx, &all_clean)))
exit(error);
if (!opts.force && all_clean && opts.preen) {
log_err( _("%s: clean.\n"), opts.device);
- destroy(&cx, &opts);
+ destroy(&cx);
exit(FSCK_OK);
}
@@ -363,7 +364,7 @@ int main(int argc, char **argv)
fsync(sb.device_fd);
link1_destroy(&nlink1map);
link1_destroy(&clink1map);
- destroy(&cx, &opts);
+ destroy(&cx);
if (sb_fixed)
log_warn(_("Superblock was reset. Use tunegfs2 to manually "
"set lock table before mounting.\n"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.