[PATCH 02/25] libxfs: remove LIBXFS_EXIT_ON_FAILURE

Darrick J. Wong
2020-02-25T00:11:48Z

Now that the read-side users of LIBXFS_EXIT_ON_FAILURE are gone and the
only write-side callers are in mkfs which now checks for buffer write
failures, get rid of LIBXFS_EXIT_ON_FAILURE.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
include/libxfs.h | 1 -
libxfs/libxfs_io.h | 2 +-
libxfs/rdwr.c | 2 +-
mkfs/proto.c | 2 +-
mkfs/xfs_mkfs.c | 14 +++++++-------
5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/libxfs.h b/include/libxfs.h
index 504f6e9c..12447835 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -126,7 +126,6 @@ typedef struct libxfs_xinit {
int bcache_flags; /* cache init flags */
} libxfs_init_t;

-#define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */
#define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */
#define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */
#define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 6bb75a67..87c6ea3e 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -91,7 +91,7 @@ bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic);
bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic);

/* b_flags bits */
-#define LIBXFS_B_EXIT 0x0001 /* ==LIBXFS_EXIT_ON_FAILURE */
+#define LIBXFS_B_EXIT 0x0001 /* exit if write fails */
#define LIBXFS_B_DIRTY 0x0002 /* buffer has been modified */
#define LIBXFS_B_STALE 0x0004 /* buffer marked as invalid */
#define LIBXFS_B_UPTODATE 0x0008 /* buffer is sync'd to disk */
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 474fceb0..011b449d 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -19,7 +19,7 @@
#include "xfs_trans.h"
#include "libfrog/platform.h"

-#include "libxfs.h" /* for LIBXFS_EXIT_ON_FAILURE */
+#include "libxfs.h"

/*
* Important design/architecture note:
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 2ece593e..c3813ea2 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -262,7 +262,7 @@ newfile(
if (logit)
libxfs_trans_log_buf(tp, bp, 0, bp->b_bcount - 1);
else
- libxfs_writebuf(bp, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(bp, 0);
}
ip->i_d.di_size = len;
return flags;
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 3de73fc6..fbf2b7f2 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3447,7 +3447,7 @@ prepare_devices(
buf = libxfs_getbuf(mp->m_ddev_targp, (xi->dsize - whack_blks),
whack_blks);
memset(buf->b_addr, 0, WHACK_SIZE);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);
libxfs_purgebuf(buf);

/*
@@ -3458,7 +3458,7 @@ prepare_devices(
*/
buf = libxfs_getbuf(mp->m_ddev_targp, 0, whack_blks);
memset(buf->b_addr, 0, WHACK_SIZE);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);
libxfs_purgebuf(buf);

/* OK, now write the superblock... */
@@ -3466,7 +3466,7 @@ prepare_devices(
buf->b_ops = &xfs_sb_buf_ops;
memset(buf->b_addr, 0, cfg->sectorsize);
libxfs_sb_to_disk(buf->b_addr, sbp);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);
libxfs_purgebuf(buf);

/* ...and zero the log.... */
@@ -3486,7 +3486,7 @@ prepare_devices(
XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
BTOBB(cfg->blocksize));
memset(buf->b_addr, 0, cfg->blocksize);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);
libxfs_purgebuf(buf);
}

@@ -3583,7 +3583,7 @@ rewrite_secondary_superblocks(
exit(1);
}
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);

/* and one in the middle for luck if there's enough AGs for that */
if (mp->m_sb.sb_agcount <= 2)
@@ -3599,7 +3599,7 @@ rewrite_secondary_superblocks(
exit(1);
}
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);
}

static void
@@ -3946,7 +3946,7 @@ main(
if (!buf || buf->b_error)
exit(1);
(XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, 0);

/* Report failure if anything failed to get written to our new fs. */
error = -libxfs_umount(mp);