From 43fe6e51804f8fb4cca4445be576233595e27b42 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. 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-on: https://review.whamcloud.com/c/fs/lustre-release/+/49514 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- 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 18c747d..bb57382 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1155,7 +1155,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