From: "Darrick J. Wong" <djwong@kernel.org>
To: hch@lst.de, chandanbabu@kernel.org, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 6/6] xfs: honor init_xattrs in xfs_init_new_inode for !ATTR fs
Date: Thu, 20 Jun 2024 16:14:58 -0700 [thread overview]
Message-ID: <171892459334.3192151.413694580283882579.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <171892459218.3192151.10366641366672957906.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
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: 2442ee15bb1e ("xfs: eager inode attr fork init needs attr feature awareness")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_inode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b699fa6ee3b6..aa134687027c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -42,6 +42,7 @@
#include "xfs_pnfs.h"
#include "xfs_parent.h"
#include "xfs_xattr.h"
+#include "xfs_sb.h"
struct kmem_cache *xfs_inode_cache;
@@ -870,9 +871,16 @@ xfs_init_new_inode(
* this saves us from needing to run a separate transaction to set the
* fork offset in the immediate future.
*/
- if (init_xattrs && xfs_has_attr(mp)) {
+ if (init_xattrs) {
ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0);
+
+ if (!xfs_has_attr(mp)) {
+ spin_lock(&mp->m_sb_lock);
+ xfs_add_attr(mp);
+ spin_unlock(&mp->m_sb_lock);
+ xfs_log_sb(tp);
+ }
}
/*
next prev parent reply other threads:[~2024-06-20 23:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 23:13 [PATCHSET v2] xfs: random fixes for 6.10 Darrick J. Wong
2024-06-20 23:13 ` [PATCH 1/6] xfs: fix freeing speculative preallocations for preallocated files Darrick J. Wong
2024-06-20 23:13 ` [PATCH 2/6] xfs: restrict when we try to align cow fork delalloc to cowextsz hints Darrick J. Wong
2024-06-21 4:32 ` Christoph Hellwig
2024-06-20 23:14 ` [PATCH 3/6] xfs: allow unlinked symlinks and dirs with zero size Darrick J. Wong
2024-06-20 23:14 ` [PATCH 4/6] xfs: verify buffer, inode, and dquot items every tx commit Darrick J. Wong
2024-06-20 23:14 ` [PATCH 5/6] xfs: fix direction in XFS_IOC_EXCHANGE_RANGE Darrick J. Wong
2024-06-21 4:32 ` Christoph Hellwig
2024-06-20 23:14 ` Darrick J. Wong [this message]
2024-06-21 4:34 ` [PATCH 6/6] xfs: honor init_xattrs in xfs_init_new_inode for !ATTR fs Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=171892459334.3192151.413694580283882579.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox