Whamcloud - gitweb
LU-12025 osp: allow OS_STATE_* flags from OSTs
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
index 25ba0ba..71ee75a 100644 (file)
@@ -191,11 +191,7 @@ LPROC_SEQ_FOPS_RO(ofd_last_id);
  * this OST are slowed down.  It also reduces the contention on the OST
  * RAID device, allowing it to rebuild more quickly.
  *
- * \param[in] m                seq_file handle
- * \param[in] data     unused for single entry
- *
- * \retval             0 on success
- * \retval             negative value on error
+ * \retval             count of bytes written
  */
 static ssize_t degraded_show(struct kobject *kobj, struct attribute *attr,
                             char *buf)
@@ -214,10 +210,6 @@ static ssize_t degraded_show(struct kobject *kobj, struct attribute *attr,
  * the underlying RAID storage, so that they can mark an OST
  * as having degraded performance.
  *
- * \param[in] file     proc file
- * \param[in] buffer   string which represents mode
- *                     1: set degraded mode
- *                     0: unset degraded mode
  * \param[in] count    \a buffer length
  * \param[in] off      unused for single entry
  *
@@ -245,6 +237,57 @@ static ssize_t degraded_store(struct kobject *kobj, struct attribute *attr,
 LUSTRE_RW_ATTR(degraded);
 
 /**
+ * Show if the OFD is in no precreate mode.
+ *
+ * This means OFD has been adminstratively disabled at the OST to prevent
+ * the MDS from creating any new files on the OST, though existing files
+ * can still be read, written, and unlinked.
+ *
+ * \retval             number of bytes written
+ */
+static ssize_t no_precreate_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_no_precreate);
+}
+
+/**
+ * Set OFD to no precreate mode.
+ *
+ * This is used to interface to userspace administrative tools to
+ * disable new object creation on the OST.
+ *
+ * \param[in] count    \a buffer length
+ *
+ * \retval             \a count on success
+ * \retval             negative number on error
+ */
+static ssize_t no_precreate_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+       bool val;
+       int rc;
+
+       rc = kstrtobool(buffer, &val);
+       if (rc)
+               return rc;
+
+       spin_lock(&ofd->ofd_flags_lock);
+       ofd->ofd_no_precreate = val;
+       spin_unlock(&ofd->ofd_flags_lock);
+
+       return count;
+}
+LUSTRE_RW_ATTR(no_precreate);
+
+/**
  * Show OFD filesystem type.
  *
  * \param[in] m                seq_file handle
@@ -759,51 +802,33 @@ LUSTRE_RW_ATTR(writethrough_cache_enable);
 #endif
 
 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard);
+LUSTRE_RW_ATTR(recovery_time_hard);
+LUSTRE_RW_ATTR(recovery_time_soft);
+LUSTRE_RW_ATTR(ir_factor);
+
 LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
-LPROC_SEQ_FOPS_RO_TYPE(ofd, num_exports);
-LPROC_SEQ_FOPS_RO_TYPE(ofd, target_instance);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, ir_factor);
 LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, job_interval);
+LUSTRE_RW_ATTR(job_cleanup_interval);
+
+LUSTRE_RO_ATTR(tot_dirty);
+LUSTRE_RO_ATTR(tot_granted);
+LUSTRE_RO_ATTR(tot_pending);
+LUSTRE_RW_ATTR(grant_compat_disable);
+LUSTRE_RO_ATTR(instance);
 
-LPROC_SEQ_FOPS_RO(tgt_tot_dirty);
-LPROC_SEQ_FOPS_RO(tgt_tot_granted);
-LPROC_SEQ_FOPS_RO(tgt_tot_pending);
-LPROC_SEQ_FOPS(tgt_grant_compat_disable);
+LUSTRE_RO_ATTR(num_exports);
 
 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { .name =       "last_id",
          .fops =       &ofd_last_id_fops               },
-       { .name =       "tot_dirty",
-         .fops =       &tgt_tot_dirty_fops             },
-       { .name =       "tot_pending",
-         .fops =       &tgt_tot_pending_fops           },
-       { .name =       "tot_granted",
-         .fops =       &tgt_tot_granted_fops           },
        { .name =       "recovery_status",
          .fops =       &ofd_recovery_status_fops       },
-       { .name =       "recovery_time_soft",
-         .fops =       &ofd_recovery_time_soft_fops    },
-       { .name =       "recovery_time_hard",
-         .fops =       &ofd_recovery_time_hard_fops    },
        { .name =       "evict_client",
          .fops =       &ofd_evict_client_fops          },
-       { .name =       "num_exports",
-         .fops =       &ofd_num_exports_fops           },
        { .name =       "brw_size",
          .fops =       &ofd_brw_size_fops              },
-       { .name =       "instance",
-         .fops =       &ofd_target_instance_fops       },
-       { .name =       "ir_factor",
-         .fops =       &ofd_ir_factor_fops             },
        { .name =       "checksum_dump",
          .fops =       &ofd_checksum_dump_fops         },
-       { .name =       "grant_compat_disable",
-         .fops =       &tgt_grant_compat_disable_fops  },
-       { .name =       "job_cleanup_interval",
-         .fops =       &ofd_job_interval_fops          },
        { .name =       "lfsck_layout",
          .fops =       &ofd_lfsck_layout_fops          },
        { .name =       "lfsck_verify_pfid",
@@ -851,14 +876,25 @@ void ofd_stats_counter_init(struct lprocfs_stats *stats)
 LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
 
 static struct attribute *ofd_attrs[] = {
+       &lustre_attr_tot_dirty.attr,
+       &lustre_attr_tot_granted.attr,
+       &lustre_attr_tot_pending.attr,
+       &lustre_attr_grant_compat_disable.attr,
+       &lustre_attr_instance.attr,
+       &lustre_attr_recovery_time_hard.attr,
+       &lustre_attr_recovery_time_soft.attr,
+       &lustre_attr_ir_factor.attr,
+       &lustre_attr_num_exports.attr,
        &lustre_attr_seqs_allocated.attr,
        &lustre_attr_grant_precreate.attr,
        &lustre_attr_precreate_batch.attr,
        &lustre_attr_degraded.attr,
        &lustre_attr_fstype.attr,
+       &lustre_attr_no_precreate.attr,
        &lustre_attr_sync_journal.attr,
        &lustre_attr_soft_sync_limit.attr,
        &lustre_attr_lfsck_speed_limit.attr,
+       &lustre_attr_job_cleanup_interval.attr,
        &lustre_attr_checksum_t10pi_enforce.attr,
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
        &lustre_attr_read_cache_enable.attr,