mirror of https://github.com/torvalds/linux.git
jfs: jfs_xtree: replace XT_GETPAGE macro with xt_getpage()
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> Simplified xt_getpage by removing size and rc arguments. Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
This commit is contained in:
parent
2d04df8116
commit
1014354cd8
|
|
@ -49,26 +49,6 @@
|
||||||
|
|
||||||
#define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot)
|
#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 */
|
/* for consistency */
|
||||||
#define XT_PUTPAGE(MP) BT_PUTPAGE(MP)
|
#define XT_PUTPAGE(MP) BT_PUTPAGE(MP)
|
||||||
|
|
||||||
|
|
@ -114,6 +94,42 @@ static int xtSplitPage(tid_t tid, struct inode *ip, struct xtsplit * split,
|
||||||
static int xtSplitRoot(tid_t tid, struct inode *ip,
|
static int xtSplitRoot(tid_t tid, struct inode *ip,
|
||||||
struct xtsplit * split, struct metapage ** rmpp);
|
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;
|
||||||
|
*
|
||||||
|
* returns:
|
||||||
|
* A pointer to the xtree page (xtpage_t) on success, -EIO on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline xtpage_t *xt_getpage(struct inode *ip, s64 bn, struct metapage **mp)
|
||||||
|
{
|
||||||
|
xtpage_t *p;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
BT_GETPAGE(ip, bn, *mp, xtpage_t, PSIZE, p, rc, i_xtroot);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
return ERR_PTR(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;
|
||||||
|
return ERR_PTR(-EIO);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xtLookup()
|
* xtLookup()
|
||||||
*
|
*
|
||||||
|
|
@ -216,7 +232,6 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
|
||||||
int *cmpp, struct btstack * btstack, int flag)
|
int *cmpp, struct btstack * btstack, int flag)
|
||||||
{
|
{
|
||||||
struct jfs_inode_info *jfs_ip = JFS_IP(ip);
|
struct jfs_inode_info *jfs_ip = JFS_IP(ip);
|
||||||
int rc = 0;
|
|
||||||
int cmp = 1; /* init for empty page */
|
int cmp = 1; /* init for empty page */
|
||||||
s64 bn; /* block number */
|
s64 bn; /* block number */
|
||||||
struct metapage *mp; /* page buffer */
|
struct metapage *mp; /* page buffer */
|
||||||
|
|
@ -252,9 +267,9 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
|
||||||
*/
|
*/
|
||||||
for (bn = 0;;) {
|
for (bn = 0;;) {
|
||||||
/* get/pin the page to search */
|
/* get/pin the page to search */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
/* try sequential access heuristics with the previous
|
/* try sequential access heuristics with the previous
|
||||||
* access entry in target leaf page:
|
* access entry in target leaf page:
|
||||||
|
|
@ -807,10 +822,10 @@ xtSplitUp(tid_t tid,
|
||||||
* insert router entry in parent for new right child page <rp>
|
* insert router entry in parent for new right child page <rp>
|
||||||
*/
|
*/
|
||||||
/* get/pin the parent page <sp> */
|
/* get/pin the parent page <sp> */
|
||||||
XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc);
|
sp = xt_getpage(ip, parent->bn, &smp);
|
||||||
if (rc) {
|
if (IS_ERR(sp)) {
|
||||||
XT_PUTPAGE(rcmp);
|
XT_PUTPAGE(rcmp);
|
||||||
return rc;
|
return PTR_ERR(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1062,10 +1077,10 @@ xtSplitPage(tid_t tid, struct inode *ip,
|
||||||
* update previous pointer of old next/right page of <sp>
|
* update previous pointer of old next/right page of <sp>
|
||||||
*/
|
*/
|
||||||
if (nextbn != 0) {
|
if (nextbn != 0) {
|
||||||
XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, nextbn, &mp);
|
||||||
if (rc) {
|
if (IS_ERR(p)) {
|
||||||
XT_PUTPAGE(rmp);
|
XT_PUTPAGE(rmp);
|
||||||
goto clean_up;
|
return PTR_ERR(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_MARK_DIRTY(mp, ip);
|
BT_MARK_DIRTY(mp, ip);
|
||||||
|
|
@ -1417,9 +1432,9 @@ int xtExtend(tid_t tid, /* transaction id */
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* get back old page */
|
/* get back old page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
/*
|
/*
|
||||||
* if leaf root has been split, original root has been
|
* if leaf root has been split, original root has been
|
||||||
* copied to new child page, i.e., original entry now
|
* copied to new child page, i.e., original entry now
|
||||||
|
|
@ -1433,9 +1448,9 @@ int xtExtend(tid_t tid, /* transaction id */
|
||||||
XT_PUTPAGE(mp);
|
XT_PUTPAGE(mp);
|
||||||
|
|
||||||
/* get new child page */
|
/* get new child page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
BT_MARK_DIRTY(mp, ip);
|
BT_MARK_DIRTY(mp, ip);
|
||||||
if (!test_cflag(COMMIT_Nolink, ip)) {
|
if (!test_cflag(COMMIT_Nolink, ip)) {
|
||||||
|
|
@ -1711,9 +1726,9 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* get back old page */
|
/* get back old page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
/*
|
/*
|
||||||
* if leaf root has been split, original root has been
|
* if leaf root has been split, original root has been
|
||||||
* copied to new child page, i.e., original entry now
|
* copied to new child page, i.e., original entry now
|
||||||
|
|
@ -1727,9 +1742,9 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
|
||||||
XT_PUTPAGE(mp);
|
XT_PUTPAGE(mp);
|
||||||
|
|
||||||
/* get new child page */
|
/* get new child page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
BT_MARK_DIRTY(mp, ip);
|
BT_MARK_DIRTY(mp, ip);
|
||||||
if (!test_cflag(COMMIT_Nolink, ip)) {
|
if (!test_cflag(COMMIT_Nolink, ip)) {
|
||||||
|
|
@ -1788,9 +1803,9 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
|
||||||
XT_PUTPAGE(mp);
|
XT_PUTPAGE(mp);
|
||||||
|
|
||||||
/* get new right page */
|
/* get new right page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
BT_MARK_DIRTY(mp, ip);
|
BT_MARK_DIRTY(mp, ip);
|
||||||
if (!test_cflag(COMMIT_Nolink, ip)) {
|
if (!test_cflag(COMMIT_Nolink, ip)) {
|
||||||
|
|
@ -1864,9 +1879,9 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* get back old page */
|
/* get back old page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if leaf root has been split, original root has been
|
* if leaf root has been split, original root has been
|
||||||
|
|
@ -1881,9 +1896,9 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p);
|
||||||
XT_PUTPAGE(mp);
|
XT_PUTPAGE(mp);
|
||||||
|
|
||||||
/* get new child page */
|
/* get new child page */
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
BT_MARK_DIRTY(mp, ip);
|
BT_MARK_DIRTY(mp, ip);
|
||||||
if (!test_cflag(COMMIT_Nolink, ip)) {
|
if (!test_cflag(COMMIT_Nolink, ip)) {
|
||||||
|
|
@ -2187,7 +2202,6 @@ void xtInitRoot(tid_t tid, struct inode *ip)
|
||||||
*/
|
*/
|
||||||
s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
|
s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
|
||||||
s64 teof;
|
s64 teof;
|
||||||
struct metapage *mp;
|
struct metapage *mp;
|
||||||
xtpage_t *p;
|
xtpage_t *p;
|
||||||
|
|
@ -2268,9 +2282,9 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
|
||||||
* first access of each page:
|
* first access of each page:
|
||||||
*/
|
*/
|
||||||
getPage:
|
getPage:
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
/* process entries backward from last index */
|
/* process entries backward from last index */
|
||||||
index = le16_to_cpu(p->header.nextindex) - 1;
|
index = le16_to_cpu(p->header.nextindex) - 1;
|
||||||
|
|
@ -2506,9 +2520,9 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
|
||||||
|
|
||||||
/* get back the parent page */
|
/* get back the parent page */
|
||||||
bn = parent->bn;
|
bn = parent->bn;
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
index = parent->index;
|
index = parent->index;
|
||||||
|
|
||||||
|
|
@ -2791,9 +2805,9 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
|
||||||
* first access of each page:
|
* first access of each page:
|
||||||
*/
|
*/
|
||||||
getPage:
|
getPage:
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
/* process entries backward from last index */
|
/* process entries backward from last index */
|
||||||
index = le16_to_cpu(p->header.nextindex) - 1;
|
index = le16_to_cpu(p->header.nextindex) - 1;
|
||||||
|
|
@ -2836,9 +2850,9 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
|
||||||
|
|
||||||
/* get back the parent page */
|
/* get back the parent page */
|
||||||
bn = parent->bn;
|
bn = parent->bn;
|
||||||
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
|
p = xt_getpage(ip, bn, &mp);
|
||||||
if (rc)
|
if (IS_ERR(p))
|
||||||
return rc;
|
return PTR_ERR(p);
|
||||||
|
|
||||||
index = parent->index;
|
index = parent->index;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue