Whamcloud - gitweb
LU-10629 lod: Clear OST pool with setstripe
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index 2dbcb73..03a03db 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, 2013, 2014 Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,7 +40,7 @@
 
 #include "osp_internal.h"
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
 /**
  * Show OSP active status
  *
 static int osp_active_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
-       int                      rc;
 
        LPROCFS_CLIMP_CHECK(dev);
-       rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
+       seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
        LPROCFS_CLIMP_EXIT(dev);
-       return rc;
+       return 0;
 }
 
 /**
@@ -71,18 +70,17 @@ static int osp_active_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_active_seq_write(struct file *file, const char *buffer,
+osp_active_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 *dev = m->private;
-       int                val, rc;
+       bool val;
+       int rc;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > 1)
-               return -ERANGE;
 
        LPROCFS_CLIMP_CHECK(dev);
        /* opposite senses */
@@ -105,7 +103,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,9 +111,10 @@ static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", 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)
@@ -125,7 +124,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);
@@ -133,9 +132,10 @@ static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", 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
@@ -145,7 +145,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);
@@ -153,7 +153,8 @@ static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%lu\n", osp->opd_syn_changes);
+       seq_printf(m, "%u\n", atomic_read(&osp->opd_sync_changes));
+       return 0;
 }
 
 /**
@@ -166,7 +167,8 @@ 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, const char *buffer,
+static ssize_t osp_sync_changes_seq_write(struct file *file,
+                                        const char __user *buffer,
                                         size_t count, loff_t *off)
 {
        struct seq_file         *m      = file->private_data;
@@ -184,7 +186,7 @@ static ssize_t osp_syn_changes_seq_write(struct file *file, const char *buffer,
 
        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
@@ -202,7 +204,8 @@ static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return 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;
 }
 
 /**
@@ -216,25 +219,26 @@ static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
+osp_max_rpcs_in_flight_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);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
+       int rc;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val == 0)
                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);
@@ -247,7 +251,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);
@@ -255,7 +259,8 @@ static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return 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;
 }
 
 /**
@@ -269,29 +274,30 @@ 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 *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;
-       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
+       int rc;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val == 0)
                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
@@ -309,7 +315,8 @@ static int osp_create_count_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
+       seq_printf(m, "%d\n", osp->opd_pre_create_count);
+       return 0;
 }
 
 /**
@@ -323,18 +330,19 @@ static int osp_create_count_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_create_count_seq_write(struct file *file, const char *buffer,
+osp_create_count_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 osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
-       int                      val, rc, i;
+       struct seq_file *m = file->private_data;
+       struct obd_device *obd = m->private;
+       struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       unsigned int val;
+       int rc, i;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -350,12 +358,12 @@ osp_create_count_seq_write(struct file *file, const char *buffer,
         * filesystem as a safety measure. */
        if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
                return -ERANGE;
-       if (val > osp->opd_pre_max_grow_count)
+       if (val > osp->opd_pre_max_create_count)
                return -ERANGE;
 
        for (i = 1; (i << 1) <= val; i <<= 1)
                ;
-       osp->opd_pre_grow_count = i;
+       osp->opd_pre_create_count = i;
 
        return count;
 }
@@ -377,7 +385,8 @@ static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
+       seq_printf(m, "%d\n", osp->opd_pre_max_create_count);
+       return 0;
 }
 
 /**
@@ -391,30 +400,31 @@ static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_max_create_count_seq_write(struct file *file, const char *buffer,
+osp_max_create_count_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 osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *obd = m->private;
+       struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       unsigned int val;
+       int rc;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0)
+       if (val < 0 || val > INT_MAX)
                return -ERANGE;
        if (val > OST_MAX_PRECREATE)
                return -ERANGE;
 
-       if (osp->opd_pre_grow_count > val)
-               osp->opd_pre_grow_count = val;
+       if (osp->opd_pre_create_count > val)
+               osp->opd_pre_create_count = val;
 
-       osp->opd_pre_max_grow_count = val;
+       osp->opd_pre_max_create_count = val;
 
        return count;
 }
@@ -432,11 +442,23 @@ static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       struct lu_fid *fid;
+       __u64 id;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
+       fid = &osp->opd_pre_used_fid;
+       if (fid_is_idif(fid)) {
+               id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
+               id++;
+       } else {
+               id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
+                       1 : fid_oid(fid) + 1;
+       }
+
+       seq_printf(m, "%llu\n", id);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
 
@@ -452,11 +474,18 @@ static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       struct lu_fid *fid;
+       __u64 id;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
+       fid = &osp->opd_pre_last_created_fid;
+       id = fid_is_idif(fid) ?
+                        fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
+                        fid_oid(fid);
 
-       return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
+       seq_printf(m, "%llu\n", id);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
 
@@ -472,11 +501,16 @@ static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       struct lu_fid *fid;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
+       fid = &osp->opd_pre_used_fid;
+       seq_printf(m, "%#llx\n", fid_is_idif(fid) ?
+                  fid_seq(fid) & (~0xffff) : fid_seq(fid));
+
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
 
@@ -492,12 +526,16 @@ static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       struct lu_fid *fid;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPX64"\n",
-                       fid_seq(&osp->opd_pre_last_created_fid));
+       fid = &osp->opd_pre_last_created_fid;
+       seq_printf(m, "%#llx\n", fid_is_idif(fid) ?
+                  fid_seq(fid) & (~0xffff) : fid_seq(fid));
+
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
 
@@ -517,7 +555,8 @@ static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
+       seq_printf(m, "%llu\n", osp->opd_pre_reserved);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
 
@@ -537,7 +576,8 @@ static int osp_maxage_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
+       seq_printf(m, "%lld\n", osp->opd_statfs_maxage);
+       return 0;
 }
 
 /**
@@ -551,22 +591,23 @@ static int osp_maxage_seq_show(struct seq_file *m, void *data)
  * \retval             negative number on error
  */
 static ssize_t
-osp_maxage_seq_write(struct file *file, const char *buffer,
+osp_maxage_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);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
+       int rc;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val == 0)
                return -ERANGE;
 
        osp->opd_statfs_maxage = val;
@@ -592,7 +633,8 @@ static int osp_pre_status_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_status);
+       seq_printf(m, "%d\n", osp->opd_pre_status);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_pre_status);
 
@@ -619,8 +661,10 @@ static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%lu\n",
-                         osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
+       seq_printf(m, "%u\n",
+                  atomic_read(&osp->opd_sync_rpcs_in_progress) +
+                  atomic_read(&osp->opd_sync_changes));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
 
@@ -640,7 +684,8 @@ static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return 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);
 
@@ -659,7 +704,8 @@ osp_lfsck_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        __u32 max;
 
        max = obd_get_max_rpcs_in_flight(&dev->u.cli);
-       return seq_printf(m, "%u\n", max);
+       seq_printf(m, "%u\n", max);
+       return 0;
 }
 
 /**
@@ -679,47 +725,170 @@ osp_lfsck_max_rpcs_in_flight_seq_write(struct file *file,
 {
        struct seq_file   *m = file->private_data;
        struct obd_device *dev = m->private;
-       int val;
+       unsigned int val;
        int rc;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc == 0)
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
+       if (!rc)
                rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
-
-       if (rc != 0)
+       else
                count = rc;
 
        return count;
 }
 LPROC_SEQ_FOPS(osp_lfsck_max_rpcs_in_flight);
 
-LPROC_SEQ_FOPS_WO_TYPE(osp, ping);
-LPROC_SEQ_FOPS_RO_TYPE(osp, uuid);
+LPROC_SEQ_FOPS_WR_ONLY(osp, ping);
 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;
+}
 
-static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = {
-       { .name =       "uuid",
-         .fops =       &osp_uuid_fops                  },
+/**
+ * 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 ssize_t
+lprocfs_force_sync_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 dt_device  *dt = lu2dt_dev(dev->obd_lu_dev);
+       struct lu_env      env;
+       int                rc;
+
+       rc = lu_env_init(&env, LCT_LOCAL);
+       if (rc)
+               return rc;
+       rc = dt_sync(&env, dt);
+       lu_env_fini(&env);
+
+       return rc == 0 ? count : rc;
+}
+LPROC_SEQ_FOPS_WR_ONLY(osp, force_sync);
+
+static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { .name =       "ping",
          .fops =       &osp_ping_fops,
          .proc_mode =  0222                            },
@@ -734,7 +903,7 @@ static struct lprocfs_seq_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",
@@ -760,20 +929,61 @@ static struct lprocfs_seq_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       },
+       { .name =       "force_sync",
+         .fops =       &osp_force_sync_fops    },
 
        /* for compatibility reasons */
        { .name =       "destroys_in_flight",
          .fops =       &osp_destroys_in_flight_fops            },
        { .name =       "lfsck_max_rpcs_in_flight",
          .fops =       &osp_lfsck_max_rpcs_in_flight_fops      },
-       { 0 }
+       { NULL }
+};
+
+static struct lprocfs_vars lprocfs_osp_md_vars[] = {
+       { .name =       "ping",
+         .fops =       &osp_ping_fops,
+         .proc_mode =  0222                            },
+       { .name =       "connect_flags",
+         .fops =       &osp_connect_flags_fops         },
+       { .name =       "mdt_server_uuid",
+         .fops =       &osp_server_uuid_fops           },
+       { .name =       "mdt_conn_uuid",
+         .fops =       &osp_conn_uuid_fops             },
+       { .name =       "active",
+         .fops =       &osp_active_fops                },
+       { .name =       "max_rpcs_in_flight",
+         .fops =       &osp_max_rpcs_in_flight_fops    },
+       { .name =       "max_rpcs_in_progress",
+         .fops =       &osp_max_rpcs_in_progress_fops  },
+       { .name =       "timeouts",
+         .fops =       &osp_timeouts_fops              },
+       { .name =       "import",
+         .fops =       &osp_import_fops                },
+       { .name =       "state",
+         .fops =       &osp_state_fops                 },
+       { .name =       "maxage",
+         .fops =       &osp_maxage_fops                },
+       { .name =       "prealloc_status",
+         .fops =       &osp_pre_status_fops            },
+
+       /* for compatibility reasons */
+       { .name =       "destroys_in_flight",
+         .fops =       &osp_destroys_in_flight_fops            },
+       { .name =       "lfsck_max_rpcs_in_flight",
+         .fops =       &osp_lfsck_max_rpcs_in_flight_fops      },
+       { NULL }
 };
 
 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize);
@@ -783,7 +993,7 @@ LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail);
 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal);
 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree);
 
-static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = {
+static struct lprocfs_vars lprocfs_osp_osd_vars[] = {
        { .name =       "blocksize",
          .fops =       &osp_dt_blksize_fops            },
        { .name =       "kbytestotal",
@@ -796,9 +1006,28 @@ static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = {
          .fops =       &osp_dt_filestotal_fops         },
        { .name =       "filesfree",
          .fops =       &osp_dt_filesfree_fops          },
-       { 0 }
+       { NULL }
 };
 
+void osp_lprocfs_fini(struct osp_device *osp)
+{
+       struct obd_device *obd = osp->opd_obd;
+       struct kobject *osc;
+
+       osc = kset_find_obj(lustre_kset, "osc");
+       if (osc) {
+               sysfs_remove_link(osc, obd->obd_name);
+               kobject_put(osc);
+       }
+
+       if (!IS_ERR_OR_NULL(osp->opd_debugfs))
+               ldebugfs_remove(&osp->opd_debugfs);
+
+       ptlrpc_lprocfs_unregister_obd(obd);
+       if (osp->opd_symlink)
+               lprocfs_remove(&osp->opd_symlink);
+}
+
 /**
  * Initialize OSP lprocfs
  *
@@ -806,23 +1035,28 @@ static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = {
  */
 void osp_lprocfs_init(struct osp_device *osp)
 {
-       struct obd_device       *obd = osp->opd_obd;
-       struct proc_dir_entry   *osc_proc_dir = NULL;
-       struct obd_type         *type;
-       int                      rc;
+       struct obd_device *obd = osp->opd_obd;
+       struct proc_dir_entry *osc_proc_dir = NULL;
+       struct obd_type *type;
+       struct kobject *osc;
+       int rc;
 
-       obd->obd_vars = lprocfs_osp_obd_vars;
-       if (lprocfs_obd_setup(obd) != 0)
+       if (osp->opd_connect_mdt)
+               obd->obd_vars = lprocfs_osp_md_vars;
+       else
+               obd->obd_vars = lprocfs_osp_obd_vars;
+       if (lprocfs_obd_setup(obd, true) != 0)
                return;
 
-       rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_osd_vars,
-                                 &osp->opd_dt_dev);
+       rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_osd_vars,
+                             &osp->opd_dt_dev);
        if (rc) {
                CERROR("%s: can't register in lprocfs, rc %d\n",
                       obd->obd_name, rc);
                return;
        }
 
+       sptlrpc_lprocfs_cliobd_attach(obd);
        ptlrpc_lprocfs_register_obd(obd);
 
        if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
@@ -830,6 +1064,23 @@ void osp_lprocfs_init(struct osp_device *osp)
 
        /* If the real OSC is present which is the case for setups
         * with both server and clients on the same node then use
+        * the OSC's proc root
+        */
+       osc = kset_find_obj(lustre_kset, "osc");
+       if (osc) {
+               rc = sysfs_create_link(osc, &obd->obd_kset.kobj,
+                                      obd->obd_name);
+               kobject_put(osc);
+       }
+
+       osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
+                                               "../osp/%s", obd->obd_name);
+       if (!osp->opd_debugfs)
+               CERROR("%s: failed to create OSC debugfs symlink\n",
+                      obd->obd_name);
+
+       /* If the real OSC is present which is the case for setups
+        * with both server and clients on the same node then use
         * the OSC's proc root */
        type = class_search_type(LUSTRE_OSC_NAME);
        if (type != NULL && type->typ_procroot != NULL)
@@ -844,9 +1095,9 @@ void osp_lprocfs_init(struct osp_device *osp)
        osp->opd_symlink = lprocfs_add_symlink(obd->obd_name, osc_proc_dir,
                                               "../osp/%s", obd->obd_name);
        if (osp->opd_symlink == NULL)
-               CERROR("could not register OSC symlink for "
-                      "/proc/fs/lustre/osp/%s.", obd->obd_name);
+               CERROR("cannot create OSC symlink for /proc/fs/lustre/osp/%s\n",
+                      obd->obd_name);
 }
 
-#endif /* LPROCFS */
+#endif /* CONFIG_PROC_FS */