Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Suchit Karunakaran and committed by
Dave Kleikamp
1014354c 2d04df81

+78 -64
+78 -64
fs/jfs/jfs_xtree.c
··· 49 49 50 50 #define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot) 51 51 52 - /* get page buffer for specified block address */ 53 - /* ToDo: Replace this ugly macro with a function */ 54 - #define XT_GETPAGE(IP, BN, MP, SIZE, P, RC) \ 55 - do { \ 56 - BT_GETPAGE(IP, BN, MP, xtpage_t, SIZE, P, RC, i_xtroot); \ 57 - if (!(RC)) { \ 58 - if ((le16_to_cpu((P)->header.nextindex) < XTENTRYSTART) || \ 59 - (le16_to_cpu((P)->header.nextindex) > \ 60 - le16_to_cpu((P)->header.maxentry)) || \ 61 - (le16_to_cpu((P)->header.maxentry) > \ 62 - (((BN) == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) { \ 63 - jfs_error((IP)->i_sb, \ 64 - "XT_GETPAGE: xtree page corrupt\n"); \ 65 - BT_PUTPAGE(MP); \ 66 - MP = NULL; \ 67 - RC = -EIO; \ 68 - } \ 69 - } \ 70 - } while (0) 71 - 72 52 /* for consistency */ 73 53 #define XT_PUTPAGE(MP) BT_PUTPAGE(MP) 74 54 ··· 93 113 94 114 static int xtSplitRoot(tid_t tid, struct inode *ip, 95 115 struct xtsplit * split, struct metapage ** rmpp); 116 + 117 + /* 118 + * xt_getpage() 119 + * 120 + * function: get the page buffer for a specified block address. 121 + * 122 + * parameters: 123 + * ip - pointer to the inode 124 + * bn - block number (s64) of the xtree page to be retrieved; 125 + * mp - pointer to a metapage pointer where the page buffer is returned; 126 + * 127 + * returns: 128 + * A pointer to the xtree page (xtpage_t) on success, -EIO on error. 129 + */ 130 + 131 + static inline xtpage_t *xt_getpage(struct inode *ip, s64 bn, struct metapage **mp) 132 + { 133 + xtpage_t *p; 134 + int rc; 135 + 136 + BT_GETPAGE(ip, bn, *mp, xtpage_t, PSIZE, p, rc, i_xtroot); 137 + 138 + if (rc) 139 + return ERR_PTR(rc); 140 + if ((le16_to_cpu(p->header.nextindex) < XTENTRYSTART) || 141 + (le16_to_cpu(p->header.nextindex) > 142 + le16_to_cpu(p->header.maxentry)) || 143 + (le16_to_cpu(p->header.maxentry) > 144 + ((bn == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) { 145 + jfs_error(ip->i_sb, "xt_getpage: xtree page corrupt\n"); 146 + BT_PUTPAGE(*mp); 147 + *mp = NULL; 148 + return ERR_PTR(-EIO); 149 + } 150 + return p; 151 + } 96 152 97 153 /* 98 154 * xtLookup() ··· 232 216 int *cmpp, struct btstack * btstack, int flag) 233 217 { 234 218 struct jfs_inode_info *jfs_ip = JFS_IP(ip); 235 - int rc = 0; 236 219 int cmp = 1; /* init for empty page */ 237 220 s64 bn; /* block number */ 238 221 struct metapage *mp; /* page buffer */ ··· 267 252 */ 268 253 for (bn = 0;;) { 269 254 /* get/pin the page to search */ 270 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 271 - if (rc) 272 - return rc; 255 + p = xt_getpage(ip, bn, &mp); 256 + if (IS_ERR(p)) 257 + return PTR_ERR(p); 273 258 274 259 /* try sequential access heuristics with the previous 275 260 * access entry in target leaf page: ··· 822 807 * insert router entry in parent for new right child page <rp> 823 808 */ 824 809 /* get/pin the parent page <sp> */ 825 - XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc); 826 - if (rc) { 810 + sp = xt_getpage(ip, parent->bn, &smp); 811 + if (IS_ERR(sp)) { 827 812 XT_PUTPAGE(rcmp); 828 - return rc; 813 + return PTR_ERR(sp); 829 814 } 830 815 831 816 /* ··· 1077 1062 * update previous pointer of old next/right page of <sp> 1078 1063 */ 1079 1064 if (nextbn != 0) { 1080 - XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc); 1081 - if (rc) { 1065 + p = xt_getpage(ip, nextbn, &mp); 1066 + if (IS_ERR(p)) { 1082 1067 XT_PUTPAGE(rmp); 1083 - goto clean_up; 1068 + return PTR_ERR(p); 1084 1069 } 1085 1070 1086 1071 BT_MARK_DIRTY(mp, ip); ··· 1432 1417 return rc; 1433 1418 1434 1419 /* get back old page */ 1435 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1436 - if (rc) 1437 - return rc; 1420 + p = xt_getpage(ip, bn, &mp); 1421 + if (IS_ERR(p)) 1422 + return PTR_ERR(p); 1438 1423 /* 1439 1424 * if leaf root has been split, original root has been 1440 1425 * copied to new child page, i.e., original entry now ··· 1448 1433 XT_PUTPAGE(mp); 1449 1434 1450 1435 /* get new child page */ 1451 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1452 - if (rc) 1453 - return rc; 1436 + p = xt_getpage(ip, bn, &mp); 1437 + if (IS_ERR(p)) 1438 + return PTR_ERR(p); 1454 1439 1455 1440 BT_MARK_DIRTY(mp, ip); 1456 1441 if (!test_cflag(COMMIT_Nolink, ip)) { ··· 1726 1711 return rc; 1727 1712 1728 1713 /* get back old page */ 1729 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1730 - if (rc) 1731 - return rc; 1714 + p = xt_getpage(ip, bn, &mp); 1715 + if (IS_ERR(p)) 1716 + return PTR_ERR(p); 1732 1717 /* 1733 1718 * if leaf root has been split, original root has been 1734 1719 * copied to new child page, i.e., original entry now ··· 1742 1727 XT_PUTPAGE(mp); 1743 1728 1744 1729 /* get new child page */ 1745 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1746 - if (rc) 1747 - return rc; 1730 + p = xt_getpage(ip, bn, &mp); 1731 + if (IS_ERR(p)) 1732 + return PTR_ERR(p); 1748 1733 1749 1734 BT_MARK_DIRTY(mp, ip); 1750 1735 if (!test_cflag(COMMIT_Nolink, ip)) { ··· 1803 1788 XT_PUTPAGE(mp); 1804 1789 1805 1790 /* get new right page */ 1806 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1807 - if (rc) 1808 - return rc; 1791 + p = xt_getpage(ip, bn, &mp); 1792 + if (IS_ERR(p)) 1793 + return PTR_ERR(p); 1809 1794 1810 1795 BT_MARK_DIRTY(mp, ip); 1811 1796 if (!test_cflag(COMMIT_Nolink, ip)) { ··· 1879 1864 return rc; 1880 1865 1881 1866 /* get back old page */ 1882 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1883 - if (rc) 1884 - return rc; 1867 + p = xt_getpage(ip, bn, &mp); 1868 + if (IS_ERR(p)) 1869 + return PTR_ERR(p); 1885 1870 1886 1871 /* 1887 1872 * if leaf root has been split, original root has been ··· 1896 1881 XT_PUTPAGE(mp); 1897 1882 1898 1883 /* get new child page */ 1899 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 1900 - if (rc) 1901 - return rc; 1884 + p = xt_getpage(ip, bn, &mp); 1885 + if (IS_ERR(p)) 1886 + return PTR_ERR(p); 1902 1887 1903 1888 BT_MARK_DIRTY(mp, ip); 1904 1889 if (!test_cflag(COMMIT_Nolink, ip)) { ··· 2202 2187 */ 2203 2188 s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) 2204 2189 { 2205 - int rc = 0; 2206 2190 s64 teof; 2207 2191 struct metapage *mp; 2208 2192 xtpage_t *p; ··· 2282 2268 * first access of each page: 2283 2269 */ 2284 2270 getPage: 2285 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 2286 - if (rc) 2287 - return rc; 2271 + p = xt_getpage(ip, bn, &mp); 2272 + if (IS_ERR(p)) 2273 + return PTR_ERR(p); 2288 2274 2289 2275 /* process entries backward from last index */ 2290 2276 index = le16_to_cpu(p->header.nextindex) - 1; ··· 2520 2506 2521 2507 /* get back the parent page */ 2522 2508 bn = parent->bn; 2523 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 2524 - if (rc) 2525 - return rc; 2509 + p = xt_getpage(ip, bn, &mp); 2510 + if (IS_ERR(p)) 2511 + return PTR_ERR(p); 2526 2512 2527 2513 index = parent->index; 2528 2514 ··· 2805 2791 * first access of each page: 2806 2792 */ 2807 2793 getPage: 2808 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 2809 - if (rc) 2810 - return rc; 2794 + p = xt_getpage(ip, bn, &mp); 2795 + if (IS_ERR(p)) 2796 + return PTR_ERR(p); 2811 2797 2812 2798 /* process entries backward from last index */ 2813 2799 index = le16_to_cpu(p->header.nextindex) - 1; ··· 2850 2836 2851 2837 /* get back the parent page */ 2852 2838 bn = parent->bn; 2853 - XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); 2854 - if (rc) 2855 - return rc; 2839 + p = xt_getpage(ip, bn, &mp); 2840 + if (IS_ERR(p)) 2841 + return PTR_ERR(p); 2856 2842 2857 2843 index = parent->index; 2858 2844