]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: make xfs_buf_delwri_submit actually do something
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 26 Sep 2019 17:46:27 +0000 (13:46 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 26 Sep 2019 17:46:27 +0000 (13:46 -0400)
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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_io.h
libxfs/libxfs_priv.h
libxfs/rdwr.c

index 09ed043b929b0fc06acddd3b8372079539fd9b34..579df52bfef2aa99c1572cb3a3fcf1f062cce3ee 100644 (file)
@@ -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__ */
index 13dab58ad3933a42e789ac5ec7aa4e1a339fb83b..ff35c51e4ff230088a71a6bee19f3d4f6dbccde7 100644 (file)
@@ -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
index 3282f6de48b8454f57d569528d027f4f68af1f79..0d3e608986167b3510ec4ce95dd8038e47df15c2 100644 (file)
@@ -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;
+}