Skip to content

Commit 673cd88

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: honor init_xattrs in xfs_init_new_inode for !ATTR fs
xfs_init_new_inode ignores the init_xattrs parameter for filesystems that do not have ATTR enabled. As a result, the first init_xattrs file to be created by the kernel will not have an attr fork created to store acls. Storing that first acl will add ATTR to the superblock flags, so subsequent files will be created with attr forks. The overhead of this is so small that chances are that nobody has noticed this behavior. However, this is disastrous on a filesystem with parent pointers because it requires that a new linkable file /must/ have a pre-existing attr fork, and the parent pointers code uses init_xattrs to create that fork. The preproduction version of mkfs.xfs used to set this, but the V5 sb verifier only requires ATTR2, not ATTR. There is no guard for filesystems with (PARENT && !ATTR). It turns out that I misunderstood the two flags -- ATTR means that we at some point created an attr fork to store xattrs in a file; ATTR2 apparently means only that inodes have dynamic fork offsets or that the filesystem was mounted with the "attr2" option. Fixes: 2442ee1 ("xfs: eager inode attr fork init needs attr feature awareness") Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent dc5e1cb commit 673cd88

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/xfs/xfs_inode.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "xfs_pnfs.h"
4343
#include "xfs_parent.h"
4444
#include "xfs_xattr.h"
45+
#include "xfs_sb.h"
4546

4647
struct kmem_cache *xfs_inode_cache;
4748

@@ -870,9 +871,16 @@ xfs_init_new_inode(
870871
* this saves us from needing to run a separate transaction to set the
871872
* fork offset in the immediate future.
872873
*/
873-
if (init_xattrs && xfs_has_attr(mp)) {
874+
if (init_xattrs) {
874875
ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
875876
xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0);
877+
878+
if (!xfs_has_attr(mp)) {
879+
spin_lock(&mp->m_sb_lock);
880+
xfs_add_attr(mp);
881+
spin_unlock(&mp->m_sb_lock);
882+
xfs_log_sb(tp);
883+
}
876884
}
877885

878886
/*

0 commit comments

Comments
 (0)