Whamcloud - gitweb
LU-13542 osd: brw stats are initialized too late 54/38554/6
authorAndrew Perepechko <andrew.perepechko@hpe.com>
Thu, 25 Nov 2021 17:28:01 +0000 (20:28 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 13 Dec 2021 03:52:44 +0000 (03:52 +0000)
Lustre crashes with the following stack trace:

 [<ffffffffc113cbac>] lprocfs_oh_tally+0x2c/0x40 [obdclass]
 [<ffffffffc169719b>] record_start_io.part.14+0x2b/0x40 [osd_zfs]
 [<ffffffffc1698322>] osd_read+0xa2/0x180 [osd_zfs]
 [<ffffffffc1167dee>] dt_record_read+0x1e/0x70 [obdclass]
 [<ffffffffc1190997>] lustre_index_restore+0x527/0x1720 [obdclass]
 [<ffffffffc16b2564>] osd_initial_OI_scrub+0xa34/0xd50 [osd_zfs]
 [<ffffffffc16b34fd>] osd_scrub_setup+0x9ed/0xb90 [osd_zfs]
 [<ffffffffc168a97b>] osd_mount+0xf4b/0x1380 [osd_zfs]

osd_procfs_init()/osd_stats_init() are called *after*
osd_initial_OI_scrub(), so osd stats are not yet initialized
when osd_read() first tries to update them.

This patch separates osd stats initialization from procfs
initialization so that osd stats should become initialized
by the time scrub starts its own initialization.

Change-Id: I15ab03e77eaab76e3dea8067b849c891e89aa9a8
Signed-off-by: Andrew Perepechko <andrew.perepechko@hpe.com>
HPE-bug-id: LUS-8173
Reviewed-on: https://review.whamcloud.com/38554
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/obdclass/lprocfs_status_server.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_handler.c

index 5c7ddb2..d622f8c 100644 (file)
@@ -416,6 +416,8 @@ struct brw_stats {
        struct brw_stats_props  bs_props[BRW_RW_STATS_NUM / 2];
 };
 
+void lprocfs_init_brw_stats(struct brw_stats *brw_stats);
+
 void ldebugfs_register_osd_stats(struct dentry *parent,
                                 struct brw_stats *brw_stats,
                                 struct lprocfs_stats *stats);
index 7a78959..a912ba6 100644 (file)
@@ -775,6 +775,15 @@ static ssize_t brw_stats_seq_write(struct file *file,
 
 LDEBUGFS_SEQ_FOPS(brw_stats);
 
+void lprocfs_init_brw_stats(struct brw_stats *brw_stats)
+{
+       int i;
+
+       for (i = 0; i < BRW_RW_STATS_NUM; i++)
+               spin_lock_init(&brw_stats->bs_hist[i].oh_lock);
+}
+EXPORT_SYMBOL(lprocfs_init_brw_stats);
+
 void ldebugfs_register_osd_stats(struct dentry *parent,
                                 struct brw_stats *brw_stats,
                                 struct lprocfs_stats *stats)
@@ -786,7 +795,6 @@ void ldebugfs_register_osd_stats(struct dentry *parent,
        for (i = 0; i < BRW_RW_STATS_NUM; i++) {
                struct brw_stats_props *props = brw_stats->bs_props;
 
-               spin_lock_init(&brw_stats->bs_hist[i].oh_lock);
                if (i % 2) {
                        props[i / 2].bsp_name = brw_props[i / 2].bsp_name;
                        props[i / 2].bsp_units = brw_props[i / 2].bsp_units;
index 756a0fc..c95ceb3 100644 (file)
@@ -8169,6 +8169,9 @@ static int osd_device_init0(const struct lu_env *env,
                restored = true;
 
        INIT_LIST_HEAD(&o->od_ios_list);
+
+       lprocfs_init_brw_stats(&o->od_brw_stats);
+
        /* setup scrub, including OI files initialization */
        o->od_in_init = 1;
        rc = osd_scrub_setup(env, o, restored);
index bd6d8df..9552fa9 100644 (file)
@@ -1191,6 +1191,8 @@ static int osd_mount(const struct lu_env *env,
        if (opts && strstr(opts, "resetoi"))
                resetoi = true;
 
+       lprocfs_init_brw_stats(&o->od_brw_stats);
+
        o->od_in_init = 1;
        rc = osd_scrub_setup(env, o, interval, resetoi);
        o->od_in_init = 0;