xfs_buf_item.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_types.h"
  21. #include "xfs_bit.h"
  22. #include "xfs_log.h"
  23. #include "xfs_inum.h"
  24. #include "xfs_trans.h"
  25. #include "xfs_sb.h"
  26. #include "xfs_ag.h"
  27. #include "xfs_dmapi.h"
  28. #include "xfs_mount.h"
  29. #include "xfs_buf_item.h"
  30. #include "xfs_trans_priv.h"
  31. #include "xfs_error.h"
  32. kmem_zone_t *xfs_buf_item_zone;
  33. #ifdef XFS_TRANS_DEBUG
  34. /*
  35. * This function uses an alternate strategy for tracking the bytes
  36. * that the user requests to be logged. This can then be used
  37. * in conjunction with the bli_orig array in the buf log item to
  38. * catch bugs in our callers' code.
  39. *
  40. * We also double check the bits set in xfs_buf_item_log using a
  41. * simple algorithm to check that every byte is accounted for.
  42. */
  43. STATIC void
  44. xfs_buf_item_log_debug(
  45. xfs_buf_log_item_t *bip,
  46. uint first,
  47. uint last)
  48. {
  49. uint x;
  50. uint byte;
  51. uint nbytes;
  52. uint chunk_num;
  53. uint word_num;
  54. uint bit_num;
  55. uint bit_set;
  56. uint *wordp;
  57. ASSERT(bip->bli_logged != NULL);
  58. byte = first;
  59. nbytes = last - first + 1;
  60. bfset(bip->bli_logged, first, nbytes);
  61. for (x = 0; x < nbytes; x++) {
  62. chunk_num = byte >> XFS_BLI_SHIFT;
  63. word_num = chunk_num >> BIT_TO_WORD_SHIFT;
  64. bit_num = chunk_num & (NBWORD - 1);
  65. wordp = &(bip->bli_format.blf_data_map[word_num]);
  66. bit_set = *wordp & (1 << bit_num);
  67. ASSERT(bit_set);
  68. byte++;
  69. }
  70. }
  71. /*
  72. * This function is called when we flush something into a buffer without
  73. * logging it. This happens for things like inodes which are logged
  74. * separately from the buffer.
  75. */
  76. void
  77. xfs_buf_item_flush_log_debug(
  78. xfs_buf_t *bp,
  79. uint first,
  80. uint last)
  81. {
  82. xfs_buf_log_item_t *bip;
  83. uint nbytes;
  84. bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
  85. if ((bip == NULL) || (bip->bli_item.li_type != XFS_LI_BUF)) {
  86. return;
  87. }
  88. ASSERT(bip->bli_logged != NULL);
  89. nbytes = last - first + 1;
  90. bfset(bip->bli_logged, first, nbytes);
  91. }
  92. /*
  93. * This function is called to verify that our callers have logged
  94. * all the bytes that they changed.
  95. *
  96. * It does this by comparing the original copy of the buffer stored in
  97. * the buf log item's bli_orig array to the current copy of the buffer
  98. * and ensuring that all bytes which mismatch are set in the bli_logged
  99. * array of the buf log item.
  100. */
  101. STATIC void
  102. xfs_buf_item_log_check(
  103. xfs_buf_log_item_t *bip)
  104. {
  105. char *orig;
  106. char *buffer;
  107. int x;
  108. xfs_buf_t *bp;
  109. ASSERT(bip->bli_orig != NULL);
  110. ASSERT(bip->bli_logged != NULL);
  111. bp = bip->bli_buf;
  112. ASSERT(XFS_BUF_COUNT(bp) > 0);
  113. ASSERT(XFS_BUF_PTR(bp) != NULL);
  114. orig = bip->bli_orig;
  115. buffer = XFS_BUF_PTR(bp);
  116. for (x = 0; x < XFS_BUF_COUNT(bp); x++) {
  117. if (orig[x] != buffer[x] && !btst(bip->bli_logged, x))
  118. cmn_err(CE_PANIC,
  119. "xfs_buf_item_log_check bip %x buffer %x orig %x index %d",
  120. bip, bp, orig, x);
  121. }
  122. }
  123. #else
  124. #define xfs_buf_item_log_debug(x,y,z)
  125. #define xfs_buf_item_log_check(x)
  126. #endif
  127. STATIC void xfs_buf_error_relse(xfs_buf_t *bp);
  128. STATIC void xfs_buf_do_callbacks(xfs_buf_t *bp, xfs_log_item_t *lip);
  129. /*
  130. * This returns the number of log iovecs needed to log the
  131. * given buf log item.
  132. *
  133. * It calculates this as 1 iovec for the buf log format structure
  134. * and 1 for each stretch of non-contiguous chunks to be logged.
  135. * Contiguous chunks are logged in a single iovec.
  136. *
  137. * If the XFS_BLI_STALE flag has been set, then log nothing.
  138. */
  139. STATIC uint
  140. xfs_buf_item_size(
  141. xfs_buf_log_item_t *bip)
  142. {
  143. uint nvecs;
  144. int next_bit;
  145. int last_bit;
  146. xfs_buf_t *bp;
  147. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  148. if (bip->bli_flags & XFS_BLI_STALE) {
  149. /*
  150. * The buffer is stale, so all we need to log
  151. * is the buf log format structure with the
  152. * cancel flag in it.
  153. */
  154. xfs_buf_item_trace("SIZE STALE", bip);
  155. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  156. return 1;
  157. }
  158. bp = bip->bli_buf;
  159. ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
  160. nvecs = 1;
  161. last_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  162. bip->bli_format.blf_map_size, 0);
  163. ASSERT(last_bit != -1);
  164. nvecs++;
  165. while (last_bit != -1) {
  166. /*
  167. * This takes the bit number to start looking from and
  168. * returns the next set bit from there. It returns -1
  169. * if there are no more bits set or the start bit is
  170. * beyond the end of the bitmap.
  171. */
  172. next_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  173. bip->bli_format.blf_map_size,
  174. last_bit + 1);
  175. /*
  176. * If we run out of bits, leave the loop,
  177. * else if we find a new set of bits bump the number of vecs,
  178. * else keep scanning the current set of bits.
  179. */
  180. if (next_bit == -1) {
  181. last_bit = -1;
  182. } else if (next_bit != last_bit + 1) {
  183. last_bit = next_bit;
  184. nvecs++;
  185. } else if (xfs_buf_offset(bp, next_bit * XFS_BLI_CHUNK) !=
  186. (xfs_buf_offset(bp, last_bit * XFS_BLI_CHUNK) +
  187. XFS_BLI_CHUNK)) {
  188. last_bit = next_bit;
  189. nvecs++;
  190. } else {
  191. last_bit++;
  192. }
  193. }
  194. xfs_buf_item_trace("SIZE NORM", bip);
  195. return nvecs;
  196. }
  197. /*
  198. * This is called to fill in the vector of log iovecs for the
  199. * given log buf item. It fills the first entry with a buf log
  200. * format structure, and the rest point to contiguous chunks
  201. * within the buffer.
  202. */
  203. STATIC void
  204. xfs_buf_item_format(
  205. xfs_buf_log_item_t *bip,
  206. xfs_log_iovec_t *log_vector)
  207. {
  208. uint base_size;
  209. uint nvecs;
  210. xfs_log_iovec_t *vecp;
  211. xfs_buf_t *bp;
  212. int first_bit;
  213. int last_bit;
  214. int next_bit;
  215. uint nbits;
  216. uint buffer_offset;
  217. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  218. ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
  219. (bip->bli_flags & XFS_BLI_STALE));
  220. bp = bip->bli_buf;
  221. vecp = log_vector;
  222. /*
  223. * The size of the base structure is the size of the
  224. * declared structure plus the space for the extra words
  225. * of the bitmap. We subtract one from the map size, because
  226. * the first element of the bitmap is accounted for in the
  227. * size of the base structure.
  228. */
  229. base_size =
  230. (uint)(sizeof(xfs_buf_log_format_t) +
  231. ((bip->bli_format.blf_map_size - 1) * sizeof(uint)));
  232. vecp->i_addr = (xfs_caddr_t)&bip->bli_format;
  233. vecp->i_len = base_size;
  234. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BFORMAT);
  235. vecp++;
  236. nvecs = 1;
  237. if (bip->bli_flags & XFS_BLI_STALE) {
  238. /*
  239. * The buffer is stale, so all we need to log
  240. * is the buf log format structure with the
  241. * cancel flag in it.
  242. */
  243. xfs_buf_item_trace("FORMAT STALE", bip);
  244. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  245. bip->bli_format.blf_size = nvecs;
  246. return;
  247. }
  248. /*
  249. * Fill in an iovec for each set of contiguous chunks.
  250. */
  251. first_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  252. bip->bli_format.blf_map_size, 0);
  253. ASSERT(first_bit != -1);
  254. last_bit = first_bit;
  255. nbits = 1;
  256. for (;;) {
  257. /*
  258. * This takes the bit number to start looking from and
  259. * returns the next set bit from there. It returns -1
  260. * if there are no more bits set or the start bit is
  261. * beyond the end of the bitmap.
  262. */
  263. next_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  264. bip->bli_format.blf_map_size,
  265. (uint)last_bit + 1);
  266. /*
  267. * If we run out of bits fill in the last iovec and get
  268. * out of the loop.
  269. * Else if we start a new set of bits then fill in the
  270. * iovec for the series we were looking at and start
  271. * counting the bits in the new one.
  272. * Else we're still in the same set of bits so just
  273. * keep counting and scanning.
  274. */
  275. if (next_bit == -1) {
  276. buffer_offset = first_bit * XFS_BLI_CHUNK;
  277. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  278. vecp->i_len = nbits * XFS_BLI_CHUNK;
  279. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  280. nvecs++;
  281. break;
  282. } else if (next_bit != last_bit + 1) {
  283. buffer_offset = first_bit * XFS_BLI_CHUNK;
  284. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  285. vecp->i_len = nbits * XFS_BLI_CHUNK;
  286. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  287. nvecs++;
  288. vecp++;
  289. first_bit = next_bit;
  290. last_bit = next_bit;
  291. nbits = 1;
  292. } else if (xfs_buf_offset(bp, next_bit << XFS_BLI_SHIFT) !=
  293. (xfs_buf_offset(bp, last_bit << XFS_BLI_SHIFT) +
  294. XFS_BLI_CHUNK)) {
  295. buffer_offset = first_bit * XFS_BLI_CHUNK;
  296. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  297. vecp->i_len = nbits * XFS_BLI_CHUNK;
  298. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  299. /* You would think we need to bump the nvecs here too, but we do not
  300. * this number is used by recovery, and it gets confused by the boundary
  301. * split here
  302. * nvecs++;
  303. */
  304. vecp++;
  305. first_bit = next_bit;
  306. last_bit = next_bit;
  307. nbits = 1;
  308. } else {
  309. last_bit++;
  310. nbits++;
  311. }
  312. }
  313. bip->bli_format.blf_size = nvecs;
  314. /*
  315. * Check to make sure everything is consistent.
  316. */
  317. xfs_buf_item_trace("FORMAT NORM", bip);
  318. xfs_buf_item_log_check(bip);
  319. }
  320. /*
  321. * This is called to pin the buffer associated with the buf log
  322. * item in memory so it cannot be written out. Simply call bpin()
  323. * on the buffer to do this.
  324. */
  325. STATIC void
  326. xfs_buf_item_pin(
  327. xfs_buf_log_item_t *bip)
  328. {
  329. xfs_buf_t *bp;
  330. bp = bip->bli_buf;
  331. ASSERT(XFS_BUF_ISBUSY(bp));
  332. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  333. ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
  334. (bip->bli_flags & XFS_BLI_STALE));
  335. xfs_buf_item_trace("PIN", bip);
  336. xfs_buftrace("XFS_PIN", bp);
  337. xfs_bpin(bp);
  338. }
  339. /*
  340. * This is called to unpin the buffer associated with the buf log
  341. * item which was previously pinned with a call to xfs_buf_item_pin().
  342. * Just call bunpin() on the buffer to do this.
  343. *
  344. * Also drop the reference to the buf item for the current transaction.
  345. * If the XFS_BLI_STALE flag is set and we are the last reference,
  346. * then free up the buf log item and unlock the buffer.
  347. */
  348. STATIC void
  349. xfs_buf_item_unpin(
  350. xfs_buf_log_item_t *bip,
  351. int stale)
  352. {
  353. xfs_mount_t *mp;
  354. xfs_buf_t *bp;
  355. int freed;
  356. SPLDECL(s);
  357. bp = bip->bli_buf;
  358. ASSERT(bp != NULL);
  359. ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip);
  360. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  361. xfs_buf_item_trace("UNPIN", bip);
  362. xfs_buftrace("XFS_UNPIN", bp);
  363. freed = atomic_dec_and_test(&bip->bli_refcount);
  364. mp = bip->bli_item.li_mountp;
  365. xfs_bunpin(bp);
  366. if (freed && stale) {
  367. ASSERT(bip->bli_flags & XFS_BLI_STALE);
  368. ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
  369. ASSERT(!(XFS_BUF_ISDELAYWRITE(bp)));
  370. ASSERT(XFS_BUF_ISSTALE(bp));
  371. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  372. xfs_buf_item_trace("UNPIN STALE", bip);
  373. xfs_buftrace("XFS_UNPIN STALE", bp);
  374. /*
  375. * If we get called here because of an IO error, we may
  376. * or may not have the item on the AIL. xfs_trans_delete_ail()
  377. * will take care of that situation.
  378. * xfs_trans_delete_ail() drops the AIL lock.
  379. */
  380. if (bip->bli_flags & XFS_BLI_STALE_INODE) {
  381. xfs_buf_do_callbacks(bp, (xfs_log_item_t *)bip);
  382. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  383. XFS_BUF_CLR_IODONE_FUNC(bp);
  384. } else {
  385. AIL_LOCK(mp,s);
  386. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip, s);
  387. xfs_buf_item_relse(bp);
  388. ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL);
  389. }
  390. xfs_buf_relse(bp);
  391. }
  392. }
  393. /*
  394. * this is called from uncommit in the forced-shutdown path.
  395. * we need to check to see if the reference count on the log item
  396. * is going to drop to zero. If so, unpin will free the log item
  397. * so we need to free the item's descriptor (that points to the item)
  398. * in the transaction.
  399. */
  400. STATIC void
  401. xfs_buf_item_unpin_remove(
  402. xfs_buf_log_item_t *bip,
  403. xfs_trans_t *tp)
  404. {
  405. xfs_buf_t *bp;
  406. xfs_log_item_desc_t *lidp;
  407. int stale = 0;
  408. bp = bip->bli_buf;
  409. /*
  410. * will xfs_buf_item_unpin() call xfs_buf_item_relse()?
  411. */
  412. if ((atomic_read(&bip->bli_refcount) == 1) &&
  413. (bip->bli_flags & XFS_BLI_STALE)) {
  414. ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0);
  415. xfs_buf_item_trace("UNPIN REMOVE", bip);
  416. xfs_buftrace("XFS_UNPIN_REMOVE", bp);
  417. /*
  418. * yes -- clear the xaction descriptor in-use flag
  419. * and free the chunk if required. We can safely
  420. * do some work here and then call buf_item_unpin
  421. * to do the rest because if the if is true, then
  422. * we are holding the buffer locked so no one else
  423. * will be able to bump up the refcount.
  424. */
  425. lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) bip);
  426. stale = lidp->lid_flags & XFS_LID_BUF_STALE;
  427. xfs_trans_free_item(tp, lidp);
  428. /*
  429. * Since the transaction no longer refers to the buffer,
  430. * the buffer should no longer refer to the transaction.
  431. */
  432. XFS_BUF_SET_FSPRIVATE2(bp, NULL);
  433. }
  434. xfs_buf_item_unpin(bip, stale);
  435. return;
  436. }
  437. /*
  438. * This is called to attempt to lock the buffer associated with this
  439. * buf log item. Don't sleep on the buffer lock. If we can't get
  440. * the lock right away, return 0. If we can get the lock, pull the
  441. * buffer from the free list, mark it busy, and return 1.
  442. */
  443. STATIC uint
  444. xfs_buf_item_trylock(
  445. xfs_buf_log_item_t *bip)
  446. {
  447. xfs_buf_t *bp;
  448. bp = bip->bli_buf;
  449. if (XFS_BUF_ISPINNED(bp)) {
  450. return XFS_ITEM_PINNED;
  451. }
  452. if (!XFS_BUF_CPSEMA(bp)) {
  453. return XFS_ITEM_LOCKED;
  454. }
  455. /*
  456. * Remove the buffer from the free list. Only do this
  457. * if it's on the free list. Private buffers like the
  458. * superblock buffer are not.
  459. */
  460. XFS_BUF_HOLD(bp);
  461. ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
  462. xfs_buf_item_trace("TRYLOCK SUCCESS", bip);
  463. return XFS_ITEM_SUCCESS;
  464. }
  465. /*
  466. * Release the buffer associated with the buf log item.
  467. * If there is no dirty logged data associated with the
  468. * buffer recorded in the buf log item, then free the
  469. * buf log item and remove the reference to it in the
  470. * buffer.
  471. *
  472. * This call ignores the recursion count. It is only called
  473. * when the buffer should REALLY be unlocked, regardless
  474. * of the recursion count.
  475. *
  476. * If the XFS_BLI_HOLD flag is set in the buf log item, then
  477. * free the log item if necessary but do not unlock the buffer.
  478. * This is for support of xfs_trans_bhold(). Make sure the
  479. * XFS_BLI_HOLD field is cleared if we don't free the item.
  480. */
  481. STATIC void
  482. xfs_buf_item_unlock(
  483. xfs_buf_log_item_t *bip)
  484. {
  485. int aborted;
  486. xfs_buf_t *bp;
  487. uint hold;
  488. bp = bip->bli_buf;
  489. xfs_buftrace("XFS_UNLOCK", bp);
  490. /*
  491. * Clear the buffer's association with this transaction.
  492. */
  493. XFS_BUF_SET_FSPRIVATE2(bp, NULL);
  494. /*
  495. * If this is a transaction abort, don't return early.
  496. * Instead, allow the brelse to happen.
  497. * Normally it would be done for stale (cancelled) buffers
  498. * at unpin time, but we'll never go through the pin/unpin
  499. * cycle if we abort inside commit.
  500. */
  501. aborted = (bip->bli_item.li_flags & XFS_LI_ABORTED) != 0;
  502. /*
  503. * If the buf item is marked stale, then don't do anything.
  504. * We'll unlock the buffer and free the buf item when the
  505. * buffer is unpinned for the last time.
  506. */
  507. if (bip->bli_flags & XFS_BLI_STALE) {
  508. bip->bli_flags &= ~XFS_BLI_LOGGED;
  509. xfs_buf_item_trace("UNLOCK STALE", bip);
  510. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  511. if (!aborted)
  512. return;
  513. }
  514. /*
  515. * Drop the transaction's reference to the log item if
  516. * it was not logged as part of the transaction. Otherwise
  517. * we'll drop the reference in xfs_buf_item_unpin() when
  518. * the transaction is really through with the buffer.
  519. */
  520. if (!(bip->bli_flags & XFS_BLI_LOGGED)) {
  521. atomic_dec(&bip->bli_refcount);
  522. } else {
  523. /*
  524. * Clear the logged flag since this is per
  525. * transaction state.
  526. */
  527. bip->bli_flags &= ~XFS_BLI_LOGGED;
  528. }
  529. /*
  530. * Before possibly freeing the buf item, determine if we should
  531. * release the buffer at the end of this routine.
  532. */
  533. hold = bip->bli_flags & XFS_BLI_HOLD;
  534. xfs_buf_item_trace("UNLOCK", bip);
  535. /*
  536. * If the buf item isn't tracking any data, free it.
  537. * Otherwise, if XFS_BLI_HOLD is set clear it.
  538. */
  539. if (xfs_bitmap_empty(bip->bli_format.blf_data_map,
  540. bip->bli_format.blf_map_size)) {
  541. xfs_buf_item_relse(bp);
  542. } else if (hold) {
  543. bip->bli_flags &= ~XFS_BLI_HOLD;
  544. }
  545. /*
  546. * Release the buffer if XFS_BLI_HOLD was not set.
  547. */
  548. if (!hold) {
  549. xfs_buf_relse(bp);
  550. }
  551. }
  552. /*
  553. * This is called to find out where the oldest active copy of the
  554. * buf log item in the on disk log resides now that the last log
  555. * write of it completed at the given lsn.
  556. * We always re-log all the dirty data in a buffer, so usually the
  557. * latest copy in the on disk log is the only one that matters. For
  558. * those cases we simply return the given lsn.
  559. *
  560. * The one exception to this is for buffers full of newly allocated
  561. * inodes. These buffers are only relogged with the XFS_BLI_INODE_BUF
  562. * flag set, indicating that only the di_next_unlinked fields from the
  563. * inodes in the buffers will be replayed during recovery. If the
  564. * original newly allocated inode images have not yet been flushed
  565. * when the buffer is so relogged, then we need to make sure that we
  566. * keep the old images in the 'active' portion of the log. We do this
  567. * by returning the original lsn of that transaction here rather than
  568. * the current one.
  569. */
  570. STATIC xfs_lsn_t
  571. xfs_buf_item_committed(
  572. xfs_buf_log_item_t *bip,
  573. xfs_lsn_t lsn)
  574. {
  575. xfs_buf_item_trace("COMMITTED", bip);
  576. if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
  577. (bip->bli_item.li_lsn != 0)) {
  578. return bip->bli_item.li_lsn;
  579. }
  580. return (lsn);
  581. }
  582. /*
  583. * This is called to asynchronously write the buffer associated with this
  584. * buf log item out to disk. The buffer will already have been locked by
  585. * a successful call to xfs_buf_item_trylock(). If the buffer still has
  586. * B_DELWRI set, then get it going out to disk with a call to bawrite().
  587. * If not, then just release the buffer.
  588. */
  589. STATIC void
  590. xfs_buf_item_push(
  591. xfs_buf_log_item_t *bip)
  592. {
  593. xfs_buf_t *bp;
  594. ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
  595. xfs_buf_item_trace("PUSH", bip);
  596. bp = bip->bli_buf;
  597. if (XFS_BUF_ISDELAYWRITE(bp)) {
  598. xfs_bawrite(bip->bli_item.li_mountp, bp);
  599. } else {
  600. xfs_buf_relse(bp);
  601. }
  602. }
  603. /* ARGSUSED */
  604. STATIC void
  605. xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
  606. {
  607. }
  608. /*
  609. * This is the ops vector shared by all buf log items.
  610. */
  611. static struct xfs_item_ops xfs_buf_item_ops = {
  612. .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size,
  613. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  614. xfs_buf_item_format,
  615. .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin,
  616. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin,
  617. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
  618. xfs_buf_item_unpin_remove,
  619. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock,
  620. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_buf_item_unlock,
  621. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  622. xfs_buf_item_committed,
  623. .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push,
  624. .iop_pushbuf = NULL,
  625. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  626. xfs_buf_item_committing
  627. };
  628. /*
  629. * Allocate a new buf log item to go with the given buffer.
  630. * Set the buffer's b_fsprivate field to point to the new
  631. * buf log item. If there are other item's attached to the
  632. * buffer (see xfs_buf_attach_iodone() below), then put the
  633. * buf log item at the front.
  634. */
  635. void
  636. xfs_buf_item_init(
  637. xfs_buf_t *bp,
  638. xfs_mount_t *mp)
  639. {
  640. xfs_log_item_t *lip;
  641. xfs_buf_log_item_t *bip;
  642. int chunks;
  643. int map_size;
  644. /*
  645. * Check to see if there is already a buf log item for
  646. * this buffer. If there is, it is guaranteed to be
  647. * the first. If we do already have one, there is
  648. * nothing to do here so return.
  649. */
  650. if (XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *) != mp)
  651. XFS_BUF_SET_FSPRIVATE3(bp, mp);
  652. XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
  653. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  654. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  655. if (lip->li_type == XFS_LI_BUF) {
  656. return;
  657. }
  658. }
  659. /*
  660. * chunks is the number of XFS_BLI_CHUNK size pieces
  661. * the buffer can be divided into. Make sure not to
  662. * truncate any pieces. map_size is the size of the
  663. * bitmap needed to describe the chunks of the buffer.
  664. */
  665. chunks = (int)((XFS_BUF_COUNT(bp) + (XFS_BLI_CHUNK - 1)) >> XFS_BLI_SHIFT);
  666. map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT);
  667. bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
  668. KM_SLEEP);
  669. bip->bli_item.li_type = XFS_LI_BUF;
  670. bip->bli_item.li_ops = &xfs_buf_item_ops;
  671. bip->bli_item.li_mountp = mp;
  672. bip->bli_buf = bp;
  673. bip->bli_format.blf_type = XFS_LI_BUF;
  674. bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp);
  675. bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp));
  676. bip->bli_format.blf_map_size = map_size;
  677. #ifdef XFS_BLI_TRACE
  678. bip->bli_trace = ktrace_alloc(XFS_BLI_TRACE_SIZE, KM_SLEEP);
  679. #endif
  680. #ifdef XFS_TRANS_DEBUG
  681. /*
  682. * Allocate the arrays for tracking what needs to be logged
  683. * and what our callers request to be logged. bli_orig
  684. * holds a copy of the original, clean buffer for comparison
  685. * against, and bli_logged keeps a 1 bit flag per byte in
  686. * the buffer to indicate which bytes the callers have asked
  687. * to have logged.
  688. */
  689. bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP);
  690. memcpy(bip->bli_orig, XFS_BUF_PTR(bp), XFS_BUF_COUNT(bp));
  691. bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP);
  692. #endif
  693. /*
  694. * Put the buf item into the list of items attached to the
  695. * buffer at the front.
  696. */
  697. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  698. bip->bli_item.li_bio_list =
  699. XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  700. }
  701. XFS_BUF_SET_FSPRIVATE(bp, bip);
  702. }
  703. /*
  704. * Mark bytes first through last inclusive as dirty in the buf
  705. * item's bitmap.
  706. */
  707. void
  708. xfs_buf_item_log(
  709. xfs_buf_log_item_t *bip,
  710. uint first,
  711. uint last)
  712. {
  713. uint first_bit;
  714. uint last_bit;
  715. uint bits_to_set;
  716. uint bits_set;
  717. uint word_num;
  718. uint *wordp;
  719. uint bit;
  720. uint end_bit;
  721. uint mask;
  722. /*
  723. * Mark the item as having some dirty data for
  724. * quick reference in xfs_buf_item_dirty.
  725. */
  726. bip->bli_flags |= XFS_BLI_DIRTY;
  727. /*
  728. * Convert byte offsets to bit numbers.
  729. */
  730. first_bit = first >> XFS_BLI_SHIFT;
  731. last_bit = last >> XFS_BLI_SHIFT;
  732. /*
  733. * Calculate the total number of bits to be set.
  734. */
  735. bits_to_set = last_bit - first_bit + 1;
  736. /*
  737. * Get a pointer to the first word in the bitmap
  738. * to set a bit in.
  739. */
  740. word_num = first_bit >> BIT_TO_WORD_SHIFT;
  741. wordp = &(bip->bli_format.blf_data_map[word_num]);
  742. /*
  743. * Calculate the starting bit in the first word.
  744. */
  745. bit = first_bit & (uint)(NBWORD - 1);
  746. /*
  747. * First set any bits in the first word of our range.
  748. * If it starts at bit 0 of the word, it will be
  749. * set below rather than here. That is what the variable
  750. * bit tells us. The variable bits_set tracks the number
  751. * of bits that have been set so far. End_bit is the number
  752. * of the last bit to be set in this word plus one.
  753. */
  754. if (bit) {
  755. end_bit = MIN(bit + bits_to_set, (uint)NBWORD);
  756. mask = ((1 << (end_bit - bit)) - 1) << bit;
  757. *wordp |= mask;
  758. wordp++;
  759. bits_set = end_bit - bit;
  760. } else {
  761. bits_set = 0;
  762. }
  763. /*
  764. * Now set bits a whole word at a time that are between
  765. * first_bit and last_bit.
  766. */
  767. while ((bits_to_set - bits_set) >= NBWORD) {
  768. *wordp |= 0xffffffff;
  769. bits_set += NBWORD;
  770. wordp++;
  771. }
  772. /*
  773. * Finally, set any bits left to be set in one last partial word.
  774. */
  775. end_bit = bits_to_set - bits_set;
  776. if (end_bit) {
  777. mask = (1 << end_bit) - 1;
  778. *wordp |= mask;
  779. }
  780. xfs_buf_item_log_debug(bip, first, last);
  781. }
  782. /*
  783. * Return 1 if the buffer has some data that has been logged (at any
  784. * point, not just the current transaction) and 0 if not.
  785. */
  786. uint
  787. xfs_buf_item_dirty(
  788. xfs_buf_log_item_t *bip)
  789. {
  790. return (bip->bli_flags & XFS_BLI_DIRTY);
  791. }
  792. /*
  793. * This is called when the buf log item is no longer needed. It should
  794. * free the buf log item associated with the given buffer and clear
  795. * the buffer's pointer to the buf log item. If there are no more
  796. * items in the list, clear the b_iodone field of the buffer (see
  797. * xfs_buf_attach_iodone() below).
  798. */
  799. void
  800. xfs_buf_item_relse(
  801. xfs_buf_t *bp)
  802. {
  803. xfs_buf_log_item_t *bip;
  804. xfs_buftrace("XFS_RELSE", bp);
  805. bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
  806. XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list);
  807. if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) &&
  808. (XFS_BUF_IODONE_FUNC(bp) != NULL)) {
  809. XFS_BUF_CLR_IODONE_FUNC(bp);
  810. }
  811. #ifdef XFS_TRANS_DEBUG
  812. kmem_free(bip->bli_orig, XFS_BUF_COUNT(bp));
  813. bip->bli_orig = NULL;
  814. kmem_free(bip->bli_logged, XFS_BUF_COUNT(bp) / NBBY);
  815. bip->bli_logged = NULL;
  816. #endif /* XFS_TRANS_DEBUG */
  817. #ifdef XFS_BLI_TRACE
  818. ktrace_free(bip->bli_trace);
  819. #endif
  820. kmem_zone_free(xfs_buf_item_zone, bip);
  821. }
  822. /*
  823. * Add the given log item with its callback to the list of callbacks
  824. * to be called when the buffer's I/O completes. If it is not set
  825. * already, set the buffer's b_iodone() routine to be
  826. * xfs_buf_iodone_callbacks() and link the log item into the list of
  827. * items rooted at b_fsprivate. Items are always added as the second
  828. * entry in the list if there is a first, because the buf item code
  829. * assumes that the buf log item is first.
  830. */
  831. void
  832. xfs_buf_attach_iodone(
  833. xfs_buf_t *bp,
  834. void (*cb)(xfs_buf_t *, xfs_log_item_t *),
  835. xfs_log_item_t *lip)
  836. {
  837. xfs_log_item_t *head_lip;
  838. ASSERT(XFS_BUF_ISBUSY(bp));
  839. ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
  840. lip->li_cb = cb;
  841. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  842. head_lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  843. lip->li_bio_list = head_lip->li_bio_list;
  844. head_lip->li_bio_list = lip;
  845. } else {
  846. XFS_BUF_SET_FSPRIVATE(bp, lip);
  847. }
  848. ASSERT((XFS_BUF_IODONE_FUNC(bp) == xfs_buf_iodone_callbacks) ||
  849. (XFS_BUF_IODONE_FUNC(bp) == NULL));
  850. XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
  851. }
  852. STATIC void
  853. xfs_buf_do_callbacks(
  854. xfs_buf_t *bp,
  855. xfs_log_item_t *lip)
  856. {
  857. xfs_log_item_t *nlip;
  858. while (lip != NULL) {
  859. nlip = lip->li_bio_list;
  860. ASSERT(lip->li_cb != NULL);
  861. /*
  862. * Clear the next pointer so we don't have any
  863. * confusion if the item is added to another buf.
  864. * Don't touch the log item after calling its
  865. * callback, because it could have freed itself.
  866. */
  867. lip->li_bio_list = NULL;
  868. lip->li_cb(bp, lip);
  869. lip = nlip;
  870. }
  871. }
  872. /*
  873. * This is the iodone() function for buffers which have had callbacks
  874. * attached to them by xfs_buf_attach_iodone(). It should remove each
  875. * log item from the buffer's list and call the callback of each in turn.
  876. * When done, the buffer's fsprivate field is set to NULL and the buffer
  877. * is unlocked with a call to iodone().
  878. */
  879. void
  880. xfs_buf_iodone_callbacks(
  881. xfs_buf_t *bp)
  882. {
  883. xfs_log_item_t *lip;
  884. static ulong lasttime;
  885. static xfs_buftarg_t *lasttarg;
  886. xfs_mount_t *mp;
  887. ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
  888. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  889. if (XFS_BUF_GETERROR(bp) != 0) {
  890. /*
  891. * If we've already decided to shutdown the filesystem
  892. * because of IO errors, there's no point in giving this
  893. * a retry.
  894. */
  895. mp = lip->li_mountp;
  896. if (XFS_FORCED_SHUTDOWN(mp)) {
  897. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  898. XFS_BUF_SUPER_STALE(bp);
  899. xfs_buftrace("BUF_IODONE_CB", bp);
  900. xfs_buf_do_callbacks(bp, lip);
  901. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  902. XFS_BUF_CLR_IODONE_FUNC(bp);
  903. /*
  904. * XFS_SHUT flag gets set when we go thru the
  905. * entire buffer cache and deliberately start
  906. * throwing away delayed write buffers.
  907. * Since there's no biowait done on those,
  908. * we should just brelse them.
  909. */
  910. if (XFS_BUF_ISSHUT(bp)) {
  911. XFS_BUF_UNSHUT(bp);
  912. xfs_buf_relse(bp);
  913. } else {
  914. xfs_biodone(bp);
  915. }
  916. return;
  917. }
  918. if ((XFS_BUF_TARGET(bp) != lasttarg) ||
  919. (time_after(jiffies, (lasttime + 5*HZ)))) {
  920. lasttime = jiffies;
  921. cmn_err(CE_ALERT, "Device %s, XFS metadata write error"
  922. " block 0x%llx in %s",
  923. XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)),
  924. (__uint64_t)XFS_BUF_ADDR(bp), mp->m_fsname);
  925. }
  926. lasttarg = XFS_BUF_TARGET(bp);
  927. if (XFS_BUF_ISASYNC(bp)) {
  928. /*
  929. * If the write was asynchronous then noone will be
  930. * looking for the error. Clear the error state
  931. * and write the buffer out again delayed write.
  932. *
  933. * XXXsup This is OK, so long as we catch these
  934. * before we start the umount; we don't want these
  935. * DELWRI metadata bufs to be hanging around.
  936. */
  937. XFS_BUF_ERROR(bp,0); /* errno of 0 unsets the flag */
  938. if (!(XFS_BUF_ISSTALE(bp))) {
  939. XFS_BUF_DELAYWRITE(bp);
  940. XFS_BUF_DONE(bp);
  941. XFS_BUF_SET_START(bp);
  942. }
  943. ASSERT(XFS_BUF_IODONE_FUNC(bp));
  944. xfs_buftrace("BUF_IODONE ASYNC", bp);
  945. xfs_buf_relse(bp);
  946. } else {
  947. /*
  948. * If the write of the buffer was not asynchronous,
  949. * then we want to make sure to return the error
  950. * to the caller of bwrite(). Because of this we
  951. * cannot clear the B_ERROR state at this point.
  952. * Instead we install a callback function that
  953. * will be called when the buffer is released, and
  954. * that routine will clear the error state and
  955. * set the buffer to be written out again after
  956. * some delay.
  957. */
  958. /* We actually overwrite the existing b-relse
  959. function at times, but we're gonna be shutting down
  960. anyway. */
  961. XFS_BUF_SET_BRELSE_FUNC(bp,xfs_buf_error_relse);
  962. XFS_BUF_DONE(bp);
  963. XFS_BUF_V_IODONESEMA(bp);
  964. }
  965. return;
  966. }
  967. #ifdef XFSERRORDEBUG
  968. xfs_buftrace("XFS BUFCB NOERR", bp);
  969. #endif
  970. xfs_buf_do_callbacks(bp, lip);
  971. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  972. XFS_BUF_CLR_IODONE_FUNC(bp);
  973. xfs_biodone(bp);
  974. }
  975. /*
  976. * This is a callback routine attached to a buffer which gets an error
  977. * when being written out synchronously.
  978. */
  979. STATIC void
  980. xfs_buf_error_relse(
  981. xfs_buf_t *bp)
  982. {
  983. xfs_log_item_t *lip;
  984. xfs_mount_t *mp;
  985. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  986. mp = (xfs_mount_t *)lip->li_mountp;
  987. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  988. XFS_BUF_STALE(bp);
  989. XFS_BUF_DONE(bp);
  990. XFS_BUF_UNDELAYWRITE(bp);
  991. XFS_BUF_ERROR(bp,0);
  992. xfs_buftrace("BUF_ERROR_RELSE", bp);
  993. if (! XFS_FORCED_SHUTDOWN(mp))
  994. xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
  995. /*
  996. * We have to unpin the pinned buffers so do the
  997. * callbacks.
  998. */
  999. xfs_buf_do_callbacks(bp, lip);
  1000. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  1001. XFS_BUF_CLR_IODONE_FUNC(bp);
  1002. XFS_BUF_SET_BRELSE_FUNC(bp,NULL);
  1003. xfs_buf_relse(bp);
  1004. }
  1005. /*
  1006. * This is the iodone() function for buffers which have been
  1007. * logged. It is called when they are eventually flushed out.
  1008. * It should remove the buf item from the AIL, and free the buf item.
  1009. * It is called by xfs_buf_iodone_callbacks() above which will take
  1010. * care of cleaning up the buffer itself.
  1011. */
  1012. /* ARGSUSED */
  1013. void
  1014. xfs_buf_iodone(
  1015. xfs_buf_t *bp,
  1016. xfs_buf_log_item_t *bip)
  1017. {
  1018. struct xfs_mount *mp;
  1019. SPLDECL(s);
  1020. ASSERT(bip->bli_buf == bp);
  1021. mp = bip->bli_item.li_mountp;
  1022. /*
  1023. * If we are forcibly shutting down, this may well be
  1024. * off the AIL already. That's because we simulate the
  1025. * log-committed callbacks to unpin these buffers. Or we may never
  1026. * have put this item on AIL because of the transaction was
  1027. * aborted forcibly. xfs_trans_delete_ail() takes care of these.
  1028. *
  1029. * Either way, AIL is useless if we're forcing a shutdown.
  1030. */
  1031. AIL_LOCK(mp,s);
  1032. /*
  1033. * xfs_trans_delete_ail() drops the AIL lock.
  1034. */
  1035. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip, s);
  1036. #ifdef XFS_TRANS_DEBUG
  1037. kmem_free(bip->bli_orig, XFS_BUF_COUNT(bp));
  1038. bip->bli_orig = NULL;
  1039. kmem_free(bip->bli_logged, XFS_BUF_COUNT(bp) / NBBY);
  1040. bip->bli_logged = NULL;
  1041. #endif /* XFS_TRANS_DEBUG */
  1042. #ifdef XFS_BLI_TRACE
  1043. ktrace_free(bip->bli_trace);
  1044. #endif
  1045. kmem_zone_free(xfs_buf_item_zone, bip);
  1046. }
  1047. #if defined(XFS_BLI_TRACE)
  1048. void
  1049. xfs_buf_item_trace(
  1050. char *id,
  1051. xfs_buf_log_item_t *bip)
  1052. {
  1053. xfs_buf_t *bp;
  1054. ASSERT(bip->bli_trace != NULL);
  1055. bp = bip->bli_buf;
  1056. ktrace_enter(bip->bli_trace,
  1057. (void *)id,
  1058. (void *)bip->bli_buf,
  1059. (void *)((unsigned long)bip->bli_flags),
  1060. (void *)((unsigned long)bip->bli_recur),
  1061. (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
  1062. (void *)((unsigned long)
  1063. (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
  1064. (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
  1065. (void *)((unsigned long)XFS_BUF_COUNT(bp)),
  1066. (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
  1067. XFS_BUF_FSPRIVATE(bp, void *),
  1068. XFS_BUF_FSPRIVATE2(bp, void *),
  1069. (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
  1070. (void *)XFS_BUF_IODONE_FUNC(bp),
  1071. (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
  1072. (void *)bip->bli_item.li_desc,
  1073. (void *)((unsigned long)bip->bli_item.li_flags));
  1074. }
  1075. #endif /* XFS_BLI_TRACE */