Skip to contentSkip to conversation

misc xfsprogs cleanups

PATCH In review Christoph Hellwig 2 participants 10 messages Mar 12, 2020

lore
Share & tools
lore
#0 lore raw

Hi all,

a bunch of random xfsprogs cleanup for things I found while porting over the attr cleanups.

#1 lore raw

PATCH 1/4 libxfs: turn the xfs_buf_incore stub into an inline function

Replace the macro with an inline function to avoid compiler warnings with new backports of kernel code.

---
 libxfs/libxfs_priv.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
libxfs/libxfs_priv.h +6 -8
index 5d6dd063..17a0104b 100644
@@ -369,14 +369,12 @@ roundup_64(uint64_t x, uint32_t y)
 #define XFS_BUF_UNDELAYWRITE(bp)	((bp)->b_flags &= ~LIBXFS_B_DIRTY)
 #define XFS_BUF_SET_BDSTRAT_FUNC(a,b)	((void) 0)
 
-/* avoid gcc warning */
-#define xfs_buf_incore(bt,blkno,len,lockit) ({		\
-	typeof(blkno) __foo = (blkno);			\
-	typeof(len) __bar = (len);			\
-	(blkno) = __foo;				\
-	(len) = __bar; /* no set-but-unused warning */	\
-	NULL;						\
-})
+static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
+		xfs_daddr_t blkno, size_t numblks, xfs_buf_flags_t flags)
+{
+	return NULL;
+}
+
 #define xfs_buf_oneshot(bp)		((void) 0)
 
 #define XBRW_READ			LIBXFS_BREAD
Signature · 1 line
2.24.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] libxfs: turn the xfs_buf_incore stub into an inline function

Quoted 4 lines · Christoph Hellwig

Replace the macro with an inline function to avoid compiler warnings with new backports of kernel code.

Looks ok,

--D

Quoted 32 lines
---
 libxfs/libxfs_priv.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
libxfs/libxfs_priv.h +6 -8
index 5d6dd063..17a0104b 100644
@@ -369,14 +369,12 @@ roundup_64(uint64_t x, uint32_t y)
 #define XFS_BUF_UNDELAYWRITE(bp)	((bp)->b_flags &= ~LIBXFS_B_DIRTY)
 #define XFS_BUF_SET_BDSTRAT_FUNC(a,b)	((void) 0)
 
-/* avoid gcc warning */
-#define xfs_buf_incore(bt,blkno,len,lockit) ({		\
-	typeof(blkno) __foo = (blkno);			\
-	typeof(len) __bar = (len);			\
-	(blkno) = __foo;				\
-	(len) = __bar; /* no set-but-unused warning */	\
-	NULL;						\
-})
+static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
+		xfs_daddr_t blkno, size_t numblks, xfs_buf_flags_t flags)
+{
+	return NULL;
+}
+
 #define xfs_buf_oneshot(bp)		((void) 0)
 
 #define XBRW_READ			LIBXFS_BREAD
Signature · 1 line
2.24.1
#3 lore raw

PATCH 2/4 libxfs: remove xfs_buf_oneshot

In reply to Christoph Hellwig

This function doesn't exist in the kernel and is purely a stub in xfsprogs, so remove it.

---
 libxfs/libxfs_priv.h | 2 --
 libxfs/xfs_sb.c      | 2 --
 2 files changed, 4 deletions(-)
libxfs/libxfs_priv.h +0 -2
index 17a0104b..723dddcd 100644
@@ -375,8 +375,6 @@ static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 	return NULL;
 }
 
-#define xfs_buf_oneshot(bp)		((void) 0)
-
 #define XBRW_READ			LIBXFS_BREAD
 #define XBRW_WRITE			LIBXFS_BWRITE
 #define xfs_buf_zero(bp,off,len)     libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)
libxfs/xfs_sb.c +0 -2
index 4f750d19..b931fee7 100644
@@ -982,7 +982,6 @@ xfs_update_secondary_sbs(
 		}
 
 		bp->b_ops = &xfs_sb_buf_ops;
-		xfs_buf_oneshot(bp);
 		xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
 		xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
 		xfs_buf_delwri_queue(bp, &buffer_list);
@@ -1170,7 +1169,6 @@ xfs_sb_get_secondary(
 	if (!bp)
 		return -ENOMEM;
 	bp->b_ops = &xfs_sb_buf_ops;
-	xfs_buf_oneshot(bp);
 	*bpp = bp;
 	return 0;
 }
Signature · 1 line
2.24.1
#4 lore raw

Re: [PATCH 2/4] libxfs: remove xfs_buf_oneshot

Quoted 27 lines · Christoph Hellwig

This function doesn't exist in the kernel and is purely a stub in xfsprogs, so remove it.

---
 libxfs/libxfs_priv.h | 2 --
 libxfs/xfs_sb.c      | 2 --
 2 files changed, 4 deletions(-)
libxfs/libxfs_priv.h +0 -2
index 17a0104b..723dddcd 100644
@@ -375,8 +375,6 @@ static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 	return NULL;
 }
 
-#define xfs_buf_oneshot(bp)		((void) 0)
-
 #define XBRW_READ			LIBXFS_BREAD
 #define XBRW_WRITE			LIBXFS_BWRITE
 #define xfs_buf_zero(bp,off,len)     libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)
libxfs/xfs_sb.c +0 -0
index 4f750d19..b931fee7 100644

libxfs/xfs_sb.c xfs_update_secondary_sbs( · line 985

Quoted 4 lines
libxfs/xfs_sb.c +0 -1
@@ -982,7 +982,6 @@ xfs_update_secondary_sbs(
 		}
 
 		bp->b_ops = &xfs_sb_buf_ops;
-		xfs_buf_oneshot(bp);

Removing this will cause xfsprogs' libxfs to fall further out of sync with the kernel's libxfs. Eric and I have been trying to keep that to a minimum.

--D

Quoted 14 lines
libxfs/xfs_sb.c +0 -1
 		xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
 		xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
 		xfs_buf_delwri_queue(bp, &buffer_list);
@@ -1170,7 +1169,6 @@ xfs_sb_get_secondary(
 	if (!bp)
 		return -ENOMEM;
 	bp->b_ops = &xfs_sb_buf_ops;
-	xfs_buf_oneshot(bp);
 	*bpp = bp;
 	return 0;
 }
Signature · 1 line
2.24.1
#5 lore raw

Re: [PATCH 2/4] libxfs: remove xfs_buf_oneshot

Quoted 6 lines · Darrick J. Wong
Quoted 6 lines

index 4f750d19..b931fee7 100644

libxfs/xfs_sb.c +0 -0
@@ -982,7 +982,6 @@ xfs_update_secondary_sbs(
 		}
 
Quoted 6 lines

libxfs/xfs_sb.c xfs_update_secondary_sbs( · line 985

Quoted 2 lines
libxfs/xfs_sb.c +0 -1
 		bp->b_ops = &xfs_sb_buf_ops;
-		xfs_buf_oneshot(bp);

Removing this will cause xfsprogs' libxfs to fall further out of sync with the kernel's libxfs. Eric and I have been trying to keep that to a minimum.

Oops. Somehow I was under the impression that xfs_buf_oneshot didn't exist in the kernel, but in fact it does. Feel free to skip this patch.

#6 lore raw

PATCH 3/4 xfs: remove XFS_BUF_SET_BDSTRAT_FUNC

In reply to Christoph Hellwig

This function doesn't exist in the kernel and is purely a stub in xfsprogs, so remove it.

---
 libxfs/libxfs_priv.h | 1 -
 libxfs/logitem.c     | 1 -
 2 files changed, 2 deletions(-)
libxfs/libxfs_priv.h +0 -1
index 723dddcd..d07d8f32 100644
@@ -367,7 +367,6 @@ roundup_64(uint64_t x, uint32_t y)
 #define XBF_DONE			0
 #define xfs_buf_stale(bp)		((bp)->b_flags |= LIBXFS_B_STALE)
 #define XFS_BUF_UNDELAYWRITE(bp)	((bp)->b_flags &= ~LIBXFS_B_DIRTY)
-#define XFS_BUF_SET_BDSTRAT_FUNC(a,b)	((void) 0)
 
 static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 		xfs_daddr_t blkno, size_t numblks, xfs_buf_flags_t flags)
libxfs/logitem.c +0 -1
index b11df4fa..d0819dcb 100644
@@ -84,7 +84,6 @@ xfs_buf_item_init(
 	 * the first.  If we do already have one, there is
 	 * nothing to do here so return.
 	 */
-	XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
 	if (bp->b_log_item != NULL) {
 		lip = bp->b_log_item;
 		if (lip->li_type == XFS_LI_BUF) {
Signature · 1 line
2.24.1
Reviewed-by on v1 3/4
#7 lore raw

Re: [PATCH 3/4] xfs: remove XFS_BUF_SET_BDSTRAT_FUNC

Quoted 4 lines · Christoph Hellwig

This function doesn't exist in the kernel and is purely a stub in xfsprogs, so remove it.

Looks ok,

--D

Quoted 32 lines
---
 libxfs/libxfs_priv.h | 1 -
 libxfs/logitem.c     | 1 -
 2 files changed, 2 deletions(-)
libxfs/libxfs_priv.h +0 -1
index 723dddcd..d07d8f32 100644
@@ -367,7 +367,6 @@ roundup_64(uint64_t x, uint32_t y)
 #define XBF_DONE			0
 #define xfs_buf_stale(bp)		((bp)->b_flags |= LIBXFS_B_STALE)
 #define XFS_BUF_UNDELAYWRITE(bp)	((bp)->b_flags &= ~LIBXFS_B_DIRTY)
-#define XFS_BUF_SET_BDSTRAT_FUNC(a,b)	((void) 0)
 
 static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 		xfs_daddr_t blkno, size_t numblks, xfs_buf_flags_t flags)
libxfs/logitem.c +0 -1
index b11df4fa..d0819dcb 100644
@@ -84,7 +84,6 @@ xfs_buf_item_init(
 	 * the first.  If we do already have one, there is
 	 * nothing to do here so return.
 	 */
-	XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
 	if (bp->b_log_item != NULL) {
 		lip = bp->b_log_item;
 		if (lip->li_type == XFS_LI_BUF) {
Signature · 1 line
2.24.1
#8 lore raw

PATCH 4/4 libxfs: remove libxfs_iomove

In reply to Christoph Hellwig

This function has been removed in the kernel already. Replace the only user that want to zero buffers with a straight call to memset.

---
 libxfs/libxfs_io.h   |  6 ------
 libxfs/libxfs_priv.h |  5 ++---
 libxfs/rdwr.c        | 24 ------------------------
 3 files changed, 2 insertions(+), 33 deletions(-)
libxfs/libxfs_io.h +0 -6
index a0605882..0f682305 100644
@@ -213,12 +213,6 @@ extern int	libxfs_device_zero(struct xfs_buftarg *, xfs_daddr_t, uint);
 
 extern int libxfs_bhash_size;
 
-#define LIBXFS_BREAD	0x1
-#define LIBXFS_BWRITE	0x2
-#define LIBXFS_BZERO	0x4
-
-extern void	libxfs_iomove (xfs_buf_t *, uint, int, void *, int);
-
 static inline int
 xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
 {
libxfs/libxfs_priv.h +2 -3
index d07d8f32..b5677a22 100644
@@ -374,9 +374,8 @@ static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 	return NULL;
 }
 
-#define XBRW_READ			LIBXFS_BREAD
-#define XBRW_WRITE			LIBXFS_BWRITE
-#define xfs_buf_zero(bp,off,len)     libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)
+#define xfs_buf_zero(bp, off, len) \
+	memset((bp)->b_addr + off, 0, len);
 
 /* mount stuff */
 #define XFS_MOUNT_32BITINODES		LIBXFS_MOUNT_32BITINODES
libxfs/rdwr.c +0 -24
index 7430ff09..6a9895f1 100644
@@ -1009,30 +1009,6 @@ libxfs_buf_mark_dirty(
 	bp->b_flags |= LIBXFS_B_DIRTY;
 }
 
-void
-libxfs_iomove(xfs_buf_t *bp, uint boff, int len, void *data, int flags)
-{
-#ifdef IO_DEBUG
-	if (boff + len > bp->b_bcount) {
-		printf("Badness, iomove out of range!\n"
-			"bp=(bno 0x%llx, bytes %u) range=(boff %u, bytes %u)\n",
-			(long long)bp->b_bn, bp->b_bcount, boff, len);
-		abort();
-	}
-#endif
-	switch (flags) {
-	case LIBXFS_BZERO:
-		memset(bp->b_addr + boff, 0, len);
-		break;
-	case LIBXFS_BREAD:
-		memcpy(data, bp->b_addr + boff, len);
-		break;
-	case LIBXFS_BWRITE:
-		memcpy(bp->b_addr + boff, data, len);
-		break;
-	}
-}
-
 /* Complain about (and remember) dropping dirty buffers. */
 static void
 libxfs_whine_dirty_buf(
Signature · 1 line
2.24.1
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] libxfs: remove libxfs_iomove

Quoted 9 lines · Christoph Hellwig

This function has been removed in the kernel already. Replace the only user that want to zero buffers with a straight call to memset.

---
 libxfs/libxfs_io.h   |  6 ------
 libxfs/libxfs_priv.h |  5 ++---
 libxfs/rdwr.c        | 24 ------------------------
 3 files changed, 2 insertions(+), 33 deletions(-)

woot,

--D

Quoted 72 lines
libxfs/libxfs_io.h +0 -6
index a0605882..0f682305 100644
@@ -213,12 +213,6 @@ extern int	libxfs_device_zero(struct xfs_buftarg *, xfs_daddr_t, uint);
 
 extern int libxfs_bhash_size;
 
-#define LIBXFS_BREAD	0x1
-#define LIBXFS_BWRITE	0x2
-#define LIBXFS_BZERO	0x4
-
-extern void	libxfs_iomove (xfs_buf_t *, uint, int, void *, int);
-
 static inline int
 xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
 {
libxfs/libxfs_priv.h +2 -3
index d07d8f32..b5677a22 100644
@@ -374,9 +374,8 @@ static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target,
 	return NULL;
 }
 
-#define XBRW_READ			LIBXFS_BREAD
-#define XBRW_WRITE			LIBXFS_BWRITE
-#define xfs_buf_zero(bp,off,len)     libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)
+#define xfs_buf_zero(bp, off, len) \
+	memset((bp)->b_addr + off, 0, len);
 
 /* mount stuff */
 #define XFS_MOUNT_32BITINODES		LIBXFS_MOUNT_32BITINODES
libxfs/rdwr.c +0 -24
index 7430ff09..6a9895f1 100644
@@ -1009,30 +1009,6 @@ libxfs_buf_mark_dirty(
 	bp->b_flags |= LIBXFS_B_DIRTY;
 }
 
-void
-libxfs_iomove(xfs_buf_t *bp, uint boff, int len, void *data, int flags)
-{
-#ifdef IO_DEBUG
-	if (boff + len > bp->b_bcount) {
-		printf("Badness, iomove out of range!\n"
-			"bp=(bno 0x%llx, bytes %u) range=(boff %u, bytes %u)\n",
-			(long long)bp->b_bn, bp->b_bcount, boff, len);
-		abort();
-	}
-#endif
-	switch (flags) {
-	case LIBXFS_BZERO:
-		memset(bp->b_addr + boff, 0, len);
-		break;
-	case LIBXFS_BREAD:
-		memcpy(data, bp->b_addr + boff, len);
-		break;
-	case LIBXFS_BWRITE:
-		memcpy(bp->b_addr + boff, data, len);
-		break;
-	}
-}
-
 /* Complain about (and remember) dropping dirty buffers. */
 static void
 libxfs_whine_dirty_buf(
Signature · 1 line
2.24.1