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_dmapi.h"
  27. #include "xfs_mount.h"
  28. #include "xfs_buf_item.h"
  29. #include "xfs_trans_priv.h"
  30. #include "xfs_error.h"
  31. kmem_zone_t *xfs_buf_item_zone;
  32. #ifdef XFS_TRANS_DEBUG
  33. /*
  34. * This function uses an alternate strategy for tracking the bytes
  35. * that the user requests to be logged. This can then be used
  36. * in conjunction with the bli_orig array in the buf log item to
  37. * catch bugs in our callers' code.
  38. *
  39. * We also double check the bits set in xfs_buf_item_log using a
  40. * simple algorithm to check that every byte is accounted for.
  41. */
  42. STATIC void
  43. xfs_buf_item_log_debug(
  44. xfs_buf_log_item_t *bip,
  45. uint first,
  46. uint last)
  47. {
  48. uint x;
  49. uint byte;
  50. uint nbytes;
  51. uint chunk_num;
  52. uint word_num;
  53. uint bit_num;
  54. uint bit_set;
  55. uint *wordp;
  56. ASSERT(bip->bli_logged != NULL);
  57. byte = first;
  58. nbytes = last - first + 1;
  59. bfset(bip->bli_logged, first, nbytes);
  60. for (x = 0; x < nbytes; x++) {
  61. chunk_num = byte >> XFS_BLI_SHIFT;
  62. word_num = chunk_num >> BIT_TO_WORD_SHIFT;
  63. bit_num = chunk_num & (NBWORD - 1);
  64. wordp = &(bip->bli_format.blf_data_map[word_num]);
  65. bit_set = *wordp & (1 << bit_num);
  66. ASSERT(bit_set);
  67. byte++;
  68. }
  69. }
  70. /*
  71. * This function is called when we flush something into a buffer without
  72. * logging it. This happens for things like inodes which are logged
  73. * separately from the buffer.
  74. */
  75. void
  76. xfs_buf_item_flush_log_debug(
  77. xfs_buf_t *bp,
  78. uint first,
  79. uint last)
  80. {
  81. xfs_buf_log_item_t *bip;
  82. uint nbytes;
  83. bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
  84. if ((bip == NULL) || (bip->bli_item.li_type != XFS_LI_BUF)) {
  85. return;
  86. }
  87. ASSERT(bip->bli_logged != NULL);
  88. nbytes = last - first + 1;
  89. bfset(bip->bli_logged, first, nbytes);
  90. }
  91. /*
  92. * This function is called to verify that our callers have logged
  93. * all the bytes that they changed.
  94. *
  95. * It does this by comparing the original copy of the buffer stored in
  96. * the buf log item's bli_orig array to the current copy of the buffer
  97. * and ensuring that all bytes which mismatch are set in the bli_logged
  98. * array of the buf log item.
  99. */
  100. STATIC void
  101. xfs_buf_item_log_check(
  102. xfs_buf_log_item_t *bip)
  103. {
  104. char *orig;
  105. char *buffer;
  106. int x;
  107. xfs_buf_t *bp;
  108. ASSERT(bip->bli_orig != NULL);
  109. ASSERT(bip->bli_logged != NULL);
  110. bp = bip->bli_buf;
  111. ASSERT(XFS_BUF_COUNT(bp) > 0);
  112. ASSERT(XFS_BUF_PTR(bp) != NULL);
  113. orig = bip->bli_orig;
  114. buffer = XFS_BUF_PTR(bp);
  115. for (x = 0; x < XFS_BUF_COUNT(bp); x++) {
  116. if (orig[x] != buffer[x] && !btst(bip->bli_logged, x))
  117. cmn_err(CE_PANIC,
  118. "xfs_buf_item_log_check bip %x buffer %x orig %x index %d",
  119. bip, bp, orig, x);
  120. }
  121. }
  122. #else
  123. #define xfs_buf_item_log_debug(x,y,z)
  124. #define xfs_buf_item_log_check(x)
  125. #endif
  126. STATIC void xfs_buf_error_relse(xfs_buf_t *bp);
  127. STATIC void xfs_buf_do_callbacks(xfs_buf_t *bp, xfs_log_item_t *lip);
  128. /*
  129. * This returns the number of log iovecs needed to log the
  130. * given buf log item.
  131. *
  132. * It calculates this as 1 iovec for the buf log format structure
  133. * and 1 for each stretch of non-contiguous chunks to be logged.
  134. * Contiguous chunks are logged in a single iovec.
  135. *
  136. * If the XFS_BLI_STALE flag has been set, then log nothing.
  137. */
  138. STATIC uint
  139. xfs_buf_item_size(
  140. xfs_buf_log_item_t *bip)
  141. {
  142. uint nvecs;
  143. int next_bit;
  144. int last_bit;
  145. xfs_buf_t *bp;
  146. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  147. if (bip->bli_flags & XFS_BLI_STALE) {
  148. /*
  149. * The buffer is stale, so all we need to log
  150. * is the buf log format structure with the
  151. * cancel flag in it.
  152. */
  153. xfs_buf_item_trace("SIZE STALE", bip);
  154. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  155. return 1;
  156. }
  157. bp = bip->bli_buf;
  158. ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
  159. nvecs = 1;
  160. last_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  161. bip->bli_format.blf_map_size, 0);
  162. ASSERT(last_bit != -1);
  163. nvecs++;
  164. while (last_bit != -1) {
  165. /*
  166. * This takes the bit number to start looking from and
  167. * returns the next set bit from there. It returns -1
  168. * if there are no more bits set or the start bit is
  169. * beyond the end of the bitmap.
  170. */
  171. next_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  172. bip->bli_format.blf_map_size,
  173. last_bit + 1);
  174. /*
  175. * If we run out of bits, leave the loop,
  176. * else if we find a new set of bits bump the number of vecs,
  177. * else keep scanning the current set of bits.
  178. */
  179. if (next_bit == -1) {
  180. last_bit = -1;
  181. } else if (next_bit != last_bit + 1) {
  182. last_bit = next_bit;
  183. nvecs++;
  184. } else if (xfs_buf_offset(bp, next_bit * XFS_BLI_CHUNK) !=
  185. (xfs_buf_offset(bp, last_bit * XFS_BLI_CHUNK) +
  186. XFS_BLI_CHUNK)) {
  187. last_bit = next_bit;
  188. nvecs++;
  189. } else {
  190. last_bit++;
  191. }
  192. }
  193. xfs_buf_item_trace("SIZE NORM", bip);
  194. return nvecs;
  195. }
  196. /*
  197. * This is called to fill in the vector of log iovecs for the
  198. * given log buf item. It fills the first entry with a buf log
  199. * format structure, and the rest point to contiguous chunks
  200. * within the buffer.
  201. */
  202. STATIC void
  203. xfs_buf_item_format(
  204. xfs_buf_log_item_t *bip,
  205. xfs_log_iovec_t *log_vector)
  206. {
  207. uint base_size;
  208. uint nvecs;
  209. xfs_log_iovec_t *vecp;
  210. xfs_buf_t *bp;
  211. int first_bit;
  212. int last_bit;
  213. int next_bit;
  214. uint nbits;
  215. uint buffer_offset;
  216. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  217. ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
  218. (bip->bli_flags & XFS_BLI_STALE));
  219. bp = bip->bli_buf;
  220. vecp = log_vector;
  221. /*
  222. * The size of the base structure is the size of the
  223. * declared structure plus the space for the extra words
  224. * of the bitmap. We subtract one from the map size, because
  225. * the first element of the bitmap is accounted for in the
  226. * size of the base structure.
  227. */
  228. base_size =
  229. (uint)(sizeof(xfs_buf_log_format_t) +
  230. ((bip->bli_format.blf_map_size - 1) * sizeof(uint)));
  231. vecp->i_addr = (xfs_caddr_t)&bip->bli_format;
  232. vecp->i_len = base_size;
  233. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BFORMAT);
  234. vecp++;
  235. nvecs = 1;
  236. if (bip->bli_flags & XFS_BLI_STALE) {
  237. /*
  238. * The buffer is stale, so all we need to log
  239. * is the buf log format structure with the
  240. * cancel flag in it.
  241. */
  242. xfs_buf_item_trace("FORMAT STALE", bip);
  243. ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
  244. bip->bli_format.blf_size = nvecs;
  245. return;
  246. }
  247. /*
  248. * Fill in an iovec for each set of contiguous chunks.
  249. */
  250. first_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  251. bip->bli_format.blf_map_size, 0);
  252. ASSERT(first_bit != -1);
  253. last_bit = first_bit;
  254. nbits = 1;
  255. for (;;) {
  256. /*
  257. * This takes the bit number to start looking from and
  258. * returns the next set bit from there. It returns -1
  259. * if there are no more bits set or the start bit is
  260. * beyond the end of the bitmap.
  261. */
  262. next_bit = xfs_next_bit(bip->bli_format.blf_data_map,
  263. bip->bli_format.blf_map_size,
  264. (uint)last_bit + 1);
  265. /*
  266. * If we run out of bits fill in the last iovec and get
  267. * out of the loop.
  268. * Else if we start a new set of bits then fill in the
  269. * iovec for the series we were looking at and start
  270. * counting the bits in the new one.
  271. * Else we're still in the same set of bits so just
  272. * keep counting and scanning.
  273. */
  274. if (next_bit == -1) {
  275. buffer_offset = first_bit * XFS_BLI_CHUNK;
  276. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  277. vecp->i_len = nbits * XFS_BLI_CHUNK;
  278. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  279. nvecs++;
  280. break;
  281. } else if (next_bit != last_bit + 1) {
  282. buffer_offset = first_bit * XFS_BLI_CHUNK;
  283. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  284. vecp->i_len = nbits * XFS_BLI_CHUNK;
  285. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  286. nvecs++;
  287. vecp++;
  288. first_bit = next_bit;
  289. last_bit = next_bit;
  290. nbits = 1;
  291. } else if (xfs_buf_offset(bp, next_bit << XFS_BLI_SHIFT) !=
  292. (xfs_buf_offset(bp, last_bit << XFS_BLI_SHIFT) +
  293. XFS_BLI_CHUNK)) {
  294. buffer_offset = first_bit * XFS_BLI_CHUNK;
  295. vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
  296. vecp->i_len = nbits * XFS_BLI_CHUNK;
  297. XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_BCHUNK);
  298. /* You would think we need to bump the nvecs here too, but we do not
  299. * this number is used by recovery, and it gets confused by the boundary
  300. * split here
  301. * nvecs++;
  302. */
  303. vecp++;
  304. first_bit = next_bit;
  305. last_bit = next_bit;
  306. nbits = 1;
  307. } else {
  308. last_bit++;
  309. nbits++;
  310. }
  311. }
  312. bip->bli_format.blf_size = nvecs;
  313. /*
  314. * Check to make sure everything is consistent.
  315. */
  316. xfs_buf_item_trace("FORMAT NORM", bip);
  317. xfs_buf_item_log_check(bip);
  318. }
  319. /*
  320. * This is called to pin the buffer associated with the buf log
  321. * item in memory so it cannot be written out. Simply call bpin()
  322. * on the buffer to do this.
  323. */
  324. STATIC void
  325. xfs_buf_item_pin(
  326. xfs_buf_log_item_t *bip)
  327. {
  328. xfs_buf_t *bp;
  329. bp = bip->bli_buf;
  330. ASSERT(XFS_BUF_ISBUSY(bp));
  331. ASSERT(atomic_read(&bip->bli_refcount) > 0);
  332. ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
  333. (bip->bli_flags & XFS_BLI_STALE));
  334. xfs_buf_item_trace("PIN", bip);
  335. xfs_buftrace("XFS_PIN", bp);
  336. xfs_bpin(bp);
  337. }
  338. /*
  339. * This is called to unpin the buffer associated with the buf log
  340. * item which was previously pinned with a call to xfs_buf_item_pin().
  341. * Just call bunpin() on the buffer to do this.
  342. *
  343. * Also drop the reference to the buf item for the current transaction.
  344. * If the XFS_BLI_STALE flag is set and we are the last reference,
  345. * then free up the buf log item and unlock the buffer.
  346. */
  347. STATIC void
  348. xfs_buf_item_unpin(
  349. xfs_buf_log_item_t *bip,
  350. int stale)
  351. {
  352. xfs_mount_t *mp;
  353. xfs_buf_t *bp;
  354. int freed;
  355. SPLDECL(s);
  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. AIL_LOCK(mp,s);
  385. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip, s);
  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_count_bits(bip->bli_format.blf_data_map,
  539. bip->bli_format.blf_map_size, 0) == 0) {
  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. xfs_bawrite(bip->bli_item.li_mountp, bp);
  598. } else {
  599. xfs_buf_relse(bp);
  600. }
  601. }
  602. /* ARGSUSED */
  603. STATIC void
  604. xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
  605. {
  606. }
  607. /*
  608. * This is the ops vector shared by all buf log items.
  609. */
  610. static struct xfs_item_ops xfs_buf_item_ops = {
  611. .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size,
  612. .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
  613. xfs_buf_item_format,
  614. .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin,
  615. .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin,
  616. .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
  617. xfs_buf_item_unpin_remove,
  618. .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock,
  619. .iop_unlock = (void(*)(xfs_log_item_t*))xfs_buf_item_unlock,
  620. .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
  621. xfs_buf_item_committed,
  622. .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push,
  623. .iop_pushbuf = NULL,
  624. .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
  625. xfs_buf_item_committing
  626. };
  627. /*
  628. * Allocate a new buf log item to go with the given buffer.
  629. * Set the buffer's b_fsprivate field to point to the new
  630. * buf log item. If there are other item's attached to the
  631. * buffer (see xfs_buf_attach_iodone() below), then put the
  632. * buf log item at the front.
  633. */
  634. void
  635. xfs_buf_item_init(
  636. xfs_buf_t *bp,
  637. xfs_mount_t *mp)
  638. {
  639. xfs_log_item_t *lip;
  640. xfs_buf_log_item_t *bip;
  641. int chunks;
  642. int map_size;
  643. /*
  644. * Check to see if there is already a buf log item for
  645. * this buffer. If there is, it is guaranteed to be
  646. * the first. If we do already have one, there is
  647. * nothing to do here so return.
  648. */
  649. if (XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *) != mp)
  650. XFS_BUF_SET_FSPRIVATE3(bp, mp);
  651. XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
  652. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  653. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  654. if (lip->li_type == XFS_LI_BUF) {
  655. return;
  656. }
  657. }
  658. /*
  659. * chunks is the number of XFS_BLI_CHUNK size pieces
  660. * the buffer can be divided into. Make sure not to
  661. * truncate any pieces. map_size is the size of the
  662. * bitmap needed to describe the chunks of the buffer.
  663. */
  664. chunks = (int)((XFS_BUF_COUNT(bp) + (XFS_BLI_CHUNK - 1)) >> XFS_BLI_SHIFT);
  665. map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT);
  666. bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
  667. KM_SLEEP);
  668. bip->bli_item.li_type = XFS_LI_BUF;
  669. bip->bli_item.li_ops = &xfs_buf_item_ops;
  670. bip->bli_item.li_mountp = mp;
  671. bip->bli_buf = bp;
  672. bip->bli_format.blf_type = XFS_LI_BUF;
  673. bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp);
  674. bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp));
  675. bip->bli_format.blf_map_size = map_size;
  676. #ifdef XFS_BLI_TRACE
  677. bip->bli_trace = ktrace_alloc(XFS_BLI_TRACE_SIZE, KM_SLEEP);
  678. #endif
  679. #ifdef XFS_TRANS_DEBUG
  680. /*
  681. * Allocate the arrays for tracking what needs to be logged
  682. * and what our callers request to be logged. bli_orig
  683. * holds a copy of the original, clean buffer for comparison
  684. * against, and bli_logged keeps a 1 bit flag per byte in
  685. * the buffer to indicate which bytes the callers have asked
  686. * to have logged.
  687. */
  688. bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP);
  689. memcpy(bip->bli_orig, XFS_BUF_PTR(bp), XFS_BUF_COUNT(bp));
  690. bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP);
  691. #endif
  692. /*
  693. * Put the buf item into the list of items attached to the
  694. * buffer at the front.
  695. */
  696. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  697. bip->bli_item.li_bio_list =
  698. XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  699. }
  700. XFS_BUF_SET_FSPRIVATE(bp, bip);
  701. }
  702. /*
  703. * Mark bytes first through last inclusive as dirty in the buf
  704. * item's bitmap.
  705. */
  706. void
  707. xfs_buf_item_log(
  708. xfs_buf_log_item_t *bip,
  709. uint first,
  710. uint last)
  711. {
  712. uint first_bit;
  713. uint last_bit;
  714. uint bits_to_set;
  715. uint bits_set;
  716. uint word_num;
  717. uint *wordp;
  718. uint bit;
  719. uint end_bit;
  720. uint mask;
  721. /*
  722. * Mark the item as having some dirty data for
  723. * quick reference in xfs_buf_item_dirty.
  724. */
  725. bip->bli_flags |= XFS_BLI_DIRTY;
  726. /*
  727. * Convert byte offsets to bit numbers.
  728. */
  729. first_bit = first >> XFS_BLI_SHIFT;
  730. last_bit = last >> XFS_BLI_SHIFT;
  731. /*
  732. * Calculate the total number of bits to be set.
  733. */
  734. bits_to_set = last_bit - first_bit + 1;
  735. /*
  736. * Get a pointer to the first word in the bitmap
  737. * to set a bit in.
  738. */
  739. word_num = first_bit >> BIT_TO_WORD_SHIFT;
  740. wordp = &(bip->bli_format.blf_data_map[word_num]);
  741. /*
  742. * Calculate the starting bit in the first word.
  743. */
  744. bit = first_bit & (uint)(NBWORD - 1);
  745. /*
  746. * First set any bits in the first word of our range.
  747. * If it starts at bit 0 of the word, it will be
  748. * set below rather than here. That is what the variable
  749. * bit tells us. The variable bits_set tracks the number
  750. * of bits that have been set so far. End_bit is the number
  751. * of the last bit to be set in this word plus one.
  752. */
  753. if (bit) {
  754. end_bit = MIN(bit + bits_to_set, (uint)NBWORD);
  755. mask = ((1 << (end_bit - bit)) - 1) << bit;
  756. *wordp |= mask;
  757. wordp++;
  758. bits_set = end_bit - bit;
  759. } else {
  760. bits_set = 0;
  761. }
  762. /*
  763. * Now set bits a whole word at a time that are between
  764. * first_bit and last_bit.
  765. */
  766. while ((bits_to_set - bits_set) >= NBWORD) {
  767. *wordp |= 0xffffffff;
  768. bits_set += NBWORD;
  769. wordp++;
  770. }
  771. /*
  772. * Finally, set any bits left to be set in one last partial word.
  773. */
  774. end_bit = bits_to_set - bits_set;
  775. if (end_bit) {
  776. mask = (1 << end_bit) - 1;
  777. *wordp |= mask;
  778. }
  779. xfs_buf_item_log_debug(bip, first, last);
  780. }
  781. /*
  782. * Return 1 if the buffer has some data that has been logged (at any
  783. * point, not just the current transaction) and 0 if not.
  784. */
  785. uint
  786. xfs_buf_item_dirty(
  787. xfs_buf_log_item_t *bip)
  788. {
  789. return (bip->bli_flags & XFS_BLI_DIRTY);
  790. }
  791. /*
  792. * This is called when the buf log item is no longer needed. It should
  793. * free the buf log item associated with the given buffer and clear
  794. * the buffer's pointer to the buf log item. If there are no more
  795. * items in the list, clear the b_iodone field of the buffer (see
  796. * xfs_buf_attach_iodone() below).
  797. */
  798. void
  799. xfs_buf_item_relse(
  800. xfs_buf_t *bp)
  801. {
  802. xfs_buf_log_item_t *bip;
  803. xfs_buftrace("XFS_RELSE", bp);
  804. bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
  805. XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list);
  806. if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) &&
  807. (XFS_BUF_IODONE_FUNC(bp) != NULL)) {
  808. XFS_BUF_CLR_IODONE_FUNC(bp);
  809. }
  810. #ifdef XFS_TRANS_DEBUG
  811. kmem_free(bip->bli_orig, XFS_BUF_COUNT(bp));
  812. bip->bli_orig = NULL;
  813. kmem_free(bip->bli_logged, XFS_BUF_COUNT(bp) / NBBY);
  814. bip->bli_logged = NULL;
  815. #endif /* XFS_TRANS_DEBUG */
  816. #ifdef XFS_BLI_TRACE
  817. ktrace_free(bip->bli_trace);
  818. #endif
  819. kmem_zone_free(xfs_buf_item_zone, bip);
  820. }
  821. /*
  822. * Add the given log item with its callback to the list of callbacks
  823. * to be called when the buffer's I/O completes. If it is not set
  824. * already, set the buffer's b_iodone() routine to be
  825. * xfs_buf_iodone_callbacks() and link the log item into the list of
  826. * items rooted at b_fsprivate. Items are always added as the second
  827. * entry in the list if there is a first, because the buf item code
  828. * assumes that the buf log item is first.
  829. */
  830. void
  831. xfs_buf_attach_iodone(
  832. xfs_buf_t *bp,
  833. void (*cb)(xfs_buf_t *, xfs_log_item_t *),
  834. xfs_log_item_t *lip)
  835. {
  836. xfs_log_item_t *head_lip;
  837. ASSERT(XFS_BUF_ISBUSY(bp));
  838. ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
  839. lip->li_cb = cb;
  840. if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
  841. head_lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  842. lip->li_bio_list = head_lip->li_bio_list;
  843. head_lip->li_bio_list = lip;
  844. } else {
  845. XFS_BUF_SET_FSPRIVATE(bp, lip);
  846. }
  847. ASSERT((XFS_BUF_IODONE_FUNC(bp) == xfs_buf_iodone_callbacks) ||
  848. (XFS_BUF_IODONE_FUNC(bp) == NULL));
  849. XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
  850. }
  851. STATIC void
  852. xfs_buf_do_callbacks(
  853. xfs_buf_t *bp,
  854. xfs_log_item_t *lip)
  855. {
  856. xfs_log_item_t *nlip;
  857. while (lip != NULL) {
  858. nlip = lip->li_bio_list;
  859. ASSERT(lip->li_cb != NULL);
  860. /*
  861. * Clear the next pointer so we don't have any
  862. * confusion if the item is added to another buf.
  863. * Don't touch the log item after calling its
  864. * callback, because it could have freed itself.
  865. */
  866. lip->li_bio_list = NULL;
  867. lip->li_cb(bp, lip);
  868. lip = nlip;
  869. }
  870. }
  871. /*
  872. * This is the iodone() function for buffers which have had callbacks
  873. * attached to them by xfs_buf_attach_iodone(). It should remove each
  874. * log item from the buffer's list and call the callback of each in turn.
  875. * When done, the buffer's fsprivate field is set to NULL and the buffer
  876. * is unlocked with a call to iodone().
  877. */
  878. void
  879. xfs_buf_iodone_callbacks(
  880. xfs_buf_t *bp)
  881. {
  882. xfs_log_item_t *lip;
  883. static ulong lasttime;
  884. static xfs_buftarg_t *lasttarg;
  885. xfs_mount_t *mp;
  886. ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
  887. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  888. if (XFS_BUF_GETERROR(bp) != 0) {
  889. /*
  890. * If we've already decided to shutdown the filesystem
  891. * because of IO errors, there's no point in giving this
  892. * a retry.
  893. */
  894. mp = lip->li_mountp;
  895. if (XFS_FORCED_SHUTDOWN(mp)) {
  896. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  897. XFS_BUF_SUPER_STALE(bp);
  898. xfs_buftrace("BUF_IODONE_CB", bp);
  899. xfs_buf_do_callbacks(bp, lip);
  900. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  901. XFS_BUF_CLR_IODONE_FUNC(bp);
  902. /*
  903. * XFS_SHUT flag gets set when we go thru the
  904. * entire buffer cache and deliberately start
  905. * throwing away delayed write buffers.
  906. * Since there's no biowait done on those,
  907. * we should just brelse them.
  908. */
  909. if (XFS_BUF_ISSHUT(bp)) {
  910. XFS_BUF_UNSHUT(bp);
  911. xfs_buf_relse(bp);
  912. } else {
  913. xfs_biodone(bp);
  914. }
  915. return;
  916. }
  917. if ((XFS_BUF_TARGET(bp) != lasttarg) ||
  918. (time_after(jiffies, (lasttime + 5*HZ)))) {
  919. lasttime = jiffies;
  920. cmn_err(CE_ALERT, "Device %s, XFS metadata write error"
  921. " block 0x%llx in %s",
  922. XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)),
  923. (__uint64_t)XFS_BUF_ADDR(bp), mp->m_fsname);
  924. }
  925. lasttarg = XFS_BUF_TARGET(bp);
  926. if (XFS_BUF_ISASYNC(bp)) {
  927. /*
  928. * If the write was asynchronous then noone will be
  929. * looking for the error. Clear the error state
  930. * and write the buffer out again delayed write.
  931. *
  932. * XXXsup This is OK, so long as we catch these
  933. * before we start the umount; we don't want these
  934. * DELWRI metadata bufs to be hanging around.
  935. */
  936. XFS_BUF_ERROR(bp,0); /* errno of 0 unsets the flag */
  937. if (!(XFS_BUF_ISSTALE(bp))) {
  938. XFS_BUF_DELAYWRITE(bp);
  939. XFS_BUF_DONE(bp);
  940. XFS_BUF_SET_START(bp);
  941. }
  942. ASSERT(XFS_BUF_IODONE_FUNC(bp));
  943. xfs_buftrace("BUF_IODONE ASYNC", bp);
  944. xfs_buf_relse(bp);
  945. } else {
  946. /*
  947. * If the write of the buffer was not asynchronous,
  948. * then we want to make sure to return the error
  949. * to the caller of bwrite(). Because of this we
  950. * cannot clear the B_ERROR state at this point.
  951. * Instead we install a callback function that
  952. * will be called when the buffer is released, and
  953. * that routine will clear the error state and
  954. * set the buffer to be written out again after
  955. * some delay.
  956. */
  957. /* We actually overwrite the existing b-relse
  958. function at times, but we're gonna be shutting down
  959. anyway. */
  960. XFS_BUF_SET_BRELSE_FUNC(bp,xfs_buf_error_relse);
  961. XFS_BUF_DONE(bp);
  962. XFS_BUF_V_IODONESEMA(bp);
  963. }
  964. return;
  965. }
  966. #ifdef XFSERRORDEBUG
  967. xfs_buftrace("XFS BUFCB NOERR", bp);
  968. #endif
  969. xfs_buf_do_callbacks(bp, lip);
  970. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  971. XFS_BUF_CLR_IODONE_FUNC(bp);
  972. xfs_biodone(bp);
  973. }
  974. /*
  975. * This is a callback routine attached to a buffer which gets an error
  976. * when being written out synchronously.
  977. */
  978. STATIC void
  979. xfs_buf_error_relse(
  980. xfs_buf_t *bp)
  981. {
  982. xfs_log_item_t *lip;
  983. xfs_mount_t *mp;
  984. lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
  985. mp = (xfs_mount_t *)lip->li_mountp;
  986. ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
  987. XFS_BUF_STALE(bp);
  988. XFS_BUF_DONE(bp);
  989. XFS_BUF_UNDELAYWRITE(bp);
  990. XFS_BUF_ERROR(bp,0);
  991. xfs_buftrace("BUF_ERROR_RELSE", bp);
  992. if (! XFS_FORCED_SHUTDOWN(mp))
  993. xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
  994. /*
  995. * We have to unpin the pinned buffers so do the
  996. * callbacks.
  997. */
  998. xfs_buf_do_callbacks(bp, lip);
  999. XFS_BUF_SET_FSPRIVATE(bp, NULL);
  1000. XFS_BUF_CLR_IODONE_FUNC(bp);
  1001. XFS_BUF_SET_BRELSE_FUNC(bp,NULL);
  1002. xfs_buf_relse(bp);
  1003. }
  1004. /*
  1005. * This is the iodone() function for buffers which have been
  1006. * logged. It is called when they are eventually flushed out.
  1007. * It should remove the buf item from the AIL, and free the buf item.
  1008. * It is called by xfs_buf_iodone_callbacks() above which will take
  1009. * care of cleaning up the buffer itself.
  1010. */
  1011. /* ARGSUSED */
  1012. void
  1013. xfs_buf_iodone(
  1014. xfs_buf_t *bp,
  1015. xfs_buf_log_item_t *bip)
  1016. {
  1017. struct xfs_mount *mp;
  1018. SPLDECL(s);
  1019. ASSERT(bip->bli_buf == bp);
  1020. mp = bip->bli_item.li_mountp;
  1021. /*
  1022. * If we are forcibly shutting down, this may well be
  1023. * off the AIL already. That's because we simulate the
  1024. * log-committed callbacks to unpin these buffers. Or we may never
  1025. * have put this item on AIL because of the transaction was
  1026. * aborted forcibly. xfs_trans_delete_ail() takes care of these.
  1027. *
  1028. * Either way, AIL is useless if we're forcing a shutdown.
  1029. */
  1030. AIL_LOCK(mp,s);
  1031. /*
  1032. * xfs_trans_delete_ail() drops the AIL lock.
  1033. */
  1034. xfs_trans_delete_ail(mp, (xfs_log_item_t *)bip, s);
  1035. #ifdef XFS_TRANS_DEBUG
  1036. kmem_free(bip->bli_orig, XFS_BUF_COUNT(bp));
  1037. bip->bli_orig = NULL;
  1038. kmem_free(bip->bli_logged, XFS_BUF_COUNT(bp) / NBBY);
  1039. bip->bli_logged = NULL;
  1040. #endif /* XFS_TRANS_DEBUG */
  1041. #ifdef XFS_BLI_TRACE
  1042. ktrace_free(bip->bli_trace);
  1043. #endif
  1044. kmem_zone_free(xfs_buf_item_zone, bip);
  1045. }
  1046. #if defined(XFS_BLI_TRACE)
  1047. void
  1048. xfs_buf_item_trace(
  1049. char *id,
  1050. xfs_buf_log_item_t *bip)
  1051. {
  1052. xfs_buf_t *bp;
  1053. ASSERT(bip->bli_trace != NULL);
  1054. bp = bip->bli_buf;
  1055. ktrace_enter(bip->bli_trace,
  1056. (void *)id,
  1057. (void *)bip->bli_buf,
  1058. (void *)((unsigned long)bip->bli_flags),
  1059. (void *)((unsigned long)bip->bli_recur),
  1060. (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
  1061. (void *)((unsigned long)
  1062. (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
  1063. (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
  1064. (void *)((unsigned long)XFS_BUF_COUNT(bp)),
  1065. (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
  1066. XFS_BUF_FSPRIVATE(bp, void *),
  1067. XFS_BUF_FSPRIVATE2(bp, void *),
  1068. (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
  1069. (void *)XFS_BUF_IODONE_FUNC(bp),
  1070. (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
  1071. (void *)bip->bli_item.li_desc,
  1072. (void *)((unsigned long)bip->bli_item.li_flags));
  1073. }
  1074. #endif /* XFS_BLI_TRACE */