From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 3/4] libxfs: make xfs_buf_delwri_submit actually do something
Date: Thu, 05 Sep 2019 20:34:39 -0700 [thread overview]
Message-ID: <156774087984.2643362.3110363143998046856.stgit@magnolia> (raw)
In-Reply-To: <156774086083.2643362.4042713521116931635.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
xfs_buf_delwri_queue doesn't report errors, which means that if the
buffer write fails we have no way of knowing that something bad
happened. In the kernel we queue and then submit buffers, and the
submit call communicates errors to callers. Do the same here since
we're going to start using the AG header initialization functions, which
use delwri_{queue,submit} heavily.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
libxfs/libxfs_io.h | 6 +++++-
libxfs/libxfs_priv.h | 1 -
libxfs/rdwr.c | 25 +++++++++++++++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 09ed043b..579df52b 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -71,6 +71,7 @@ typedef struct xfs_buf {
struct xfs_buf_map *b_maps;
struct xfs_buf_map __b_map;
int b_nmaps;
+ struct list_head b_list;
#ifdef XFS_BUF_TRACING
struct list_head b_lock_list;
const char *b_func;
@@ -245,11 +246,14 @@ xfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags)
return bp;
}
+/* Push a single buffer on a delwri queue. */
static inline void
xfs_buf_delwri_queue(struct xfs_buf *bp, struct list_head *buffer_list)
{
bp->b_node.cn_count++;
- libxfs_writebuf(bp, 0);
+ list_add_tail(&bp->b_list, buffer_list);
}
+int xfs_buf_delwri_submit(struct list_head *buffer_list);
+
#endif /* __LIBXFS_IO_H__ */
diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 13dab58a..ff35c51e 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -382,7 +382,6 @@ roundup_64(uint64_t x, uint32_t y)
#define xfs_buf_relse(bp) libxfs_putbuf(bp)
#define xfs_buf_get(devp,blkno,len) (libxfs_getbuf((devp), (blkno), (len)))
#define xfs_bwrite(bp) libxfs_writebuf((bp), 0)
-#define xfs_buf_delwri_submit(bl) (0)
#define xfs_buf_oneshot(bp) ((void) 0)
#define XBRW_READ LIBXFS_BREAD
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 3282f6de..0d3e6089 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1473,3 +1473,28 @@ libxfs_irele(
libxfs_idestroy(ip);
kmem_zone_free(xfs_inode_zone, ip);
}
+
+/*
+ * Write out a buffer list synchronously.
+ *
+ * This will take the @buffer_list, write all buffers out and wait for I/O
+ * completion on all of the buffers. @buffer_list is consumed by the function,
+ * so callers must have some other way of tracking buffers if they require such
+ * functionality.
+ */
+int
+xfs_buf_delwri_submit(
+ struct list_head *buffer_list)
+{
+ struct xfs_buf *bp, *n;
+ int error = 0, error2;
+
+ list_for_each_entry_safe(bp, n, buffer_list, b_list) {
+ list_del_init(&bp->b_list);
+ error2 = libxfs_writebuf(bp, 0);
+ if (!error)
+ error = error2;
+ }
+
+ return error;
+}
next prev parent reply other threads:[~2019-09-06 3:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 3:34 [PATCH 0/4] xfsprogs: help mkfs shed its AG initialization code Darrick J. Wong
2019-09-06 3:34 ` [PATCH 1/4] libxfs: fix uncached buffer refcounting Darrick J. Wong
2019-09-06 3:34 ` [PATCH 2/4] libxfs: fix buffer refcounting in delwri_queue Darrick J. Wong
2019-09-06 3:34 ` Darrick J. Wong [this message]
2019-09-06 3:34 ` [PATCH 4/4] mkfs: use libxfs to write out new AGs Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2019-09-25 21:32 [PATCH 0/4] xfsprogs: help mkfs shed its AG initialization code Darrick J. Wong
2019-09-25 21:32 ` [PATCH 3/4] libxfs: make xfs_buf_delwri_submit actually do something Darrick J. Wong
2019-08-26 21:21 [PATCH 0/4] xfsprogs: help mkfs shed its AG initialization code Darrick J. Wong
2019-08-26 21:21 ` [PATCH 3/4] libxfs: make xfs_buf_delwri_submit actually do something Darrick J. Wong
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=156774087984.2643362.3110363143998046856.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=hch@lst.de \
--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 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).