35 static inline struct xfs_buf_log_item *BUF_ITEM(
struct xfs_log_item *
lip)
37 return container_of(lip,
struct xfs_buf_log_item, bli_item);
41 #ifdef XFS_TRANS_DEBUG
53 xfs_buf_log_item_t *bip,
68 nbytes = last - first + 1;
69 bfset(bip->bli_logged, first, nbytes);
70 for (x = 0; x <
nbytes; x++) {
73 bit_num = chunk_num & (
NBWORD - 1);
74 wordp = &(bip->bli_format.blf_data_map[word_num]);
75 bit_set = *wordp & (1 << bit_num);
87 xfs_buf_item_flush_log_debug(
92 xfs_buf_log_item_t *bip = bp->
b_fspriv;
99 nbytes = last - first + 1;
100 bfset(bip->bli_logged, first, nbytes);
114 xfs_buf_log_item_t *bip)
127 orig = bip->bli_orig;
130 if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) {
131 xfs_emerg(bp->b_mount,
132 "%s: bip %x buffer %x orig %x index %d",
133 __func__, bip, bp, orig, x);
139 #define xfs_buf_item_log_debug(x,y,z)
140 #define xfs_buf_item_log_check(x)
157 struct xfs_buf_log_item *bip,
160 struct xfs_buf *bp = bip->bli_buf;
175 while (last_bit != -1) {
189 if (next_bit == -1) {
191 }
else if (next_bit != last_bit + 1) {
226 struct xfs_log_item *
lip)
228 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
239 trace_xfs_buf_item_size_stale(bip);
241 return bip->bli_format_count;
256 for (i = 0; i < bip->bli_format_count; i++) {
260 trace_xfs_buf_item_size(bip);
265 xfs_buf_item_format_segment(
266 struct xfs_buf_log_item *bip,
271 struct xfs_buf *bp = bip->bli_buf;
281 blfp->
blf_flags = bip->bli_format.blf_flags;
291 vecp->
i_len = base_size;
302 trace_xfs_buf_item_format_stale(bip);
313 last_bit = first_bit;
333 if (next_bit == -1) {
340 }
else if (next_bit != last_bit + 1) {
347 first_bit = next_bit;
366 first_bit = next_bit;
374 bip->bli_format.blf_size = nvecs;
386 struct xfs_log_item *
lip,
389 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
390 struct xfs_buf *bp = bip->bli_buf;
412 for (i = 0; i < bip->bli_format_count; i++) {
413 vecp = xfs_buf_item_format_segment(bip, vecp, offset,
414 &bip->bli_formats[i]);
415 offset += bp->
b_maps[
i].bm_len;
421 trace_xfs_buf_item_format(bip);
436 struct xfs_log_item *
lip)
438 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
444 trace_xfs_buf_item_pin(bip);
465 struct xfs_log_item *
lip,
468 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
470 struct xfs_ail *ailp = lip->li_ailp;
477 trace_xfs_buf_item_unpin(bip);
484 if (freed && stale) {
490 trace_xfs_buf_item_unpin_stale(bip);
523 xfs_trans_ail_delete(ailp, lip, SHUTDOWN_LOG_IO_ERROR);
528 }
else if (freed &&
remove) {
557 struct xfs_log_item *
lip,
560 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
561 struct xfs_buf *bp = bip->bli_buf;
562 uint rval = XFS_ITEM_SUCCESS;
564 if (xfs_buf_ispinned(bp))
565 return XFS_ITEM_PINNED;
567 return XFS_ITEM_LOCKED;
571 trace_xfs_buf_item_push(bip);
574 rval = XFS_ITEM_FLUSHING;
600 struct xfs_log_item *
lip)
602 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
603 struct xfs_buf *bp = bip->bli_buf;
616 aborted = (lip->li_flags & XFS_LI_ABORTED) != 0;
633 trace_xfs_buf_item_unlock_stale(bip);
641 trace_xfs_buf_item_unlock(bip);
648 bip->bli_format.blf_map_size))
677 struct xfs_log_item *
lip,
680 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
682 trace_xfs_buf_item_committed(bip);
691 struct xfs_log_item *
lip,
699 static const struct xfs_item_ops xfs_buf_item_ops = {
712 struct xfs_buf_log_item *bip,
716 bip->bli_format_count =
count;
719 bip->bli_formats = &bip->bli_format;
725 if (!bip->bli_formats)
732 struct xfs_buf_log_item *bip)
734 if (bip->bli_formats != &bip->bli_format) {
736 bip->bli_formats =
NULL;
753 xfs_buf_log_item_t *bip;
786 for (i = 0; i < bip->bli_format_count; i++) {
792 bip->bli_formats[
i].blf_blkno = bp->
b_maps[
i].bm_bn;
793 bip->bli_formats[
i].blf_len = bp->
b_maps[
i].bm_len;
794 bip->bli_formats[
i].blf_map_size = map_size;
797 #ifdef XFS_TRANS_DEBUG
816 bip->bli_item.li_bio_list = bp->
b_fspriv;
827 struct xfs_buf_log_item *bip,
851 bits_to_set = last_bit - first_bit + 1;
858 wordp = &map[word_num];
875 mask = ((1 << (end_bit -
bit)) - 1) << bit;
878 bits_set = end_bit -
bit;
887 while ((bits_to_set - bits_set) >=
NBWORD) {
888 *wordp |= 0xffffffff;
896 end_bit = bits_to_set - bits_set;
898 mask = (1 << end_bit) - 1;
911 xfs_buf_log_item_t *bip,
918 struct xfs_buf *bp = bip->bli_buf;
930 for (i = 0; i < bip->bli_format_count; i++) {
944 &bip->bli_formats[i].blf_data_map[0]);
957 xfs_buf_log_item_t *bip)
964 xfs_buf_log_item_t *bip)
966 #ifdef XFS_TRANS_DEBUG
986 xfs_buf_log_item_t *bip;
988 trace_xfs_buf_item_relse(bp,
_RET_IP_);
991 bp->
b_fspriv = bip->bli_item.li_bio_list;
1013 xfs_log_item_t *
lip)
1015 xfs_log_item_t *head_lip;
1022 lip->li_bio_list = head_lip->li_bio_list;
1023 head_lip->li_bio_list =
lip;
1049 struct xfs_log_item *
lip;
1060 lip->li_bio_list =
NULL;
1061 lip->li_cb(bp, lip);
1077 struct xfs_mount *
mp = lip->li_mountp;
1078 static ulong lasttime;
1081 if (
likely(!xfs_buf_geterror(bp)))
1088 if (XFS_FORCED_SHUTDOWN(mp)) {
1091 trace_xfs_buf_item_iodone(bp,
_RET_IP_);
1116 trace_xfs_buf_item_iodone_async(bp,
_RET_IP_);
1137 trace_xfs_buf_error_relse(bp,
_RET_IP_);
1156 struct xfs_log_item *
lip)
1158 struct xfs_ail *ailp = lip->li_ailp;
1160 ASSERT(BUF_ITEM(lip)->bli_buf == bp);
1174 xfs_trans_ail_delete(ailp, lip, SHUTDOWN_CORRUPT_INCORE);