Patch "xfs: xfs_attr_inactive leaves inconsistent attr fork state behind" has been added to the 4.0-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
xfs: xfs_attr_inactive leaves inconsistent attr fork state behind
to the 4.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
xfs-xfs_attr_inactive-leaves-inconsistent-attr-fork-state-behind.patch
and it can be found in the queue-4.0 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
6dfe5a049f2d48582050339d2a6b6fda36dfd14cMon Sep 17 00:00:00 2001
From: Dave Chinner <[email protected]>
Date: Fri, 29 May 2015 07:40:08 +1000
Subject: xfs: xfs_attr_inactive leaves inconsistent attr fork state behind
From: Dave Chinner <[email protected]>
commit 6dfe5a049f2d48582050339d2a6b6fda36dfd14c upstream.
xfs_attr_inactive() is supposed to clean up the attribute fork when the inode is being freed. While it removes attribute fork extents, it completely ignores attributes in local format, which means that there can still be active attributes on the inode after xfs_attr_inactive() has run.
This leads to problems with concurrent inode writeback - the in-core inode attribute fork is removed without locking on the assumption that nothing will be attempting to access the attribute fork after a call to xfs_attr_inactive() because it isn't supposed to exist on disk any more.
To fix this, make xfs_attr_inactive() completely remove all traces of the attribute fork from the inode, regardless of it's state. Further, also remove the in-core attribute fork structure safely so that there is nothing further that needs to be done by callers to clean up the attribute fork. This means we can remove the in-core and on-disk attribute forks atomically.
Also, on error simply remove the in-memory attribute fork. There's nothing that can be done with it once we have failed to remove the on-disk attribute fork, so we may as well just blow it away here anyway.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 8 ++-- fs/xfs/libxfs/xfs_attr_leaf.h | 2 - fs/xfs/xfs_attr_inactive.c | 83 ++++++++++++++++++++++++------------------ fs/xfs/xfs_inode.c | 12 ++---- 4 files changed, 58 insertions(+), 47 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +4 -4
@@ -498,8 +498,8 @@ xfs_attr_shortform_add(xfs_da_args_t *ar* After the last attribute is removed revert to original inode format, * making all literal area available to the data fork once more. */ -STATIC void -xfs_attr_fork_reset ( +void +xfs_attr_fork_remove (struct xfs_inode *ip,struct xfs_trans *tp) {
@@ -565,7 +565,7 @@ xfs_attr_shortform_remove(xfs_da_args_t (mp->m_flags & XFS_MOUNT_ATTR2) && (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) && !(args->op_flags & XFS_DA_OP_ADDNAME)) { - xfs_attr_fork_reset(dp, args->trans); + xfs_attr_fork_remove(dp, args->trans); } else {xfs_idata_realloc (dp, -size,XFS_ATTR_FORK ); dp->i_d.di_forkoff =xfs_attr_shortform_bytesfit (dp, totsize);
@@ -828,7 +828,7 @@ xfs_attr3_leaf_to_shortform(if (forkoff ==-1 ) {ASSERT (dp->i_mount->m_flags &XFS_MOUNT_ATTR2 );ASSERT (dp->i_d.di_format !=XFS_DINODE_FMT_BTREE ); -xfs_attr_fork_reset (dp, args->trans); +xfs_attr_fork_remove (dp, args->trans); goto out; }
fs/xfs/libxfs/xfs_attr_leaf.h +1 -1
@@ -53,7 +53,7 @@ int xfs_attr_shortform_remove(struct xfsint xfs_attr_shortform_list (struct xfs_attr_list_context *context);int xfs_attr_shortform_allfit (struct xfs_buf *bp,struct xfs_inode *dp);int xfs_attr_shortform_bytesfit (xfs_inode_t *dp,int bytes); - +void xfs_attr_fork_remove (struct xfs_inode *ip,struct xfs_trans *tp);/* * Internal routines when attribute fork size == XFS_LBSIZE(mp).
fs/xfs/xfs_attr_inactive.c +49 -34
114 lines not on this page · raw message
fs/xfs/xfs_inode.c +4 -8
@@ -1889,21 +1889,17 @@ xfs_inactive(/* * If there are attributes associated with the file then blow them away * now. The code calls a routine that recursively deconstructs the -* attribute fork. We need to just commit the current transaction -* because we can't use it for xfs_attr_inactive(). +* attribute fork. If also blows away the in-core attribute fork. */ -if (ip->i_d.di_anextents >0 ) { -ASSERT (ip->i_d.di_forkoff !=0 ); - +if (XFS_IFORK_Q (ip)) { error =xfs_attr_inactive (ip);if (error)return ; } -if (ip->i_afp) -xfs_idestroy_fork (ip,XFS_ATTR_FORK ); - +ASSERT (!ip->i_afp);ASSERT (ip->i_d.di_anextents ==0 ); +ASSERT (ip->i_d.di_forkoff ==0 );/* * Free the inode.
Patches currently in stable-queue which might be from [email protected] are
queue-4.0/xfs-xfs_iozero-can-return-positive-errno.patch queue-4.0/xfs-xfs_attr_inactive-leaves-inconsistent-attr-fork-state-behind.patch