All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 01/18] libxfs: clean up readbuf flags
Date: Wed, 19 Feb 2020 17:42:40 -0800	[thread overview]
Message-ID: <158216296035.602314.7876331402312462299.stgit@magnolia> (raw)
In-Reply-To: <158216295405.602314.2094526611933874427.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Create a separate namespace for libxfs_readbuf() flags so that it's a
little more obvious when we're trying to use the "read or die" logic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/init.c      |   11 ++++++++---
 libxfs/libxfs_io.h |    3 +++
 libxfs/rdwr.c      |    4 ++--
 mkfs/xfs_mkfs.c    |    4 ++--
 4 files changed, 15 insertions(+), 7 deletions(-)


diff --git a/libxfs/init.c b/libxfs/init.c
index d1d3f4df..428497f0 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -640,6 +640,7 @@ libxfs_mount(
 	xfs_buf_t	*bp;
 	xfs_sb_t	*sbp;
 	int		error;
+	int		readflags = 0;
 
 	libxfs_buftarg_init(mp, dev, logdev, rtdev);
 
@@ -716,9 +717,13 @@ libxfs_mount(
 	if (dev == 0)	/* maxtrres, we have no device so leave now */
 		return mp;
 
+	/* device size checks must pass unless we're a debugger. */
+	if (!(flags & LIBXFS_MOUNT_DEBUGGER))
+		readflags |= LIBXFS_READBUF_FAIL_EXIT;
+
 	bp = libxfs_readbuf(mp->m_dev,
 			d - XFS_FSS_TO_BB(mp, 1), XFS_FSS_TO_BB(mp, 1),
-			!(flags & LIBXFS_MOUNT_DEBUGGER), NULL);
+			readflags, NULL);
 	if (!bp) {
 		fprintf(stderr, _("%s: data size check failed\n"), progname);
 		if (!(flags & LIBXFS_MOUNT_DEBUGGER))
@@ -733,7 +738,7 @@ libxfs_mount(
 		     (!(bp = libxfs_readbuf(mp->m_logdev_targp,
 					d - XFS_FSB_TO_BB(mp, 1),
 					XFS_FSB_TO_BB(mp, 1),
-					!(flags & LIBXFS_MOUNT_DEBUGGER), NULL))) ) {
+					readflags, NULL))) ) {
 			fprintf(stderr, _("%s: log size checks failed\n"),
 					progname);
 			if (!(flags & LIBXFS_MOUNT_DEBUGGER))
@@ -760,7 +765,7 @@ libxfs_mount(
 	if (sbp->sb_agcount > 1000000) {
 		bp = libxfs_readbuf(mp->m_dev,
 				XFS_AG_DADDR(mp, sbp->sb_agcount - 1, 0), 1,
-				!(flags & LIBXFS_MOUNT_DEBUGGER), NULL);
+				readflags, NULL);
 		if (bp->b_error) {
 			fprintf(stderr, _("%s: read of AG %u failed\n"),
 						progname, sbp->sb_agcount);
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index fc0fd060..b294e659 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -124,6 +124,9 @@ extern struct cache_operations	libxfs_bcache_operations;
 
 #define LIBXFS_GETBUF_TRYLOCK	(1 << 0)
 
+/* Exit on buffer read error */
+#define LIBXFS_READBUF_FAIL_EXIT	(1 << 0)
+
 #ifdef XFS_BUF_TRACING
 
 #define libxfs_readbuf(dev, daddr, len, flags, ops) \
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 92e497f9..32619a8d 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -911,13 +911,13 @@ __read_buf(int fd, void *buf, int len, off64_t offset, int flags)
 		int error = errno;
 		fprintf(stderr, _("%s: read failed: %s\n"),
 			progname, strerror(error));
-		if (flags & LIBXFS_EXIT_ON_FAILURE)
+		if (flags & LIBXFS_READBUF_FAIL_EXIT)
 			exit(1);
 		return -error;
 	} else if (sts != len) {
 		fprintf(stderr, _("%s: error - read only %d of %d bytes\n"),
 			progname, sts, len);
-		if (flags & LIBXFS_EXIT_ON_FAILURE)
+		if (flags & LIBXFS_READBUF_FAIL_EXIT)
 			exit(1);
 		return -EIO;
 	}
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 6b182264..a57046f1 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3577,7 +3577,7 @@ rewrite_secondary_superblocks(
 			XFS_AGB_TO_DADDR(mp, mp->m_sb.sb_agcount - 1,
 				XFS_SB_DADDR),
 			XFS_FSS_TO_BB(mp, 1),
-			LIBXFS_EXIT_ON_FAILURE, &xfs_sb_buf_ops);
+			LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
 	XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
@@ -3589,7 +3589,7 @@ rewrite_secondary_superblocks(
 			XFS_AGB_TO_DADDR(mp, (mp->m_sb.sb_agcount - 1) / 2,
 				XFS_SB_DADDR),
 			XFS_FSS_TO_BB(mp, 1),
-			LIBXFS_EXIT_ON_FAILURE, &xfs_sb_buf_ops);
+			LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
 	XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 }


  reply	other threads:[~2020-02-20  1:42 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20  1:42 [PATCH 00/18] xfsprogs: refactor buffer function names Darrick J. Wong
2020-02-20  1:42 ` Darrick J. Wong [this message]
2020-02-21 14:42   ` [PATCH 01/18] libxfs: clean up readbuf flags Christoph Hellwig
2020-02-21 15:55     ` Darrick J. Wong
2020-02-20  1:42 ` [PATCH 02/18] libxfs: clean up writebuf flags Darrick J. Wong
2020-02-20  1:42 ` [PATCH 03/18] libxfs: remove LIBXFS_EXIT_ON_FAILURE Darrick J. Wong
2020-02-20  1:43 ` [PATCH 04/18] libxfs: replace libxfs_putbuf with libxfs_buf_relse Darrick J. Wong
2020-02-21 14:43   ` Christoph Hellwig
2020-02-21 15:01   ` Eric Sandeen
2020-02-20  1:43 ` [PATCH 05/18] libxfs: replace libxfs_getbuf with libxfs_buf_get Darrick J. Wong
2020-02-21 14:43   ` Christoph Hellwig
2020-02-20  1:43 ` [PATCH 06/18] libxfs: replace libxfs_readbuf with libxfs_buf_read Darrick J. Wong
2020-02-21 14:44   ` Christoph Hellwig
2020-02-20  1:43 ` [PATCH 07/18] libxfs: make libxfs_bwrite do what libxfs_writebufr does Darrick J. Wong
2020-02-21 14:45   ` Christoph Hellwig
2020-02-21 20:43     ` Darrick J. Wong
2020-02-20  1:43 ` [PATCH 08/18] libxfs: make libxfs_readbuf_verify return an error code Darrick J. Wong
2020-02-21 14:46   ` Christoph Hellwig
2020-02-20  1:43 ` [PATCH 09/18] libxfs: make libxfs_readbufr stash the error value in b_error Darrick J. Wong
2020-02-21 14:46   ` Christoph Hellwig
2020-02-20  1:43 ` [PATCH 10/18] libxfs: introduce libxfs_buf_read_uncached Darrick J. Wong
2020-02-21 14:48   ` Christoph Hellwig
2020-02-21 20:50     ` Darrick J. Wong
2020-02-21 20:59       ` Darrick J. Wong
2020-02-20  1:43 ` [PATCH 11/18] libxlog: use uncached buffers instead of open-coding them Darrick J. Wong
2020-02-21 14:49   ` Christoph Hellwig
2020-02-21 15:51     ` Darrick J. Wong
2020-02-20  1:43 ` [PATCH 12/18] libxfs: use uncached buffers for initial mkfs writes Darrick J. Wong
2020-02-21 14:51   ` Christoph Hellwig
2020-02-21 15:52     ` Darrick J. Wong
2020-02-20  1:43 ` [PATCH 13/18] libxfs: straighten out libxfs_writebuf confusion Darrick J. Wong
2020-02-21 14:53   ` Christoph Hellwig
2020-02-21 15:54     ` Darrick J. Wong
2020-02-20  1:44 ` [PATCH 14/18] libxfs: remove libxfs_writebuf_int Darrick J. Wong
2020-02-21 14:53   ` Christoph Hellwig
2020-02-20  1:44 ` [PATCH 15/18] libxfs: hide libxfs_{get,put}bufr Darrick J. Wong
2020-02-21 14:53   ` Christoph Hellwig
2020-02-21 16:00     ` Darrick J. Wong
2020-02-20  1:44 ` [PATCH 16/18] libxfs: hide libxfs_getbuf_flags Darrick J. Wong
2020-02-21 14:54   ` Christoph Hellwig
2020-02-20  1:44 ` [PATCH 17/18] libxfs: rename libxfs_readbuf_map to libxfs_buf_read_map Darrick J. Wong
2020-02-21 14:54   ` Christoph Hellwig
2020-02-20  1:44 ` [PATCH 18/18] libxfs: rename libxfs_getbuf_map to libxfs_buf_get_map Darrick J. Wong
2020-02-21 14:55   ` Christoph Hellwig

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=158216296035.602314.7876331402312462299.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.