* [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage()
@ 2025-06-05 17:56 Suchit Karunakaran
2025-07-11 20:10 ` Dave Kleikamp
0 siblings, 1 reply; 4+ messages in thread
From: Suchit Karunakaran @ 2025-06-05 17:56 UTC (permalink / raw)
To: shaggy, jfs-discussion
Cc: linux-kernel-mentees, linux-kernel, skhan, Suchit Karunakaran
Replace legacy XT_GETPAGE macro with an inline function that returns a
xtpage_t pointer and update all instances of XT_GETPAGE in jfs_xtree.c
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
---
fs/jfs/jfs_xtree.c | 87 ++++++++++++++++++++++++++++------------------
1 file changed, 53 insertions(+), 34 deletions(-)
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 5ee618d17e77..5b8b7819cf29 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -49,26 +49,6 @@
#define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot)
-/* get page buffer for specified block address */
-/* ToDo: Replace this ugly macro with a function */
-#define XT_GETPAGE(IP, BN, MP, SIZE, P, RC) \
-do { \
- BT_GETPAGE(IP, BN, MP, xtpage_t, SIZE, P, RC, i_xtroot); \
- if (!(RC)) { \
- if ((le16_to_cpu((P)->header.nextindex) < XTENTRYSTART) || \
- (le16_to_cpu((P)->header.nextindex) > \
- le16_to_cpu((P)->header.maxentry)) || \
- (le16_to_cpu((P)->header.maxentry) > \
- (((BN) == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) { \
- jfs_error((IP)->i_sb, \
- "XT_GETPAGE: xtree page corrupt\n"); \
- BT_PUTPAGE(MP); \
- MP = NULL; \
- RC = -EIO; \
- } \
- } \
-} while (0)
-
/* for consistency */
#define XT_PUTPAGE(MP) BT_PUTPAGE(MP)
@@ -114,6 +94,45 @@ static int xtSplitPage(tid_t tid, struct inode *ip, struct xtsplit * split,
static int xtSplitRoot(tid_t tid, struct inode *ip,
struct xtsplit * split, struct metapage ** rmpp);
+/*
+ * xt_getpage()
+ *
+ * function: get the page buffer for a specified block address.
+ *
+ * parameters:
+ * ip - pointer to the inode
+ * bn - block number (s64) of the xtree page to be retrieved;
+ * mp - pointer to a metapage pointer where the page buffer is returned;
+ * size - size parameter to pass to BT_GETPAGE;
+ * rc - pointer to an integer to store the return code;
+ *
+ * returns:
+ * A pointer to the xtree page (xtpage_t) on success. If an error occurs,
+ * sets rc to -EIO, releases the page buffer, sets mp to NULL and returns NULL.
+ */
+
+static inline xtpage_t *xt_getpage(struct inode *ip, s64 bn, struct metapage **mp,
+ unsigned int size, int *rc)
+{
+ xtpage_t *p;
+
+ BT_GETPAGE(ip, bn, *mp, xtpage_t, size, p, *rc, i_xtroot);
+
+ if (!(*rc)) {
+ if ((le16_to_cpu(p->header.nextindex) < XTENTRYSTART) ||
+ (le16_to_cpu(p->header.nextindex) >
+ le16_to_cpu(p->header.maxentry)) ||
+ (le16_to_cpu(p->header.maxentry) >
+ ((bn == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) {
+ jfs_error(ip->i_sb, "xt_getpage: xtree page corrupt\n");
+ BT_PUTPAGE(*mp);
+ *mp = NULL;
+ *rc = -EIO;
+ }
+ }
+ return p;
+}
+
/*
* xtLookup()
*
@@ -252,7 +271,7 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
*/
for (bn = 0;;) {
/* get/pin the page to search */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -807,7 +826,7 @@ xtSplitUp(tid_t tid,
* insert router entry in parent for new right child page <rp>
*/
/* get/pin the parent page <sp> */
- XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc);
+ sp = xt_getpage(ip, parent->bn, &smp, PSIZE, &rc);
if (rc) {
XT_PUTPAGE(rcmp);
return rc;
@@ -1062,7 +1081,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
* update previous pointer of old next/right page of <sp>
*/
if (nextbn != 0) {
- XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, nextbn, &mp, PSIZE, &rc);
if (rc) {
XT_PUTPAGE(rmp);
goto clean_up;
@@ -1417,7 +1436,7 @@ int xtExtend(tid_t tid, /* transaction id */
return rc;
/* get back old page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
/*
@@ -1433,7 +1452,7 @@ int xtExtend(tid_t tid, /* transaction id */
XT_PUTPAGE(mp);
/* get new child page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -1711,7 +1730,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
return rc;
/* get back old page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
/*
@@ -1727,7 +1746,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
XT_PUTPAGE(mp);
/* get new child page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -1788,7 +1807,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
XT_PUTPAGE(mp);
/* get new right page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -1864,7 +1883,7 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
return rc;
/* get back old page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -1881,7 +1900,7 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
XT_PUTPAGE(mp);
/* get new child page */
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -2268,7 +2287,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
* first access of each page:
*/
getPage:
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -2506,7 +2525,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
/* get back the parent page */
bn = parent->bn;
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -2791,7 +2810,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
* first access of each page:
*/
getPage:
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
@@ -2836,7 +2855,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
/* get back the parent page */
bn = parent->bn;
- XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+ p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
if (rc)
return rc;
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage()
2025-06-05 17:56 [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage() Suchit Karunakaran
@ 2025-07-11 20:10 ` Dave Kleikamp
2025-07-13 7:24 ` Suchit K
0 siblings, 1 reply; 4+ messages in thread
From: Dave Kleikamp @ 2025-07-11 20:10 UTC (permalink / raw)
To: Suchit Karunakaran, jfs-discussion
Cc: linux-kernel-mentees, linux-kernel, skhan
On 6/5/25 12:56PM, Suchit Karunakaran wrote:
> Replace legacy XT_GETPAGE macro with an inline function that returns a
> xtpage_t pointer and update all instances of XT_GETPAGE in jfs_xtree.c
I'm picking this up, but I simplified it a bit. I dropped the size and
rc arguments. size is always passed in as PSIZE and I have the function
return ERR_PTR(-EIO) on error.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
> ---
> fs/jfs/jfs_xtree.c | 87 ++++++++++++++++++++++++++++------------------
> 1 file changed, 53 insertions(+), 34 deletions(-)
>
> diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
> index 5ee618d17e77..5b8b7819cf29 100644
> --- a/fs/jfs/jfs_xtree.c
> +++ b/fs/jfs/jfs_xtree.c
> @@ -49,26 +49,6 @@
>
> #define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot)
>
> -/* get page buffer for specified block address */
> -/* ToDo: Replace this ugly macro with a function */
> -#define XT_GETPAGE(IP, BN, MP, SIZE, P, RC) \
> -do { \
> - BT_GETPAGE(IP, BN, MP, xtpage_t, SIZE, P, RC, i_xtroot); \
> - if (!(RC)) { \
> - if ((le16_to_cpu((P)->header.nextindex) < XTENTRYSTART) || \
> - (le16_to_cpu((P)->header.nextindex) > \
> - le16_to_cpu((P)->header.maxentry)) || \
> - (le16_to_cpu((P)->header.maxentry) > \
> - (((BN) == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) { \
> - jfs_error((IP)->i_sb, \
> - "XT_GETPAGE: xtree page corrupt\n"); \
> - BT_PUTPAGE(MP); \
> - MP = NULL; \
> - RC = -EIO; \
> - } \
> - } \
> -} while (0)
> -
> /* for consistency */
> #define XT_PUTPAGE(MP) BT_PUTPAGE(MP)
>
> @@ -114,6 +94,45 @@ static int xtSplitPage(tid_t tid, struct inode *ip, struct xtsplit * split,
> static int xtSplitRoot(tid_t tid, struct inode *ip,
> struct xtsplit * split, struct metapage ** rmpp);
>
> +/*
> + * xt_getpage()
> + *
> + * function: get the page buffer for a specified block address.
> + *
> + * parameters:
> + * ip - pointer to the inode
> + * bn - block number (s64) of the xtree page to be retrieved;
> + * mp - pointer to a metapage pointer where the page buffer is returned;
> + * size - size parameter to pass to BT_GETPAGE;
> + * rc - pointer to an integer to store the return code;
> + *
> + * returns:
> + * A pointer to the xtree page (xtpage_t) on success. If an error occurs,
> + * sets rc to -EIO, releases the page buffer, sets mp to NULL and returns NULL.
> + */
> +
> +static inline xtpage_t *xt_getpage(struct inode *ip, s64 bn, struct metapage **mp,
> + unsigned int size, int *rc)
> +{
> + xtpage_t *p;
> +
> + BT_GETPAGE(ip, bn, *mp, xtpage_t, size, p, *rc, i_xtroot);
> +
> + if (!(*rc)) {
> + if ((le16_to_cpu(p->header.nextindex) < XTENTRYSTART) ||
> + (le16_to_cpu(p->header.nextindex) >
> + le16_to_cpu(p->header.maxentry)) ||
> + (le16_to_cpu(p->header.maxentry) >
> + ((bn == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) {
> + jfs_error(ip->i_sb, "xt_getpage: xtree page corrupt\n");
> + BT_PUTPAGE(*mp);
> + *mp = NULL;
> + *rc = -EIO;
> + }
> + }
> + return p;
> +}
> +
> /*
> * xtLookup()
> *
> @@ -252,7 +271,7 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
> */
> for (bn = 0;;) {
> /* get/pin the page to search */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -807,7 +826,7 @@ xtSplitUp(tid_t tid,
> * insert router entry in parent for new right child page <rp>
> */
> /* get/pin the parent page <sp> */
> - XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc);
> + sp = xt_getpage(ip, parent->bn, &smp, PSIZE, &rc);
> if (rc) {
> XT_PUTPAGE(rcmp);
> return rc;
> @@ -1062,7 +1081,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
> * update previous pointer of old next/right page of <sp>
> */
> if (nextbn != 0) {
> - XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, nextbn, &mp, PSIZE, &rc);
> if (rc) {
> XT_PUTPAGE(rmp);
> goto clean_up;
> @@ -1417,7 +1436,7 @@ int xtExtend(tid_t tid, /* transaction id */
> return rc;
>
> /* get back old page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
> /*
> @@ -1433,7 +1452,7 @@ int xtExtend(tid_t tid, /* transaction id */
> XT_PUTPAGE(mp);
>
> /* get new child page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -1711,7 +1730,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
> return rc;
>
> /* get back old page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
> /*
> @@ -1727,7 +1746,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
> XT_PUTPAGE(mp);
>
> /* get new child page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -1788,7 +1807,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
> XT_PUTPAGE(mp);
>
> /* get new right page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -1864,7 +1883,7 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
> return rc;
>
> /* get back old page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -1881,7 +1900,7 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
> XT_PUTPAGE(mp);
>
> /* get new child page */
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -2268,7 +2287,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
> * first access of each page:
> */
> getPage:
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -2506,7 +2525,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
>
> /* get back the parent page */
> bn = parent->bn;
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -2791,7 +2810,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
> * first access of each page:
> */
> getPage:
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
> @@ -2836,7 +2855,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
>
> /* get back the parent page */
> bn = parent->bn;
> - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
> + p = xt_getpage(ip, bn, &mp, PSIZE, &rc);
> if (rc)
> return rc;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage()
2025-07-11 20:10 ` Dave Kleikamp
@ 2025-07-13 7:24 ` Suchit K
2025-07-13 18:29 ` Dave Kleikamp
0 siblings, 1 reply; 4+ messages in thread
From: Suchit K @ 2025-07-13 7:24 UTC (permalink / raw)
To: Dave Kleikamp; +Cc: jfs-discussion, linux-kernel-mentees, linux-kernel, skhan
On Sat, 12 Jul 2025 at 01:40, Dave Kleikamp <dave.kleikamp@oracle.com> wrote:
>
> On 6/5/25 12:56PM, Suchit Karunakaran wrote:
> > Replace legacy XT_GETPAGE macro with an inline function that returns a
> > xtpage_t pointer and update all instances of XT_GETPAGE in jfs_xtree.c
>
> I'm picking this up, but I simplified it a bit. I dropped the size and
> rc arguments. size is always passed in as PSIZE and I have the function
> return ERR_PTR(-EIO) on error.
>
Hi Dave. Thanks for picking this up. Is there anything that I need to
do from my end?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage()
2025-07-13 7:24 ` Suchit K
@ 2025-07-13 18:29 ` Dave Kleikamp
0 siblings, 0 replies; 4+ messages in thread
From: Dave Kleikamp @ 2025-07-13 18:29 UTC (permalink / raw)
To: Suchit K; +Cc: jfs-discussion, linux-kernel-mentees, linux-kernel, skhan
On 7/13/25 2:24AM, Suchit K wrote:
> On Sat, 12 Jul 2025 at 01:40, Dave Kleikamp <dave.kleikamp@oracle.com> wrote:
>>
>> On 6/5/25 12:56PM, Suchit Karunakaran wrote:
>>> Replace legacy XT_GETPAGE macro with an inline function that returns a
>>> xtpage_t pointer and update all instances of XT_GETPAGE in jfs_xtree.c
>>
>> I'm picking this up, but I simplified it a bit. I dropped the size and
>> rc arguments. size is always passed in as PSIZE and I have the function
>> return ERR_PTR(-EIO) on error.
>>
>
> Hi Dave. Thanks for picking this up. Is there anything that I need to
> do from my end?
No. I've got it from here. Thanks for cleaning this up.
Shaggy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-13 18:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 17:56 [PATCH RESEND] jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage() Suchit Karunakaran
2025-07-11 20:10 ` Dave Kleikamp
2025-07-13 7:24 ` Suchit K
2025-07-13 18:29 ` Dave Kleikamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).