Whamcloud - gitweb
LU-14119 osd: add mount option "resetoi"
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index bca22d1..cde52ff 100644 (file)
@@ -699,7 +699,7 @@ static int osd_ro(const struct lu_env *env, struct dt_device *d)
        RETURN(0);
 }
 
-static struct dt_device_operations osd_dt_ops = {
+static const struct dt_device_operations osd_dt_ops = {
        .dt_root_get            = osd_root_get,
        .dt_statfs              = osd_statfs,
        .dt_trans_create        = osd_trans_create,
@@ -1070,12 +1070,14 @@ osd_unlinked_drain(const struct lu_env *env, struct osd_device *osd)
 static int osd_mount(const struct lu_env *env,
                     struct osd_device *o, struct lustre_cfg *cfg)
 {
-       char                    *mntdev = lustre_cfg_string(cfg, 1);
-       char                    *str    = lustre_cfg_string(cfg, 2);
-       char                    *svname = lustre_cfg_string(cfg, 4);
+       char *mntdev = lustre_cfg_string(cfg, 1);
+       char *str = lustre_cfg_string(cfg, 2);
+       char *svname = lustre_cfg_string(cfg, 4);
        dnode_t *rootdn;
-       const char              *opts;
-       int                      rc;
+       const char *opts;
+       bool resetoi = false;
+       int rc;
+
        ENTRY;
 
        if (o->od_os != NULL)
@@ -1092,6 +1094,8 @@ static int osd_mount(const struct lu_env *env,
        if (rc >= sizeof(o->od_svname))
                RETURN(-E2BIG);
 
+       opts = lustre_cfg_string(cfg, 3);
+
        o->od_index_backup_stop = 0;
        o->od_index = -1; /* -1 means index is invalid */
        rc = server_name2index(o->od_svname, &o->od_index, NULL);
@@ -1162,8 +1166,11 @@ static int osd_mount(const struct lu_env *env,
        if (rc)
                GOTO(err, rc);
 
+       if (opts && strstr(opts, "resetoi"))
+               resetoi = true;
+
        o->od_in_init = 1;
-       rc = osd_scrub_setup(env, o);
+       rc = osd_scrub_setup(env, o, resetoi);
        o->od_in_init = 0;
        if (rc)
                GOTO(err, rc);
@@ -1206,7 +1213,6 @@ static int osd_mount(const struct lu_env *env,
 #endif
 
        /* parse mount option "noacl", and enable ACL by default */
-       opts = lustre_cfg_string(cfg, 3);
        if (opts == NULL || strstr(opts, "noacl") == NULL)
                o->od_posix_acl = 1;
 
@@ -1361,7 +1367,7 @@ static struct lu_device *osd_device_fini(const struct lu_env *env,
        int                rc;
        ENTRY;
 
-
+       osd_index_backup(env, o, false);
        if (o->od_os) {
                osd_objset_unregister_callbacks(o);
                if (!o->od_dt_dev.dd_rdonly) {
@@ -1581,7 +1587,7 @@ static int osd_fid_alloc(const struct lu_env *env, struct lu_device *d,
        return seq_client_alloc_fid(env, osd->od_cl_seq, fid);
 }
 
-struct lu_device_operations osd_lu_ops = {
+const struct lu_device_operations osd_lu_ops = {
        .ldo_object_alloc       = osd_object_alloc,
        .ldo_process_config     = osd_process_config,
        .ldo_recovery_complete  = osd_recovery_complete,
@@ -1597,7 +1603,7 @@ static void osd_type_stop(struct lu_device_type *t)
 {
 }
 
-static struct lu_device_type_operations osd_device_type_ops = {
+static const struct lu_device_type_operations osd_device_type_ops = {
        .ldto_init              = osd_type_init,
        .ldto_fini              = osd_type_fini,
 
@@ -1637,7 +1643,7 @@ static int __init osd_init(void)
        if (rc)
                return rc;
 
-       rc = class_register_type(&osd_obd_device_ops, NULL, true, NULL,
+       rc = class_register_type(&osd_obd_device_ops, NULL, true,
                                 LUSTRE_OSD_ZFS_NAME, &osd_device_type);
        if (rc)
                lu_kmem_fini(osd_caches);