From 3e26db5487083dfc221425d52e0ec24970f27483 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Sat, 17 Dec 2022 08:06:16 -0500 Subject: [PATCH] LU-16380 osd-ldiskfs: race in OI mapping There is race in OI scrub thread and OI mapping entry insertion, which may add an inconsistent OI mapping entry, but not started OI scrub thread. This may lead to osd_fid_lookup() always returns -EINPROGRESS. To avoid such race, osd_fid_lookup() returns -EINPROGRESS only when OI mapping is inconsistent, and OI scrub thread is not running. Lustre-change: https://review.whamcloud.com/49514 Lustre-commit: 43fe6e51804f8fb4cca4445be576233595e27b42 Fixes: 558784caad ("LU-15643 osd-ldiskfs: don't trigger scrub on irreparable FIDs") Test-Parameters: mdscount=2 mdtcount=4 testlist=conf-sanity env=ONLY=108b,ONLY_REPEAT=50 Signed-off-by: Lai Siyao Change-Id: I05114b6a33940c210e9952f6e24f6c36fd7f76a2 Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49719 Tested-by: jenkins Tested-by: Maloo --- lustre/osd-ldiskfs/osd_handler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index ad6935c..17c777e 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1193,7 +1193,8 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, /* Search order: 2. OI scrub pending list. */ id = &info->oti_id; memset(id, 0, sizeof(struct osd_inode_id)); - if (fid_in_scrub_list(scrub, &scrub->os_inconsistent_items, fid)) + if (fid_in_scrub_list(scrub, &scrub->os_inconsistent_items, fid) && + scrub->os_running) RETURN(-EINPROGRESS); stale = fid_in_scrub_list(scrub, &scrub->os_stale_items, fid); -- 1.8.3.1