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 12/18] libxfs: use uncached buffers for initial mkfs writes
Date: Wed, 19 Feb 2020 17:43:49 -0800	[thread overview]
Message-ID: <158216302984.602314.15196666031325406487.stgit@magnolia> (raw)
In-Reply-To: <158216295405.602314.2094526611933874427.stgit@magnolia>

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

Teach mkfs to use uncached buffers to write the start and end of the
data device, the initial superblock, and the end of the realtime device
instead of open-coding uncached buffers.  This means we can get rid of
libxfs_purgebuf since we handle the state from the start now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/libxfs_io.h |    1 -
 libxfs/rdwr.c      |   12 ------------
 mkfs/xfs_mkfs.c    |   34 +++++++++++++++++++++++-----------
 3 files changed, 23 insertions(+), 24 deletions(-)


diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 546b7710..6598dba7 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -213,7 +213,6 @@ struct xfs_buf *libxfs_getsb(struct xfs_mount *);
 extern void	libxfs_bcache_purge(void);
 extern void	libxfs_bcache_free(void);
 extern void	libxfs_bcache_flush(void);
-extern void	libxfs_purgebuf(xfs_buf_t *);
 extern int	libxfs_bcache_overflowed(void);
 
 /* Buffer (Raw) Interfaces */
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index ada20dd9..20a8b0ce 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -869,18 +869,6 @@ libxfs_buf_relse(
 		libxfs_putbufr(bp);
 }
 
-void
-libxfs_purgebuf(xfs_buf_t *bp)
-{
-	struct xfs_bufkey key = {NULL};
-
-	key.buftarg = bp->b_target;
-	key.blkno = bp->b_bn;
-	key.bblen = bp->b_length;
-
-	cache_node_purge(libxfs_bcache, &key, (struct cache_node *)bp);
-}
-
 static struct cache_node *
 libxfs_balloc(cache_key_t key)
 {
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 9ca4cb1a..f58f235d 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3396,6 +3396,21 @@ finish_superblock_setup(
 
 }
 
+/* Prepare an uncached buffer, ready to write something out. */
+static inline struct xfs_buf *
+get_write_buf(
+	struct xfs_buftarg	*btp,
+	xfs_daddr_t		daddr,
+	int			bblen)
+{
+	struct xfs_buf		*bp;
+
+	bp = libxfs_buf_get_uncached(btp, bblen, 0);
+	bp->b_bn = daddr;
+	bp->b_maps[0].bm_bn = daddr;
+	return bp;
+}
+
 /*
  * Sanitise the data and log devices and prepare them so libxfs can mount the
  * device successfully. Also check we can access the rt device if configured.
@@ -3444,11 +3459,10 @@ prepare_devices(
 	 * the end of the device.  (MD sb is ~64k from the end, take out a wider
 	 * swath to be sure)
 	 */
-	buf = libxfs_buf_get(mp->m_ddev_targp, (xi->dsize - whack_blks),
-			    whack_blks);
+	buf = get_write_buf(mp->m_ddev_targp, (xi->dsize - whack_blks),
+			whack_blks);
 	memset(buf->b_addr, 0, WHACK_SIZE);
 	libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
-	libxfs_purgebuf(buf);
 
 	/*
 	 * Now zero out the beginning of the device, to obliterate any old
@@ -3456,18 +3470,17 @@ prepare_devices(
 	 * swap (somewhere around the page size), jfs (32k),
 	 * ext[2,3] and reiserfs (64k) - and hopefully all else.
 	 */
-	buf = libxfs_buf_get(mp->m_ddev_targp, 0, whack_blks);
+	buf = get_write_buf(mp->m_ddev_targp, 0, whack_blks);
 	memset(buf->b_addr, 0, WHACK_SIZE);
 	libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
-	libxfs_purgebuf(buf);
 
 	/* OK, now write the superblock... */
-	buf = libxfs_buf_get(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
+	buf = get_write_buf(mp->m_ddev_targp, XFS_SB_DADDR,
+			XFS_FSS_TO_BB(mp, 1));
 	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_WRITEBUF_FAIL_EXIT);
-	libxfs_purgebuf(buf);
 
 	/* ...and zero the log.... */
 	lsunit = sbp->sb_logsunit;
@@ -3482,12 +3495,11 @@ prepare_devices(
 
 	/* finally, check we can write the last block in the realtime area */
 	if (mp->m_rtdev_targp->dev && cfg->rtblocks > 0) {
-		buf = libxfs_buf_get(mp->m_rtdev_targp,
-				    XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
-				    BTOBB(cfg->blocksize));
+		buf = get_write_buf(mp->m_rtdev_targp,
+				XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
+				BTOBB(cfg->blocksize));
 		memset(buf->b_addr, 0, cfg->blocksize);
 		libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
-		libxfs_purgebuf(buf);
 	}
 
 }


  parent reply	other threads:[~2020-02-20  1:45 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 ` [PATCH 01/18] libxfs: clean up readbuf flags Darrick J. Wong
2020-02-21 14:42   ` 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 ` Darrick J. Wong [this message]
2020-02-21 14:51   ` [PATCH 12/18] libxfs: use uncached buffers for initial mkfs writes 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=158216302984.602314.15196666031325406487.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.