2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
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.
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.
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
20 #include "xfs_types.h"
24 #include "xfs_trans.h"
27 #include "xfs_mount.h"
28 #include "xfs_trans_priv.h"
29 #include "xfs_bmap_btree.h"
30 #include "xfs_dinode.h"
31 #include "xfs_inode.h"
32 #include "xfs_inode_item.h"
33 #include "xfs_error.h"
34 #include "xfs_trace.h"
37 kmem_zone_t *xfs_ili_zone; /* inode log item zone */
39 static inline struct xfs_inode_log_item *INODE_ITEM(struct xfs_log_item *lip)
41 return container_of(lip, struct xfs_inode_log_item, ili_item);
46 * This returns the number of iovecs needed to log the given inode item.
48 * We need one iovec for the inode log format structure, one for the
49 * inode core, and possibly one for the inode data/extents/b-tree root
50 * and one for the inode attribute data/extents/b-tree root.
54 struct xfs_log_item *lip)
56 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
57 struct xfs_inode *ip = iip->ili_inode;
60 switch (ip->i_d.di_format) {
61 case XFS_DINODE_FMT_EXTENTS:
62 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
63 ip->i_d.di_nextents > 0 &&
64 ip->i_df.if_bytes > 0)
68 case XFS_DINODE_FMT_BTREE:
69 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
70 ip->i_df.if_broot_bytes > 0)
74 case XFS_DINODE_FMT_LOCAL:
75 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
76 ip->i_df.if_bytes > 0)
80 case XFS_DINODE_FMT_DEV:
81 case XFS_DINODE_FMT_UUID:
94 * Log any necessary attribute data.
96 switch (ip->i_d.di_aformat) {
97 case XFS_DINODE_FMT_EXTENTS:
98 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
99 ip->i_d.di_anextents > 0 &&
100 ip->i_afp->if_bytes > 0)
104 case XFS_DINODE_FMT_BTREE:
105 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
106 ip->i_afp->if_broot_bytes > 0)
110 case XFS_DINODE_FMT_LOCAL:
111 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
112 ip->i_afp->if_bytes > 0)
125 * xfs_inode_item_format_extents - convert in-core extents to on-disk form
127 * For either the data or attr fork in extent format, we need to endian convert
128 * the in-core extent as we place them into the on-disk inode. In this case, we
129 * need to do this conversion before we write the extents into the log. Because
130 * we don't have the disk inode to write into here, we allocate a buffer and
131 * format the extents into it via xfs_iextents_copy(). We free the buffer in
132 * the unlock routine after the copy for the log has been made.
134 * In the case of the data fork, the in-core and on-disk fork sizes can be
135 * different due to delayed allocation extents. We only log on-disk extents
136 * here, so always use the physical fork size to determine the size of the
137 * buffer we need to allocate.
140 xfs_inode_item_format_extents(
141 struct xfs_inode *ip,
142 struct xfs_log_iovec *vecp,
146 xfs_bmbt_rec_t *ext_buffer;
148 ext_buffer = kmem_alloc(XFS_IFORK_SIZE(ip, whichfork), KM_SLEEP);
149 if (whichfork == XFS_DATA_FORK)
150 ip->i_itemp->ili_extents_buf = ext_buffer;
152 ip->i_itemp->ili_aextents_buf = ext_buffer;
154 vecp->i_addr = ext_buffer;
155 vecp->i_len = xfs_iextents_copy(ip, ext_buffer, whichfork);
160 * This is called to fill in the vector of log iovecs for the
161 * given inode log item. It fills the first item with an inode
162 * log format structure, the second with the on-disk inode structure,
163 * and a possible third and/or fourth with the inode data/extents/b-tree
164 * root and inode attributes data/extents/b-tree root.
167 xfs_inode_item_format(
168 struct xfs_log_item *lip,
169 struct xfs_log_iovec *vecp)
171 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
172 struct xfs_inode *ip = iip->ili_inode;
177 vecp->i_addr = &iip->ili_format;
178 vecp->i_len = sizeof(xfs_inode_log_format_t);
179 vecp->i_type = XLOG_REG_TYPE_IFORMAT;
183 vecp->i_addr = &ip->i_d;
184 vecp->i_len = sizeof(struct xfs_icdinode);
185 vecp->i_type = XLOG_REG_TYPE_ICORE;
190 * If this is really an old format inode, then we need to
191 * log it as such. This means that we have to copy the link
192 * count from the new field to the old. We don't have to worry
193 * about the new fields, because nothing trusts them as long as
194 * the old inode version number is there. If the superblock already
195 * has a new version number, then we don't bother converting back.
198 ASSERT(ip->i_d.di_version == 1 || xfs_sb_version_hasnlink(&mp->m_sb));
199 if (ip->i_d.di_version == 1) {
200 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
204 ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
205 ip->i_d.di_onlink = ip->i_d.di_nlink;
208 * The superblock version has already been bumped,
209 * so just make the conversion to the new inode
212 ip->i_d.di_version = 2;
213 ip->i_d.di_onlink = 0;
214 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
218 switch (ip->i_d.di_format) {
219 case XFS_DINODE_FMT_EXTENTS:
221 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
222 XFS_ILOG_DEV | XFS_ILOG_UUID);
224 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
225 ip->i_d.di_nextents > 0 &&
226 ip->i_df.if_bytes > 0) {
227 ASSERT(ip->i_df.if_u1.if_extents != NULL);
228 ASSERT(ip->i_df.if_bytes / sizeof(xfs_bmbt_rec_t) > 0);
229 ASSERT(iip->ili_extents_buf == NULL);
231 #ifdef XFS_NATIVE_HOST
232 if (ip->i_d.di_nextents == ip->i_df.if_bytes /
233 (uint)sizeof(xfs_bmbt_rec_t)) {
235 * There are no delayed allocation
236 * extents, so just point to the
237 * real extents array.
239 vecp->i_addr = ip->i_df.if_u1.if_extents;
240 vecp->i_len = ip->i_df.if_bytes;
241 vecp->i_type = XLOG_REG_TYPE_IEXT;
245 xfs_inode_item_format_extents(ip, vecp,
246 XFS_DATA_FORK, XLOG_REG_TYPE_IEXT);
248 ASSERT(vecp->i_len <= ip->i_df.if_bytes);
249 iip->ili_format.ilf_dsize = vecp->i_len;
253 iip->ili_fields &= ~XFS_ILOG_DEXT;
257 case XFS_DINODE_FMT_BTREE:
259 ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT |
260 XFS_ILOG_DEV | XFS_ILOG_UUID);
262 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
263 ip->i_df.if_broot_bytes > 0) {
264 ASSERT(ip->i_df.if_broot != NULL);
265 vecp->i_addr = ip->i_df.if_broot;
266 vecp->i_len = ip->i_df.if_broot_bytes;
267 vecp->i_type = XLOG_REG_TYPE_IBROOT;
270 iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes;
272 ASSERT(!(iip->ili_fields &
274 #ifdef XFS_TRANS_DEBUG
275 if (iip->ili_root_size > 0) {
276 ASSERT(iip->ili_root_size ==
277 ip->i_df.if_broot_bytes);
278 ASSERT(memcmp(iip->ili_orig_root,
280 iip->ili_root_size) == 0);
282 ASSERT(ip->i_df.if_broot_bytes == 0);
285 iip->ili_fields &= ~XFS_ILOG_DBROOT;
289 case XFS_DINODE_FMT_LOCAL:
291 ~(XFS_ILOG_DEXT | XFS_ILOG_DBROOT |
292 XFS_ILOG_DEV | XFS_ILOG_UUID);
293 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
294 ip->i_df.if_bytes > 0) {
295 ASSERT(ip->i_df.if_u1.if_data != NULL);
296 ASSERT(ip->i_d.di_size > 0);
298 vecp->i_addr = ip->i_df.if_u1.if_data;
300 * Round i_bytes up to a word boundary.
301 * The underlying memory is guaranteed to
302 * to be there by xfs_idata_realloc().
304 data_bytes = roundup(ip->i_df.if_bytes, 4);
305 ASSERT((ip->i_df.if_real_bytes == 0) ||
306 (ip->i_df.if_real_bytes == data_bytes));
307 vecp->i_len = (int)data_bytes;
308 vecp->i_type = XLOG_REG_TYPE_ILOCAL;
311 iip->ili_format.ilf_dsize = (unsigned)data_bytes;
313 iip->ili_fields &= ~XFS_ILOG_DDATA;
317 case XFS_DINODE_FMT_DEV:
319 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
320 XFS_ILOG_DEXT | XFS_ILOG_UUID);
321 if (iip->ili_fields & XFS_ILOG_DEV) {
322 iip->ili_format.ilf_u.ilfu_rdev =
323 ip->i_df.if_u2.if_rdev;
327 case XFS_DINODE_FMT_UUID:
329 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
330 XFS_ILOG_DEXT | XFS_ILOG_DEV);
331 if (iip->ili_fields & XFS_ILOG_UUID) {
332 iip->ili_format.ilf_u.ilfu_uuid =
333 ip->i_df.if_u2.if_uuid;
343 * If there are no attributes associated with the file, then we're done.
345 if (!XFS_IFORK_Q(ip)) {
347 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
351 switch (ip->i_d.di_aformat) {
352 case XFS_DINODE_FMT_EXTENTS:
354 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT);
356 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
357 ip->i_d.di_anextents > 0 &&
358 ip->i_afp->if_bytes > 0) {
359 ASSERT(ip->i_afp->if_bytes / sizeof(xfs_bmbt_rec_t) ==
360 ip->i_d.di_anextents);
361 ASSERT(ip->i_afp->if_u1.if_extents != NULL);
362 #ifdef XFS_NATIVE_HOST
364 * There are not delayed allocation extents
365 * for attributes, so just point at the array.
367 vecp->i_addr = ip->i_afp->if_u1.if_extents;
368 vecp->i_len = ip->i_afp->if_bytes;
369 vecp->i_type = XLOG_REG_TYPE_IATTR_EXT;
371 ASSERT(iip->ili_aextents_buf == NULL);
372 xfs_inode_item_format_extents(ip, vecp,
373 XFS_ATTR_FORK, XLOG_REG_TYPE_IATTR_EXT);
375 iip->ili_format.ilf_asize = vecp->i_len;
379 iip->ili_fields &= ~XFS_ILOG_AEXT;
383 case XFS_DINODE_FMT_BTREE:
385 ~(XFS_ILOG_ADATA | XFS_ILOG_AEXT);
387 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
388 ip->i_afp->if_broot_bytes > 0) {
389 ASSERT(ip->i_afp->if_broot != NULL);
391 vecp->i_addr = ip->i_afp->if_broot;
392 vecp->i_len = ip->i_afp->if_broot_bytes;
393 vecp->i_type = XLOG_REG_TYPE_IATTR_BROOT;
396 iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes;
398 iip->ili_fields &= ~XFS_ILOG_ABROOT;
402 case XFS_DINODE_FMT_LOCAL:
404 ~(XFS_ILOG_AEXT | XFS_ILOG_ABROOT);
406 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
407 ip->i_afp->if_bytes > 0) {
408 ASSERT(ip->i_afp->if_u1.if_data != NULL);
410 vecp->i_addr = ip->i_afp->if_u1.if_data;
412 * Round i_bytes up to a word boundary.
413 * The underlying memory is guaranteed to
414 * to be there by xfs_idata_realloc().
416 data_bytes = roundup(ip->i_afp->if_bytes, 4);
417 ASSERT((ip->i_afp->if_real_bytes == 0) ||
418 (ip->i_afp->if_real_bytes == data_bytes));
419 vecp->i_len = (int)data_bytes;
420 vecp->i_type = XLOG_REG_TYPE_IATTR_LOCAL;
423 iip->ili_format.ilf_asize = (unsigned)data_bytes;
425 iip->ili_fields &= ~XFS_ILOG_ADATA;
436 * Now update the log format that goes out to disk from the in-core
437 * values. We always write the inode core to make the arithmetic
438 * games in recovery easier, which isn't a big deal as just about any
439 * transaction would dirty it anyway.
441 iip->ili_format.ilf_fields = XFS_ILOG_CORE |
442 (iip->ili_fields & ~XFS_ILOG_TIMESTAMP);
443 iip->ili_format.ilf_size = nvecs;
448 * This is called to pin the inode associated with the inode log
449 * item in memory so it cannot be written out.
453 struct xfs_log_item *lip)
455 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
457 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
459 trace_xfs_inode_pin(ip, _RET_IP_);
460 atomic_inc(&ip->i_pincount);
465 * This is called to unpin the inode associated with the inode log
466 * item which was previously pinned with a call to xfs_inode_item_pin().
468 * Also wake up anyone in xfs_iunpin_wait() if the count goes to 0.
471 xfs_inode_item_unpin(
472 struct xfs_log_item *lip,
475 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
477 trace_xfs_inode_unpin(ip, _RET_IP_);
478 ASSERT(atomic_read(&ip->i_pincount) > 0);
479 if (atomic_dec_and_test(&ip->i_pincount))
480 wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
485 struct xfs_log_item *lip,
486 struct list_head *buffer_list)
488 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
489 struct xfs_inode *ip = iip->ili_inode;
490 struct xfs_buf *bp = NULL;
491 uint rval = XFS_ITEM_SUCCESS;
494 if (xfs_ipincount(ip) > 0)
495 return XFS_ITEM_PINNED;
497 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
498 return XFS_ITEM_LOCKED;
501 * Re-check the pincount now that we stabilized the value by
504 if (xfs_ipincount(ip) > 0) {
505 rval = XFS_ITEM_PINNED;
510 * Someone else is already flushing the inode. Nothing we can do
511 * here but wait for the flush to finish and remove the item from
514 if (!xfs_iflock_nowait(ip)) {
515 rval = XFS_ITEM_FLUSHING;
520 * Stale inode items should force out the iclog.
522 if (ip->i_flags & XFS_ISTALE) {
524 xfs_iunlock(ip, XFS_ILOCK_SHARED);
525 return XFS_ITEM_PINNED;
528 ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
529 ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
531 spin_unlock(&lip->li_ailp->xa_lock);
533 error = xfs_iflush(ip, &bp);
535 if (!xfs_buf_delwri_queue(bp, buffer_list))
536 rval = XFS_ITEM_FLUSHING;
540 spin_lock(&lip->li_ailp->xa_lock);
542 xfs_iunlock(ip, XFS_ILOCK_SHARED);
547 * Unlock the inode associated with the inode log item.
548 * Clear the fields of the inode and inode log item that
549 * are specific to the current transaction. If the
550 * hold flags is set, do not unlock the inode.
553 xfs_inode_item_unlock(
554 struct xfs_log_item *lip)
556 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
557 struct xfs_inode *ip = iip->ili_inode;
558 unsigned short lock_flags;
560 ASSERT(ip->i_itemp != NULL);
561 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
564 * If the inode needed a separate buffer with which to log
565 * its extents, then free it now.
567 if (iip->ili_extents_buf != NULL) {
568 ASSERT(ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS);
569 ASSERT(ip->i_d.di_nextents > 0);
570 ASSERT(iip->ili_fields & XFS_ILOG_DEXT);
571 ASSERT(ip->i_df.if_bytes > 0);
572 kmem_free(iip->ili_extents_buf);
573 iip->ili_extents_buf = NULL;
575 if (iip->ili_aextents_buf != NULL) {
576 ASSERT(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS);
577 ASSERT(ip->i_d.di_anextents > 0);
578 ASSERT(iip->ili_fields & XFS_ILOG_AEXT);
579 ASSERT(ip->i_afp->if_bytes > 0);
580 kmem_free(iip->ili_aextents_buf);
581 iip->ili_aextents_buf = NULL;
584 lock_flags = iip->ili_lock_flags;
585 iip->ili_lock_flags = 0;
587 xfs_iunlock(ip, lock_flags);
591 * This is called to find out where the oldest active copy of the inode log
592 * item in the on disk log resides now that the last log write of it completed
593 * at the given lsn. Since we always re-log all dirty data in an inode, the
594 * latest copy in the on disk log is the only one that matters. Therefore,
595 * simply return the given lsn.
597 * If the inode has been marked stale because the cluster is being freed, we
598 * don't want to (re-)insert this inode into the AIL. There is a race condition
599 * where the cluster buffer may be unpinned before the inode is inserted into
600 * the AIL during transaction committed processing. If the buffer is unpinned
601 * before the inode item has been committed and inserted, then it is possible
602 * for the buffer to be written and IO completes before the inode is inserted
603 * into the AIL. In that case, we'd be inserting a clean, stale inode into the
604 * AIL which will never get removed. It will, however, get reclaimed which
605 * triggers an assert in xfs_inode_free() complaining about freein an inode
608 * To avoid this, just unpin the inode directly and return a LSN of -1 so the
609 * transaction committed code knows that it does not need to do any further
610 * processing on the item.
613 xfs_inode_item_committed(
614 struct xfs_log_item *lip,
617 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
618 struct xfs_inode *ip = iip->ili_inode;
620 if (xfs_iflags_test(ip, XFS_ISTALE)) {
621 xfs_inode_item_unpin(lip, 0);
628 * XXX rcc - this one really has to do something. Probably needs
629 * to stamp in a new field in the incore inode.
632 xfs_inode_item_committing(
633 struct xfs_log_item *lip,
636 INODE_ITEM(lip)->ili_last_lsn = lsn;
640 * This is the ops vector shared by all buf log items.
642 static const struct xfs_item_ops xfs_inode_item_ops = {
643 .iop_size = xfs_inode_item_size,
644 .iop_format = xfs_inode_item_format,
645 .iop_pin = xfs_inode_item_pin,
646 .iop_unpin = xfs_inode_item_unpin,
647 .iop_unlock = xfs_inode_item_unlock,
648 .iop_committed = xfs_inode_item_committed,
649 .iop_push = xfs_inode_item_push,
650 .iop_committing = xfs_inode_item_committing
655 * Initialize the inode log item for a newly allocated (in-core) inode.
659 struct xfs_inode *ip,
660 struct xfs_mount *mp)
662 struct xfs_inode_log_item *iip;
664 ASSERT(ip->i_itemp == NULL);
665 iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);
668 xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE,
669 &xfs_inode_item_ops);
670 iip->ili_format.ilf_type = XFS_LI_INODE;
671 iip->ili_format.ilf_ino = ip->i_ino;
672 iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
673 iip->ili_format.ilf_len = ip->i_imap.im_len;
674 iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
678 * Free the inode log item and any memory hanging off of it.
681 xfs_inode_item_destroy(
684 #ifdef XFS_TRANS_DEBUG
685 if (ip->i_itemp->ili_root_size != 0) {
686 kmem_free(ip->i_itemp->ili_orig_root);
689 kmem_zone_free(xfs_ili_zone, ip->i_itemp);
694 * This is the inode flushing I/O completion routine. It is called
695 * from interrupt level when the buffer containing the inode is
696 * flushed to disk. It is responsible for removing the inode item
697 * from the AIL if it has not been re-logged, and unlocking the inode's
700 * To reduce AIL lock traffic as much as possible, we scan the buffer log item
701 * list for other inodes that will run this function. We remove them from the
702 * buffer list so we can process all the inode IO completions in one AIL lock
708 struct xfs_log_item *lip)
710 struct xfs_inode_log_item *iip;
711 struct xfs_log_item *blip;
712 struct xfs_log_item *next;
713 struct xfs_log_item *prev;
714 struct xfs_ail *ailp = lip->li_ailp;
718 * Scan the buffer IO completions for other inodes being completed and
719 * attach them to the current inode log item.
723 while (blip != NULL) {
724 if (lip->li_cb != xfs_iflush_done) {
726 blip = blip->li_bio_list;
730 /* remove from list */
731 next = blip->li_bio_list;
735 prev->li_bio_list = next;
738 /* add to current list */
739 blip->li_bio_list = lip->li_bio_list;
740 lip->li_bio_list = blip;
743 * while we have the item, do the unlocked check for needing
746 iip = INODE_ITEM(blip);
747 if (iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn)
753 /* make sure we capture the state of the initial inode. */
754 iip = INODE_ITEM(lip);
755 if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn)
759 * We only want to pull the item from the AIL if it is
760 * actually there and its location in the log has not
761 * changed since we started the flush. Thus, we only bother
762 * if the ili_logged flag is set and the inode's lsn has not
763 * changed. First we check the lsn outside
764 * the lock since it's cheaper, and then we recheck while
765 * holding the lock before removing the inode from the AIL.
768 struct xfs_log_item *log_items[need_ail];
770 spin_lock(&ailp->xa_lock);
771 for (blip = lip; blip; blip = blip->li_bio_list) {
772 iip = INODE_ITEM(blip);
773 if (iip->ili_logged &&
774 blip->li_lsn == iip->ili_flush_lsn) {
775 log_items[i++] = blip;
777 ASSERT(i <= need_ail);
779 /* xfs_trans_ail_delete_bulk() drops the AIL lock. */
780 xfs_trans_ail_delete_bulk(ailp, log_items, i);
785 * clean up and unlock the flush lock now we are done. We can clear the
786 * ili_last_fields bits now that we know that the data corresponding to
787 * them is safely on disk.
789 for (blip = lip; blip; blip = next) {
790 next = blip->li_bio_list;
791 blip->li_bio_list = NULL;
793 iip = INODE_ITEM(blip);
795 iip->ili_last_fields = 0;
796 xfs_ifunlock(iip->ili_inode);
801 * This is the inode flushing abort routine. It is called
802 * from xfs_iflush when the filesystem is shutting down to clean
803 * up the inode state.
804 * It is responsible for removing the inode item
805 * from the AIL if it has not been re-logged, and unlocking the inode's
812 xfs_inode_log_item_t *iip = ip->i_itemp;
815 struct xfs_ail *ailp = iip->ili_item.li_ailp;
816 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
817 spin_lock(&ailp->xa_lock);
818 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
819 /* xfs_trans_ail_delete() drops the AIL lock. */
820 xfs_trans_ail_delete(ailp, (xfs_log_item_t *)iip);
822 spin_unlock(&ailp->xa_lock);
826 * Clear the ili_last_fields bits now that we know that the
827 * data corresponding to them is safely on disk.
829 iip->ili_last_fields = 0;
831 * Clear the inode logging fields so no more flushes are
837 * Release the inode's flush lock since we're done with it.
845 struct xfs_log_item *lip)
847 xfs_iflush_abort(INODE_ITEM(lip)->ili_inode);
851 * convert an xfs_inode_log_format struct from either 32 or 64 bit versions
852 * (which can have different field alignments) to the native version
855 xfs_inode_item_format_convert(
856 xfs_log_iovec_t *buf,
857 xfs_inode_log_format_t *in_f)
859 if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) {
860 xfs_inode_log_format_32_t *in_f32 = buf->i_addr;
862 in_f->ilf_type = in_f32->ilf_type;
863 in_f->ilf_size = in_f32->ilf_size;
864 in_f->ilf_fields = in_f32->ilf_fields;
865 in_f->ilf_asize = in_f32->ilf_asize;
866 in_f->ilf_dsize = in_f32->ilf_dsize;
867 in_f->ilf_ino = in_f32->ilf_ino;
868 /* copy biggest field of ilf_u */
869 memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
870 in_f32->ilf_u.ilfu_uuid.__u_bits,
872 in_f->ilf_blkno = in_f32->ilf_blkno;
873 in_f->ilf_len = in_f32->ilf_len;
874 in_f->ilf_boffset = in_f32->ilf_boffset;
876 } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){
877 xfs_inode_log_format_64_t *in_f64 = buf->i_addr;
879 in_f->ilf_type = in_f64->ilf_type;
880 in_f->ilf_size = in_f64->ilf_size;
881 in_f->ilf_fields = in_f64->ilf_fields;
882 in_f->ilf_asize = in_f64->ilf_asize;
883 in_f->ilf_dsize = in_f64->ilf_dsize;
884 in_f->ilf_ino = in_f64->ilf_ino;
885 /* copy biggest field of ilf_u */
886 memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
887 in_f64->ilf_u.ilfu_uuid.__u_bits,
889 in_f->ilf_blkno = in_f64->ilf_blkno;
890 in_f->ilf_len = in_f64->ilf_len;
891 in_f->ilf_boffset = in_f64->ilf_boffset;