Whamcloud - gitweb
LU-9503 kernel: kernel update [SLES11 SP4 3.0.101-100]
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index b1d782d..4bd59f6 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -105,7 +105,7 @@ LPROC_SEQ_FOPS(osp_active);
  * \retval             0 on success
  * \retval             negative number on error
  */
-static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
+static int osp_sync_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
        struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
@@ -113,10 +113,10 @@ static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%u\n", atomic_read(&osp->opd_syn_rpc_in_flight));
+       seq_printf(m, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_flight));
        return 0;
 }
-LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
+LPROC_SEQ_FOPS_RO(osp_sync_rpcs_in_flight);
 
 /**
  * Show number of RPCs in processing (including uncommitted by OST)
@@ -126,7 +126,7 @@ LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
  * \retval             0 on success
  * \retval             negative number on error
  */
-static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
+static int osp_sync_rpcs_in_progress_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
        struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
@@ -134,10 +134,10 @@ static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%u\n", atomic_read(&osp->opd_syn_rpc_in_progress));
+       seq_printf(m, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_progress));
        return 0;
 }
-LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
+LPROC_SEQ_FOPS_RO(osp_sync_rpcs_in_progress);
 
 /**
  * Show number of changes to sync
@@ -147,7 +147,7 @@ LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
  * \retval             0 on success
  * \retval             negative number on error
  */
-static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
+static int osp_sync_changes_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
        struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
@@ -155,7 +155,7 @@ static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%u\n", atomic_read(&osp->opd_syn_changes));
+       seq_printf(m, "%u\n", atomic_read(&osp->opd_sync_changes));
        return 0;
 }
 
@@ -169,7 +169,7 @@ static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
  * \retval             \a count on success
  * \retval             negative number on error
  */
-static ssize_t osp_syn_changes_seq_write(struct file *file,
+static ssize_t osp_sync_changes_seq_write(struct file *file,
                                         const char __user *buffer,
                                         size_t count, loff_t *off)
 {
@@ -188,7 +188,7 @@ static ssize_t osp_syn_changes_seq_write(struct file *file,
 
        return rc == 0 ? count : rc;
 }
-LPROC_SEQ_FOPS(osp_syn_changes);
+LPROC_SEQ_FOPS(osp_sync_changes);
 
 /**
  * Show maximum number of RPCs in flight allowed
@@ -206,7 +206,7 @@ static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
+       seq_printf(m, "%u\n", osp->opd_sync_max_rpcs_in_flight);
        return 0;
 }
 
@@ -240,7 +240,7 @@ osp_max_rpcs_in_flight_seq_write(struct file *file, const char __user *buffer,
        if (val < 1 || val > INT_MAX)
                return -ERANGE;
 
-       osp->opd_syn_max_rpc_in_flight = val;
+       osp->opd_sync_max_rpcs_in_flight = val;
        return count;
 }
 LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
@@ -253,7 +253,7 @@ LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
  * \retval             0 on success
  * \retval             negative number on error
  */
-static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
+static int osp_max_rpcs_in_progress_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
        struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
@@ -261,7 +261,7 @@ static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
+       seq_printf(m, "%u\n", osp->opd_sync_max_rpcs_in_progress);
        return 0;
 }
 
@@ -276,8 +276,8 @@ static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_max_rpcs_in_prog_seq_write(struct file *file, const char __user *buffer,
-                               size_t count, loff_t *off)
+osp_max_rpcs_in_progress_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 *dev = m->private;
@@ -295,11 +295,11 @@ osp_max_rpcs_in_prog_seq_write(struct file *file, const char __user *buffer,
        if (val < 1 || val > INT_MAX)
                return -ERANGE;
 
-       osp->opd_syn_max_rpc_in_progress = val;
+       osp->opd_sync_max_rpcs_in_progress = val;
 
        return count;
 }
-LPROC_SEQ_FOPS(osp_max_rpcs_in_prog);
+LPROC_SEQ_FOPS(osp_max_rpcs_in_progress);
 
 /**
  * Show number of objects to precreate next time
@@ -640,8 +640,8 @@ static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
                return -EINVAL;
 
        seq_printf(m, "%u\n",
-                  atomic_read(&osp->opd_syn_rpc_in_progress) +
-                  atomic_read(&osp->opd_syn_changes));
+                  atomic_read(&osp->opd_sync_rpcs_in_progress) +
+                  atomic_read(&osp->opd_sync_changes));
        return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
@@ -662,7 +662,7 @@ static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       seq_printf(m, "%d\n", osp->opd_syn_prev_done);
+       seq_printf(m, "%d\n", osp->opd_sync_prev_done);
        return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
@@ -726,23 +726,130 @@ LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
 
+LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
+
+LPROC_SEQ_FOPS_RW_TYPE(osp, import);
+LPROC_SEQ_FOPS_RO_TYPE(osp, state);
+
 /**
- * Show maximum pages per bulk RPC
+ * Show high watermark (in megabytes). If available free space at OST is grater
+ * than high watermark and object allocation for OST is disabled, enable it.
  *
  * \param[in] m                seq_file handle
  * \param[in] data     unused for single entry
  * \retval             0 on success
  * \retval             negative number on error
  */
-static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
 {
-       return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
+       struct obd_device       *dev = m->private;
+       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
+
+       if (osp == NULL)
+               return -EINVAL;
+
+       seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
+       return 0;
 }
-LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc);
-LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
 
-LPROC_SEQ_FOPS_RW_TYPE(osp, import);
-LPROC_SEQ_FOPS_RO_TYPE(osp, state);
+/**
+ * Change high watermark
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents new value (in megabytes)
+ * \param[in] count    \a buffer length
+ * \param[in] off      unused for single entry
+ * \retval             \a count on success
+ * \retval             negative number on error
+ */
+static ssize_t
+osp_reserved_mb_high_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       *dev = m->private;
+       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
+       __s64                   val;
+       int                     rc;
+
+       if (osp == NULL)
+               return -EINVAL;
+
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
+       if (rc)
+               return rc;
+       val >>= 20;
+       if (val < 1)
+               return -ERANGE;
+
+       spin_lock(&osp->opd_pre_lock);
+       osp->opd_reserved_mb_high = val;
+       if (val <= osp->opd_reserved_mb_low)
+               osp->opd_reserved_mb_low = val - 1;
+       spin_unlock(&osp->opd_pre_lock);
+
+       return count;
+}
+LPROC_SEQ_FOPS(osp_reserved_mb_high);
+
+/**
+ * Show low watermark (in megabytes). If available free space at OST is less
+ * than low watermark, object allocation for OST is disabled.
+ *
+ * \param[in] m                seq_file handle
+ * \param[in] data     unused for single entry
+ * \retval             0 on success
+ * \retval             negative number on error
+ */
+static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
+{
+       struct obd_device       *dev = m->private;
+       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
+
+       if (osp == NULL)
+               return -EINVAL;
+
+       seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
+       return 0;
+}
+
+/**
+ * Change low watermark
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents new value (in megabytes)
+ * \param[in] count    \a buffer length
+ * \param[in] off      unused for single entry
+ * \retval             \a count on success
+ * \retval             negative number on error
+ */
+static ssize_t
+osp_reserved_mb_low_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       *dev = m->private;
+       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
+       __s64                   val;
+       int                     rc;
+
+       if (osp == NULL)
+               return -EINVAL;
+
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
+       if (rc)
+               return rc;
+       val >>= 20;
+
+       spin_lock(&osp->opd_pre_lock);
+       osp->opd_reserved_mb_low = val;
+       if (val >= osp->opd_reserved_mb_high)
+               osp->opd_reserved_mb_high = val + 1;
+       spin_unlock(&osp->opd_pre_lock);
+
+       return count;
+}
+LPROC_SEQ_FOPS(osp_reserved_mb_low);
 
 static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { .name =       "uuid",
@@ -761,7 +868,7 @@ static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { .name =       "max_rpcs_in_flight",
          .fops =       &osp_max_rpcs_in_flight_fops    },
        { .name =       "max_rpcs_in_progress",
-         .fops =       &osp_max_rpcs_in_prog_fops      },
+         .fops =       &osp_max_rpcs_in_progress_fops  },
        { .name =       "create_count",
          .fops =       &osp_create_count_fops          },
        { .name =       "max_create_count",
@@ -787,13 +894,17 @@ static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { .name =       "prealloc_status",
          .fops =       &osp_pre_status_fops            },
        { .name =       "sync_changes",
-         .fops =       &osp_syn_changes_fops           },
+         .fops =       &osp_sync_changes_fops          },
        { .name =       "sync_in_flight",
-         .fops =       &osp_syn_in_flight_fops         },
+         .fops =       &osp_sync_rpcs_in_flight_fops   },
        { .name =       "sync_in_progress",
-         .fops =       &osp_syn_in_prog_fops           },
+         .fops =       &osp_sync_rpcs_in_progress_fops },
        { .name =       "old_sync_processed",
          .fops =       &osp_old_sync_processed_fops    },
+       { .name =       "reserved_mb_high",
+         .fops =       &osp_reserved_mb_high_fops      },
+       { .name =       "reserved_mb_low",
+         .fops =       &osp_reserved_mb_low_fops       },
 
        /* for compatibility reasons */
        { .name =       "destroys_in_flight",
@@ -820,7 +931,7 @@ static struct lprocfs_vars lprocfs_osp_md_vars[] = {
        { .name =       "max_rpcs_in_flight",
          .fops =       &osp_max_rpcs_in_flight_fops    },
        { .name =       "max_rpcs_in_progress",
-         .fops =       &osp_max_rpcs_in_prog_fops      },
+         .fops =       &osp_max_rpcs_in_progress_fops  },
        { .name =       "timeouts",
          .fops =       &osp_timeouts_fops              },
        { .name =       "import",