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_format.h"
21 #include "xfs_log_format.h"
22 #include "xfs_trans_resv.h"
25 #include "xfs_mount.h"
26 #include "xfs_inode.h"
27 #include "xfs_trans.h"
28 #include "xfs_inode_item.h"
29 #include "xfs_error.h"
30 #include "xfs_trace.h"
31 #include "xfs_trans_priv.h"
32 #include "xfs_dinode.h"
35 kmem_zone_t *xfs_ili_zone; /* inode log item zone */
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);
43 xfs_inode_item_data_fork_size(
44 struct xfs_inode_log_item *iip,
48 struct xfs_inode *ip = iip->ili_inode;
50 switch (ip->i_d.di_format) {
51 case XFS_DINODE_FMT_EXTENTS:
52 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
53 ip->i_d.di_nextents > 0 &&
54 ip->i_df.if_bytes > 0) {
55 /* worst case, doesn't subtract delalloc extents */
56 *nbytes += XFS_IFORK_DSIZE(ip);
60 case XFS_DINODE_FMT_BTREE:
61 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
62 ip->i_df.if_broot_bytes > 0) {
63 *nbytes += ip->i_df.if_broot_bytes;
67 case XFS_DINODE_FMT_LOCAL:
68 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
69 ip->i_df.if_bytes > 0) {
70 *nbytes += roundup(ip->i_df.if_bytes, 4);
75 case XFS_DINODE_FMT_DEV:
76 case XFS_DINODE_FMT_UUID:
85 xfs_inode_item_attr_fork_size(
86 struct xfs_inode_log_item *iip,
90 struct xfs_inode *ip = iip->ili_inode;
92 switch (ip->i_d.di_aformat) {
93 case XFS_DINODE_FMT_EXTENTS:
94 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
95 ip->i_d.di_anextents > 0 &&
96 ip->i_afp->if_bytes > 0) {
97 /* worst case, doesn't subtract unused space */
98 *nbytes += XFS_IFORK_ASIZE(ip);
102 case XFS_DINODE_FMT_BTREE:
103 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
104 ip->i_afp->if_broot_bytes > 0) {
105 *nbytes += ip->i_afp->if_broot_bytes;
109 case XFS_DINODE_FMT_LOCAL:
110 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
111 ip->i_afp->if_bytes > 0) {
112 *nbytes += roundup(ip->i_afp->if_bytes, 4);
123 * This returns the number of iovecs needed to log the given inode item.
125 * We need one iovec for the inode log format structure, one for the
126 * inode core, and possibly one for the inode data/extents/b-tree root
127 * and one for the inode attribute data/extents/b-tree root.
131 struct xfs_log_item *lip,
135 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
136 struct xfs_inode *ip = iip->ili_inode;
139 *nbytes += sizeof(struct xfs_inode_log_format) +
140 xfs_icdinode_size(ip->i_d.di_version);
142 xfs_inode_item_data_fork_size(iip, nvecs, nbytes);
144 xfs_inode_item_attr_fork_size(iip, nvecs, nbytes);
148 * xfs_inode_item_format_extents - convert in-core extents to on-disk form
150 * For either the data or attr fork in extent format, we need to endian convert
151 * the in-core extent as we place them into the on-disk inode. In this case, we
152 * need to do this conversion before we write the extents into the log. Because
153 * we don't have the disk inode to write into here, we allocate a buffer and
154 * format the extents into it via xfs_iextents_copy(). We free the buffer in
155 * the unlock routine after the copy for the log has been made.
157 * In the case of the data fork, the in-core and on-disk fork sizes can be
158 * different due to delayed allocation extents. We only log on-disk extents
159 * here, so always use the physical fork size to determine the size of the
160 * buffer we need to allocate.
163 xfs_inode_item_format_extents(
164 struct xfs_inode *ip,
165 struct xfs_log_iovec *vecp,
169 xfs_bmbt_rec_t *ext_buffer;
171 ext_buffer = kmem_alloc(XFS_IFORK_SIZE(ip, whichfork), KM_SLEEP);
172 if (whichfork == XFS_DATA_FORK)
173 ip->i_itemp->ili_extents_buf = ext_buffer;
175 ip->i_itemp->ili_aextents_buf = ext_buffer;
177 vecp->i_addr = ext_buffer;
178 vecp->i_len = xfs_iextents_copy(ip, ext_buffer, whichfork);
183 * This is called to fill in the vector of log iovecs for the
184 * given inode log item. It fills the first item with an inode
185 * log format structure, the second with the on-disk inode structure,
186 * and a possible third and/or fourth with the inode data/extents/b-tree
187 * root and inode attributes data/extents/b-tree root.
190 xfs_inode_item_format(
191 struct xfs_log_item *lip,
192 struct xfs_log_iovec *vecp)
194 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
195 struct xfs_inode *ip = iip->ili_inode;
200 vecp->i_addr = &iip->ili_format;
201 vecp->i_len = sizeof(xfs_inode_log_format_t);
202 vecp->i_type = XLOG_REG_TYPE_IFORMAT;
206 vecp->i_addr = &ip->i_d;
207 vecp->i_len = xfs_icdinode_size(ip->i_d.di_version);
208 vecp->i_type = XLOG_REG_TYPE_ICORE;
213 * If this is really an old format inode, then we need to
214 * log it as such. This means that we have to copy the link
215 * count from the new field to the old. We don't have to worry
216 * about the new fields, because nothing trusts them as long as
217 * the old inode version number is there. If the superblock already
218 * has a new version number, then we don't bother converting back.
221 ASSERT(ip->i_d.di_version == 1 || xfs_sb_version_hasnlink(&mp->m_sb));
222 if (ip->i_d.di_version == 1) {
223 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
227 ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
228 ip->i_d.di_onlink = ip->i_d.di_nlink;
231 * The superblock version has already been bumped,
232 * so just make the conversion to the new inode
235 ip->i_d.di_version = 2;
236 ip->i_d.di_onlink = 0;
237 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
241 switch (ip->i_d.di_format) {
242 case XFS_DINODE_FMT_EXTENTS:
244 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
245 XFS_ILOG_DEV | XFS_ILOG_UUID);
247 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
248 ip->i_d.di_nextents > 0 &&
249 ip->i_df.if_bytes > 0) {
250 ASSERT(ip->i_df.if_u1.if_extents != NULL);
251 ASSERT(ip->i_df.if_bytes / sizeof(xfs_bmbt_rec_t) > 0);
252 ASSERT(iip->ili_extents_buf == NULL);
254 #ifdef XFS_NATIVE_HOST
255 if (ip->i_d.di_nextents == ip->i_df.if_bytes /
256 (uint)sizeof(xfs_bmbt_rec_t)) {
258 * There are no delayed allocation
259 * extents, so just point to the
260 * real extents array.
262 vecp->i_addr = ip->i_df.if_u1.if_extents;
263 vecp->i_len = ip->i_df.if_bytes;
264 vecp->i_type = XLOG_REG_TYPE_IEXT;
268 xfs_inode_item_format_extents(ip, vecp,
269 XFS_DATA_FORK, XLOG_REG_TYPE_IEXT);
271 ASSERT(vecp->i_len <= ip->i_df.if_bytes);
272 iip->ili_format.ilf_dsize = vecp->i_len;
276 iip->ili_fields &= ~XFS_ILOG_DEXT;
280 case XFS_DINODE_FMT_BTREE:
282 ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT |
283 XFS_ILOG_DEV | XFS_ILOG_UUID);
285 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
286 ip->i_df.if_broot_bytes > 0) {
287 ASSERT(ip->i_df.if_broot != NULL);
288 vecp->i_addr = ip->i_df.if_broot;
289 vecp->i_len = ip->i_df.if_broot_bytes;
290 vecp->i_type = XLOG_REG_TYPE_IBROOT;
293 iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes;
295 ASSERT(!(iip->ili_fields &
297 iip->ili_fields &= ~XFS_ILOG_DBROOT;
301 case XFS_DINODE_FMT_LOCAL:
303 ~(XFS_ILOG_DEXT | XFS_ILOG_DBROOT |
304 XFS_ILOG_DEV | XFS_ILOG_UUID);
305 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
306 ip->i_df.if_bytes > 0) {
307 ASSERT(ip->i_df.if_u1.if_data != NULL);
308 ASSERT(ip->i_d.di_size > 0);
310 vecp->i_addr = ip->i_df.if_u1.if_data;
312 * Round i_bytes up to a word boundary.
313 * The underlying memory is guaranteed to
314 * to be there by xfs_idata_realloc().
316 data_bytes = roundup(ip->i_df.if_bytes, 4);
317 ASSERT((ip->i_df.if_real_bytes == 0) ||
318 (ip->i_df.if_real_bytes == data_bytes));
319 vecp->i_len = (int)data_bytes;
320 vecp->i_type = XLOG_REG_TYPE_ILOCAL;
323 iip->ili_format.ilf_dsize = (unsigned)data_bytes;
325 iip->ili_fields &= ~XFS_ILOG_DDATA;
329 case XFS_DINODE_FMT_DEV:
331 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
332 XFS_ILOG_DEXT | XFS_ILOG_UUID);
333 if (iip->ili_fields & XFS_ILOG_DEV) {
334 iip->ili_format.ilf_u.ilfu_rdev =
335 ip->i_df.if_u2.if_rdev;
339 case XFS_DINODE_FMT_UUID:
341 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT |
342 XFS_ILOG_DEXT | XFS_ILOG_DEV);
343 if (iip->ili_fields & XFS_ILOG_UUID) {
344 iip->ili_format.ilf_u.ilfu_uuid =
345 ip->i_df.if_u2.if_uuid;
355 * If there are no attributes associated with the file, then we're done.
357 if (!XFS_IFORK_Q(ip)) {
359 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
363 switch (ip->i_d.di_aformat) {
364 case XFS_DINODE_FMT_EXTENTS:
366 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT);
368 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
369 ip->i_d.di_anextents > 0 &&
370 ip->i_afp->if_bytes > 0) {
371 ASSERT(ip->i_afp->if_bytes / sizeof(xfs_bmbt_rec_t) ==
372 ip->i_d.di_anextents);
373 ASSERT(ip->i_afp->if_u1.if_extents != NULL);
374 #ifdef XFS_NATIVE_HOST
376 * There are not delayed allocation extents
377 * for attributes, so just point at the array.
379 vecp->i_addr = ip->i_afp->if_u1.if_extents;
380 vecp->i_len = ip->i_afp->if_bytes;
381 vecp->i_type = XLOG_REG_TYPE_IATTR_EXT;
383 ASSERT(iip->ili_aextents_buf == NULL);
384 xfs_inode_item_format_extents(ip, vecp,
385 XFS_ATTR_FORK, XLOG_REG_TYPE_IATTR_EXT);
387 iip->ili_format.ilf_asize = vecp->i_len;
391 iip->ili_fields &= ~XFS_ILOG_AEXT;
395 case XFS_DINODE_FMT_BTREE:
397 ~(XFS_ILOG_ADATA | XFS_ILOG_AEXT);
399 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
400 ip->i_afp->if_broot_bytes > 0) {
401 ASSERT(ip->i_afp->if_broot != NULL);
403 vecp->i_addr = ip->i_afp->if_broot;
404 vecp->i_len = ip->i_afp->if_broot_bytes;
405 vecp->i_type = XLOG_REG_TYPE_IATTR_BROOT;
408 iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes;
410 iip->ili_fields &= ~XFS_ILOG_ABROOT;
414 case XFS_DINODE_FMT_LOCAL:
416 ~(XFS_ILOG_AEXT | XFS_ILOG_ABROOT);
418 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
419 ip->i_afp->if_bytes > 0) {
420 ASSERT(ip->i_afp->if_u1.if_data != NULL);
422 vecp->i_addr = ip->i_afp->if_u1.if_data;
424 * Round i_bytes up to a word boundary.
425 * The underlying memory is guaranteed to
426 * to be there by xfs_idata_realloc().
428 data_bytes = roundup(ip->i_afp->if_bytes, 4);
429 ASSERT((ip->i_afp->if_real_bytes == 0) ||
430 (ip->i_afp->if_real_bytes == data_bytes));
431 vecp->i_len = (int)data_bytes;
432 vecp->i_type = XLOG_REG_TYPE_IATTR_LOCAL;
435 iip->ili_format.ilf_asize = (unsigned)data_bytes;
437 iip->ili_fields &= ~XFS_ILOG_ADATA;
448 * Now update the log format that goes out to disk from the in-core
449 * values. We always write the inode core to make the arithmetic
450 * games in recovery easier, which isn't a big deal as just about any
451 * transaction would dirty it anyway.
453 iip->ili_format.ilf_fields = XFS_ILOG_CORE |
454 (iip->ili_fields & ~XFS_ILOG_TIMESTAMP);
455 iip->ili_format.ilf_size = nvecs;
460 * This is called to pin the inode associated with the inode log
461 * item in memory so it cannot be written out.
465 struct xfs_log_item *lip)
467 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
469 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
471 trace_xfs_inode_pin(ip, _RET_IP_);
472 atomic_inc(&ip->i_pincount);
477 * This is called to unpin the inode associated with the inode log
478 * item which was previously pinned with a call to xfs_inode_item_pin().
480 * Also wake up anyone in xfs_iunpin_wait() if the count goes to 0.
483 xfs_inode_item_unpin(
484 struct xfs_log_item *lip,
487 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
489 trace_xfs_inode_unpin(ip, _RET_IP_);
490 ASSERT(atomic_read(&ip->i_pincount) > 0);
491 if (atomic_dec_and_test(&ip->i_pincount))
492 wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
497 struct xfs_log_item *lip,
498 struct list_head *buffer_list)
500 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
501 struct xfs_inode *ip = iip->ili_inode;
502 struct xfs_buf *bp = NULL;
503 uint rval = XFS_ITEM_SUCCESS;
506 if (xfs_ipincount(ip) > 0)
507 return XFS_ITEM_PINNED;
509 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
510 return XFS_ITEM_LOCKED;
513 * Re-check the pincount now that we stabilized the value by
516 if (xfs_ipincount(ip) > 0) {
517 rval = XFS_ITEM_PINNED;
522 * Stale inode items should force out the iclog.
524 if (ip->i_flags & XFS_ISTALE) {
525 rval = XFS_ITEM_PINNED;
530 * Someone else is already flushing the inode. Nothing we can do
531 * here but wait for the flush to finish and remove the item from
534 if (!xfs_iflock_nowait(ip)) {
535 rval = XFS_ITEM_FLUSHING;
539 ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
540 ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
542 spin_unlock(&lip->li_ailp->xa_lock);
544 error = xfs_iflush(ip, &bp);
546 if (!xfs_buf_delwri_queue(bp, buffer_list))
547 rval = XFS_ITEM_FLUSHING;
551 spin_lock(&lip->li_ailp->xa_lock);
553 xfs_iunlock(ip, XFS_ILOCK_SHARED);
558 * Unlock the inode associated with the inode log item.
559 * Clear the fields of the inode and inode log item that
560 * are specific to the current transaction. If the
561 * hold flags is set, do not unlock the inode.
564 xfs_inode_item_unlock(
565 struct xfs_log_item *lip)
567 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
568 struct xfs_inode *ip = iip->ili_inode;
569 unsigned short lock_flags;
571 ASSERT(ip->i_itemp != NULL);
572 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
575 * If the inode needed a separate buffer with which to log
576 * its extents, then free it now.
578 if (iip->ili_extents_buf != NULL) {
579 ASSERT(ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS);
580 ASSERT(ip->i_d.di_nextents > 0);
581 ASSERT(iip->ili_fields & XFS_ILOG_DEXT);
582 ASSERT(ip->i_df.if_bytes > 0);
583 kmem_free(iip->ili_extents_buf);
584 iip->ili_extents_buf = NULL;
586 if (iip->ili_aextents_buf != NULL) {
587 ASSERT(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS);
588 ASSERT(ip->i_d.di_anextents > 0);
589 ASSERT(iip->ili_fields & XFS_ILOG_AEXT);
590 ASSERT(ip->i_afp->if_bytes > 0);
591 kmem_free(iip->ili_aextents_buf);
592 iip->ili_aextents_buf = NULL;
595 lock_flags = iip->ili_lock_flags;
596 iip->ili_lock_flags = 0;
598 xfs_iunlock(ip, lock_flags);
602 * This is called to find out where the oldest active copy of the inode log
603 * item in the on disk log resides now that the last log write of it completed
604 * at the given lsn. Since we always re-log all dirty data in an inode, the
605 * latest copy in the on disk log is the only one that matters. Therefore,
606 * simply return the given lsn.
608 * If the inode has been marked stale because the cluster is being freed, we
609 * don't want to (re-)insert this inode into the AIL. There is a race condition
610 * where the cluster buffer may be unpinned before the inode is inserted into
611 * the AIL during transaction committed processing. If the buffer is unpinned
612 * before the inode item has been committed and inserted, then it is possible
613 * for the buffer to be written and IO completes before the inode is inserted
614 * into the AIL. In that case, we'd be inserting a clean, stale inode into the
615 * AIL which will never get removed. It will, however, get reclaimed which
616 * triggers an assert in xfs_inode_free() complaining about freein an inode
619 * To avoid this, just unpin the inode directly and return a LSN of -1 so the
620 * transaction committed code knows that it does not need to do any further
621 * processing on the item.
624 xfs_inode_item_committed(
625 struct xfs_log_item *lip,
628 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
629 struct xfs_inode *ip = iip->ili_inode;
631 if (xfs_iflags_test(ip, XFS_ISTALE)) {
632 xfs_inode_item_unpin(lip, 0);
639 * XXX rcc - this one really has to do something. Probably needs
640 * to stamp in a new field in the incore inode.
643 xfs_inode_item_committing(
644 struct xfs_log_item *lip,
647 INODE_ITEM(lip)->ili_last_lsn = lsn;
651 * This is the ops vector shared by all buf log items.
653 static const struct xfs_item_ops xfs_inode_item_ops = {
654 .iop_size = xfs_inode_item_size,
655 .iop_format = xfs_inode_item_format,
656 .iop_pin = xfs_inode_item_pin,
657 .iop_unpin = xfs_inode_item_unpin,
658 .iop_unlock = xfs_inode_item_unlock,
659 .iop_committed = xfs_inode_item_committed,
660 .iop_push = xfs_inode_item_push,
661 .iop_committing = xfs_inode_item_committing
666 * Initialize the inode log item for a newly allocated (in-core) inode.
670 struct xfs_inode *ip,
671 struct xfs_mount *mp)
673 struct xfs_inode_log_item *iip;
675 ASSERT(ip->i_itemp == NULL);
676 iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);
679 xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE,
680 &xfs_inode_item_ops);
681 iip->ili_format.ilf_type = XFS_LI_INODE;
682 iip->ili_format.ilf_ino = ip->i_ino;
683 iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
684 iip->ili_format.ilf_len = ip->i_imap.im_len;
685 iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
689 * Free the inode log item and any memory hanging off of it.
692 xfs_inode_item_destroy(
695 kmem_zone_free(xfs_ili_zone, ip->i_itemp);
700 * This is the inode flushing I/O completion routine. It is called
701 * from interrupt level when the buffer containing the inode is
702 * flushed to disk. It is responsible for removing the inode item
703 * from the AIL if it has not been re-logged, and unlocking the inode's
706 * To reduce AIL lock traffic as much as possible, we scan the buffer log item
707 * list for other inodes that will run this function. We remove them from the
708 * buffer list so we can process all the inode IO completions in one AIL lock
714 struct xfs_log_item *lip)
716 struct xfs_inode_log_item *iip;
717 struct xfs_log_item *blip;
718 struct xfs_log_item *next;
719 struct xfs_log_item *prev;
720 struct xfs_ail *ailp = lip->li_ailp;
724 * Scan the buffer IO completions for other inodes being completed and
725 * attach them to the current inode log item.
729 while (blip != NULL) {
730 if (lip->li_cb != xfs_iflush_done) {
732 blip = blip->li_bio_list;
736 /* remove from list */
737 next = blip->li_bio_list;
741 prev->li_bio_list = next;
744 /* add to current list */
745 blip->li_bio_list = lip->li_bio_list;
746 lip->li_bio_list = blip;
749 * while we have the item, do the unlocked check for needing
752 iip = INODE_ITEM(blip);
753 if (iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn)
759 /* make sure we capture the state of the initial inode. */
760 iip = INODE_ITEM(lip);
761 if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn)
765 * We only want to pull the item from the AIL if it is
766 * actually there and its location in the log has not
767 * changed since we started the flush. Thus, we only bother
768 * if the ili_logged flag is set and the inode's lsn has not
769 * changed. First we check the lsn outside
770 * the lock since it's cheaper, and then we recheck while
771 * holding the lock before removing the inode from the AIL.
774 struct xfs_log_item *log_items[need_ail];
776 spin_lock(&ailp->xa_lock);
777 for (blip = lip; blip; blip = blip->li_bio_list) {
778 iip = INODE_ITEM(blip);
779 if (iip->ili_logged &&
780 blip->li_lsn == iip->ili_flush_lsn) {
781 log_items[i++] = blip;
783 ASSERT(i <= need_ail);
785 /* xfs_trans_ail_delete_bulk() drops the AIL lock. */
786 xfs_trans_ail_delete_bulk(ailp, log_items, i,
787 SHUTDOWN_CORRUPT_INCORE);
792 * clean up and unlock the flush lock now we are done. We can clear the
793 * ili_last_fields bits now that we know that the data corresponding to
794 * them is safely on disk.
796 for (blip = lip; blip; blip = next) {
797 next = blip->li_bio_list;
798 blip->li_bio_list = NULL;
800 iip = INODE_ITEM(blip);
802 iip->ili_last_fields = 0;
803 xfs_ifunlock(iip->ili_inode);
808 * This is the inode flushing abort routine. It is called from xfs_iflush when
809 * the filesystem is shutting down to clean up the inode state. It is
810 * responsible for removing the inode item from the AIL if it has not been
811 * re-logged, and unlocking the inode's flush lock.
818 xfs_inode_log_item_t *iip = ip->i_itemp;
821 struct xfs_ail *ailp = iip->ili_item.li_ailp;
822 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
823 spin_lock(&ailp->xa_lock);
824 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
825 /* xfs_trans_ail_delete() drops the AIL lock. */
826 xfs_trans_ail_delete(ailp, &iip->ili_item,
828 SHUTDOWN_LOG_IO_ERROR :
829 SHUTDOWN_CORRUPT_INCORE);
831 spin_unlock(&ailp->xa_lock);
835 * Clear the ili_last_fields bits now that we know that the
836 * data corresponding to them is safely on disk.
838 iip->ili_last_fields = 0;
840 * Clear the inode logging fields so no more flushes are
846 * Release the inode's flush lock since we're done with it.
854 struct xfs_log_item *lip)
856 xfs_iflush_abort(INODE_ITEM(lip)->ili_inode, true);
860 * convert an xfs_inode_log_format struct from either 32 or 64 bit versions
861 * (which can have different field alignments) to the native version
864 xfs_inode_item_format_convert(
865 xfs_log_iovec_t *buf,
866 xfs_inode_log_format_t *in_f)
868 if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) {
869 xfs_inode_log_format_32_t *in_f32 = buf->i_addr;
871 in_f->ilf_type = in_f32->ilf_type;
872 in_f->ilf_size = in_f32->ilf_size;
873 in_f->ilf_fields = in_f32->ilf_fields;
874 in_f->ilf_asize = in_f32->ilf_asize;
875 in_f->ilf_dsize = in_f32->ilf_dsize;
876 in_f->ilf_ino = in_f32->ilf_ino;
877 /* copy biggest field of ilf_u */
878 memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
879 in_f32->ilf_u.ilfu_uuid.__u_bits,
881 in_f->ilf_blkno = in_f32->ilf_blkno;
882 in_f->ilf_len = in_f32->ilf_len;
883 in_f->ilf_boffset = in_f32->ilf_boffset;
885 } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){
886 xfs_inode_log_format_64_t *in_f64 = buf->i_addr;
888 in_f->ilf_type = in_f64->ilf_type;
889 in_f->ilf_size = in_f64->ilf_size;
890 in_f->ilf_fields = in_f64->ilf_fields;
891 in_f->ilf_asize = in_f64->ilf_asize;
892 in_f->ilf_dsize = in_f64->ilf_dsize;
893 in_f->ilf_ino = in_f64->ilf_ino;
894 /* copy biggest field of ilf_u */
895 memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
896 in_f64->ilf_u.ilfu_uuid.__u_bits,
898 in_f->ilf_blkno = in_f64->ilf_blkno;
899 in_f->ilf_len = in_f64->ilf_len;
900 in_f->ilf_boffset = in_f64->ilf_boffset;