From 6138b9e36dfa0a28c7fed9d8ad8890a174fe78d9 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Sun, 15 Dec 2024 08:28:12 +0300 Subject: [PATCH] LU-18558 scrub: don't release os_ls_fids too early a running iterator can use os_ls_fids (in osd_iit_iget()) even with the scrubber thread completed which should not release os_ls_fids too early. Test-Parameters: testlist=sanity-scrub,sanity-lfsck Test-Parameters: testlist=sanity-scrub,sanity-lfsck Test-Parameters: testlist=sanity-scrub,sanity-lfsck Signed-off-by: Alex Zhuravlev Change-Id: I3c5739f3b475f368235344716cd1b596e7f11bd8 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57434 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_scrub.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 0ff58e1..33ecf15 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -1279,17 +1279,7 @@ post: osd_scrub2name(scrub), scrub->os_pos_current, rc, scrub->os_file.sf_param & SP_DRYRUN ? " dryrun mode" : ""); - out: - if (scrub->os_ls_fids) { - OBD_FREE(scrub->os_ls_fids, - scrub->os_ls_size * sizeof(struct lu_fid)); - - scrub->os_ls_size = 0; - scrub->os_ls_count = 0; - scrub->os_ls_fids = NULL; - } - osd_scrub_ois_fini(scrub, &scrub->os_inconsistent_items); lu_env_fini(&env); @@ -1301,6 +1291,18 @@ noenv: /* scrub_stop() is waiting, we need to synchronize */ wait_var_event(scrub, kthread_should_stop()); wake_up_var(scrub); + + /* a running iterator can be using os_ls_fids, so let's release + * only when we're asked to stop by that iterator */ + if (scrub->os_ls_fids) { + OBD_FREE(scrub->os_ls_fids, + scrub->os_ls_size * sizeof(struct lu_fid)); + + scrub->os_ls_size = 0; + scrub->os_ls_count = 0; + scrub->os_ls_fids = NULL; + } + return rc; } -- 1.8.3.1