xfs: directory parent pointers
PATCH 4/4 xfs: fix corruptions in the directory tree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Repair corruptions in the directory tree itself. Cycles are broken by removing an incoming parent->child link. Multiply-owned directories are fixed by pruning the extra parent -> child links Disconnected subtrees are reconnected to the lost and found.
--- fs/xfs/Makefile | 1 fs/xfs/scrub/dirtree.c | 38 ++ fs/xfs/scrub/dirtree.h | 29 + fs/xfs/scrub/dirtree_repair.c | 821 +++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/orphanage.c | 6 fs/xfs/scrub/orphanage.h | 8 fs/xfs/scrub/repair.h | 4 fs/xfs/scrub/scrub.c | 2 fs/xfs/scrub/trace.h | 23 + fs/xfs/xfs_inode.c | 2 fs/xfs/xfs_inode.h | 1 11 files changed, 927 insertions(+), 8 deletions(-) create mode 100644 fs/xfs/scrub/dirtree_repair.c
fs/xfs/Makefile +1 -0
@@ -204,6 +204,7 @@ xfs-y += $(addprefix scrub/, \ bmap_repair.o \ cow_repair.o \ dir_repair.o \ + dirtree_repair.o \ findparent.o \ fscounters_repair.o \ ialloc_repair.o \
fs/xfs/scrub/dirtree.c +35 -3
@@ -26,6 +26,8 @@#include "scrub/xfblob.h" #include "scrub/listxattr.h" #include "scrub/trace.h" +#include "scrub/repair.h" +#include "scrub/orphanage.h" #include "scrub/dirtree.h" /*
@@ -95,6 +97,12 @@ xchk_setup_dirtree(xchk_fsgates_enable (sc,XCHK_FSGATES_DIRENTS ); +if (xchk_could_repair (sc)) { + error =xrep_setup_dirtree (sc); +if (error) +return error; + } + dl =kvzalloc (sizeof (struct xchk_dirtree ),XCHK_GFP_FLAGS );if (!dl)return -ENOMEM ;
@@ -104,6 +112,7 @@ xchk_setup_dirtree(INIT_LIST_HEAD (&dl->path_list); dl->root_ino =NULLFSINO ; dl->scan_ino =NULLFSINO ; + dl->parent_ino =NULLFSINO ;mutex_init (&dl->lock);
@@ -142,7 +151,7 @@ xchk_setup_dirtree(* Add the parent pointer described by @dl->pptr to the given path as a new * step. Returns -ELNRNG if the path is too deep. */ -STATIC int +int xchk_dirpath_append( struct xchk_dirtree *dl, struct xfs_inode *ip,
@@ -609,6 +618,22 @@ xchk_dirpath_step_is_stale(if (memcmp (dl->hook_xname.name, p->name->name, p->name->len) !=0 )return 0 ; +/* +* If the update comes from the repair code itself, walk the state +* machine forward. +*/ +if (p->ip->i_ino == dl->scan_ino && + path->outcome ==XREP_DIRPATH_ADOPTING ) { +xchk_dirpath_set_outcome (dl, path,XREP_DIRPATH_ADOPTED ); +return 0 ; + } + +if (p->ip->i_ino == dl->scan_ino && + path->outcome ==XREP_DIRPATH_DELETING ) { +xchk_dirpath_set_outcome (dl, path,XREP_DIRPATH_DELETED ); +return 0 ; + } +/* Exact match, scan data is out of date. */ trace_xchk_dirpath_changed (dl->sc, path->path_nr, step_nr, p->dp, p->ip, p->name);
@@ -747,7 +772,7 @@ xchk_dirtree_load_path(* path was too deep; -ENOSR if there were too many parent pointers; or * a negative errno. */ -STATIC int +int xchk_dirtree_find_paths_to_root (struct xchk_dirtree *dl) {
@@ -819,7 +844,7 @@ xchk_dirtree_find_paths_to_root(* Figure out what to do with the paths we tried to find. Do not call this * if the scan results are stale. */ -STATIC void +void xchk_dirtree_evaluate (struct xchk_dirtree *dl,struct xchk_dirtree_outcomes *oc)
@@ -856,6 +881,13 @@ xchk_dirtree_evaluate(/* This path got all the way to the root. */ oc->good++;break ; +case XREP_DIRPATH_DELETING : +case XREP_DIRPATH_DELETED : +case XREP_DIRPATH_ADOPTING : +case XREP_DIRPATH_ADOPTED : +/* These should not be in progress! */ +ASSERT (0 ); +break ; } }
fs/xfs/scrub/dirtree.h +29 -0
@@ -26,6 +26,11 @@ enum xchk_dirpath_outcome {XCHK_DIRPATH_LOOP ,/* cycle detected further up */ XCHK_DIRPATH_STALE ,/* path is stale */ XCHK_DIRPATH_OK ,/* path reaches the root */ + +XREP_DIRPATH_DELETING ,/* path is being deleted */ +XREP_DIRPATH_DELETED ,/* path has been deleted */ +XREP_DIRPATH_ADOPTING ,/* path is being adopted */ + XREP_DIRPATH_ADOPTED, /* path has been adopted */ };/*
@@ -64,6 +69,9 @@ struct xchk_dirtree_outcomes {/* Number of XCHK_DIRPATH_OK */ unsigned int good; + +/* Directory needs to be added to lost+found */ +bool needs_adoption; };struct xchk_dirtree {
@@ -79,6 +87,14 @@ struct xchk_dirtree {*/ xfs_ino_t scan_ino; +/* +* If we start deleting redundant paths to this subdirectory, this is +* the inode number of the surviving parent and the dotdot entry will +* be set to this value. If the value is NULLFSINO, then use @root_ino +* as a stand-in until the orphanage can adopt the subdirectory. +*/ +xfs_ino_t parent_ino; +/* Scratch buffer for scanning pptr xattrs */ struct xfs_parent_rec pptr_rec;struct xfs_da_args pptr_args;
@@ -87,12 +103,18 @@ struct xchk_dirtree {struct xfs_name xname;char namebuf[MAXNAMELEN ]; +/* Information for reparenting this directory. */ +struct xrep_adoption adoption; +/* * Hook into directory updates so that we can receive live updates * from other writer threads. */ struct xfs_dir_hook dhook; +/* Parent pointer update arguments. */ +struct xfs_parent_args ppargs; +/* lock for everything below here */ struct mutex lock;
@@ -146,4 +168,11 @@ xchk_dirtree_parentless(const struct xchk_dirtree *dl) return false; } +int xchk_dirtree_find_paths_to_root (struct xchk_dirtree *dl); +int xchk_dirpath_append (struct xchk_dirtree *dl,struct xfs_inode *ip, +struct xchk_dirpath *path,const struct xfs_name *name, +const struct xfs_parent_rec *pptr); +void xchk_dirtree_evaluate (struct xchk_dirtree *dl, +struct xchk_dirtree_outcomes *oc); +#endif /* __XFS_SCRUB_DIRTREE_H__ */
fs/xfs/scrub/dirtree_repair.c new file +821 -0
821 lines not on this page · raw message
fs/xfs/scrub/orphanage.c +6 -0
@@ -570,6 +570,12 @@ xrep_adoption_move(xfs_bumplink (sc->tp, sc->orphanage);xfs_trans_log_inode (sc->tp, sc->orphanage,XFS_ILOG_CORE ); +/* Bump the link count of the child. */ +if (adopt->bump_child_nlink) { +xfs_bumplink (sc->tp, sc->ip); +xfs_trans_log_inode (sc->tp, sc->ip,XFS_ILOG_CORE ); + } +/* Replace the dotdot entry if the child is a subdirectory. */ if (isdir) { error = xfs_dir_replace(sc->tp, sc->ip, &xfs_name_dotdot,
fs/xfs/scrub/orphanage.h +8 -0
@@ -60,6 +60,14 @@ struct xrep_adoption {/* Block reservations for orphanage and child (if directory). */ unsigned int orphanage_blkres;unsigned int child_blkres; + +/* +* Does the caller want us to bump the child link count? This is not +* needed when reattaching files that have become disconnected but have +* nlink > 1. It is necessary when changing the directory tree +* structure. +*/ + bool bump_child_nlink:1; };bool xrep_orphanage_can_adopt (struct xfs_scrub *sc);
fs/xfs/scrub/repair.h +4 -0
@@ -95,6 +95,7 @@ int xrep_setup_directory(struct xfs_scrub *sc);int xrep_setup_parent (struct xfs_scrub *sc);int xrep_setup_nlinks (struct xfs_scrub *sc);int xrep_setup_symlink (struct xfs_scrub *sc,unsigned int *resblks); +int xrep_setup_dirtree (struct xfs_scrub *sc);/* Repair setup functions */ int xrep_setup_ag_allocbt (struct xfs_scrub *sc);
@@ -132,6 +133,7 @@ int xrep_xattr(struct xfs_scrub *sc);int xrep_directory (struct xfs_scrub *sc);int xrep_parent (struct xfs_scrub *sc);int xrep_symlink (struct xfs_scrub *sc); +int xrep_dirtree (struct xfs_scrub *sc);#ifdef CONFIG_XFS_RT int xrep_rtbitmap (struct xfs_scrub *sc);
@@ -205,6 +207,7 @@ xrep_setup_nothing(#define xrep_setup_directory xrep_setup_nothing#define xrep_setup_parent xrep_setup_nothing#define xrep_setup_nlinks xrep_setup_nothing +#define xrep_setup_dirtree xrep_setup_nothing#define xrep_setup_inode (sc, imap) ((void)0)
@@ -239,6 +242,7 @@ static inline int xrep_setup_symlink(struct xfs_scrub *sc, unsigned int *x)#define xrep_directory xrep_notsupported#define xrep_parent xrep_notsupported#define xrep_symlink xrep_notsupported +#define xrep_dirtree xrep_notsupported#endif /* CONFIG_XFS_ONLINE_REPAIR */
fs/xfs/scrub/scrub.c +1 -1
@@ -441,7 +441,7 @@ static const struct xchk_meta_ops meta_scrub_ops[] = { .setup = xchk_setup_dirtree, .scrub = xchk_dirtree, .has = xfs_has_parent, - .repair = xrep_notsupported, + .repair = xrep_dirtree, }, };
fs/xfs/scrub/trace.h +20 -3
@@ -1685,6 +1685,10 @@ TRACE_DEFINE_ENUM(XCHK_DIRPATH_CORRUPT);TRACE_DEFINE_ENUM (XCHK_DIRPATH_LOOP );TRACE_DEFINE_ENUM (XCHK_DIRPATH_STALE );TRACE_DEFINE_ENUM (XCHK_DIRPATH_OK ); +TRACE_DEFINE_ENUM (XREP_DIRPATH_DELETING ); +TRACE_DEFINE_ENUM (XREP_DIRPATH_DELETED ); +TRACE_DEFINE_ENUM (XREP_DIRPATH_ADOPTING ); +TRACE_DEFINE_ENUM (XREP_DIRPATH_ADOPTED );#define XCHK_DIRPATH_OUTCOME_STRINGS \ { XCHK_DIRPATH_SCANNING, "scanning" }, \
@@ -1692,7 +1696,11 @@ TRACE_DEFINE_ENUM(XCHK_DIRPATH_OK); { XCHK_DIRPATH_CORRUPT, "corrupt" }, \ { XCHK_DIRPATH_LOOP, "loop" }, \ { XCHK_DIRPATH_STALE, "stale" }, \ - { XCHK_DIRPATH_OK, "ok" } + { XCHK_DIRPATH_OK, "ok" }, \ + { XREP_DIRPATH_DELETING, "deleting" }, \ + { XREP_DIRPATH_DELETED, "deleted" }, \ + { XREP_DIRPATH_ADOPTING, "adopting" }, \ + { XREP_DIRPATH_ADOPTED, "adopted" } DECLARE_EVENT_CLASS(xchk_dirpath_outcome_class, TP_PROTO(struct xfs_scrub *sc, unsigned long long path_nr,
@@ -1738,6 +1746,7 @@ DECLARE_EVENT_CLASS(xchk_dirtree_evaluate_class, __field(unsigned int, bad) __field(unsigned int, suspect) __field(unsigned int, good) + __field(bool, needs_adoption) ),TP_fast_assign ( __entry->dev = dl->sc->mp->m_super->s_dev;
@@ -1747,15 +1756,17 @@ DECLARE_EVENT_CLASS(xchk_dirtree_evaluate_class, __entry->bad = oc->bad; __entry->suspect = oc->suspect; __entry->good = oc->good; + __entry->needs_adoption = oc->needs_adoption ?1 :0 ; ), -TP_printk ("dev %d:%d ino 0x%llx rootino 0x%llx nr_paths %u bad %u suspect %u good %u" , +TP_printk ("dev %d:%d ino 0x%llx rootino 0x%llx nr_paths %u bad %u suspect %u good %u adopt? %d" ,MAJOR (__entry->dev),MINOR (__entry->dev), __entry->ino, __entry->rootino, __entry->nr_paths, __entry->bad, __entry->suspect, - __entry->good) + __entry->good, + __entry->needs_adoption) );#define DEFINE_XCHK_DIRTREE_EVALUATE_EVENT (name) \ DEFINE_EVENT(xchk_dirtree_evaluate_class, name, \
@@ -3181,6 +3192,7 @@ 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); TRACE_EVENT(xrep_symlink_salvage_target, TP_PROTO(struct xfs_inode *ip, char *target, unsigned int targetlen),
@@ -3483,6 +3495,11 @@ TRACE_EVENT(xrep_iunlink_commit_bucket, __entry->agino) ); +DEFINE_XCHK_DIRPATH_OUTCOME_EVENT (xrep_dirpath_set_outcome); +DEFINE_XCHK_DIRTREE_EVENT (xrep_dirtree_delete_path); +DEFINE_XCHK_DIRTREE_EVENT (xrep_dirtree_create_adoption); +DEFINE_XCHK_DIRTREE_EVALUATE_EVENT (xrep_dirtree_decided_fate); +#endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */ #endif /* _TRACE_XFS_SCRUB_TRACE_H */
fs/xfs/xfs_inode.c +1 -1
@@ -892,7 +892,7 @@ xfs_init_new_inode(* link count to go to zero, move the inode to AGI unlinked list so that it can * be freed when the last active reference goes away via xfs_inactive(). */ -static int /* error */ +int xfs_droplink (struct xfs_trans *tp,struct xfs_inode *ip)
fs/xfs/xfs_inode.h +1 -0
@@ -626,6 +626,7 @@ void xfs_end_io(struct work_struct *work);int xfs_ilock2_io_mmap (struct xfs_inode *ip1,struct xfs_inode *ip2);void xfs_iunlock2_io_mmap (struct xfs_inode *ip1,struct xfs_inode *ip2);void xfs_iunlock2_remapping (struct xfs_inode *ip1,struct xfs_inode *ip2); +int xfs_droplink (struct xfs_trans *tp,struct xfs_inode *ip);void xfs_bumplink (struct xfs_trans *tp,struct xfs_inode *ip);void xfs_lock_inodes (struct xfs_inode **ips,int inodes,uint lock_mode);void xfs_sort_inodes (struct xfs_inode **i_tab,unsigned int num_inodes);
PATCH 7/7 xfs: vectorize scrub kernel calls
In reply to Darrick J. WongHi all,
Create a vectorized version of the metadata scrub and repair ioctl, and adapt xfs_scrub to use that. This is an experiment to measure overhead and to try refactoring xfs_scrub.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=vectorized-scrub
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=vectorized-scrub
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=vectorized-scrub
---
Commits in this patchset:
* xfs: reduce the rate of cond_resched calls inside scrub
* xfs: move xfs_ioc_scrub_metadata to scrub.c
* xfs: introduce vectored scrub mode
* xfs: only iget the file once when doing vectored scrub-by-handle
--- fs/xfs/libxfs/xfs_fs.h | 33 +++++++ fs/xfs/scrub/common.h | 25 ----- fs/xfs/scrub/scrub.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/scrub.h | 64 +++++++++++++ fs/xfs/scrub/trace.h | 79 ++++++++++++++++ fs/xfs/scrub/xfarray.c | 10 +- fs/xfs/scrub/xfarray.h | 3 + fs/xfs/scrub/xfile.c | 2 fs/xfs/scrub/xfs_scrub.h | 6 + fs/xfs/xfs_ioctl.c | 26 ----- 10 files changed, 412 insertions(+), 59 deletions(-)
PATCH 1/4 xfs: reduce the rate of cond_resched calls inside scrub
From: Darrick J. Wong <[email protected]>
We really don't want to call cond_resched every single time we go through a loop in scrub -- there may be billions of records, and probing into the scheduler itself has overhead. Reduce this overhead by only calling cond_resched 10x per second; and add a counter so that we only check jiffies once every 1000 records or so.
Surprisingly, this reduces scrub-only fstests runtime by about 2%. I used the bmapinflate xfs_db command to produce a billion-extent file and this stupid gadget reduced the scrub runtime by about 4%.
From a stupid microbenchmark of calling these things 1 billion times, I estimate that cond_resched costs about 5.5ns per call; jiffes costs about 0.3ns per read; and fatal_signal_pending costs about 0.4ns per call.
--- fs/xfs/scrub/common.h | 25 ------------------- fs/xfs/scrub/scrub.c | 1 + fs/xfs/scrub/scrub.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/xfarray.c | 10 ++++---- fs/xfs/scrub/xfarray.h | 3 ++ fs/xfs/scrub/xfile.c | 2 +- 6 files changed, 74 insertions(+), 31 deletions(-)
fs/xfs/scrub/common.h +0 -25
@@ -6,31 +6,6 @@#ifndef __XFS_SCRUB_COMMON_H__#define __XFS_SCRUB_COMMON_H__ -/* -* We /could/ terminate a scrub/repair operation early. If we're not -* in a good place to continue (fatal signal, etc.) then bail out. -* Note that we're careful not to make any judgements about *error. -*/ -static inline bool -xchk_should_terminate ( -struct xfs_scrub *sc, -int *error) -{ -/* -* If preemption is disabled, we need to yield to the scheduler every -* few seconds so that we don't run afoul of the soft lockup watchdog -* or RCU stall detector. -*/ -cond_resched (); - -if (fatal_signal_pending (current)) { -if (*error ==0 ) - *error = -EINTR ; -return true; - } -return false; -} -int xchk_trans_alloc (struct xfs_scrub *sc,uint resblks);int xchk_trans_alloc_empty (struct xfs_scrub *sc);void xchk_trans_cancel (struct xfs_scrub *sc);
fs/xfs/scrub/scrub.c +1 -0
@@ -620,6 +620,7 @@ xfs_scrub_metadata( sc->sm = sm; sc->ops = &meta_scrub_ops[sm->sm_type]; sc->sick_mask =xchk_health_mask_for_scrub_type (sm->sm_type); + sc->relax =INIT_XCHK_RELAX ; retry_op:/* * When repairs are allowed, prevent freezing or readonly remount while
fs/xfs/scrub/scrub.h +64 -0
82 lines not on this page · raw message
fs/xfs/scrub/xfarray.c +5 -5
@@ -7,9 +7,9 @@#include "xfs_fs.h" #include "xfs_shared.h" #include "xfs_format.h" +#include "scrub/scrub.h" #include "scrub/xfile.h" #include "scrub/xfarray.h" -#include "scrub/scrub.h" #include "scrub/trace.h" /*
@@ -486,6 +486,9 @@ xfarray_sortinfo_alloc(xfarray_sortinfo_lo (si)[0 ] =0 ;xfarray_sortinfo_hi (si)[0 ] = array->nr -1 ; + si->relax =INIT_XCHK_RELAX ; +if (flags &XFARRAY_SORT_KILLABLE ) + si->relax.interruptible = false;trace_xfarray_sort (si, nr_bytes); *infop = si;
@@ -503,10 +506,7 @@ xfarray_sort_terminated(* few seconds so that we don't run afoul of the soft lockup watchdog * or RCU stall detector. */ -cond_resched (); - -if ((si->flags &XFARRAY_SORT_KILLABLE ) && -fatal_signal_pending (current)) { +if (xchk_maybe_relax (&si->relax)) {if (*error ==0 ) *error = -EINTR ;return true;
fs/xfs/scrub/xfarray.h +3 -0
@@ -127,6 +127,9 @@ struct xfarray_sortinfo {/* XFARRAY_SORT_* flags; see below. */ unsigned int flags; +/* next time we want to cond_resched() */ +struct xchk_relax relax; +/* Cache a folio here for faster scanning for pivots */ struct folio *folio;
fs/xfs/scrub/xfile.c +1 -1
@@ -10,9 +10,9 @@#include "xfs_log_format.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" +#include "scrub/scrub.h" #include "scrub/xfile.h" #include "scrub/xfarray.h" -#include "scrub/scrub.h" #include "scrub/trace.h" #include <linux/shmem_fs.h>
PATCH 2/4 xfs: move xfs_ioc_scrub_metadata to scrub.c
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move the scrub ioctl handler to scrub.c to keep the code together and to reduce unnecessary code when CONFIG_XFS_ONLINE_SCRUB=n.
--- fs/xfs/scrub/scrub.c | 27 ++++++++++++++++++++++++++- fs/xfs/scrub/xfs_scrub.h | 4 ++-- fs/xfs/xfs_ioctl.c | 24 ------------------------ 3 files changed, 28 insertions(+), 27 deletions(-)
fs/xfs/scrub/scrub.c +26 -1
@@ -578,7 +578,7 @@ xchk_scrub_create_subord( }/* Dispatch metadata scrubbing. */ -int +STATIC intxfs_scrub_metadata (struct file *file,struct xfs_scrub_metadata *sm)
@@ -724,3 +724,28 @@ xfs_scrub_metadata( run.retries++; goto retry_op; } + +/* Scrub one aspect of one piece of metadata. */ +int +xfs_ioc_scrub_metadata ( +struct file *file, +void __user *arg) +{ +struct xfs_scrub_metadata scrub; +int error; + +if (!capable (CAP_SYS_ADMIN )) +return -EPERM ; + +if (copy_from_user (&scrub, arg,sizeof (scrub))) +return -EFAULT ; + + error =xfs_scrub_metadata (file, &scrub); +if (error) +return error; + +if (copy_to_user (arg, &scrub,sizeof (scrub))) +return -EFAULT ; + +return 0 ; +}
fs/xfs/scrub/xfs_scrub.h +2 -2
@@ -7,9 +7,9 @@#define __XFS_SCRUB_H__#ifndef CONFIG_XFS_ONLINE_SCRUB -# define xfs_scrub_metadata (file, sm) (-ENOTTY) +# define xfs_ioc_scrub_metadata (f, a) (-ENOTTY)#else -int xfs_scrub_metadata (struct file *file,struct xfs_scrub_metadata *sm); +int xfs_ioc_scrub_metadata (struct file *file,void __user *arg);#endif /* CONFIG_XFS_ONLINE_SCRUB */ #endif /* __XFS_SCRUB_H__ */
fs/xfs/xfs_ioctl.c +0 -24
@@ -1055,30 +1055,6 @@ xfs_ioc_getfsmap(return error; } -STATIC int -xfs_ioc_scrub_metadata ( -struct file *file, -void __user *arg) -{ -struct xfs_scrub_metadata scrub; -int error; - -if (!capable (CAP_SYS_ADMIN )) -return -EPERM ; - -if (copy_from_user (&scrub, arg,sizeof (scrub))) -return -EFAULT ; - - error =xfs_scrub_metadata (file, &scrub); -if (error) -return error; - -if (copy_to_user (arg, &scrub,sizeof (scrub))) -return -EFAULT ; - -return 0 ; -} -int xfs_ioc_swapext (xfs_swapext_t *sxp)
Re: [PATCH 2/4] xfs: move xfs_ioc_scrub_metadata to scrub.c
Looks good:
PATCH 3/4 xfs: introduce vectored scrub mode
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Introduce a variant on XFS_SCRUB_METADATA that allows for a vectored mode. The caller specifies the principal metadata object that they want to scrub (allocation group, inode, etc.) once, followed by an array of scrub types they want called on that object. The kernel runs the scrub operations and writes the output flags and errno code to the corresponding array element.
A new pseudo scrub type BARRIER is introduced to force the kernel to return to userspace if any corruptions have been found when scrubbing the previous scrub types in the array. This enables userspace to schedule, for example, the sequence:
1. data fork
2. barrier
3. directory
If the data fork scrub is clean, then the kernel will perform the directory scrub. If not, the barrier in 2 will exit back to userspace.
When running fstests in "rebuild all metadata after each test" mode, I observed a 10% reduction in runtime due to fewer transitions across the system call boundary.
--- fs/xfs/libxfs/xfs_fs.h | 33 ++++++++++ fs/xfs/scrub/scrub.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/trace.h | 79 ++++++++++++++++++++++++ fs/xfs/scrub/xfs_scrub.h | 2 + fs/xfs/xfs_ioctl.c | 2 + 5 files changed, 264 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_fs.h +33 -0
@@ -725,6 +725,15 @@ struct xfs_scrub_metadata {/* Number of scrub subcommands. */ #define XFS_SCRUB_TYPE_NR 29 +/* +* This special type code only applies to the vectored scrub implementation. +* +* If any of the previous scrub vectors recorded runtime errors or have +* sv_flags bits set that match the OFLAG bits in the barrier vector's +* sv_flags, set the barrier's sv_ret to -ECANCELED and return to userspace. +*/ +#define XFS_SCRUB_TYPE_BARRIER (0xFFFFFFFF) +/* i: Repair this metadata. */ #define XFS_SCRUB_IFLAG_REPAIR (1u << 0)
@@ -769,6 +778,29 @@ struct xfs_scrub_metadata { XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED)#define XFS_SCRUB_FLAGS_ALL (XFS_SCRUB_FLAGS_IN | XFS_SCRUB_FLAGS_OUT) +/* Vectored scrub calls to reduce the number of kernel transitions. */ + +struct xfs_scrub_vec { +__u32 sv_type;/* XFS_SCRUB_TYPE_* */ +__u32 sv_flags;/* XFS_SCRUB_FLAGS_* */ +__s32 sv_ret;/* 0 or a negative error code */ +__u32 sv_reserved;/* must be zero */ +}; + +/* Vectored metadata scrub control structure. */ +struct xfs_scrub_vec_head { +__u64 svh_ino;/* inode number. */ +__u32 svh_gen;/* inode generation. */ +__u32 svh_agno;/* ag number. */ +__u32 svh_flags;/* XFS_SCRUB_VEC_FLAGS_* */ +__u16 svh_rest_us;/* wait this much time between vector items */ +__u16 svh_nr;/* number of svh_vectors */ +__u64 svh_reserved;/* must be zero */ +__u64 svh_vectors;/* pointer to buffer of xfs_scrub_vec */ +}; + +#define XFS_SCRUB_VEC_FLAGS_ALL (0) +/* * ioctl limits */
@@ -951,6 +983,7 @@ struct xfs_getparents_by_handle {#define XFS_IOC_AG_GEOMETRY _IOWR('X', 61, struct xfs_ag_geometry)#define XFS_IOC_GETPARENTS _IOWR('X', 62, struct xfs_getparents)#define XFS_IOC_GETPARENTS_BY_HANDLE _IOWR('X', 63, struct xfs_getparents_by_handle) +#define XFS_IOC_SCRUBV_METADATA _IOWR('X', 64, struct xfs_scrub_vec_head)/* * ioctl commands that replace IRIX syssgi()'s
fs/xfs/scrub/scrub.c +149 -0
158 lines not on this page · raw message
fs/xfs/scrub/trace.h +78 -1
97 lines not on this page · raw message
fs/xfs/scrub/xfs_scrub.h +2 -0
@@ -8,8 +8,10 @@#ifndef CONFIG_XFS_ONLINE_SCRUB # define xfs_ioc_scrub_metadata (f, a) (-ENOTTY) +# define xfs_ioc_scrubv_metadata (f, a) (-ENOTTY)#else int xfs_ioc_scrub_metadata (struct file *file,void __user *arg); +int xfs_ioc_scrubv_metadata (struct file *file,void __user *arg);#endif /* CONFIG_XFS_ONLINE_SCRUB */ #endif /* __XFS_SCRUB_H__ */
fs/xfs/xfs_ioctl.c +2 -0
@@ -1413,6 +1413,8 @@ xfs_file_ioctl(case FS_IOC_GETFSMAP :return xfs_ioc_getfsmap (ip, arg); +case XFS_IOC_SCRUBV_METADATA : +return xfs_ioc_scrubv_metadata (filp, arg);case XFS_IOC_SCRUB_METADATA :return xfs_ioc_scrub_metadata (filp, arg);
Re: [PATCH 3/4] xfs: introduce vectored scrub mode
Quoted 9 lines · Darrick J. Wong
A new pseudo scrub type BARRIER is introduced to force the kernel to return to userspace if any corruptions have been found when scrubbing the previous scrub types in the array. This enables userspace to schedule, for example, the sequence:
1. data fork
2. barrier
3. directory
Quoted 6 lines
If the data fork scrub is clean, then the kernel will perform the directory scrub. If not, the barrier in 2 will exit back to userspace.
When running fstests in "rebuild all metadata after each test" mode, I observed a 10% reduction in runtime due to fewer transitions across the system call boundary.
Can you record your explanation on why we don't encode the order in the kernel code here?
Otherwise looks good:
Re: [PATCH 3/4] xfs: introduce vectored scrub mode
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Darrick J. Wong
A new pseudo scrub type BARRIER is introduced to force the kernel to return to userspace if any corruptions have been found when scrubbing the previous scrub types in the array. This enables userspace to schedule, for example, the sequence:
1. data fork
2. barrier
3. directoryIf the data fork scrub is clean, then the kernel will perform the directory scrub. If not, the barrier in 2 will exit back to userspace.
Quoted 6 lines
Quoted 3 lines
When running fstests in "rebuild all metadata after each test" mode, I observed a 10% reduction in runtime due to fewer transitions across the system call boundary.
Can you record your explanation on why we don't encode the order in the kernel code here?
I have added the following to the commit message:
"A reviewer asked why didn't I design the interface so that the kernel determines what scrubbers to run and in what order, and then fills the output buffer with the results of whatever it decided to do.
"I thought about designing this interface that way, where userspace passes a pointer to an empty buffer, and the kernel formats that with xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome was. I didn't like that, because now the kernel has to have a way to communicate that the buffer needed to have been at least X size, even though for our cases XFS_SCRUB_TYPE_NR + 2 would always be enough.
"Better, I thought, to let userspace figure out what it wants to run, and tell that explicitly to the kernel. Then the kernel can just do that. The upside is that all that dependency policy and ordering logic can be in userspace instead of the kernel; the downside is that now we need the barriers."
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thanks!
--D
Re: [PATCH 3/4] xfs: introduce vectored scrub mode
Quoted 11 lines · Darrick J. Wong
"A reviewer asked why didn't I design the interface so that the kernel determines what scrubbers to run and in what order, and then fills the output buffer with the results of whatever it decided to do.
"I thought about designing this interface that way, where userspace passes a pointer to an empty buffer, and the kernel formats that with
xfs_scrub_vecsthat tell userspace what it scrubbed and what the outcome was. I didn't like that, because now the kernel has to have a way to communicate that the buffer needed to have been at least X size, even though for our casesXFS_SCRUB_TYPE_NR+ 2 would always be enough.
Quoted 5 lines
"Better, I thought, to let userspace figure out what it wants to run, and tell that explicitly to the kernel. Then the kernel can just do that. The upside is that all that dependency policy and ordering logic can be in userspace instead of the kernel; the downside is that now we need the barriers."
Maybe it's just personal preferences, but I find these a reviewer asked dialogs really odd. Here is how I would have written the above:
The alternative would have been an interface where userspace passes a pointer to an empty buffer, and the kernel formats that with xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome was. With that the kernel would have to communicate that the buffer needed to have been at least X size, even though for our cases XFS_SCRUB_TYPE_NR + 2 would always be enough.
Compared to that this design keeps all the dependency policy and ordering logic in userspace where it already resides instead of duplicating it in the kernel. The downside of that is tha it needs the barrier logic.
Re: [PATCH 3/4] xfs: introduce vectored scrub mode
Quoted 18 lines · Christoph Hellwig
Quoted 11 lines · Darrick J. Wong
"A reviewer asked why didn't I design the interface so that the kernel determines what scrubbers to run and in what order, and then fills the output buffer with the results of whatever it decided to do.
"I thought about designing this interface that way, where userspace passes a pointer to an empty buffer, and the kernel formats that with
xfs_scrub_vecsthat tell userspace what it scrubbed and what the outcome was. I didn't like that, because now the kernel has to have a way to communicate that the buffer needed to have been at least X size, even though for our casesXFS_SCRUB_TYPE_NR+ 2 would always be enough.Quoted 5 lines
"Better, I thought, to let userspace figure out what it wants to run, and tell that explicitly to the kernel. Then the kernel can just do that. The upside is that all that dependency policy and ordering logic can be in userspace instead of the kernel; the downside is that now we need the barriers."
Quoted 3 lines
Maybe it's just personal preferences, but I find these a reviewer asked dialogs really odd. Here is how I would have written the above:
I find it weird too. This is a defensive reaction on my part due to criticisms from patch reviewers earlier in this project over documenting paths not taken, aka "Why would you include this bit that doesn't correspond to anything in the patch?" :(
Quoted 11 lines
The alternative would have been an interface where userspace passes a pointer to an empty buffer, and the kernel formats that with
xfs_scrub_vecsthat tell userspace what it scrubbed and what the outcome was. With that the kernel would have to communicate that the buffer needed to have been at least X size, even though for our casesXFS_SCRUB_TYPE_NR+ 2 would always be enough.Compared to that this design keeps all the dependency policy and ordering logic in userspace where it already resides instead of duplicating it in the kernel. The downside of that is tha it needs the barrier logic.
That sounds better to me; I'll put that in the commit message instead. Thank you for that.
--D
PATCH 3/4 xfs: introduce vectored scrub mode
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Introduce a variant on XFS_SCRUB_METADATA that allows for a vectored mode. The caller specifies the principal metadata object that they want to scrub (allocation group, inode, etc.) once, followed by an array of scrub types they want called on that object. The kernel runs the scrub operations and writes the output flags and errno code to the corresponding array element.
A new pseudo scrub type BARRIER is introduced to force the kernel to return to userspace if any corruptions have been found when scrubbing the previous scrub types in the array. This enables userspace to schedule, for example, the sequence:
1. data fork
2. barrier
3. directory
If the data fork scrub is clean, then the kernel will perform the directory scrub. If not, the barrier in 2 will exit back to userspace.
The alternative would have been an interface where userspace passes a pointer to an empty buffer, and the kernel formats that with xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome was. With that the kernel would have to communicate that the buffer needed to have been at least X size, even though for our cases XFS_SCRUB_TYPE_NR + 2 would always be enough.
Compared to that, this design keeps all the dependency policy and ordering logic in userspace where it already resides instead of duplicating it in the kernel. The downside of that is that it needs the barrier logic.
When running fstests in "rebuild all metadata after each test" mode, I observed a 10% reduction in runtime due to fewer transitions across the system call boundary.
---
v13.2.1: improve commit message
--- fs/xfs/libxfs/xfs_fs.h | 33 ++++++++++ fs/xfs/scrub/scrub.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/trace.h | 79 ++++++++++++++++++++++++ fs/xfs/scrub/xfs_scrub.h | 2 + fs/xfs/xfs_ioctl.c | 2 + 5 files changed, 264 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_fs.h +33 -0
@@ -725,6 +725,15 @@ struct xfs_scrub_metadata {/* Number of scrub subcommands. */ #define XFS_SCRUB_TYPE_NR 29 +/* +* This special type code only applies to the vectored scrub implementation. +* +* If any of the previous scrub vectors recorded runtime errors or have +* sv_flags bits set that match the OFLAG bits in the barrier vector's +* sv_flags, set the barrier's sv_ret to -ECANCELED and return to userspace. +*/ +#define XFS_SCRUB_TYPE_BARRIER (0xFFFFFFFF) +/* i: Repair this metadata. */ #define XFS_SCRUB_IFLAG_REPAIR (1u << 0)
@@ -769,6 +778,29 @@ struct xfs_scrub_metadata { XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED)#define XFS_SCRUB_FLAGS_ALL (XFS_SCRUB_FLAGS_IN | XFS_SCRUB_FLAGS_OUT) +/* Vectored scrub calls to reduce the number of kernel transitions. */ + +struct xfs_scrub_vec { +__u32 sv_type;/* XFS_SCRUB_TYPE_* */ +__u32 sv_flags;/* XFS_SCRUB_FLAGS_* */ +__s32 sv_ret;/* 0 or a negative error code */ +__u32 sv_reserved;/* must be zero */ +}; + +/* Vectored metadata scrub control structure. */ +struct xfs_scrub_vec_head { +__u64 svh_ino;/* inode number. */ +__u32 svh_gen;/* inode generation. */ +__u32 svh_agno;/* ag number. */ +__u32 svh_flags;/* XFS_SCRUB_VEC_FLAGS_* */ +__u16 svh_rest_us;/* wait this much time between vector items */ +__u16 svh_nr;/* number of svh_vectors */ +__u64 svh_reserved;/* must be zero */ +__u64 svh_vectors;/* pointer to buffer of xfs_scrub_vec */ +}; + +#define XFS_SCRUB_VEC_FLAGS_ALL (0) +/* * ioctl limits */
@@ -951,6 +983,7 @@ struct xfs_getparents_by_handle {#define XFS_IOC_AG_GEOMETRY _IOWR('X', 61, struct xfs_ag_geometry)#define XFS_IOC_GETPARENTS _IOWR('X', 62, struct xfs_getparents)#define XFS_IOC_GETPARENTS_BY_HANDLE _IOWR('X', 63, struct xfs_getparents_by_handle) +#define XFS_IOC_SCRUBV_METADATA _IOWR('X', 64, struct xfs_scrub_vec_head)/* * ioctl commands that replace IRIX syssgi()'s
fs/xfs/scrub/scrub.c +149 -0
158 lines not on this page · raw message
fs/xfs/scrub/trace.h +78 -1
97 lines not on this page · raw message
fs/xfs/scrub/xfs_scrub.h +2 -0
@@ -8,8 +8,10 @@#ifndef CONFIG_XFS_ONLINE_SCRUB # define xfs_ioc_scrub_metadata (f, a) (-ENOTTY) +# define xfs_ioc_scrubv_metadata (f, a) (-ENOTTY)#else int xfs_ioc_scrub_metadata (struct file *file,void __user *arg); +int xfs_ioc_scrubv_metadata (struct file *file,void __user *arg);#endif /* CONFIG_XFS_ONLINE_SCRUB */ #endif /* __XFS_SCRUB_H__ */
fs/xfs/xfs_ioctl.c +2 -0
@@ -1413,6 +1413,8 @@ xfs_file_ioctl(case FS_IOC_GETFSMAP :return xfs_ioc_getfsmap (ip, arg); +case XFS_IOC_SCRUBV_METADATA : +return xfs_ioc_scrubv_metadata (filp, arg);case XFS_IOC_SCRUB_METADATA :return xfs_ioc_scrub_metadata (filp, arg);
PATCH 4/4 xfs: only iget the file once when doing vectored scrub-by-handle
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
If a program wants us to perform a scrub on a file handle and the fd passed to ioctl() is not the file referenced in the handle, iget the file once and pass it into the scrub code. This amortizes the untrusted iget lookup over /all/ the scrubbers mentioned in the scrubv call.
When running fstests in "rebuild all metadata after each test" mode, I observed a 10% reduction in runtime on account of avoiding repeated inobt lookups.
--- fs/xfs/scrub/scrub.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
fs/xfs/scrub/scrub.c +46 -0
@@ -792,6 +792,31 @@ xfs_scrubv_check_barrier(return 0 ; } +/* +* If the caller provided us with a nonzero inode number that isn't the ioctl +* file, try to grab a reference to it to eliminate all further untrusted inode +* lookups. If we can't get the inode, let each scrub function try again. +*/ +STATIC struct xfs_inode * +xchk_scrubv_open_by_handle ( +struct xfs_mount *mp, +const struct xfs_scrub_vec_head *head) +{ +struct xfs_inode *ip; +int error; + + error =xfs_iget (mp,NULL , head->svh_ino,XFS_IGET_UNTRUSTED ,0 , &ip); +if (error) +return NULL ; + +if (VFS_I (ip)->i_generation != head->svh_gen) { +xfs_irele (ip); +return NULL ; + } + +return ip; +} +/* Vectored scrub implementation to reduce ioctl calls. */ int xfs_ioc_scrubv_metadata(
@@ -804,6 +829,7 @@ xfs_ioc_scrubv_metadata(struct xfs_scrub_vec __user *uvectors;struct xfs_inode *ip_in =XFS_I (file_inode (file));struct xfs_mount *mp = ip_in->i_mount; +struct xfs_inode *handle_ip =NULL ;struct xfs_scrub_vec *v;size_t vec_bytes;unsigned int i;
@@ -848,6 +874,17 @@ xfs_ioc_scrubv_metadata(trace_xchk_scrubv_item (mp, &head, i, v); } +/* +* If the caller wants us to do a scrub-by-handle and the file used to +* call the ioctl is not the same file, load the incore inode and pin +* it across all the scrubv actions to avoid repeated UNTRUSTED +* lookups. The reference is not passed to deeper layers of scrub +* because each scrubber gets to decide its own strategy for getting an +* inode. +*/ +if (head.svh_ino && head.svh_ino != ip_in->i_ino) + handle_ip =xchk_scrubv_open_by_handle (mp, &head); +/* Run all the scrubbers. */ for (i =0 , v = vectors; i < head.svh_nr; i++, v++) {struct xfs_scrub_metadata sm = {
@@ -895,6 +932,15 @@ xfs_ioc_scrubv_metadata( } out_free: +/* +* If we're holding the only reference to an inode opened via handle, +* mark it dontcache so that we don't pollute the cache. +*/ +if (handle_ip) { +if (atomic_read (&VFS_I (handle_ip)->i_count) ==1 ) +d_mark_dontcache (VFS_I (handle_ip)); +xfs_irele (handle_ip); + }kfree (vectors);return error; }
Re: [PATCH 4/4] xfs: only iget the file once when doing vectored scrub-by-handle
fs/xfs/scrub/scrub.c xfs_ioc_scrubv_metadata( · line 942
Quoted 9 lines
out_free:fs/xfs/scrub/scrub.c +8
-0+/* +* If we're holding the only reference to an inode opened via handle, +* mark it dontcache so that we don't pollute the cache. +*/ +if (handle_ip) { +if (atomic_read (&VFS_I (handle_ip)->i_count) ==1 ) +d_mark_dontcache (VFS_I (handle_ip)); +xfs_irele (handle_ip);
This still feels the wrong way around vs just using IGET_UNCACHED?
Or did I miss the killer argument why that can't work?
Re: [PATCH 4/4] xfs: only iget the file once when doing vectored scrub-by-handle
Quoted 12 lines · Christoph Hellwig
fs/xfs/scrub/scrub.c xfs_ioc_scrubv_metadata( · line 942
Quoted 9 lines
out_free:fs/xfs/scrub/scrub.c +8
-0+/* +* If we're holding the only reference to an inode opened via handle, +* mark it dontcache so that we don't pollute the cache. +*/ +if (handle_ip) { +if (atomic_read (&VFS_I (handle_ip)->i_count) ==1 ) +d_mark_dontcache (VFS_I (handle_ip)); +xfs_irele (handle_ip);This still feels the wrong way around vs just using
IGET_UNCACHED?
Quoted 1 line
Or did I miss the killer argument why that can't work?
No, I missed the killer argument. In fact, I think the fsdax reorganization into d_mark_dontcache makes this counterproductive.
Initially, I had thought that we'd be doing users a favor by only marking inodes dontcache at the end of a scrub operation, and only if there's only one reference to that inode. This was more or less true back when I_DONTCACHE was an XFS iflag and the only thing it did was change the outcome of xfs_fs_drop_inode to 1. If there are dentries pointing to the inode when scrub finishes, the inode will have positive i_count and stay around in cache until dentry reclaim.
But now we have d_mark_dontcache, which cause the inode *and* the dentries attached to it all to be marked I_DONTCACHE, which means that we drop the dentries ASAP, which drops the inode ASAP.
This is bad if scrub found problems with the inode, because now they can be scheduled for inactivation, which can cause inodegc to trip on it and shut down the filesystem.
Even if the inode isn't bad, this is still suboptimal because phases 3-7 each initiate inode scans. Dropping the inode immediately during phase 3 is silly because phase 5 will reload it and drop it immediately, etc. It's fine to mark the inodes dontcache, but if there have been accesses to the file that set up dentries, we should keep them.
I validated this by setting up ftrace to capture xfs_iget_recycle* tracepoints and ran xfs/285 for 30 seconds. With current djwong-wtf I saw ~30,000 recycle events. I then dropped the d_mark_dontcache calls and set XFS_IGET_DONTCACHE, and the recycle events dropped to ~5,000 per 30 seconds.
So I think I want to change xchk_irele to clear I_DONTCACHE if we're in transaction context or if corruption was found; and to use XFS_IGET_DONTCACHE instead of the i_count-based d_mark_dontcache calls.
--D
Re: [PATCH 4/4] xfs: only iget the file once when doing vectored scrub-by-handle
Quoted 46 lines · Darrick J. Wong
Quoted 12 lines · Christoph Hellwig
fs/xfs/scrub/scrub.c xfs_ioc_scrubv_metadata( · line 942
Quoted 9 lines
out_free:fs/xfs/scrub/scrub.c +8
-0+/* +* If we're holding the only reference to an inode opened via handle, +* mark it dontcache so that we don't pollute the cache. +*/ +if (handle_ip) { +if (atomic_read (&VFS_I (handle_ip)->i_count) ==1 ) +d_mark_dontcache (VFS_I (handle_ip)); +xfs_irele (handle_ip);This still feels the wrong way around vs just using
IGET_UNCACHED?Quoted 1 line
Or did I miss the killer argument why that can't work?
No, I missed the killer argument. In fact, I think the fsdax reorganization into
d_mark_dontcachemakes this counterproductive.Initially, I had thought that we'd be doing users a favor by only marking inodes dontcache at the end of a scrub operation, and only if there's only one reference to that inode. This was more or less true back when
I_DONTCACHEwas an XFS iflag and the only thing it did was change the outcome ofxfs_fs_drop_inodeto 1. If there are dentries pointing to the inode when scrub finishes, the inode will have positivei_countand stay around in cache until dentry reclaim.But now we have
d_mark_dontcache, which cause the inode *and* the dentries attached to it all to be markedI_DONTCACHE, which means that we drop the dentries ASAP, which drops the inode ASAP.This is bad if scrub found problems with the inode, because now they can be scheduled for inactivation, which can cause inodegc to trip on it and shut down the filesystem.
Even if the inode isn't bad, this is still suboptimal because phases 3-7 each initiate inode scans. Dropping the inode immediately during phase 3 is silly because phase 5 will reload it and drop it immediately, etc. It's fine to mark the inodes dontcache, but if there have been accesses to the file that set up dentries, we should keep them.
I validated this by setting up ftrace to capture xfs_iget_recycle* tracepoints and ran xfs/285 for 30 seconds. With current djwong-wtf I saw ~30,000 recycle events. I then dropped the
d_mark_dontcachecalls and setXFS_IGET_DONTCACHE, and the recycle events dropped to ~5,000 per 30 seconds.
Quoted 3 lines
So I think I want to change
xchk_ireleto clearI_DONTCACHEif we're in transaction context or if corruption was found; and to useXFS_IGET_DONTCACHEinstead of the i_count-basedd_mark_dontcachecalls.
Actually we don't even need to clear DONTCACHE on sick inodes; commit 7975e465af6b4 ("xfs: drop IDONTCACHE on inodes when we mark them sick") already took care of that.
--D
Quoted 2 lines
--D
Re: [PATCH 4/4] xfs: only iget the file once when doing vectored scrub-by-handle
Quoted 3 lines · Darrick J. Wong
Actually we don't even need to clear DONTCACHE on sick inodes; commit
7975e465af6b4("xfs: drop IDONTCACHE on inodes when we mark them sick") already took care of that.
Even better.
Re: [PATCH 4/4] xfs: only iget the file once when doing vectored scrub-by-handle
In reply to Darrick J. WongQuoted 3 lines · Darrick J. Wong
So I think I want to change
xchk_ireleto clearI_DONTCACHEif we're in transaction context or if corruption was found; and to useXFS_IGET_DONTCACHEinstead of the i_count-basedd_mark_dontcachecalls.
Yes, that's what I thought.