If a filesystem has been forced shutdown we are never going to write inodes to disk, which means the dquot items will stay in the AIL until we free the inod. Currently that is not a problem, but a pending chance requires us to empty the AIL before shutting down the filesystem, in which case this behaviour is lethal. Make sure to remove the log item from the AIL to allow emptying the AIL on shutdown filesystems. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- fs/xfs/xfs_iget.c | 17 +---------------- fs/xfs/xfs_inode.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 24 deletions(-) Index: xfs/fs/xfs/xfs_iget.c =================================================================== --- xfs.orig/fs/xfs/xfs_iget.c 2011-10-27 22:39:59.605174201 +0200 +++ xfs/fs/xfs/xfs_iget.c 2011-10-27 22:40:11.904690190 +0200 @@ -124,23 +124,8 @@ xfs_inode_free( xfs_idestroy_fork(ip, XFS_ATTR_FORK); if (ip->i_itemp) { - /* - * Only if we are shutting down the fs will we see an - * inode still in the AIL. If it is there, we should remove - * it to prevent a use-after-free from occurring. - */ - xfs_log_item_t *lip = &ip->i_itemp->ili_item; - struct xfs_ail *ailp = lip->li_ailp; + ASSERT(!(ip->i_itemp->ili_item.li_flags & XFS_LI_IN_AIL)); - ASSERT(((lip->li_flags & XFS_LI_IN_AIL) == 0) || - XFS_FORCED_SHUTDOWN(ip->i_mount)); - if (lip->li_flags & XFS_LI_IN_AIL) { - spin_lock(&ailp->xa_lock); - if (lip->li_flags & XFS_LI_IN_AIL) - xfs_trans_ail_delete(ailp, lip); - else - spin_unlock(&ailp->xa_lock); - } xfs_inode_item_destroy(ip); ip->i_itemp = NULL; } Index: xfs/fs/xfs/xfs_inode.c =================================================================== --- xfs.orig/fs/xfs/xfs_inode.c 2011-10-27 22:39:59.613171175 +0200 +++ xfs/fs/xfs/xfs_inode.c 2011-10-27 22:40:11.904690190 +0200 @@ -2407,7 +2407,6 @@ xfs_iflush( xfs_inode_t *ip, uint flags) { - xfs_inode_log_item_t *iip; xfs_buf_t *bp; xfs_dinode_t *dip; xfs_mount_t *mp; @@ -2420,7 +2419,6 @@ xfs_iflush( ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || ip->i_d.di_nextents > ip->i_df.if_ext_max); - iip = ip->i_itemp; mp = ip->i_mount; /* @@ -2457,13 +2455,14 @@ xfs_iflush( /* * This may have been unpinned because the filesystem is shutting * down forcibly. If that's the case we must not write this inode - * to disk, because the log record didn't make it to disk! + * to disk, because the log record didn't make it to disk. + * + * We also have to remove the log item from the AIL in this case, + * as we wait for an empty AIL as part of the unmount process. */ if (XFS_FORCED_SHUTDOWN(mp)) { - if (iip) - iip->ili_format.ilf_fields = 0; - xfs_ifunlock(ip); - return XFS_ERROR(EIO); + error = XFS_ERROR(EIO); + goto abort_out; } /* @@ -2510,11 +2509,13 @@ corrupt_out: xfs_buf_relse(bp); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); cluster_corrupt_out: + error = XFS_ERROR(EFSCORRUPTED); +abort_out: /* * Unlocks the flush lock */ xfs_iflush_abort(ip); - return XFS_ERROR(EFSCORRUPTED); + return error; } _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs