xfs_buf_item.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  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. bp = bip->bli_buf;
  357. ASSERT(bp != NULL);
  358. ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip);
  359. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  360. xfs_buf_item_trace("UNPIN", bip);
  361. xfs_buftrace("XFS_UNPIN", bp);
  362. freed = atomic_dec_and_test(&bip->bli_refcount);
  363. mp = bip->bli_item.li_mountp;
  364. xfs_bunpin(bp);
  365. if (freed && stale) {
  366. ASSERT(bip->bli_flags & XFS_BLI_STALE);
  367. ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
  368. ASSERT(!(XFS_BUF_ISDELAYWRITE(bp)));
  369. ASSERT(XFS_BUF_ISSTALE(bp));
  370. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  371. xfs_buf_item_trace("UNPIN STALE", bip);
  372. xfs_buftrace("XFS_UNPIN STALE", bp);
  373. /*
  374. * If we get called here because of an IO error, we may
  375. * or may not have the item on the AIL. xfs_trans_delete_ail()
  376. * will take care of that situation.
  377. * xfs_trans_delete_ail() drops the AIL lock.
  378. */
  379. if (bip->bli_flags & XFS_BLI_STALE_INODE) {
  380. xfs_buf_do_callbacks(bp, (xfs_log_item_t *)bip);
  381. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  382. XFS_BUF_CLR_IODONE_FUNC(bp);
  383. } else {
  384. spin_lock(&mp->m_ail_lock);
  385. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip);
  386. xfs_buf_item_relse(bp);
  387. ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL);
  388. }
  389. xfs_buf_relse(bp);
  390. }
  391. }
  392. /*
  393. * this is called from uncommit in the forced-shutdown path.
  394. * we need to check to see if the reference count on the log item
  395. * is going to drop to zero. If so, unpin will free the log item
  396. * so we need to free the item's descriptor (that points to the item)
  397. * in the transaction.
  398. */
  399. STATIC void
  400. xfs_buf_item_unpin_remove(
  401. xfs_buf_log_item_t *bip,
  402. xfs_trans_t *tp)
  403. {
  404. xfs_buf_t *bp;
  405. xfs_log_item_desc_t *lidp;
  406. int stale = 0;
  407. bp = bip->bli_buf;
  408. /*
  409. * will xfs_buf_item_unpin() call xfs_buf_item_relse()?
  410. */
  411. if ((atomic_read(&bip->bli_refcount) == 1) &&
  412. (bip->bli_flags & XFS_BLI_STALE)) {
  413. ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0);
  414. xfs_buf_item_trace("UNPIN REMOVE", bip);
  415. xfs_buftrace("XFS_UNPIN_REMOVE", bp);
  416. /*
  417. * yes -- clear the xaction descriptor in-use flag
  418. * and free the chunk if required. We can safely
  419. * do some work here and then call buf_item_unpin
  420. * to do the rest because if the if is true, then
  421. * we are holding the buffer locked so no one else
  422. * will be able to bump up the refcount.
  423. */
  424. lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) bip);
  425. stale = lidp->lid_flags & XFS_LID_BUF_STALE;
  426. xfs_trans_free_item(tp, lidp);
  427. /*
  428. * Since the transaction no longer refers to the buffer,
  429. * the buffer should no longer refer to the transaction.
  430. */
  431. XFS_BUF_SET_FSPRIVATE2(bp, NULL);
  432. }
  433. xfs_buf_item_unpin(bip, stale);
  434. return;
  435. }
  436. /*
  437. * This is called to attempt to lock the buffer associated with this
  438. * buf log item. Don't sleep on the buffer lock. If we can't get
  439. * the lock right away, return 0. If we can get the lock, pull the
  440. * buffer from the free list, mark it busy, and return 1.
  441. */
  442. STATIC uint
  443. xfs_buf_item_trylock(
  444. xfs_buf_log_item_t *bip)
  445. {
  446. xfs_buf_t *bp;
  447. bp = bip->bli_buf;
  448. if (XFS_BUF_ISPINNED(bp)) {
  449. return XFS_ITEM_PINNED;
  450. }
  451. if (!XFS_BUF_CPSEMA(bp)) {
  452. return XFS_ITEM_LOCKED;
  453. }
  454. /*
  455. * Remove the buffer from the free list. Only do this
  456. * if it's on the free list. Private buffers like the
  457. * superblock buffer are not.
  458. */
  459. XFS_BUF_HOLD(bp);
  460. ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
  461. xfs_buf_item_trace("TRYLOCK SUCCESS", bip);
  462. return XFS_ITEM_SUCCESS;
  463. }
  464. /*
  465. * Release the buffer associated with the buf log item.
  466. * If there is no dirty logged data associated with the
  467. * buffer recorded in the buf log item, then free the
  468. * buf log item and remove the reference to it in the
  469. * buffer.
  470. *
  471. * This call ignores the recursion count. It is only called
  472. * when the buffer should REALLY be unlocked, regardless
  473. * of the recursion count.
  474. *
  475. * If the XFS_BLI_HOLD flag is set in the buf log item, then
  476. * free the log item if necessary but do not unlock the buffer.
  477. * This is for support of xfs_trans_bhold(). Make sure the
  478. * XFS_BLI_HOLD field is cleared if we don't free the item.
  479. */
  480. STATIC void
  481. xfs_buf_item_unlock(
  482. xfs_buf_log_item_t *bip)
  483. {
  484. int aborted;
  485. xfs_buf_t *bp;
  486. uint hold;
  487. bp = bip->bli_buf;
  488. xfs_buftrace("XFS_UNLOCK", bp);
  489. /*
  490. * Clear the buffer's association with this transaction.
  491. */
  492. XFS_BUF_SET_FSPRIVATE2(bp, NULL);
  493. /*
  494. * If this is a transaction abort, don't return early.
  495. * Instead, allow the brelse to happen.
  496. * Normally it would be done for stale (cancelled) buffers
  497. * at unpin time, but we'll never go through the pin/unpin
  498. * cycle if we abort inside commit.
  499. */
  500. aborted = (bip->bli_item.li_flags & XFS_LI_ABORTED) != 0;
  501. /*
  502. * If the buf item is marked stale, then don't do anything.
  503. * We'll unlock the buffer and free the buf item when the
  504. * buffer is unpinned for the last time.
  505. */
  506. if (bip->bli_flags & XFS_BLI_STALE) {
  507. bip->bli_flags &= ~XFS_BLI_LOGGED;
  508. xfs_buf_item_trace("UNLOCK STALE", bip);
  509. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  510. if (!aborted)
  511. return;
  512. }
  513. /*
  514. * Drop the transaction's reference to the log item if
  515. * it was not logged as part of the transaction. Otherwise
  516. * we'll drop the reference in xfs_buf_item_unpin() when
  517. * the transaction is really through with the buffer.
  518. */
  519. if (!(bip->bli_flags & XFS_BLI_LOGGED)) {
  520. atomic_dec(&bip->bli_refcount);
  521. } else {
  522. /*
  523. * Clear the logged flag since this is per
  524. * transaction state.
  525. */
  526. bip->bli_flags &= ~XFS_BLI_LOGGED;
  527. }
  528. /*
  529. * Before possibly freeing the buf item, determine if we should
  530. * release the buffer at the end of this routine.
  531. */
  532. hold = bip->bli_flags & XFS_BLI_HOLD;
  533. xfs_buf_item_trace("UNLOCK", bip);
  534. /*
  535. * If the buf item isn't tracking any data, free it.
  536. * Otherwise, if XFS_BLI_HOLD is set clear it.
  537. */
  538. if (xfs_bitmap_empty(bip->bli_format.blf_data_map,
  539. bip->bli_format.blf_map_size)) {
  540. xfs_buf_item_relse(bp);
  541. } else if (hold) {
  542. bip->bli_flags &= ~XFS_BLI_HOLD;
  543. }
  544. /*
  545. * Release the buffer if XFS_BLI_HOLD was not set.
  546. */
  547. if (!hold) {
  548. xfs_buf_relse(bp);
  549. }
  550. }
  551. /*
  552. * This is called to find out where the oldest active copy of the
  553. * buf log item in the on disk log resides now that the last log
  554. * write of it completed at the given lsn.
  555. * We always re-log all the dirty data in a buffer, so usually the
  556. * latest copy in the on disk log is the only one that matters. For
  557. * those cases we simply return the given lsn.
  558. *
  559. * The one exception to this is for buffers full of newly allocated
  560. * inodes. These buffers are only relogged with the XFS_BLI_INODE_BUF
  561. * flag set, indicating that only the di_next_unlinked fields from the
  562. * inodes in the buffers will be replayed during recovery. If the
  563. * original newly allocated inode images have not yet been flushed
  564. * when the buffer is so relogged, then we need to make sure that we
  565. * keep the old images in the 'active' portion of the log. We do this
  566. * by returning the original lsn of that transaction here rather than
  567. * the current one.
  568. */
  569. STATIC xfs_lsn_t
  570. xfs_buf_item_committed(
  571. xfs_buf_log_item_t *bip,
  572. xfs_lsn_t lsn)
  573. {
  574. xfs_buf_item_trace("COMMITTED", bip);
  575. if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
  576. (bip->bli_item.li_lsn != 0)) {
  577. return bip->bli_item.li_lsn;
  578. }
  579. return (lsn);
  580. }
  581. /*
  582. * This is called to asynchronously write the buffer associated with this
  583. * buf log item out to disk. The buffer will already have been locked by
  584. * a successful call to xfs_buf_item_trylock(). If the buffer still has
  585. * B_DELWRI set, then get it going out to disk with a call to bawrite().
  586. * If not, then just release the buffer.
  587. */
  588. STATIC void
  589. xfs_buf_item_push(
  590. xfs_buf_log_item_t *bip)
  591. {
  592. xfs_buf_t *bp;
  593. ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
  594. xfs_buf_item_trace("PUSH", bip);
  595. bp = bip->bli_buf;
  596. if (XFS_BUF_ISDELAYWRITE(bp)) {
  597. int error;
  598. error = xfs_bawrite(bip->bli_item.li_mountp, bp);
  599. if (error)
  600. xfs_fs_cmn_err(CE_WARN, bip->bli_item.li_mountp,
  601. "xfs_buf_item_push: pushbuf error %d on bip %p, bp %p",
  602. error, bip, bp);
  603. } else {
  604. xfs_buf_relse(bp);
  605. }
  606. }
  607. /* ARGSUSED */
  608. STATIC void
  609. xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
  610. {
  611. }
  612. /*
  613. * This is the ops vector shared by all buf log items.
  614. */
  615. static struct xfs_item_ops xfs_buf_item_ops = {
  616. .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size,
  617. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  618. xfs_buf_item_format,
  619. .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin,
  620. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin,
  621. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
  622. xfs_buf_item_unpin_remove,
  623. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock,
  624. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_buf_item_unlock,
  625. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  626. xfs_buf_item_committed,
  627. .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push,
  628. .iop_pushbuf = NULL,
  629. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  630. xfs_buf_item_committing
  631. };
  632. /*
  633. * Allocate a new buf log item to go with the given buffer.
  634. * Set the buffer's b_fsprivate field to point to the new
  635. * buf log item. If there are other item's attached to the
  636. * buffer (see xfs_buf_attach_iodone() below), then put the
  637. * buf log item at the front.
  638. */
  639. void
  640. xfs_buf_item_init(
  641. xfs_buf_t *bp,
  642. xfs_mount_t *mp)
  643. {
  644. xfs_log_item_t *lip;
  645. xfs_buf_log_item_t *bip;
  646. int chunks;
  647. int map_size;
  648. /*
  649. * Check to see if there is already a buf log item for
  650. * this buffer. If there is, it is guaranteed to be
  651. * the first. If we do already have one, there is
  652. * nothing to do here so return.
  653. */
  654. if (XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *) != mp)
  655. XFS_BUF_SET_FSPRIVATE3(bp, mp);
  656. XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
  657. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  658. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  659. if (lip->li_type == XFS_LI_BUF) {
  660. return;
  661. }
  662. }
  663. /*
  664. * chunks is the number of XFS_BLI_CHUNK size pieces
  665. * the buffer can be divided into. Make sure not to
  666. * truncate any pieces. map_size is the size of the
  667. * bitmap needed to describe the chunks of the buffer.
  668. */
  669. chunks = (int)((XFS_BUF_COUNT(bp) + (XFS_BLI_CHUNK - 1)) >> XFS_BLI_SHIFT);
  670. map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT);
  671. bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
  672. KM_SLEEP);
  673. bip->bli_item.li_type = XFS_LI_BUF;
  674. bip->bli_item.li_ops = &xfs_buf_item_ops;
  675. bip->bli_item.li_mountp = mp;
  676. bip->bli_buf = bp;
  677. xfs_buf_hold(bp);
  678. bip->bli_format.blf_type = XFS_LI_BUF;
  679. bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp);
  680. bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp));
  681. bip->bli_format.blf_map_size = map_size;
  682. #ifdef XFS_BLI_TRACE
  683. bip->bli_trace = ktrace_alloc(XFS_BLI_TRACE_SIZE, KM_NOFS);
  684. #endif
  685. #ifdef XFS_TRANS_DEBUG
  686. /*
  687. * Allocate the arrays for tracking what needs to be logged
  688. * and what our callers request to be logged. bli_orig
  689. * holds a copy of the original, clean buffer for comparison
  690. * against, and bli_logged keeps a 1 bit flag per byte in
  691. * the buffer to indicate which bytes the callers have asked
  692. * to have logged.
  693. */
  694. bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP);
  695. memcpy(bip->bli_orig, XFS_BUF_PTR(bp), XFS_BUF_COUNT(bp));
  696. bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP);
  697. #endif
  698. /*
  699. * Put the buf item into the list of items attached to the
  700. * buffer at the front.
  701. */
  702. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  703. bip->bli_item.li_bio_list =
  704. XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  705. }
  706. XFS_BUF_SET_FSPRIVATE(bp, bip);
  707. }
  708. /*
  709. * Mark bytes first through last inclusive as dirty in the buf
  710. * item's bitmap.
  711. */
  712. void
  713. xfs_buf_item_log(
  714. xfs_buf_log_item_t *bip,
  715. uint first,
  716. uint last)
  717. {
  718. uint first_bit;
  719. uint last_bit;
  720. uint bits_to_set;
  721. uint bits_set;
  722. uint word_num;
  723. uint *wordp;
  724. uint bit;
  725. uint end_bit;
  726. uint mask;
  727. /*
  728. * Mark the item as having some dirty data for
  729. * quick reference in xfs_buf_item_dirty.
  730. */
  731. bip->bli_flags |= XFS_BLI_DIRTY;
  732. /*
  733. * Convert byte offsets to bit numbers.
  734. */
  735. first_bit = first >> XFS_BLI_SHIFT;
  736. last_bit = last >> XFS_BLI_SHIFT;
  737. /*
  738. * Calculate the total number of bits to be set.
  739. */
  740. bits_to_set = last_bit - first_bit + 1;
  741. /*
  742. * Get a pointer to the first word in the bitmap
  743. * to set a bit in.
  744. */
  745. word_num = first_bit >> BIT_TO_WORD_SHIFT;
  746. wordp = &(bip->bli_format.blf_data_map[word_num]);
  747. /*
  748. * Calculate the starting bit in the first word.
  749. */
  750. bit = first_bit & (uint)(NBWORD - 1);
  751. /*
  752. * First set any bits in the first word of our range.
  753. * If it starts at bit 0 of the word, it will be
  754. * set below rather than here. That is what the variable
  755. * bit tells us. The variable bits_set tracks the number
  756. * of bits that have been set so far. End_bit is the number
  757. * of the last bit to be set in this word plus one.
  758. */
  759. if (bit) {
  760. end_bit = MIN(bit + bits_to_set, (uint)NBWORD);
  761. mask = ((1 << (end_bit - bit)) - 1) << bit;
  762. *wordp |= mask;
  763. wordp++;
  764. bits_set = end_bit - bit;
  765. } else {
  766. bits_set = 0;
  767. }
  768. /*
  769. * Now set bits a whole word at a time that are between
  770. * first_bit and last_bit.
  771. */
  772. while ((bits_to_set - bits_set) >= NBWORD) {
  773. *wordp |= 0xffffffff;
  774. bits_set += NBWORD;
  775. wordp++;
  776. }
  777. /*
  778. * Finally, set any bits left to be set in one last partial word.
  779. */
  780. end_bit = bits_to_set - bits_set;
  781. if (end_bit) {
  782. mask = (1 << end_bit) - 1;
  783. *wordp |= mask;
  784. }
  785. xfs_buf_item_log_debug(bip, first, last);
  786. }
  787. /*
  788. * Return 1 if the buffer has some data that has been logged (at any
  789. * point, not just the current transaction) and 0 if not.
  790. */
  791. uint
  792. xfs_buf_item_dirty(
  793. xfs_buf_log_item_t *bip)
  794. {
  795. return (bip->bli_flags & XFS_BLI_DIRTY);
  796. }
  797. STATIC void
  798. xfs_buf_item_free(
  799. xfs_buf_log_item_t *bip)
  800. {
  801. #ifdef XFS_TRANS_DEBUG
  802. kmem_free(bip->bli_orig);
  803. kmem_free(bip->bli_logged);
  804. #endif /* XFS_TRANS_DEBUG */
  805. #ifdef XFS_BLI_TRACE
  806. ktrace_free(bip->bli_trace);
  807. #endif
  808. kmem_zone_free(xfs_buf_item_zone, bip);
  809. }
  810. /*
  811. * This is called when the buf log item is no longer needed. It should
  812. * free the buf log item associated with the given buffer and clear
  813. * the buffer's pointer to the buf log item. If there are no more
  814. * items in the list, clear the b_iodone field of the buffer (see
  815. * xfs_buf_attach_iodone() below).
  816. */
  817. void
  818. xfs_buf_item_relse(
  819. xfs_buf_t *bp)
  820. {
  821. xfs_buf_log_item_t *bip;
  822. xfs_buftrace("XFS_RELSE", bp);
  823. bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
  824. XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list);
  825. if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) &&
  826. (XFS_BUF_IODONE_FUNC(bp) != NULL)) {
  827. XFS_BUF_CLR_IODONE_FUNC(bp);
  828. }
  829. xfs_buf_rele(bp);
  830. xfs_buf_item_free(bip);
  831. }
  832. /*
  833. * Add the given log item with its callback to the list of callbacks
  834. * to be called when the buffer's I/O completes. If it is not set
  835. * already, set the buffer's b_iodone() routine to be
  836. * xfs_buf_iodone_callbacks() and link the log item into the list of
  837. * items rooted at b_fsprivate. Items are always added as the second
  838. * entry in the list if there is a first, because the buf item code
  839. * assumes that the buf log item is first.
  840. */
  841. void
  842. xfs_buf_attach_iodone(
  843. xfs_buf_t *bp,
  844. void (*cb)(xfs_buf_t *, xfs_log_item_t *),
  845. xfs_log_item_t *lip)
  846. {
  847. xfs_log_item_t *head_lip;
  848. ASSERT(XFS_BUF_ISBUSY(bp));
  849. ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
  850. lip->li_cb = cb;
  851. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  852. head_lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  853. lip->li_bio_list = head_lip->li_bio_list;
  854. head_lip->li_bio_list = lip;
  855. } else {
  856. XFS_BUF_SET_FSPRIVATE(bp, lip);
  857. }
  858. ASSERT((XFS_BUF_IODONE_FUNC(bp) == xfs_buf_iodone_callbacks) ||
  859. (XFS_BUF_IODONE_FUNC(bp) == NULL));
  860. XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
  861. }
  862. STATIC void
  863. xfs_buf_do_callbacks(
  864. xfs_buf_t *bp,
  865. xfs_log_item_t *lip)
  866. {
  867. xfs_log_item_t *nlip;
  868. while (lip != NULL) {
  869. nlip = lip->li_bio_list;
  870. ASSERT(lip->li_cb != NULL);
  871. /*
  872. * Clear the next pointer so we don't have any
  873. * confusion if the item is added to another buf.
  874. * Don't touch the log item after calling its
  875. * callback, because it could have freed itself.
  876. */
  877. lip->li_bio_list = NULL;
  878. lip->li_cb(bp, lip);
  879. lip = nlip;
  880. }
  881. }
  882. /*
  883. * This is the iodone() function for buffers which have had callbacks
  884. * attached to them by xfs_buf_attach_iodone(). It should remove each
  885. * log item from the buffer's list and call the callback of each in turn.
  886. * When done, the buffer's fsprivate field is set to NULL and the buffer
  887. * is unlocked with a call to iodone().
  888. */
  889. void
  890. xfs_buf_iodone_callbacks(
  891. xfs_buf_t *bp)
  892. {
  893. xfs_log_item_t *lip;
  894. static ulong lasttime;
  895. static xfs_buftarg_t *lasttarg;
  896. xfs_mount_t *mp;
  897. ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
  898. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  899. if (XFS_BUF_GETERROR(bp) != 0) {
  900. /*
  901. * If we've already decided to shutdown the filesystem
  902. * because of IO errors, there's no point in giving this
  903. * a retry.
  904. */
  905. mp = lip->li_mountp;
  906. if (XFS_FORCED_SHUTDOWN(mp)) {
  907. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  908. XFS_BUF_SUPER_STALE(bp);
  909. xfs_buftrace("BUF_IODONE_CB", bp);
  910. xfs_buf_do_callbacks(bp, lip);
  911. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  912. XFS_BUF_CLR_IODONE_FUNC(bp);
  913. /*
  914. * XFS_SHUT flag gets set when we go thru the
  915. * entire buffer cache and deliberately start
  916. * throwing away delayed write buffers.
  917. * Since there's no biowait done on those,
  918. * we should just brelse them.
  919. */
  920. if (XFS_BUF_ISSHUT(bp)) {
  921. XFS_BUF_UNSHUT(bp);
  922. xfs_buf_relse(bp);
  923. } else {
  924. xfs_biodone(bp);
  925. }
  926. return;
  927. }
  928. if ((XFS_BUF_TARGET(bp) != lasttarg) ||
  929. (time_after(jiffies, (lasttime + 5*HZ)))) {
  930. lasttime = jiffies;
  931. cmn_err(CE_ALERT, "Device %s, XFS metadata write error"
  932. " block 0x%llx in %s",
  933. XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)),
  934. (__uint64_t)XFS_BUF_ADDR(bp), mp->m_fsname);
  935. }
  936. lasttarg = XFS_BUF_TARGET(bp);
  937. if (XFS_BUF_ISASYNC(bp)) {
  938. /*
  939. * If the write was asynchronous then noone will be
  940. * looking for the error. Clear the error state
  941. * and write the buffer out again delayed write.
  942. *
  943. * XXXsup This is OK, so long as we catch these
  944. * before we start the umount; we don't want these
  945. * DELWRI metadata bufs to be hanging around.
  946. */
  947. XFS_BUF_ERROR(bp,0); /* errno of 0 unsets the flag */
  948. if (!(XFS_BUF_ISSTALE(bp))) {
  949. XFS_BUF_DELAYWRITE(bp);
  950. XFS_BUF_DONE(bp);
  951. XFS_BUF_SET_START(bp);
  952. }
  953. ASSERT(XFS_BUF_IODONE_FUNC(bp));
  954. xfs_buftrace("BUF_IODONE ASYNC", bp);
  955. xfs_buf_relse(bp);
  956. } else {
  957. /*
  958. * If the write of the buffer was not asynchronous,
  959. * then we want to make sure to return the error
  960. * to the caller of bwrite(). Because of this we
  961. * cannot clear the B_ERROR state at this point.
  962. * Instead we install a callback function that
  963. * will be called when the buffer is released, and
  964. * that routine will clear the error state and
  965. * set the buffer to be written out again after
  966. * some delay.
  967. */
  968. /* We actually overwrite the existing b-relse
  969. function at times, but we're gonna be shutting down
  970. anyway. */
  971. XFS_BUF_SET_BRELSE_FUNC(bp,xfs_buf_error_relse);
  972. XFS_BUF_DONE(bp);
  973. XFS_BUF_FINISH_IOWAIT(bp);
  974. }
  975. return;
  976. }
  977. #ifdef XFSERRORDEBUG
  978. xfs_buftrace("XFS BUFCB NOERR", bp);
  979. #endif
  980. xfs_buf_do_callbacks(bp, lip);
  981. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  982. XFS_BUF_CLR_IODONE_FUNC(bp);
  983. xfs_biodone(bp);
  984. }
  985. /*
  986. * This is a callback routine attached to a buffer which gets an error
  987. * when being written out synchronously.
  988. */
  989. STATIC void
  990. xfs_buf_error_relse(
  991. xfs_buf_t *bp)
  992. {
  993. xfs_log_item_t *lip;
  994. xfs_mount_t *mp;
  995. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  996. mp = (xfs_mount_t *)lip->li_mountp;
  997. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  998. XFS_BUF_STALE(bp);
  999. XFS_BUF_DONE(bp);
  1000. XFS_BUF_UNDELAYWRITE(bp);
  1001. XFS_BUF_ERROR(bp,0);
  1002. xfs_buftrace("BUF_ERROR_RELSE", bp);
  1003. if (! XFS_FORCED_SHUTDOWN(mp))
  1004. xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
  1005. /*
  1006. * We have to unpin the pinned buffers so do the
  1007. * callbacks.
  1008. */
  1009. xfs_buf_do_callbacks(bp, lip);
  1010. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  1011. XFS_BUF_CLR_IODONE_FUNC(bp);
  1012. XFS_BUF_SET_BRELSE_FUNC(bp,NULL);
  1013. xfs_buf_relse(bp);
  1014. }
  1015. /*
  1016. * This is the iodone() function for buffers which have been
  1017. * logged. It is called when they are eventually flushed out.
  1018. * It should remove the buf item from the AIL, and free the buf item.
  1019. * It is called by xfs_buf_iodone_callbacks() above which will take
  1020. * care of cleaning up the buffer itself.
  1021. */
  1022. /* ARGSUSED */
  1023. void
  1024. xfs_buf_iodone(
  1025. xfs_buf_t *bp,
  1026. xfs_buf_log_item_t *bip)
  1027. {
  1028. struct xfs_mount *mp;
  1029. ASSERT(bip->bli_buf == bp);
  1030. xfs_buf_rele(bp);
  1031. mp = bip->bli_item.li_mountp;
  1032. /*
  1033. * If we are forcibly shutting down, this may well be
  1034. * off the AIL already. That's because we simulate the
  1035. * log-committed callbacks to unpin these buffers. Or we may never
  1036. * have put this item on AIL because of the transaction was
  1037. * aborted forcibly. xfs_trans_delete_ail() takes care of these.
  1038. *
  1039. * Either way, AIL is useless if we're forcing a shutdown.
  1040. */
  1041. spin_lock(&mp->m_ail_lock);
  1042. /*
  1043. * xfs_trans_delete_ail() drops the AIL lock.
  1044. */
  1045. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip);
  1046. xfs_buf_item_free(bip);
  1047. }
  1048. #if defined(XFS_BLI_TRACE)
  1049. void
  1050. xfs_buf_item_trace(
  1051. char *id,
  1052. xfs_buf_log_item_t *bip)
  1053. {
  1054. xfs_buf_t *bp;
  1055. ASSERT(bip->bli_trace != NULL);
  1056. bp = bip->bli_buf;
  1057. ktrace_enter(bip->bli_trace,
  1058. (void *)id,
  1059. (void *)bip->bli_buf,
  1060. (void *)((unsigned long)bip->bli_flags),
  1061. (void *)((unsigned long)bip->bli_recur),
  1062. (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
  1063. (void *)((unsigned long)
  1064. (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
  1065. (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
  1066. (void *)((unsigned long)XFS_BUF_COUNT(bp)),
  1067. (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
  1068. XFS_BUF_FSPRIVATE(bp, void *),
  1069. XFS_BUF_FSPRIVATE2(bp, void *),
  1070. (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
  1071. (void *)XFS_BUF_IODONE_FUNC(bp),
  1072. (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
  1073. (void *)bip->bli_item.li_desc,
  1074. (void *)((unsigned long)bip->bli_item.li_flags));
  1075. }
  1076. #endif /* XFS_BLI_TRACE */