]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: fix buffer refcounting in delwri_queue
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 26 Sep 2019 17:46:21 +0000 (13:46 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 26 Sep 2019 17:46:21 +0000 (13:46 -0400)
In the kernel, xfs_buf_delwri_queue increments the buffer reference
count before putting the buffer on the buffer list, and the refcount is
decremented after the io completes for a net refcount change of zero.

In userspace, delwri_queue calls libxfs_writebuf, which puts the buffer.
delwri_queue is a no-op, for a net refcount change of -1.  This creates
problems for any callers that expect a net change of zero, so increment
the buffer refcount before calling writebuf.

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

index 7dcb4bff74a673f16bafd65f18a2b63dbd814e20..09ed043b929b0fc06acddd3b8372079539fd9b34 100644 (file)
@@ -245,4 +245,11 @@ xfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags)
        return bp;
 }
 
+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);
+}
+
 #endif /* __LIBXFS_IO_H__ */
index b05e082acf60a6947b49f126bef55d6efdbf4102..13dab58ad3933a42e789ac5ec7aa4e1a339fb83b 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_queue(bp, bl)   libxfs_writebuf((bp), 0)
 #define xfs_buf_delwri_submit(bl)      (0)
 #define xfs_buf_oneshot(bp)            ((void) 0)