37 static inline struct xfs_inode_log_item *INODE_ITEM(
struct xfs_log_item *
lip)
39 return container_of(lip,
struct xfs_inode_log_item, ili_item);
52 struct xfs_log_item *
lip)
54 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
55 struct xfs_inode *
ip = iip->ili_inode;
58 switch (ip->i_d.di_format) {
61 ip->i_d.di_nextents > 0 &&
62 ip->i_df.if_bytes > 0)
68 ip->i_df.if_broot_bytes > 0)
74 ip->i_df.if_bytes > 0)
94 switch (ip->i_d.di_aformat) {
97 ip->i_d.di_anextents > 0 &&
98 ip->i_afp->if_bytes > 0)
104 ip->i_afp->if_broot_bytes > 0)
110 ip->i_afp->if_bytes > 0)
139 struct xfs_inode *
ip,
148 ip->i_itemp->ili_extents_buf = ext_buffer;
150 ip->i_itemp->ili_aextents_buf = ext_buffer;
152 vecp->
i_addr = ext_buffer;
166 struct xfs_log_item *
lip,
169 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
170 struct xfs_inode *
ip = iip->ili_inode;
175 vecp->
i_addr = &iip->ili_format;
196 ASSERT(ip->i_d.di_version == 1 || xfs_sb_version_hasnlink(&mp->m_sb));
197 if (ip->i_d.di_version == 1) {
198 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
203 ip->i_d.di_onlink = ip->i_d.di_nlink;
210 ip->i_d.di_version = 2;
211 ip->i_d.di_onlink = 0;
212 memset(&(ip->i_d.di_pad[0]), 0,
sizeof(ip->i_d.di_pad));
216 switch (ip->i_d.di_format) {
223 ip->i_d.di_nextents > 0 &&
224 ip->i_df.if_bytes > 0) {
229 #ifdef XFS_NATIVE_HOST
230 if (ip->i_d.di_nextents == ip->i_df.if_bytes /
237 vecp->
i_addr = ip->i_df.if_u1.if_extents;
238 vecp->
i_len = ip->i_df.if_bytes;
247 iip->ili_format.ilf_dsize = vecp->
i_len;
261 ip->i_df.if_broot_bytes > 0) {
263 vecp->
i_addr = ip->i_df.if_broot;
264 vecp->
i_len = ip->i_df.if_broot_bytes;
268 iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes;
270 ASSERT(!(iip->ili_fields &
272 #ifdef XFS_TRANS_DEBUG
273 if (iip->ili_root_size > 0) {
274 ASSERT(iip->ili_root_size ==
275 ip->i_df.if_broot_bytes);
278 iip->ili_root_size) == 0);
280 ASSERT(ip->i_df.if_broot_bytes == 0);
292 ip->i_df.if_bytes > 0) {
294 ASSERT(ip->i_d.di_size > 0);
296 vecp->
i_addr = ip->i_df.if_u1.if_data;
302 data_bytes =
roundup(ip->i_df.if_bytes, 4);
303 ASSERT((ip->i_df.if_real_bytes == 0) ||
304 (ip->i_df.if_real_bytes == data_bytes));
309 iip->ili_format.ilf_dsize = (unsigned)data_bytes;
320 iip->ili_format.ilf_u.ilfu_rdev =
321 ip->i_df.if_u2.if_rdev;
330 iip->ili_format.ilf_u.ilfu_uuid =
331 ip->i_df.if_u2.if_uuid;
349 switch (ip->i_d.di_aformat) {
355 ip->i_d.di_anextents > 0 &&
356 ip->i_afp->if_bytes > 0) {
358 ip->i_d.di_anextents);
360 #ifdef XFS_NATIVE_HOST
365 vecp->
i_addr = ip->i_afp->if_u1.if_extents;
366 vecp->
i_len = ip->i_afp->if_bytes;
373 iip->ili_format.ilf_asize = vecp->
i_len;
386 ip->i_afp->if_broot_bytes > 0) {
389 vecp->
i_addr = ip->i_afp->if_broot;
390 vecp->
i_len = ip->i_afp->if_broot_bytes;
394 iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes;
405 ip->i_afp->if_bytes > 0) {
408 vecp->
i_addr = ip->i_afp->if_u1.if_data;
414 data_bytes =
roundup(ip->i_afp->if_bytes, 4);
415 ASSERT((ip->i_afp->if_real_bytes == 0) ||
416 (ip->i_afp->if_real_bytes == data_bytes));
421 iip->ili_format.ilf_asize = (unsigned)data_bytes;
441 iip->ili_format.ilf_size = nvecs;
451 struct xfs_log_item *
lip)
453 struct xfs_inode *
ip = INODE_ITEM(lip)->ili_inode;
455 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
470 struct xfs_log_item *
lip,
473 struct xfs_inode *
ip = INODE_ITEM(lip)->ili_inode;
475 trace_xfs_inode_unpin(ip,
_RET_IP_);
483 struct xfs_log_item *
lip,
486 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
487 struct xfs_inode *
ip = iip->ili_inode;
489 uint rval = XFS_ITEM_SUCCESS;
493 return XFS_ITEM_PINNED;
496 return XFS_ITEM_LOCKED;
503 rval = XFS_ITEM_PINNED;
510 if (ip->i_flags & XFS_ISTALE) {
511 rval = XFS_ITEM_PINNED;
520 if (!xfs_iflock_nowait(ip)) {
521 rval = XFS_ITEM_FLUSHING;
525 ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
526 ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
528 spin_unlock(&lip->li_ailp->xa_lock);
533 rval = XFS_ITEM_FLUSHING;
537 spin_lock(&lip->li_ailp->xa_lock);
551 struct xfs_log_item *
lip)
553 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
554 struct xfs_inode *
ip = iip->ili_inode;
558 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
564 if (iip->ili_extents_buf !=
NULL) {
566 ASSERT(ip->i_d.di_nextents > 0);
568 ASSERT(ip->i_df.if_bytes > 0);
570 iip->ili_extents_buf =
NULL;
572 if (iip->ili_aextents_buf !=
NULL) {
574 ASSERT(ip->i_d.di_anextents > 0);
576 ASSERT(ip->i_afp->if_bytes > 0);
578 iip->ili_aextents_buf =
NULL;
581 lock_flags = iip->ili_lock_flags;
582 iip->ili_lock_flags = 0;
611 struct xfs_log_item *
lip,
614 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
615 struct xfs_inode *
ip = iip->ili_inode;
617 if (xfs_iflags_test(ip, XFS_ISTALE)) {
630 struct xfs_log_item *
lip,
633 INODE_ITEM(lip)->ili_last_lsn =
lsn;
639 static const struct xfs_item_ops xfs_inode_item_ops = {
656 struct xfs_inode *
ip,
657 struct xfs_mount *
mp)
659 struct xfs_inode_log_item *iip;
666 &xfs_inode_item_ops);
668 iip->ili_format.ilf_ino = ip->i_ino;
669 iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
670 iip->ili_format.ilf_len = ip->i_imap.im_len;
671 iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
681 #ifdef XFS_TRANS_DEBUG
682 if (ip->i_itemp->ili_root_size != 0) {
705 struct xfs_log_item *
lip)
707 struct xfs_inode_log_item *iip;
708 struct xfs_log_item *blip;
709 struct xfs_log_item *
next;
710 struct xfs_log_item *
prev;
711 struct xfs_ail *ailp = lip->li_ailp;
720 while (blip !=
NULL) {
723 blip = blip->li_bio_list;
728 next = blip->li_bio_list;
732 prev->li_bio_list =
next;
736 blip->li_bio_list = lip->li_bio_list;
737 lip->li_bio_list = blip;
743 iip = INODE_ITEM(blip);
744 if (iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn)
751 iip = INODE_ITEM(lip);
752 if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn)
765 struct xfs_log_item *log_items[need_ail];
768 for (blip = lip; blip; blip = blip->li_bio_list) {
769 iip = INODE_ITEM(blip);
770 if (iip->ili_logged &&
771 blip->li_lsn == iip->ili_flush_lsn) {
772 log_items[i++] = blip;
778 SHUTDOWN_CORRUPT_INCORE);
787 for (blip = lip; blip; blip =
next) {
788 next = blip->li_bio_list;
789 blip->li_bio_list =
NULL;
791 iip = INODE_ITEM(blip);
793 iip->ili_last_fields = 0;
794 xfs_ifunlock(iip->ili_inode);
809 xfs_inode_log_item_t *iip = ip->i_itemp;
812 struct xfs_ail *ailp = iip->ili_item.li_ailp;
813 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
815 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
817 xfs_trans_ail_delete(ailp, &iip->ili_item,
819 SHUTDOWN_LOG_IO_ERROR :
820 SHUTDOWN_CORRUPT_INCORE);
829 iip->ili_last_fields = 0;
845 struct xfs_log_item *
lip)
859 if (buf->
i_len ==
sizeof(xfs_inode_log_format_32_t)) {
860 xfs_inode_log_format_32_t *in_f32 = buf->
i_addr;
867 in_f->
ilf_ino = in_f32->ilf_ino;
870 in_f32->ilf_u.ilfu_uuid.__u_bits,
873 in_f->
ilf_len = in_f32->ilf_len;