From: Darrick J. Wong Date: Mon, 6 May 2019 22:00:28 +0000 (-0400) Subject: xfs: cache unlinked pointers in an rhashtable X-Git-Tag: v5.1.0-rc0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9fa4408d4662613bd0b22fc608806ade9650da1;p=thirdparty%2Fxfsprogs-dev.git xfs: cache unlinked pointers in an rhashtable Source kernel commit: 9b2471797942a5947664818cfe2c6de93b43f37a Use a rhashtable to cache the unlinked list incore. This should speed up unlinked processing considerably when there are a lot of inodes on the unlinked list because iunlink_remove no longer has to traverse an entire bucket list to find which inode points to the one being removed. The incore list structure records "X.next_unlinked = Y" relations, with the rhashtable using Y to index the records. This makes finding the inode X that points to a inode Y very quick. If our cache fails to find anything we can always fall back on the old method. FWIW this drastically reduces the amount of time it takes to remove inodes from the unlinked list. I wrote a program to open a lot of O_TMPFILE files and then close them in the same order, which takes a very long time if we have to traverse the unlinked lists. With the ptach, I see: + /d/t/tmpfile/tmpfile Opened 193531 files in 6.33s. Closed 193531 files in 5.86s real 0m12.192s user 0m0.064s sys 0m11.619s + cd / + umount /mnt real 0m0.050s user 0m0.004s sys 0m0.030s And without the patch: + /d/t/tmpfile/tmpfile Opened 193588 files in 6.35s. Closed 193588 files in 751.61s real 12m38.853s user 0m0.084s sys 12m34.470s + cd / + umount /mnt real 0m0.086s user 0m0.000s sys 0m0.060s Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- diff --git a/io/inject.c b/io/inject.c index 2061c9577..cabfc3e36 100644 --- a/io/inject.c +++ b/io/inject.c @@ -53,6 +53,7 @@ error_tag(char *name) { XFS_ERRTAG_BUF_LRU_REF, "buf_lru_ref" }, { XFS_ERRTAG_FORCE_SCRUB_REPAIR, "force_repair" }, { XFS_ERRTAG_FORCE_SUMMARY_RECALC, "bad_summary" }, + { XFS_ERRTAG_IUNLINK_FALLBACK, "iunlink_fallback" }, { XFS_ERRTAG_MAX, NULL } }; int count; diff --git a/libxfs/xfs_errortag.h b/libxfs/xfs_errortag.h index 66077a105..79e6c4fb1 100644 --- a/libxfs/xfs_errortag.h +++ b/libxfs/xfs_errortag.h @@ -54,7 +54,8 @@ #define XFS_ERRTAG_BUF_LRU_REF 31 #define XFS_ERRTAG_FORCE_SCRUB_REPAIR 32 #define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33 -#define XFS_ERRTAG_MAX 34 +#define XFS_ERRTAG_IUNLINK_FALLBACK 34 +#define XFS_ERRTAG_MAX 35 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -93,5 +94,6 @@ #define XFS_RANDOM_BUF_LRU_REF 2 #define XFS_RANDOM_FORCE_SCRUB_REPAIR 1 #define XFS_RANDOM_FORCE_SUMMARY_RECALC 1 +#define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10) #endif /* __XFS_ERRORTAG_H_ */