Whamcloud - gitweb
LU-7638 recovery: do not abort update recovery.
[fs/lustre-release.git] / lustre / mdt / mdt_lproc.c
index 8cdae12..9f6ca37 100644 (file)
@@ -409,117 +409,84 @@ out:
 }
 LPROC_SEQ_FOPS_WO_TYPE(mdt, identity_info);
 
-/* for debug only */
-static int mdt_capa_seq_show(struct seq_file *m, void *data)
+static int mdt_site_stats_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
-       return seq_printf(m, "capability on: %s %s\n",
-                         mdt->mdt_lut.lut_oss_capa ? "oss" : "",
-                         mdt->mdt_lut.lut_mds_capa ? "mds" : "");
+       return lu_site_stats_seq_print(mdt_lu_site(mdt), m);
 }
+LPROC_SEQ_FOPS_RO(mdt_site_stats);
+
+#define BUFLEN (UUID_MAX + 4)
 
 static ssize_t
-mdt_capa_seq_write(struct file *file, const char __user *buffer,
-                  size_t count, loff_t *off)
+lprocfs_mds_evict_client_seq_write(struct file *file, const char __user *buf,
+                                  size_t count, loff_t *off)
 {
-       struct seq_file   *m = file->private_data;
+       struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       int val, rc;
+       char *kbuf;
+       char *tmpbuf;
+       int rc = 0;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc)
-               return rc;
+       OBD_ALLOC(kbuf, BUFLEN);
+       if (kbuf == NULL)
+               return -ENOMEM;
 
-       if (val < 0 || val > 3) {
-               CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
-                      " 0:  disable fid capability\n"
-                      " 2:  enable MDS fid capability\n"
-                      " 3:  enable both MDS and OSS fid capability\n");
-               return -EINVAL;
-       }
+       /*
+        * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
+        * bytes into kbuf, to ensure that the string is NUL-terminated.
+        * UUID_MAX should include a trailing NUL already.
+        */
+       if (copy_from_user(kbuf, buf, min_t(unsigned long, BUFLEN - 1, count)))
+               GOTO(out, rc = -EFAULT);
+       tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
 
-       /* OSS fid capability needs enable both MDS and OSS fid capability on
-        * MDS */
-       if (val == 1) {
-               CERROR("can't enable OSS fid capability only, you should use "
-                      "'3' to enable both MDS and OSS fid capability.\n");
-               return -EINVAL;
+       if (strncmp(tmpbuf, "nid:", 4) != 0) {
+               count = lprocfs_evict_client_seq_write(file, buf, count, off);
+               goto out;
        }
 
-       spin_lock(&mdt->mdt_lut.lut_flags_lock);
-       mdt->mdt_lut.lut_oss_capa = !!(val & 0x1);
-       mdt->mdt_lut.lut_mds_capa = !!(val & 0x2);
-       spin_unlock(&mdt->mdt_lut.lut_flags_lock);
-       mdt->mdt_capa_conf = 1;
-       LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
-                     mdt_obd_name(mdt),
-                     mdt->mdt_lut.lut_mds_capa ? "enabled" : "disabled");
-       LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
-                     mdt_obd_name(mdt),
-                     mdt->mdt_lut.lut_oss_capa ? "enabled" : "disabled");
-       return count;
-}
-LPROC_SEQ_FOPS(mdt_capa);
-
-static int mdt_capa_count_seq_show(struct seq_file *m, void *data)
-{
-       return seq_printf(m, "%d %d\n", capa_count[CAPA_SITE_CLIENT],
-                         capa_count[CAPA_SITE_SERVER]);
-}
-LPROC_SEQ_FOPS_RO(mdt_capa_count);
-
-static int mdt_site_stats_seq_show(struct seq_file *m, void *data)
-{
-       struct obd_device *obd = m->private;
-       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       if (mdt->mdt_opts.mo_evict_tgt_nids) {
+               rc = obd_set_info_async(NULL, mdt->mdt_child_exp,
+                                       sizeof(KEY_EVICT_BY_NID),
+                                       KEY_EVICT_BY_NID,
+                                       strlen(tmpbuf + 4) + 1,
+                                       tmpbuf + 4, NULL);
+               if (rc)
+                       CERROR("Failed to evict nid %s from OSTs: rc %d\n",
+                              tmpbuf + 4, rc);
+       }
 
-       return lu_site_stats_seq_print(mdt_lu_site(mdt), m);
-}
-LPROC_SEQ_FOPS_RO(mdt_site_stats);
+       /* See the comments in function lprocfs_wr_evict_client()
+        * in ptlrpc/lproc_ptlrpc.c for details. - jay */
+       class_incref(obd, __func__, current);
+       obd_export_evict_by_nid(obd, tmpbuf + 4);
+       class_decref(obd, __func__, current);
 
-static int mdt_capa_timeout_seq_show(struct seq_file *m, void *data)
-{
-       struct obd_device *obd = m->private;
-       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
-       return seq_printf(m, "%lu\n", mdt->mdt_capa_timeout);
+out:
+       OBD_FREE(kbuf, BUFLEN);
+       return rc < 0 ? rc : count;
 }
 
-static ssize_t
-mdt_capa_timeout_seq_write(struct file *file, const char __user *buffer,
-                          size_t count, loff_t *off)
-{
-       struct seq_file   *m = file->private_data;
-       struct obd_device *obd = m->private;
-       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       int val, rc;
-
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc)
-               return rc;
-
-       mdt->mdt_capa_timeout = (unsigned long)val;
-       mdt->mdt_capa_conf = 1;
-       return count;
-}
-LPROC_SEQ_FOPS(mdt_capa_timeout);
+#undef BUFLEN
 
-static int mdt_ck_timeout_seq_show(struct seq_file *m, void *data)
+static int mdt_evict_tgt_nids_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
-       return seq_printf(m, "%lu\n", mdt->mdt_ck_timeout);
+       return seq_printf(m, "%u\n", mdt->mdt_opts.mo_evict_tgt_nids);
 }
 
 static ssize_t
-mdt_ck_timeout_seq_write(struct file *file, const char __user *buffer,
-                        size_t count, loff_t *off)
+mdt_evict_tgt_nids_seq_write(struct file *file, const char __user *buffer,
+                              size_t count, loff_t *off)
 {
-       struct seq_file   *m = file->private_data;
+       struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
        int val, rc;
@@ -527,53 +494,11 @@ mdt_ck_timeout_seq_write(struct file *file, const char __user *buffer,
        rc = lprocfs_write_helper(buffer, count, &val);
        if (rc)
                return rc;
-
-       mdt->mdt_ck_timeout = (unsigned long)val;
-       mdt->mdt_capa_conf = 1;
+       mdt->mdt_opts.mo_evict_tgt_nids = !!val;
        return count;
 }
-LPROC_SEQ_FOPS(mdt_ck_timeout);
+LPROC_SEQ_FOPS(mdt_evict_tgt_nids);
 
-#define BUFLEN (UUID_MAX + 4)
-
-static ssize_t
-lprocfs_mds_evict_client_seq_write(struct file *file,
-                                  const char __user *buffer,
-                                  size_t count, loff_t *off)
-{
-       char *kbuf;
-       char *tmpbuf;
-
-        OBD_ALLOC(kbuf, BUFLEN);
-        if (kbuf == NULL)
-                return -ENOMEM;
-
-        /*
-         * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
-         * bytes into kbuf, to ensure that the string is NUL-terminated.
-         * UUID_MAX should include a trailing NUL already.
-         */
-       if (copy_from_user(kbuf, buffer,
-                          min_t(unsigned long, BUFLEN - 1, count))) {
-                count = -EFAULT;
-                goto out;
-        }
-        tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
-
-        if (strncmp(tmpbuf, "nid:", 4) != 0) {
-               count = lprocfs_evict_client_seq_write(file, buffer, count,
-                                                      off);
-                goto out;
-        }
-
-        CERROR("NOT implement evict client by nid %s\n", tmpbuf);
-
-out:
-        OBD_FREE(kbuf, BUFLEN);
-        return count;
-}
-
-#undef BUFLEN
 
 static int mdt_sec_level_seq_show(struct seq_file *m, void *data)
 {
@@ -763,6 +688,9 @@ LPROC_SEQ_FOPS_RW_TYPE(mdt, ir_factor);
 LPROC_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear);
 LPROC_SEQ_FOPS(mdt_hsm_cdt_control);
 
+LPROC_SEQ_FOPS_RW_TYPE(mdt, recovery_time_hard);
+LPROC_SEQ_FOPS_RW_TYPE(mdt, recovery_time_soft);
+
 static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
        { .name =       "uuid",
          .fops =       &mdt_uuid_fops                          },
@@ -780,18 +708,12 @@ static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
          .fops =       &mdt_identity_flush_fops                },
        { .name =       "identity_info",
          .fops =       &mdt_identity_info_fops                 },
-       { .name =       "capa",
-         .fops =       &mdt_capa_fops                          },
-       { .name =       "capa_timeout",
-         .fops =       &mdt_capa_timeout_fops                  },
-       { .name =       "capa_key_timeout",
-         .fops =       &mdt_ck_timeout_fops                    },
-       { .name =       "capa_count",
-         .fops =       &mdt_capa_count_fops                    },
        { .name =       "site_stats",
          .fops =       &mdt_site_stats_fops                    },
        { .name =       "evict_client",
          .fops =       &mdt_mds_evict_client_fops              },
+       { .name =       "evict_tgt_nids",
+         .fops =       &mdt_evict_tgt_nids_fops                },
        { .name =       "hash_stats",
          .fops =       &mdt_hash_fops                          },
        { .name =       "sec_level",
@@ -814,11 +736,16 @@ static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
          .fops =       &mdt_enable_remote_dir_gid_fops         },
        { .name =       "hsm_control",
          .fops =       &mdt_hsm_cdt_control_fops               },
+       { .name =       "recovery_time_hard",
+         .fops =       &mdt_recovery_time_hard_fops    },
+       { .name =       "recovery_time_soft",
+         .fops =       &mdt_recovery_time_soft_fops    },
        { NULL }
 };
 
-static int lprocfs_mdt_print_open_files(cfs_hash_t *hs, cfs_hash_bd_t *bd,
-                                       struct hlist_node *hnode, void *v)
+static int
+lprocfs_mdt_print_open_files(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+                            struct hlist_node *hnode, void *v)
 {
        struct obd_export       *exp = cfs_hash_object(hs, hnode);
        struct seq_file         *seq = v;