From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, chandanbabu@kernel.org
Cc: Christoph Hellwig <hch@lst.de>, hch@lst.de, linux-xfs@vger.kernel.org
Subject: [PATCH 4/4] xfs: invalidate dentries for a file before moving it to the orphanage
Date: Tue, 23 Apr 2024 20:29:48 -0700 [thread overview]
Message-ID: <171392786464.1907482.17907129310276500940.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <171392786386.1907482.12122730497500276549.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Invalidate the cached dentries that point to the file that we're moving
to lost+found before we actually move it.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/scrub/orphanage.c | 47 ++++++++++++++++++++--------------------------
fs/xfs/scrub/trace.h | 2 --
2 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/fs/xfs/scrub/orphanage.c b/fs/xfs/scrub/orphanage.c
index 2b142e6de8f3..7148d8362db8 100644
--- a/fs/xfs/scrub/orphanage.c
+++ b/fs/xfs/scrub/orphanage.c
@@ -434,16 +434,17 @@ xrep_adoption_check_dcache(
{
struct qstr qname = QSTR_INIT(adopt->xname->name,
adopt->xname->len);
+ struct xfs_scrub *sc = adopt->sc;
struct dentry *d_orphanage, *d_child;
int error = 0;
- d_orphanage = d_find_alias(VFS_I(adopt->sc->orphanage));
+ d_orphanage = d_find_alias(VFS_I(sc->orphanage));
if (!d_orphanage)
return 0;
d_child = d_hash_and_lookup(d_orphanage, &qname);
if (d_child) {
- trace_xrep_adoption_check_child(adopt->sc->mp, d_child);
+ trace_xrep_adoption_check_child(sc->mp, d_child);
if (d_is_positive(d_child)) {
ASSERT(d_is_negative(d_child));
@@ -454,33 +455,15 @@ xrep_adoption_check_dcache(
}
dput(d_orphanage);
- if (error)
- return error;
-
- /*
- * Do we need to update d_parent of the dentry for the file being
- * repaired? There shouldn't be a hashed dentry with a parent since
- * the file had nonzero nlink but wasn't connected to any parent dir.
- */
- d_child = d_find_alias(VFS_I(adopt->sc->ip));
- if (!d_child)
- return 0;
-
- trace_xrep_adoption_check_alias(adopt->sc->mp, d_child);
-
- if (d_child->d_parent && !d_unhashed(d_child)) {
- ASSERT(d_child->d_parent == NULL || d_unhashed(d_child));
- error = -EFSCORRUPTED;
- }
-
- dput(d_child);
return error;
}
/*
- * Remove all negative dentries from the dcache. There should not be any
- * positive entries, since we've maintained our lock on the orphanage
- * directory.
+ * Invalidate all dentries for the name that was added to the orphanage
+ * directory, and all dentries pointing to the child inode that was moved.
+ *
+ * There should not be any positive entries for the name, since we've
+ * maintained our lock on the orphanage directory.
*/
static void
xrep_adoption_zap_dcache(
@@ -488,15 +471,17 @@ xrep_adoption_zap_dcache(
{
struct qstr qname = QSTR_INIT(adopt->xname->name,
adopt->xname->len);
+ struct xfs_scrub *sc = adopt->sc;
struct dentry *d_orphanage, *d_child;
- d_orphanage = d_find_alias(VFS_I(adopt->sc->orphanage));
+ /* Invalidate all dentries for the adoption name */
+ d_orphanage = d_find_alias(VFS_I(sc->orphanage));
if (!d_orphanage)
return;
d_child = d_hash_and_lookup(d_orphanage, &qname);
while (d_child != NULL) {
- trace_xrep_adoption_invalidate_child(adopt->sc->mp, d_child);
+ trace_xrep_adoption_invalidate_child(sc->mp, d_child);
ASSERT(d_is_negative(d_child));
d_invalidate(d_child);
@@ -505,6 +490,14 @@ xrep_adoption_zap_dcache(
}
dput(d_orphanage);
+
+ /* Invalidate all the dentries pointing down to this file. */
+ while ((d_child = d_find_alias(VFS_I(sc->ip))) != NULL) {
+ trace_xrep_adoption_invalidate_child(sc->mp, d_child);
+
+ d_invalidate(d_child);
+ dput(d_child);
+ }
}
/*
diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h
index 4b945007ca6c..e27daa51cab6 100644
--- a/fs/xfs/scrub/trace.h
+++ b/fs/xfs/scrub/trace.h
@@ -3265,8 +3265,6 @@ DEFINE_EVENT(xrep_dentry_class, name, \
TP_PROTO(struct xfs_mount *mp, const struct dentry *dentry), \
TP_ARGS(mp, dentry))
DEFINE_REPAIR_DENTRY_EVENT(xrep_adoption_check_child);
-DEFINE_REPAIR_DENTRY_EVENT(xrep_adoption_check_alias);
-DEFINE_REPAIR_DENTRY_EVENT(xrep_adoption_check_dentry);
DEFINE_REPAIR_DENTRY_EVENT(xrep_adoption_invalidate_child);
DEFINE_REPAIR_DENTRY_EVENT(xrep_dirtree_delete_child);
next prev parent reply other threads:[~2024-04-24 3:29 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 3:02 [PATCHBOMB v13.4] xfs: directory parent pointers Darrick J. Wong
2024-04-24 3:05 ` [PATCHSET v13.4 1/9] xfs: shrink struct xfs_da_args Darrick J. Wong
2024-04-24 3:07 ` [PATCH 1/5] xfs: remove XFS_DA_OP_REMOVE Darrick J. Wong
2024-04-24 3:08 ` [PATCH 2/5] xfs: remove XFS_DA_OP_NOTIME Darrick J. Wong
2024-04-24 3:08 ` [PATCH 3/5] xfs: remove xfs_da_args.attr_flags Darrick J. Wong
2024-04-24 3:08 ` [PATCH 4/5] xfs: make attr removal an explicit operation Darrick J. Wong
2024-04-24 3:08 ` [PATCH 5/5] xfs: rearrange xfs_da_args a bit to use less space Darrick J. Wong
2024-04-24 3:05 ` [PATCHSET v13.4 2/9] xfs: improve extended attribute validation Darrick J. Wong
2024-04-24 3:09 ` [PATCH 01/14] xfs: attr fork iext must be loaded before calling xfs_attr_is_leaf Darrick J. Wong
2024-04-24 3:09 ` [PATCH 02/14] xfs: require XFS_SB_FEAT_INCOMPAT_LOG_XATTRS for attr log intent item recovery Darrick J. Wong
2024-04-24 3:09 ` [PATCH 03/14] xfs: use an XFS_OPSTATE_ flag for detecting if logged xattrs are available Darrick J. Wong
2024-04-24 3:09 ` [PATCH 04/14] xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2 Darrick J. Wong
2024-04-24 3:10 ` [PATCH 05/14] xfs: fix missing check for invalid attr flags Darrick J. Wong
2024-04-24 3:10 ` [PATCH 06/14] xfs: check shortform attr entry flags specifically Darrick J. Wong
2024-04-24 3:10 ` [PATCH 07/14] xfs: restructure xfs_attr_complete_op a bit Darrick J. Wong
2024-04-24 3:11 ` [PATCH 08/14] xfs: use helpers to extract xattr op from opflags Darrick J. Wong
2024-04-24 3:11 ` [PATCH 09/14] xfs: validate recovered name buffers when recovering xattr items Darrick J. Wong
2024-04-24 3:11 ` [PATCH 10/14] xfs: always set args->value in xfs_attri_item_recover Darrick J. Wong
2024-04-24 3:11 ` [PATCH 11/14] xfs: use local variables for name and value length in _attri_commit_pass2 Darrick J. Wong
2024-04-24 3:12 ` [PATCH 12/14] xfs: refactor name/length checks in xfs_attri_validate Darrick J. Wong
2024-04-24 3:12 ` [PATCH 13/14] xfs: refactor name/value iovec validation in xlog_recover_attri_commit_pass2 Darrick J. Wong
2024-04-24 3:12 ` [PATCH 14/14] xfs: enforce one namespace per attribute Darrick J. Wong
2024-04-24 3:06 ` [PATCHSET v13.4 3/9] xfs: Parent Pointers Darrick J. Wong
2024-04-24 3:12 ` [PATCH 01/30] xfs: rearrange xfs_attr_match parameters Darrick J. Wong
2024-04-24 3:13 ` [PATCH 02/30] xfs: check the flags earlier in xfs_attr_match Darrick J. Wong
2024-04-24 3:13 ` [PATCH 03/30] xfs: move xfs_attr_defer_add to xfs_attr_item.c Darrick J. Wong
2024-04-24 3:13 ` [PATCH 04/30] xfs: create a separate hashname function for extended attributes Darrick J. Wong
2024-04-24 3:13 ` [PATCH 05/30] xfs: add parent pointer support to attribute code Darrick J. Wong
2024-04-24 3:14 ` [PATCH 06/30] xfs: define parent pointer ondisk extended attribute format Darrick J. Wong
2024-04-24 3:14 ` [PATCH 07/30] xfs: allow xattr matching on name and value for parent pointers Darrick J. Wong
2024-04-24 3:14 ` [PATCH 08/30] xfs: refactor xfs_is_using_logged_xattrs checks in attr item recovery Darrick J. Wong
2024-04-24 3:14 ` [PATCH 09/30] xfs: create attr log item opcodes and formats for parent pointers Darrick J. Wong
2024-04-24 3:15 ` [PATCH 10/30] xfs: record inode generation in xattr update log intent items Darrick J. Wong
2024-04-24 3:15 ` [PATCH 11/30] xfs: Expose init_xattrs in xfs_create_tmpfile Darrick J. Wong
2024-04-24 3:15 ` [PATCH 12/30] xfs: add parent pointer validator functions Darrick J. Wong
2024-04-24 3:15 ` [PATCH 13/30] xfs: extend transaction reservations for parent attributes Darrick J. Wong
2024-04-24 3:16 ` [PATCH 14/30] xfs: create a hashname function for parent pointers Darrick J. Wong
2024-04-24 3:16 ` [PATCH 15/30] xfs: parent pointer attribute creation Darrick J. Wong
2024-04-24 3:16 ` [PATCH 16/30] xfs: add parent attributes to link Darrick J. Wong
2024-04-24 3:17 ` [PATCH 17/30] xfs: add parent attributes to symlink Darrick J. Wong
2024-04-24 3:17 ` [PATCH 18/30] xfs: remove parent pointers in unlink Darrick J. Wong
2024-04-24 3:17 ` [PATCH 19/30] xfs: Add parent pointers to rename Darrick J. Wong
2024-04-24 3:17 ` [PATCH 20/30] xfs: Add parent pointers to xfs_cross_rename Darrick J. Wong
2024-04-24 3:18 ` [PATCH 21/30] xfs: don't return XFS_ATTR_PARENT attributes via listxattr Darrick J. Wong
2024-04-24 3:18 ` [PATCH 22/30] xfs: pass the attr value to put_listent when possible Darrick J. Wong
2024-04-24 3:18 ` [PATCH 23/30] xfs: move handle ioctl code to xfs_handle.c Darrick J. Wong
2024-04-24 3:18 ` [PATCH 24/30] xfs: split out handle management helpers a bit Darrick J. Wong
2024-04-24 3:19 ` [PATCH 25/30] xfs: add parent pointer ioctls Darrick J. Wong
2024-04-24 3:19 ` [PATCH 26/30] xfs: don't remove the attr fork when parent pointers are enabled Darrick J. Wong
2024-04-24 3:19 ` [PATCH 27/30] xfs: add a incompat feature bit for parent pointers Darrick J. Wong
2024-04-24 3:19 ` [PATCH 28/30] xfs: fix unit conversion error in xfs_log_calc_max_attrsetm_res Darrick J. Wong
2024-04-24 3:20 ` [PATCH 29/30] xfs: drop compatibility minimum log size computations for reflink Darrick J. Wong
2024-04-24 3:20 ` [PATCH 30/30] xfs: enable parent pointers Darrick J. Wong
2024-04-24 3:06 ` [PATCHSET v13.4 4/9] xfs: scrubbing for " Darrick J. Wong
2024-04-24 3:20 ` [PATCH 1/7] xfs: revert commit 44af6c7e59b12 Darrick J. Wong
2024-04-24 3:20 ` [PATCH 2/7] xfs: check dirents have parent pointers Darrick J. Wong
2024-04-24 3:21 ` [PATCH 3/7] xfs: deferred scrub of dirents Darrick J. Wong
2024-04-24 3:21 ` [PATCH 4/7] xfs: scrub parent pointers Darrick J. Wong
2024-04-24 3:21 ` [PATCH 5/7] xfs: deferred scrub of " Darrick J. Wong
2024-04-24 3:21 ` [PATCH 6/7] xfs: walk directory parent pointers to determine backref count Darrick J. Wong
2024-04-24 3:22 ` [PATCH 7/7] xfs: check parent pointer xattrs when scrubbing Darrick J. Wong
2024-04-24 3:06 ` [PATCHSET v13.4 5/9] xfs: online repair for parent pointers Darrick J. Wong
2024-04-24 3:22 ` [PATCH 01/16] xfs: remove some boilerplate from xfs_attr_set Darrick J. Wong
2024-04-24 3:22 ` [PATCH 02/16] xfs: make the reserved block permission flag explicit in xfs_attr_set Darrick J. Wong
2024-04-24 3:23 ` [PATCH 03/16] xfs: salvage parent pointers when rebuilding xattr structures Darrick J. Wong
2024-04-24 3:23 ` [PATCH 04/16] xfs: add raw parent pointer apis to support repair Darrick J. Wong
2024-04-24 3:23 ` [PATCH 05/16] xfs: repair directories by scanning directory parent pointers Darrick J. Wong
2024-04-24 3:23 ` [PATCH 06/16] xfs: implement live updates for directory repairs Darrick J. Wong
2024-04-24 3:24 ` [PATCH 07/16] xfs: replay unlocked parent pointer updates that accrue during xattr repair Darrick J. Wong
2024-04-24 3:24 ` [PATCH 08/16] xfs: repair directory parent pointers by scanning for dirents Darrick J. Wong
2024-04-24 3:24 ` [PATCH 09/16] xfs: implement live updates for parent pointer repairs Darrick J. Wong
2024-04-24 3:24 ` [PATCH 10/16] xfs: remove pointless unlocked assertion Darrick J. Wong
2024-04-24 3:25 ` [PATCH 11/16] xfs: split xfs_bmap_add_attrfork into two pieces Darrick J. Wong
2024-04-24 3:25 ` [PATCH 12/16] xfs: add a per-leaf block callback to xchk_xattr_walk Darrick J. Wong
2024-04-24 3:25 ` [PATCH 13/16] xfs: actually rebuild the parent pointer xattrs Darrick J. Wong
2024-04-24 3:25 ` [PATCH 14/16] xfs: adapt the orphanage code to handle parent pointers Darrick J. Wong
2024-04-24 3:26 ` [PATCH 15/16] xfs: repair link count of nondirectories after rebuilding " Darrick J. Wong
2024-04-24 3:26 ` [PATCH 16/16] xfs: inode repair should ensure there's an attr fork to store " Darrick J. Wong
2024-04-24 3:06 ` [PATCHSET v13.4 6/9] xfs: detect and correct directory tree problems Darrick J. Wong
2024-04-24 3:26 ` [PATCH 1/4] xfs: teach online scrub to find directory tree structure problems Darrick J. Wong
2024-04-24 3:26 ` [PATCH 2/4] xfs: invalidate dirloop scrub path data when concurrent updates happen Darrick J. Wong
2024-04-24 3:27 ` [PATCH 3/4] xfs: report directory tree corruption in the health information Darrick J. Wong
2024-04-24 3:27 ` [PATCH 4/4] xfs: fix corruptions in the directory tree Darrick J. Wong
2024-04-24 3:07 ` [PATCHSET v13.4 7/9] xfs: vectorize scrub kernel calls Darrick J. Wong
2024-04-24 3:27 ` [PATCH 1/3] xfs: reduce the rate of cond_resched calls inside scrub Darrick J. Wong
2024-04-24 3:27 ` [PATCH 2/3] xfs: move xfs_ioc_scrub_metadata to scrub.c Darrick J. Wong
2024-04-24 3:28 ` [PATCH 3/3] xfs: introduce vectored scrub mode Darrick J. Wong
2024-04-24 3:07 ` [PATCHSET v13.4 8/9] xfs: reduce iget overhead in scrub Darrick J. Wong
2024-04-24 3:28 ` [PATCH 1/2] xfs: use dontcache for grabbing inodes during scrub Darrick J. Wong
2024-04-24 3:28 ` [PATCH 2/2] xfs: only iget the file once when doing vectored scrub-by-handle Darrick J. Wong
2024-04-24 3:07 ` [PATCHSET v13.4 9/9] xfs: minor fixes to online repair Darrick J. Wong
2024-04-24 3:29 ` [PATCH 1/4] xfs: drop the scrub file's iolock when transaction allocation fails Darrick J. Wong
2024-04-24 3:29 ` [PATCH 2/4] xfs: fix iunlock calls in xrep_adoption_trans_alloc Darrick J. Wong
2024-04-24 3:29 ` [PATCH 3/4] xfs: exchange-range for repairs is no longer dynamic Darrick J. Wong
2024-04-24 3:29 ` Darrick J. Wong [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-04-17 23:13 [PATCHSET v13.3 2/2] xfs: minor fixes to online repair Darrick J. Wong
2024-04-17 23:15 ` [PATCH 4/4] xfs: invalidate dentries for a file before moving it to the orphanage Darrick J. Wong
2024-04-18 4:25 ` 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=171392786464.1907482.17907129310276500940.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).