* [PATCH 0/4] Remove a few macros
@ 2018-03-06 13:00 Carlos Maiolino
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-06 13:00 UTC (permalink / raw)
To: linux-xfs
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(-)
--
2.14.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] Get rid of XFS_BUF_PTR() macro
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
@ 2018-03-06 13:00 ` Carlos Maiolino
2018-03-06 22:22 ` Dave Chinner
2018-03-06 13:00 ` [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro Carlos Maiolino
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-06 13:00 UTC (permalink / raw)
To: linux-xfs
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
libxfs/libxfs_io.h | 1 -
libxfs/rdwr.c | 6 +++---
logprint/log_print_all.c | 4 ++--
mkfs/proto.c | 4 ++--
mkfs/xfs_mkfs.c | 14 +++++++-------
| 6 +++---
repair/phase6.c | 4 ++--
repair/prefetch.c | 2 +-
8 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 6308a742..a1c62071 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -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)
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 3c5def29..7c633106 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -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
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index cdaf77bf..aa5bcea0 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -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 */
diff --git a/mkfs/proto.c b/mkfs/proto.c
index bc383458..a0a833d0 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -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
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index f973b6bc..6be09059 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -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);
/*
--git a/repair/agheader.c b/repair/agheader.c
index cce376f2..df3c3fe3 100644
--- a/repair/agheader.c
+++ 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;
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));
diff --git a/repair/phase6.c b/repair/phase6.c
index 1a398aa1..65d2fd9e 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -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);
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 9c68e35c..0783d225 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -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;
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
@ 2018-03-06 13:00 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 3/4] get rid of XFS_BUF_COUNT() macro Carlos Maiolino
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-06 13:00 UTC (permalink / raw)
To: linux-xfs
This macro is unused
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
libxfs/libxfs_io.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index a1c62071..04bbc9b7 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -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); \
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/4] get rid of XFS_BUF_COUNT() macro
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
2018-03-06 13:00 ` [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro Carlos Maiolino
@ 2018-03-06 13:00 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
2018-03-14 13:05 ` [PATCH 0/4] Remove a few macros Carlos Maiolino
4 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-06 13:00 UTC (permalink / raw)
To: linux-xfs
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
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(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 04bbc9b7..f429d667 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -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); \
diff --git a/libxfs/logitem.c b/libxfs/logitem.c
index 39ac1923..afe1570c 100644
--- a/libxfs/logitem.c
+++ b/libxfs/logitem.c
@@ -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;
}
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 7c633106..5077d074 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -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;
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 0e7b7ae0..3e80e0cb 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -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);
diff --git a/mkfs/proto.c b/mkfs/proto.c
index a0a833d0..66b8115f 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -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);
}
diff --git a/repair/attr_repair.c b/repair/attr_repair.c
index 8b1b8a75..39569ebe 100644
--- a/repair/attr_repair.c
+++ b/repair/attr_repair.c
@@ -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;
diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c
index 17de95f5..1c7f9c8d 100644
--- a/repair/dino_chunks.c
+++ b/repair/dino_chunks.c
@@ -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;
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 0783d225..ff40d18d 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -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);
/*
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
` (2 preceding siblings ...)
2018-03-06 13:00 ` [PATCH 3/4] get rid of XFS_BUF_COUNT() macro Carlos Maiolino
@ 2018-03-06 13:00 ` Carlos Maiolino
2018-03-08 8:16 ` Christoph Hellwig
2018-03-14 13:05 ` [PATCH 0/4] Remove a few macros Carlos Maiolino
4 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-06 13:00 UTC (permalink / raw)
To: linux-xfs
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
libxfs/libxfs_io.h | 3 +--
libxlog/xfs_log_recover.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index f429d667..8bf1b57e 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -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, \
diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c
index 6bd000c0..68989930 100644
--- a/libxlog/xfs_log_recover.c
+++ b/libxlog/xfs_log_recover.c
@@ -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);
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
@ 2018-03-06 22:22 ` Dave Chinner
2018-03-07 6:12 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
0 siblings, 2 replies; 14+ messages in thread
From: Dave Chinner @ 2018-03-06 22:22 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
On Tue, Mar 06, 2018 at 02:00:50PM +0100, Carlos Maiolino wrote:
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
.....
> @@ -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.
> /* 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 *
> @@ -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.
> +++ 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...
> 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.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro
2018-03-06 22:22 ` Dave Chinner
@ 2018-03-07 6:12 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
1 sibling, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-07 6:12 UTC (permalink / raw)
To: Dave Chinner; +Cc: linux-xfs
On Wed, Mar 07, 2018 at 09:22:10AM +1100, Dave Chinner wrote:
> On Tue, Mar 06, 2018 at 02:00:50PM +0100, Carlos Maiolino wrote:
> > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> .....
D'oh, I thought I paid attention to the casting, typed git-send too quick, I'll
review it and submit again.
> > @@ -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.
>
> > /* 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 *
>
> > @@ -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.
>
> > +++ 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...
>
> > 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.
> --
> Dave Chinner
> david@fromorbit.com
--
Carlos
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro
2018-03-06 22:22 ` Dave Chinner
2018-03-07 6:12 ` Carlos Maiolino
@ 2018-03-08 8:15 ` Christoph Hellwig
1 sibling, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2018-03-08 8:15 UTC (permalink / raw)
To: Dave Chinner; +Cc: Carlos Maiolino, linux-xfs
On Wed, Mar 07, 2018 at 09:22:10AM +1100, Dave Chinner wrote:
> On Tue, Mar 06, 2018 at 02:00:50PM +0100, Carlos Maiolino wrote:
> > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> .....
> > @@ -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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro
2018-03-06 13:00 ` [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro Carlos Maiolino
@ 2018-03-08 8:15 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2018-03-08 8:15 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/4] get rid of XFS_BUF_COUNT() macro
2018-03-06 13:00 ` [PATCH 3/4] get rid of XFS_BUF_COUNT() macro Carlos Maiolino
@ 2018-03-08 8:15 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2018-03-08 8:15 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro
2018-03-06 13:00 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
@ 2018-03-08 8:16 ` Christoph Hellwig
2018-03-08 13:23 ` Carlos Maiolino
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2018-03-08 8:16 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Looks good, although it conflicts with Erics patches..
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro
2018-03-08 8:16 ` Christoph Hellwig
@ 2018-03-08 13:23 ` Carlos Maiolino
0 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-08 13:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-xfs
On Thu, Mar 08, 2018 at 12:16:15AM -0800, Christoph Hellwig wrote:
> 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 :)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Carlos
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/4] Remove a few macros
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
` (3 preceding siblings ...)
2018-03-06 13:00 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
@ 2018-03-14 13:05 ` Carlos Maiolino
4 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-14 13:05 UTC (permalink / raw)
To: linux-xfs
Hi,
On Tue, Mar 06, 2018 at 02:00:49PM +0100, Carlos Maiolino wrote:
> 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
>
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
> --
> 2.14.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Carlos
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro
2018-03-07 9:05 [PATCH 0/4 V2] " Carlos Maiolino
@ 2018-03-07 9:05 ` Carlos Maiolino
0 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2018-03-07 9:05 UTC (permalink / raw)
To: linux-xfs
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
V2:
Fix indentation
libxfs/libxfs_io.h | 3 +--
libxlog/xfs_log_recover.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index f429d667..78c29445 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -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, \
diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c
index 6bd000c0..68989930 100644
--- a/libxlog/xfs_log_recover.c
+++ b/libxlog/xfs_log_recover.c
@@ -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);
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-03-14 13:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
2018-03-06 22:22 ` Dave Chinner
2018-03-07 6:12 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 3/4] get rid of XFS_BUF_COUNT() macro Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
2018-03-08 8:16 ` Christoph Hellwig
2018-03-08 13:23 ` Carlos Maiolino
2018-03-14 13:05 ` [PATCH 0/4] Remove a few macros Carlos Maiolino
2018-03-07 9:05 [PATCH 0/4 V2] " Carlos Maiolino
2018-03-07 9:05 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.