Whamcloud - gitweb
LU-16873 osd: update OI_Scrub file with new magic 26/51226/2
authorAlexander Zarochentsev <alexander.zarochentsev@hpe.com>
Sun, 28 May 2023 12:42:27 +0000 (08:42 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 14 Jun 2023 21:41:49 +0000 (21:41 +0000)
The fix for LUS-11542 detects the format change correctly
but does not write new oi scrub file magic, so new mount
triggers the "oi files counter reset" again and again.

Fixes: 126275ba83 ("LU-16655 scrub: upgrade scrub_file from 2.12 format")
HPE-bug-id: LUS-11646
Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Change-Id: Ia13fcfaf0d8f2c4ee9331dd9fec0ff159d195186
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51226
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/scrub.c
lustre/osd-ldiskfs/osd_oi.c

index daf44e3..944f9e3 100644 (file)
@@ -127,6 +127,7 @@ EXPORT_SYMBOL(scrub_file_init);
 void scrub_file_reset(struct lustre_scrub *scrub, guid_t uuid, u64 flags)
 {
        struct scrub_file *sf = &scrub->os_file;
+       ENTRY;
 
        CDEBUG(D_LFSCK, "%s: reset OI scrub file, old flags = "
               "%#llx, add flags = %#llx\n",
@@ -150,6 +151,7 @@ void scrub_file_reset(struct lustre_scrub *scrub, guid_t uuid, u64 flags)
        sf->sf_items_igif = 0;
        if (!scrub->os_in_join)
                sf->sf_items_updated_prior = 0;
+       EXIT;
 }
 EXPORT_SYMBOL(scrub_file_reset);
 
index cc69fe2..1f001db 100644 (file)
@@ -316,7 +316,7 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
 
                if (rc == -ENOENT && create == false) {
                        if (oi_count == 0)
-                               return count;
+                               RETURN(count);
 
                        rc = 0;
                        ldiskfs_set_bit(i, sf->sf_oi_bitmap);
@@ -425,23 +425,20 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd,
                if (count == sf->sf_oi_count)
                        GOTO(out, rc = count);
 
-               if (sf->sf_oi_count == 0) {
-                       if (likely((count & (count - 1)) == 0))
-                               GOTO(out, rc = count);
-
-                       LCONSOLE_WARN(
-                                     "%s: invalid oi count %d, remove them, then set it to %d\n",
+               /* Trust the counted number of OI files if it is sane */
+               if ((count & (count - 1)) != 0) {
+                       LCONSOLE_WARN("%s: invalid oi count %d, remove them, then set it to %d\n",
                                      osd_dev2name(osd), count, osd_oi_count);
                        osd_oi_table_put(info, oi, count);
                        rc = osd_remove_ois(info, osd);
                        if (rc)
                                GOTO(out, rc);
 
-                       sf->sf_oi_count = osd_oi_count;
+                       count = osd_oi_count;
                }
 
                scrub_file_reset(scrub, osd->od_uuid, SF_RECREATED);
-               count = sf->sf_oi_count;
+               sf->sf_oi_count = count;
                goto create;
        }