Skip to contentSkip to conversation

Remove a few macros

PATCH Superseded Carlos Maiolino 3 participants 13 messages Mar 6, 2018 – Mar 14, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Remove a few macros

For a while, these macros have been removed from kernel, removing them from xfsprogs brings the code closer to kernel code, and is a first step on such process.

I tried to get rid of such macros as more segmented as possible (1 macro per patch), although, last to patches are good candidates to be merged together, but I believe it's just cleaner to have them as separated patches

Carlos Maiolino (4):
Get rid of XFS_BUF_PTR() macro
Get rid of XFS_BUF_TARGET() macro
get rid of XFS_BUF_COUNT() macro
Get rid of XFS_BUF_SET_COUNT() macro

 libxfs/libxfs_io.h        |  6 +-----
 libxfs/logitem.c          |  2 +-
 libxfs/rdwr.c             |  6 +++---
 libxfs/trans.c            |  2 +-
 libxlog/xfs_log_recover.c |  2 +-
 logprint/log_print_all.c  |  4 ++--
 mkfs/proto.c              |  8 ++++----
 mkfs/xfs_mkfs.c           | 14 +++++++-------
 repair/agheader.c         |  6 +++---
 repair/attr_repair.c      |  4 ++--
 repair/dino_chunks.c      |  2 +-
 repair/phase6.c           |  4 ++--
 repair/prefetch.c         |  4 ++--
 13 files changed, 30 insertions(+), 34 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/4 Get rid of XFS_BUF_PTR() macro

---
 libxfs/libxfs_io.h       |  1 -
 libxfs/rdwr.c            |  6 +++---
 logprint/log_print_all.c |  4 ++--
 mkfs/proto.c             |  4 ++--
 mkfs/xfs_mkfs.c          | 14 +++++++-------
 repair/agheader.c        |  6 +++---
 repair/phase6.c          |  4 ++--
 repair/prefetch.c        |  2 +-
 8 files changed, 20 insertions(+), 21 deletions(-)
libxfs/libxfs_io.h +0 -1
index 6308a742..a1c62071 100644
@@ -97,7 +97,6 @@ enum xfs_buf_flags_t {	/* b_flags bits */
 
 #define XFS_BUF_DADDR_NULL		((xfs_daddr_t) (-1LL))
 
-#define XFS_BUF_PTR(bp)			((char *)(bp)->b_addr)
 #define xfs_buf_offset(bp, offset)	((bp)->b_addr + (offset))
 #define XFS_BUF_ADDR(bp)		((bp)->b_bn)
 #define XFS_BUF_SIZE(bp)		((bp)->b_bcount)
libxfs/rdwr.c +3 -3
index 3c5def29..7c633106 100644
@@ -143,7 +143,7 @@ static char *next(
 	struct xfs_buf	*buf = (struct xfs_buf *)private;
 
 	if (buf &&
-	    (XFS_BUF_COUNT(buf) < (int)(ptr - XFS_BUF_PTR(buf)) + offset))
+	    (XFS_BUF_COUNT(buf) < (int)(ptr - (char *)buf->b_addr) + offset))
 		abort();
 
 	return ptr + offset;
@@ -204,7 +204,7 @@ libxfs_log_clear(
 	ptr = dptr;
 	if (btp) {
 		bp = libxfs_getbufr(btp, start, len);
-		ptr = XFS_BUF_PTR(bp);
+		ptr = bp->b_addr;
 	}
 	libxfs_log_header(ptr, fs_uuid, version, sunit, fmt, lsn, tail_lsn,
 			  next, bp);
@@ -252,7 +252,7 @@ libxfs_log_clear(
 		ptr = dptr;
 		if (btp) {
 			bp = libxfs_getbufr(btp, blk, len);
-			ptr = XFS_BUF_PTR(bp);
+			ptr = bp->b_addr;
 		}
 		/*
 		 * Note: pass the full buffer length as the sunit to initialize
logprint/log_print_all.c +2 -2
index cdaf77bf..aa5bcea0 100644
@@ -39,10 +39,10 @@ xlog_print_find_oldest(
 	first_blk = 0;		/* read first block */
 	bp = xlog_get_bp(log, 1);
 	xlog_bread_noalign(log, 0, 1, bp);
-	first_half_cycle = xlog_get_cycle(XFS_BUF_PTR(bp));
+	first_half_cycle = xlog_get_cycle(bp->b_addr);
 	*last_blk = log->l_logBBsize-1;	/* read last block */
 	xlog_bread_noalign(log, *last_blk, 1, bp);
-	last_half_cycle = xlog_get_cycle(XFS_BUF_PTR(bp));
+	last_half_cycle = xlog_get_cycle(bp->b_addr);
 	ASSERT(last_half_cycle != 0);
 
 	if (first_half_cycle == last_half_cycle) /* all cycle nos are same */
mkfs/proto.c +2 -2
index bc383458..a0a833d0 100644
@@ -275,9 +275,9 @@ newfile(
 		d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
 		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
-		memmove(XFS_BUF_PTR(bp), buf, len);
+		memmove(bp->b_addr, buf, len);
 		if (len < XFS_BUF_COUNT(bp))
-			memset(XFS_BUF_PTR(bp) + len, 0, XFS_BUF_COUNT(bp) - len);
+			memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);
 		if (logit)
 			libxfs_trans_log_buf(tp, bp, 0, XFS_BUF_COUNT(bp) - 1);
 		else
mkfs/xfs_mkfs.c +7 -7
index f973b6bc..6be09059 100644
@@ -3299,7 +3299,7 @@ prepare_devices(
 	 */
 	buf = libxfs_getbuf(mp->m_ddev_targp, (xi->dsize - whack_blks),
 			    whack_blks);
-	memset(XFS_BUF_PTR(buf), 0, WHACK_SIZE);
+	memset(buf->b_addr, 0, WHACK_SIZE);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	libxfs_purgebuf(buf);
 
@@ -3310,15 +3310,15 @@ prepare_devices(
 	 * ext[2,3] and reiserfs (64k) - and hopefully all else.
 	 */
 	buf = libxfs_getbuf(mp->m_ddev_targp, 0, whack_blks);
-	memset(XFS_BUF_PTR(buf), 0, WHACK_SIZE);
+	memset(buf->b_addr, 0, WHACK_SIZE);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	libxfs_purgebuf(buf);
 
 	/* OK, now write the superblock... */
 	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	libxfs_purgebuf(buf);
 
@@ -3338,7 +3338,7 @@ prepare_devices(
 		buf = libxfs_getbuf(mp->m_rtdev_targp,
 				    XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
 				    BTOBB(cfg->blocksize));
-		memset(XFS_BUF_PTR(buf), 0, cfg->blocksize);
+		memset(buf->b_addr, 0, cfg->blocksize);
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 		libxfs_purgebuf(buf);
 	}
@@ -3382,8 +3382,8 @@ initialise_ag_headers(
 			XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 			XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 	/*
repair/agheader.c +3 -3
index cce376f2..df3c3fe3 100644
@@ -290,8 +290,8 @@ secondary_sb_whack(
 			+ sizeof(sb->sb_dirblklog);
 
 	/* Check the buffer we read from disk for garbage outside size */
-	for (ip = XFS_BUF_PTR(sbuf) + size;
-	     ip < XFS_BUF_PTR(sbuf) + mp->m_sb.sb_sectsize;
+	for (ip = sbuf->b_addr + size;
+	     ip < (char *)sbuf->b_addr + mp->m_sb.sb_sectsize;
 	     ip++)  {
 		if (*ip)  {
 			do_bzero = 1;
@@ -314,7 +314,7 @@ secondary_sb_whack(
 			memcpy(&tmpuuid, &sb->sb_meta_uuid, sizeof(uuid_t));
 			memset((void *)((intptr_t)sb + size), 0,
 				mp->m_sb.sb_sectsize - size);
-			memset(XFS_BUF_PTR(sbuf) + size, 0,
+			memset(sbuf->b_addr + size, 0,
 				mp->m_sb.sb_sectsize - size);
 			/* Preserve meta_uuid so we don't fail uuid checks */
 			memcpy(&sb->sb_meta_uuid, &tmpuuid, sizeof(uuid_t));
repair/phase6.c +2 -2
index 1a398aa1..65d2fd9e 100644
@@ -632,7 +632,7 @@ _("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime bitmap inode %
 			return(1);
 		}
 
-		memmove(XFS_BUF_PTR(bp), bmp, mp->m_sb.sb_blocksize);
+		memmove(bp->b_addr, bmp, mp->m_sb.sb_blocksize);
 
 		libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
 
@@ -704,7 +704,7 @@ _("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime summary inode
 			return(1);
 		}
 
-		memmove(XFS_BUF_PTR(bp), smp, mp->m_sb.sb_blocksize);
+		memmove(bp->b_addr, smp, mp->m_sb.sb_blocksize);
 
 		libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
 
repair/prefetch.c +1 -1
index 9c68e35c..0783d225 100644
@@ -591,7 +591,7 @@ pf_batch_read(
 				size = XFS_BUF_SIZE(bplist[i]);
 				if (len < size)
 					break;
-				memcpy(XFS_BUF_PTR(bplist[i]), pbuf, size);
+				memcpy(bplist[i]->b_addr, pbuf, size);
 				bplist[i]->b_flags |= (LIBXFS_B_UPTODATE |
 						       LIBXFS_B_UNCHECKED);
 				len -= size;
Signature · 1 line
2.14.3
#2 lore raw

Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro

Quoted 1 line · Carlos Maiolino

.....

mkfs/proto.c newfile( · line 280

Quoted 9 lines
mkfs/proto.c +2 -2
@@ -275,9 +275,9 @@ newfile(
 		d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
 		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
-		memmove(XFS_BUF_PTR(bp), buf, len);
+		memmove(bp->b_addr, buf, len);
 		if (len < XFS_BUF_COUNT(bp))
-			memset(XFS_BUF_PTR(bp) + len, 0, XFS_BUF_COUNT(bp) - len);
+			memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);

Bug there. pointer arithmetic changed, needs (char *) cast.

mkfs/xfs_mkfs.c prepare_devices( · line 3321

Quoted 7 lines
mkfs/xfs_mkfs.c +2 -2
 	/* OK, now write the superblock... */
 	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);

Kill the cast - b_addr is already a void *

mkfs/xfs_mkfs.c initialise_ag_headers( · line 3386

Quoted 8 lines
mkfs/xfs_mkfs.c +2 -2
@@ -3382,8 +3382,8 @@ initialise_ag_headers(
 			XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 			XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);

ditto.

repair/agheader.c secondary_sb_whack( · line 294

Quoted 9 lines
repair/agheader.c +3 -2
+++ b/repair/agheader.c
@@ -290,8 +290,8 @@ secondary_sb_whack(
 			+ sizeof(sb->sb_dirblklog);
 
 	/* Check the buffer we read from disk for garbage outside size */
-	for (ip = XFS_BUF_PTR(sbuf) + size;
-	     ip < XFS_BUF_PTR(sbuf) + mp->m_sb.sb_sectsize;
+	for (ip = sbuf->b_addr + size;
+	     ip < (char *)sbuf->b_addr + mp->m_sb.sb_sectsize;

Looks like another pointer math bug there...

repair/agheader.c secondary_sb_whack( · line 317

Quoted 9 lines
repair/agheader.c +1 -1
 	     ip++)  {
 		if (*ip)  {
 			do_bzero = 1;
@@ -314,7 +314,7 @@ secondary_sb_whack(
 			memcpy(&tmpuuid, &sb->sb_meta_uuid, sizeof(uuid_t));
 			memset((void *)((intptr_t)sb + size), 0,
 				mp->m_sb.sb_sectsize - size);
-			memset(XFS_BUF_PTR(sbuf) + size, 0,
+			memset(sbuf->b_addr + size, 0,

And another.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro

Quoted 3 lines · Dave Chinner
Quoted 1 line · Carlos Maiolino

.....

D'oh, I thought I paid attention to the casting, typed git-send too quick, I'll review it and submit again.

Quoted 63 lines

mkfs/proto.c newfile( · line 280

Quoted 9 lines
mkfs/proto.c +2 -2
@@ -275,9 +275,9 @@ newfile(
 		d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
 		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
-		memmove(XFS_BUF_PTR(bp), buf, len);
+		memmove(bp->b_addr, buf, len);
 		if (len < XFS_BUF_COUNT(bp))
-			memset(XFS_BUF_PTR(bp) + len, 0, XFS_BUF_COUNT(bp) - len);
+			memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);

Bug there. pointer arithmetic changed, needs (char *) cast.

mkfs/xfs_mkfs.c prepare_devices( · line 3321

Quoted 7 lines
mkfs/xfs_mkfs.c +2 -2
 	/* OK, now write the superblock... */
 	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);

Kill the cast - b_addr is already a void *

mkfs/xfs_mkfs.c initialise_ag_headers( · line 3386

Quoted 8 lines
mkfs/xfs_mkfs.c +2 -2
@@ -3382,8 +3382,8 @@ initialise_ag_headers(
 			XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 			XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
-	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
+	memset(buf->b_addr, 0, cfg->sectorsize);
+	libxfs_sb_to_disk((void *)buf->b_addr, sbp);

ditto.

repair/agheader.c secondary_sb_whack( · line 294

Quoted 9 lines
repair/agheader.c +3 -2
+++ b/repair/agheader.c
@@ -290,8 +290,8 @@ secondary_sb_whack(
 			+ sizeof(sb->sb_dirblklog);
 
 	/* Check the buffer we read from disk for garbage outside size */
-	for (ip = XFS_BUF_PTR(sbuf) + size;
-	     ip < XFS_BUF_PTR(sbuf) + mp->m_sb.sb_sectsize;
+	for (ip = sbuf->b_addr + size;
+	     ip < (char *)sbuf->b_addr + mp->m_sb.sb_sectsize;

Looks like another pointer math bug there...

repair/agheader.c secondary_sb_whack( · line 317

Quoted 9 lines
repair/agheader.c +1 -1
 	     ip++)  {
 		if (*ip)  {
 			do_bzero = 1;
@@ -314,7 +314,7 @@ secondary_sb_whack(
 			memcpy(&tmpuuid, &sb->sb_meta_uuid, sizeof(uuid_t));
 			memset((void *)((intptr_t)sb + size), 0,
 				mp->m_sb.sb_sectsize - size);
-			memset(XFS_BUF_PTR(sbuf) + size, 0,
+			memset(sbuf->b_addr + size, 0,

And another.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
Signature · 1 line
Carlos
#4 lore raw

Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro

In reply to Dave Chinner
Quoted 14 lines · Dave Chinner
Quoted 1 line · Carlos Maiolino

.....

mkfs/proto.c newfile( · line 280

Quoted 9 lines
mkfs/proto.c +2 -2
@@ -275,9 +275,9 @@ newfile(
 		d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
 		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
-		memmove(XFS_BUF_PTR(bp), buf, len);
+		memmove(bp->b_addr, buf, len);
 		if (len < XFS_BUF_COUNT(bp))
-			memset(XFS_BUF_PTR(bp) + len, 0, XFS_BUF_COUNT(bp) - len);
+			memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);

Bug there. pointer arithmetic changed, needs (char *) cast.

Not really. In standard C pointer arithmetics on void * isn't even defined, so this won't work. In the GCC dialect it is defined the same as on char *. And I'd much prefer not adding these pointless casts that just confuse everyone.

#5 lore raw

PATCH 2/4 Get rid of XFS_BUF_TARGET() macro

In reply to Carlos Maiolino

This macro is unused

---
 libxfs/libxfs_io.h | 1 -
 1 file changed, 1 deletion(-)
libxfs/libxfs_io.h +0 -1
index a1c62071..04bbc9b7 100644
@@ -101,7 +101,6 @@ enum xfs_buf_flags_t {	/* b_flags bits */
 #define XFS_BUF_ADDR(bp)		((bp)->b_bn)
 #define XFS_BUF_SIZE(bp)		((bp)->b_bcount)
 #define XFS_BUF_COUNT(bp)		((bp)->b_bcount)
-#define XFS_BUF_TARGET(bp)		((bp)->b_dev)
 #define XFS_BUF_SET_PTR(bp,p,cnt)	({	\
 	(bp)->b_addr = (char *)(p);		\
 	XFS_BUF_SET_COUNT(bp,cnt);		\
Signature · 1 line
2.14.3
#7 lore raw

PATCH 3/4 get rid of XFS_BUF_COUNT() macro

In reply to Carlos Maiolino
---
 libxfs/libxfs_io.h   | 1 -
 libxfs/logitem.c     | 2 +-
 libxfs/rdwr.c        | 2 +-
 libxfs/trans.c       | 2 +-
 mkfs/proto.c         | 6 +++---
 repair/attr_repair.c | 4 ++--
 repair/dino_chunks.c | 2 +-
 repair/prefetch.c    | 2 +-
 8 files changed, 10 insertions(+), 11 deletions(-)
libxfs/libxfs_io.h +0 -1
index 04bbc9b7..f429d667 100644
@@ -100,7 +100,6 @@ enum xfs_buf_flags_t {	/* b_flags bits */
 #define xfs_buf_offset(bp, offset)	((bp)->b_addr + (offset))
 #define XFS_BUF_ADDR(bp)		((bp)->b_bn)
 #define XFS_BUF_SIZE(bp)		((bp)->b_bcount)
-#define XFS_BUF_COUNT(bp)		((bp)->b_bcount)
 #define XFS_BUF_SET_PTR(bp,p,cnt)	({	\
 	(bp)->b_addr = (char *)(p);		\
 	XFS_BUF_SET_COUNT(bp,cnt);		\
libxfs/logitem.c +1 -1
index 39ac1923..afe1570c 100644
@@ -120,7 +120,7 @@ xfs_buf_item_init(
 	bip->bli_buf = bp;
 	bip->bli_format.blf_type = XFS_LI_BUF;
 	bip->bli_format.blf_blkno = (int64_t)XFS_BUF_ADDR(bp);
-	bip->bli_format.blf_len = (unsigned short)BTOBB(XFS_BUF_COUNT(bp));
+	bip->bli_format.blf_len = (unsigned short)BTOBB(bp->b_bcount);
 	bp->b_log_item = bip;
 }
 
libxfs/rdwr.c +1 -1
index 7c633106..5077d074 100644
@@ -143,7 +143,7 @@ static char *next(
 	struct xfs_buf	*buf = (struct xfs_buf *)private;
 
 	if (buf &&
-	    (XFS_BUF_COUNT(buf) < (int)(ptr - (char *)buf->b_addr) + offset))
+	    (buf->b_bcount < (int)(ptr - (char *)buf->b_addr) + offset))
 		abort();
 
 	return ptr + offset;
libxfs/trans.c +1 -1
index 0e7b7ae0..3e80e0cb 100644
@@ -402,7 +402,7 @@ libxfs_trans_log_buf(
 {
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
-	ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp)));
+	ASSERT((first <= last) && (last < bp->b_bcount));
 
 	xfs_trans_dirty_buf(tp, bp);
 	xfs_buf_item_log(bip, first, last);
mkfs/proto.c +3 -3
index a0a833d0..66b8115f 100644
@@ -276,10 +276,10 @@ newfile(
 		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
 		memmove(bp->b_addr, buf, len);
-		if (len < XFS_BUF_COUNT(bp))
-			memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);
+		if (len < bp->b_bcount)
+			memset(bp->b_addr + len, 0, bp->b_bcount - len);
 		if (logit)
-			libxfs_trans_log_buf(tp, bp, 0, XFS_BUF_COUNT(bp) - 1);
+			libxfs_trans_log_buf(tp, bp, 0, bp->b_bcount - 1);
 		else
 			libxfs_writebuf(bp, LIBXFS_EXIT_ON_FAILURE);
 	}
repair/attr_repair.c +2 -2
index 8b1b8a75..39569ebe 100644
@@ -437,9 +437,9 @@ rmtval_get(xfs_mount_t *mp, xfs_ino_t ino, blkmap_t *blkmap,
 			break;
 		}
 
-		ASSERT(mp->m_sb.sb_blocksize == XFS_BUF_COUNT(bp));
+		ASSERT(mp->m_sb.sb_blocksize == bp->b_bcount);
 
-		length = MIN(XFS_BUF_COUNT(bp) - hdrsize, valuelen - amountdone);
+		length = MIN(bp->b_bcount - hdrsize, valuelen - amountdone);
 		memmove(value, bp->b_addr + hdrsize, length);
 		amountdone += length;
 		value += length;
repair/dino_chunks.c +1 -1
index 17de95f5..1c7f9c8d 100644
@@ -689,7 +689,7 @@ process_inode_chunk(
 
 		pftrace("readbuf %p (%llu, %d) in AG %d", bplist[bp_index],
 			(long long)XFS_BUF_ADDR(bplist[bp_index]),
-			XFS_BUF_COUNT(bplist[bp_index]), agno);
+			bplist[bp_index]->b_bcount, agno);
 
 		bplist[bp_index]->b_ops = &xfs_inode_buf_ops;
 
repair/prefetch.c +1 -1
index 0783d225..ff40d18d 100644
@@ -403,7 +403,7 @@ pf_read_inode_dirs(
 	if (bp->b_error)
 		return;
 
-	for (icnt = 0; icnt < (XFS_BUF_COUNT(bp) >> mp->m_sb.sb_inodelog); icnt++) {
+	for (icnt = 0; icnt < (bp->b_bcount >> mp->m_sb.sb_inodelog); icnt++) {
 		dino = xfs_make_iptr(mp, bp, icnt);
 
 		/*
Signature · 1 line
2.14.3
#9 lore raw

PATCH 4/4 Get rid of XFS_BUF_SET_COUNT() macro

In reply to Carlos Maiolino
---
 libxfs/libxfs_io.h        | 3 +--
 libxlog/xfs_log_recover.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
libxfs/libxfs_io.h +1 -2
index f429d667..8bf1b57e 100644
@@ -102,11 +102,10 @@ enum xfs_buf_flags_t {	/* b_flags bits */
 #define XFS_BUF_SIZE(bp)		((bp)->b_bcount)
 #define XFS_BUF_SET_PTR(bp,p,cnt)	({	\
 	(bp)->b_addr = (char *)(p);		\
-	XFS_BUF_SET_COUNT(bp,cnt);		\
+	(bp)->b_bcount = (cnt);		\
 })
 
 #define XFS_BUF_SET_ADDR(bp,blk)	((bp)->b_bn = (blk))
-#define XFS_BUF_SET_COUNT(bp,cnt)	((bp)->b_bcount = (cnt))
 
 #define XFS_BUF_SET_PRIORITY(bp,pri)	cache_node_set_priority( \
 						libxfs_bcache, \
libxlog/xfs_log_recover.c +1 -1
index 6bd000c0..68989930 100644
@@ -131,7 +131,7 @@ xlog_bread_noalign(
 	ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp));
 
 	XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no);
-	XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
+	bp->b_bcount = BBTOB(nbblks);
 	bp->b_error = 0;
 
 	return libxfs_readbufr(log->l_dev, XFS_BUF_ADDR(bp), bp, nbblks, 0);
Signature · 1 line
2.14.3
#10 lore raw

Re: [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro

Looks good, although it conflicts with Erics patches..

#11 lore raw

Re: [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro

Quoted 1 line · Christoph Hellwig

Looks good, although it conflicts with Erics patches..

Thanks, I didn't try to rebase it over Eric's patches before sending it, I can do a rebase over his patches and send the new version quickly. At least as soon as we define if we should use the castings or not :)

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Carlos
#12 lore raw
In reply to Carlos Maiolino

Hi,

Quoted 8 lines · Carlos Maiolino

For a while, these macros have been removed from kernel, removing them from xfsprogs brings the code closer to kernel code, and is a first step on such process.

I tried to get rid of such macros as more segmented as possible (1 macro per patch), although, last to patches are good candidates to be merged together, but I believe it's just cleaner to have them as separated patches

Quoted 6 lines

Carlos Maiolino (4):
Get rid of XFS_BUF_PTR() macro
Get rid of XFS_BUF_TARGET() macro
get rid of XFS_BUF_COUNT() macro
Get rid of XFS_BUF_SET_COUNT() macro

Any updates, if I should rebase this patchset over Eric's patches and resend it, or if I should rework something else?

I've sent a V2 changing the casts according to Dave's suggestions, and hch preferred this version, due how GCC handles pointers calculation.

Is there anything else I should change, or can I just rebase it against Eric's patches and resend this version?

Cheers

Quoted 7 lines
Signature · 6 lines
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos