diff mbox series

[07/18] libxfs: make libxfs_bwrite do what libxfs_writebufr does

Message ID 158216299927.602314.10659390054898124986.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series xfsprogs: refactor buffer function names | expand

Commit Message

Darrick J. Wong Feb. 20, 2020, 1:43 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Make libxfs_bwrite equivalent to libxfs_writebufr.  This makes it so
that libxfs bwrite calls write the buffer to disk immediately and
without double-freeing the buffer.  However, we choose to consolidate
around the libxfs_bwrite name to match the kernel.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/io.c                  |    4 ++--
 libxfs/libxfs_api_defs.h |    1 +
 libxfs/libxfs_io.h       |    2 +-
 libxfs/libxfs_priv.h     |    1 -
 libxfs/rdwr.c            |   11 ++++++-----
 5 files changed, 10 insertions(+), 9 deletions(-)

Comments

Christoph Hellwig Feb. 21, 2020, 2:45 p.m. UTC | #1
On Wed, Feb 19, 2020 at 05:43:19PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make libxfs_bwrite equivalent to libxfs_writebufr.  This makes it so
> that libxfs bwrite calls write the buffer to disk immediately and
> without double-freeing the buffer.  However, we choose to consolidate
> around the libxfs_bwrite name to match the kernel.

The commit message looks a little odd.  Also why is the subject a
different style than the previous messages?

Also if there was a double free shouldn't we fix that in a small
backportable patch first (not that I see such a fix anywhere)?
Darrick J. Wong Feb. 21, 2020, 8:43 p.m. UTC | #2
On Fri, Feb 21, 2020 at 06:45:47AM -0800, Christoph Hellwig wrote:
> On Wed, Feb 19, 2020 at 05:43:19PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Make libxfs_bwrite equivalent to libxfs_writebufr.  This makes it so
> > that libxfs bwrite calls write the buffer to disk immediately and
> > without double-freeing the buffer.  However, we choose to consolidate
> > around the libxfs_bwrite name to match the kernel.
> 
> The commit message looks a little odd.  Also why is the subject a
> different style than the previous messages?

Ok, changed to:

"libxfs: rename libxfs_writebufr to libxfs_bwrite

"Rename this function so that we have an API that matches the kernel
without a #define."

> Also if there was a double free shouldn't we fix that in a small
> backportable patch first (not that I see such a fix anywhere)?

Hmmm... I can't find one either.  I think that's just an anachronism
from an earlier version of this series.

--D
diff mbox series

Patch

diff --git a/db/io.c b/db/io.c
index 163ccc89..7c7a4624 100644
--- a/db/io.c
+++ b/db/io.c
@@ -426,7 +426,7 @@  write_cur_buf(void)
 {
 	int ret;
 
-	ret = -libxfs_writebufr(iocur_top->bp);
+	ret = -libxfs_bwrite(iocur_top->bp);
 	if (ret != 0)
 		dbprintf(_("write error: %s\n"), strerror(ret));
 
@@ -442,7 +442,7 @@  write_cur_bbs(void)
 {
 	int ret;
 
-	ret = -libxfs_writebufr(iocur_top->bp);
+	ret = -libxfs_bwrite(iocur_top->bp);
 	if (ret != 0)
 		dbprintf(_("write error: %s\n"), strerror(ret));
 
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 57cf5f83..df267c98 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -48,6 +48,7 @@ 
 #define xfs_buf_read			libxfs_buf_read
 #define xfs_buf_relse			libxfs_buf_relse
 #define xfs_bunmapi			libxfs_bunmapi
+#define xfs_bwrite			libxfs_bwrite
 #define xfs_calc_dquots_per_chunk	libxfs_calc_dquots_per_chunk
 #define xfs_da3_node_hdr_from_disk	libxfs_da3_node_hdr_from_disk
 #define xfs_da_get_buf			libxfs_da_get_buf
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 9484c627..f00ff8d3 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -222,7 +222,7 @@  extern xfs_buf_t *libxfs_getbufr(struct xfs_buftarg *, xfs_daddr_t, int);
 extern void	libxfs_putbufr(xfs_buf_t *);
 
 extern int	libxfs_writebuf_int(xfs_buf_t *, int);
-extern int	libxfs_writebufr(struct xfs_buf *);
+int		libxfs_bwrite(struct xfs_buf *);
 extern int	libxfs_readbufr(struct xfs_buftarg *, xfs_daddr_t, xfs_buf_t *, int, int);
 extern int	libxfs_readbufr_map(struct xfs_buftarg *, struct xfs_buf *, int);
 
diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 0f26120f..5d6dd063 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -377,7 +377,6 @@  roundup_64(uint64_t x, uint32_t y)
 	(len) = __bar; /* no set-but-unused warning */	\
 	NULL;						\
 })
-#define xfs_bwrite(bp)			libxfs_writebuf((bp), 0)
 #define xfs_buf_oneshot(bp)		((void) 0)
 
 #define XBRW_READ			LIBXFS_BREAD
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index ea2f4a13..2a4ef15a 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1091,9 +1091,10 @@  __write_buf(int fd, void *buf, int len, off64_t offset, int flags)
 }
 
 int
-libxfs_writebufr(xfs_buf_t *bp)
+libxfs_bwrite(
+	struct xfs_buf	*bp)
 {
-	int	fd = libxfs_device_to_fd(bp->b_target->dev);
+	int		fd = libxfs_device_to_fd(bp->b_target->dev);
 
 	/*
 	 * we never write buffers that are marked stale. This indicates they
@@ -1303,7 +1304,7 @@  libxfs_bflush(
 	struct xfs_buf		*bp = (struct xfs_buf *)node;
 
 	if (!bp->b_error && bp->b_flags & LIBXFS_B_DIRTY)
-		return libxfs_writebufr(bp);
+		return libxfs_bwrite(bp);
 	return bp->b_error;
 }
 
@@ -1311,7 +1312,7 @@  void
 libxfs_putbufr(xfs_buf_t *bp)
 {
 	if (bp->b_flags & LIBXFS_B_DIRTY)
-		libxfs_writebufr(bp);
+		libxfs_bwrite(bp);
 	libxfs_brelse((struct cache_node *)bp);
 }
 
@@ -1524,7 +1525,7 @@  xfs_buf_delwri_submit(
 
 	list_for_each_entry_safe(bp, n, buffer_list, b_list) {
 		list_del_init(&bp->b_list);
-		error2 = libxfs_writebufr(bp);
+		error2 = libxfs_bwrite(bp);
 		if (!error)
 			error = error2;
 		libxfs_buf_relse(bp);