Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index 4565f9f..530b34e 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,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, Intel Corporation.
+ * Copyright (c) 2012, 2013, 2014 Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -35,7 +31,7 @@
  *
  * lustre/osp/lproc_osp.c
  *
- * Lustre OST Proxy Device, procfs functions
+ * Lustre OST Proxy Device (OSP), procfs functions
  *
  * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
  */
 
 #include "osp_internal.h"
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
+/**
+ * Show OSP active status
+ *
+ * \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_active_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -56,11 +60,22 @@ static int osp_active_seq_show(struct seq_file *m, void *data)
        return rc;
 }
 
+/**
+ * Activate/Deactivate OSP
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string, which is "1" or "0" to activate/deactivate OSP
+ * \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_active_seq_write(struct file *file, const char *buffer,
                        size_t count, loff_t *off)
 {
-       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+       struct seq_file   *m = file->private_data;
+       struct obd_device *dev = m->private;
        int                val, rc;
 
        rc = lprocfs_write_helper(buffer, count, &val);
@@ -82,6 +97,14 @@ osp_active_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_active);
 
+/**
+ * Show number of RPCs in flight
+ *
+ * \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_syn_in_flight_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -94,6 +117,14 @@ static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
 
+/**
+ * Show number of RPCs in processing (including uncommitted by OST)
+ *
+ * \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_syn_in_prog_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -106,6 +137,14 @@ static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
 
+/**
+ * Show number of changes to sync
+ *
+ * \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_syn_changes_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -116,8 +155,45 @@ static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
 
        return seq_printf(m, "%lu\n", osp->opd_syn_changes);
 }
-LPROC_SEQ_FOPS_RO(osp_syn_changes);
 
+/**
+ * Sync changes
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   unused because any input will do
+ * \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_syn_changes_seq_write(struct file *file, const char *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);
+       struct lu_env            env;
+       int                      rc;
+
+       rc = lu_env_init(&env, LCT_LOCAL);
+       if (rc != 0)
+               return rc;
+
+       rc = dt_sync(&env, &osp->opd_dt_dev);
+       lu_env_fini(&env);
+
+       return rc == 0 ? count : rc;
+}
+LPROC_SEQ_FOPS(osp_syn_changes);
+
+/**
+ * Show maximum number of RPCs in flight allowed
+ *
+ * \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_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -129,11 +205,22 @@ static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
 }
 
+/**
+ * Change maximum number of RPCs in flight allowed
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents maximum number
+ * \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_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
                                size_t count, loff_t *off)
 {
-       struct obd_device       *dev = ((struct seq_file *)file->private_data)->private;
+       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;
 
@@ -152,6 +239,14 @@ osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
 
+/**
+ * Show maximum number of RPCs in processing allowed
+ *
+ * \param[in] m                seq_file handle
+ * \param[in] data     unused
+ * \retval             0 on success
+ * \retval             negative number on error
+ */
 static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -163,11 +258,22 @@ static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
        return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
 }
 
+/**
+ * Change maximum number of RPCs in processing allowed
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents maximum number
+ * \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_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer,
                                size_t count, loff_t *off)
 {
-       struct obd_device       *dev = ((struct seq_file *)file->private_data)->private;
+       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;
 
@@ -187,6 +293,14 @@ osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_max_rpcs_in_prog);
 
+/**
+ * Show number of objects to precreate next time
+ *
+ * \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_create_count_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -198,11 +312,22 @@ static int osp_create_count_seq_show(struct seq_file *m, void *data)
        return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
 }
 
+/**
+ * Change number of objects to precreate next time
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents number of objects to precreate
+ * \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_create_count_seq_write(struct file *file, const char *buffer,
                                size_t count, loff_t *off)
 {
-       struct obd_device       *obd = ((struct seq_file *)file->private_data)->private;
+       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;
 
@@ -236,6 +361,14 @@ osp_create_count_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_create_count);
 
+/**
+ * Show maximum number of objects to precreate
+ *
+ * \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_create_count_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -247,11 +380,22 @@ static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
        return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
 }
 
+/**
+ * Change maximum number of objects to precreate
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents maximum number
+ * \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_max_create_count_seq_write(struct file *file, const char *buffer,
                                size_t count, loff_t *off)
 {
-       struct obd_device       *obd = ((struct seq_file *)file->private_data)->private;
+       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;
 
@@ -276,6 +420,14 @@ osp_max_create_count_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_max_create_count);
 
+/**
+ * Show last id to assign in creation
+ *
+ * \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_prealloc_next_id_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -288,6 +440,14 @@ static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
 
+/**
+ * Show last created id OST reported
+ *
+ * \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_prealloc_last_id_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -300,6 +460,14 @@ static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
 
+/**
+ * Show next FID sequence to precreate
+ *
+ * \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_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -312,6 +480,14 @@ static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
 
+/**
+ * Show last created FID sequence OST reported
+ *
+ * \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_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -325,6 +501,14 @@ static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
 
+/**
+ * Show the number of ids reserved by declare
+ *
+ * \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_prealloc_reserved_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
@@ -337,6 +521,14 @@ static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
 
+/**
+ * Show interval (in seconds) to update statfs data
+ *
+ * \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_maxage_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -348,11 +540,22 @@ static int osp_maxage_seq_show(struct seq_file *m, void *data)
        return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
 }
 
+/**
+ * Change interval to update statfs data
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents statfs interval (in seconds)
+ * \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_maxage_seq_write(struct file *file, const char *buffer,
                        size_t count, loff_t *off)
 {
-       struct obd_device       *dev = ((struct seq_file *)file->private_data)->private;
+       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;
 
@@ -372,6 +575,15 @@ osp_maxage_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(osp_maxage);
 
+/**
+ * Show current precreation status: output 0 means success, otherwise negative
+ * number is printed
+ *
+ * \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_pre_status_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -384,6 +596,21 @@ static int osp_pre_status_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_pre_status);
 
+/**
+ * Show the number of RPCs in processing (including uncommitted by OST) plus
+ * changes to sync, i.e. this is the total number of changes OST needs to apply
+ * and commit.
+ *
+ * This counter is used to determine if OST has space returned. A zero value
+ * indicates that OST storage space consumed by destroyed objects has been freed
+ * on disk, the associated llog records have been cleared, and no synchronous
+ * RPC are being processed.
+ *
+ * \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_destroys_in_flight_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *dev = m->private;
@@ -392,17 +619,19 @@ static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       /*
-        * This counter used to determine if OST has space returned.
-        * Now we need to wait for the following:
-        * - sync changes are zero - no llog records
-        * - sync in progress are zero - no RPCs in flight
-        */
        return seq_printf(m, "%lu\n",
-                       osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
+                         osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
 }
 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
 
+/**
+ * Show changes synced from previous mount
+ *
+ * \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_old_sync_processed_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
@@ -415,12 +644,69 @@ static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
 }
 LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
 
+/**
+ * Show maximum number of RPCs in flight
+ *
+ * \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_lfsck_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
+{
+       struct obd_device *dev = m->private;
+       __u32 max;
+
+       max = obd_get_max_rpcs_in_flight(&dev->u.cli);
+       return seq_printf(m, "%u\n", max);
+}
+
+/**
+ * Change maximum number of RPCs in flight
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string which represents maximum number of RPCs in flight
+ * \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_lfsck_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;
+       int val;
+       int rc;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc == 0)
+               rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
+
+       if (rc != 0)
+               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_RO_TYPE(osp, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
 
+/**
+ * Show maximum pages per bulk RPC
+ *
+ * \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)
 {
        return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
@@ -431,61 +717,100 @@ LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
 LPROC_SEQ_FOPS_RO_TYPE(osp, state);
 
-static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = {
-       { .name =       "uuid",
-         .fops =       &osp_uuid_fops                  },
-       { .name =       "ping",
-         .fops =       &osp_ping_fops,
+static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
+       { .name =       "uuid",
+         .fops =       &osp_uuid_fops                  },
+       { .name =       "ping",
+         .fops =       &osp_ping_fops,
+         .proc_mode =  0222                            },
+       { .name =       "connect_flags",
+         .fops =       &osp_connect_flags_fops         },
+       { .name =       "ost_server_uuid",
+         .fops =       &osp_server_uuid_fops           },
+       { .name =       "ost_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_prog_fops      },
+       { .name =       "create_count",
+         .fops =       &osp_create_count_fops          },
+       { .name =       "max_create_count",
+         .fops =       &osp_max_create_count_fops      },
+       { .name =       "prealloc_next_id",
+         .fops =       &osp_prealloc_next_id_fops      },
+       { .name =       "prealloc_next_seq",
+         .fops =       &osp_prealloc_next_seq_fops     },
+       { .name =       "prealloc_last_id",
+         .fops =       &osp_prealloc_last_id_fops      },
+       { .name =       "prealloc_last_seq",
+         .fops =       &osp_prealloc_last_seq_fops     },
+       { .name =       "prealloc_reserved",
+         .fops =       &osp_prealloc_reserved_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            },
+       { .name =       "sync_changes",
+         .fops =       &osp_syn_changes_fops           },
+       { .name =       "sync_in_flight",
+         .fops =       &osp_syn_in_flight_fops         },
+       { .name =       "sync_in_progress",
+         .fops =       &osp_syn_in_prog_fops           },
+       { .name =       "old_sync_processed",
+         .fops =       &osp_old_sync_processed_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 }
+};
+
+static struct lprocfs_vars lprocfs_osp_md_vars[] = {
+       { .name =       "uuid",
+         .fops =       &osp_uuid_fops                  },
+       { .name =       "ping",
+         .fops =       &osp_ping_fops,
          .proc_mode =  0222                            },
-       { .name =       "connect_flags",
-         .fops =       &osp_connect_flags_fops         },
-       { .name =       "ost_server_uuid",
-         .fops =       &osp_server_uuid_fops           },
-       { .name =       "ost_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_prog_fops      },
-       { .name =       "create_count",
-         .fops =       &osp_create_count_fops          },
-       { .name =       "max_create_count",
-         .fops =       &osp_max_create_count_fops      },
-       { .name =       "prealloc_next_id",
-         .fops =       &osp_prealloc_next_id_fops      },
-       { .name =       "prealloc_next_seq",
-         .fops =       &osp_prealloc_next_seq_fops     },
-       { .name =       "prealloc_last_id",
-         .fops =       &osp_prealloc_last_id_fops      },
-       { .name =       "prealloc_last_seq",
-         .fops =       &osp_prealloc_last_seq_fops     },
-       { .name =       "prealloc_reserved",
-         .fops =       &osp_prealloc_reserved_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            },
-       { .name =       "sync_changes",
-         .fops =       &osp_syn_changes_fops           },
-       { .name =       "sync_in_flight",
-         .fops =       &osp_syn_in_flight_fops         },
-       { .name =       "sync_in_progress",
-         .fops =       &osp_syn_in_prog_fops           },
-       { .name =       "old_sync_processed",
-         .fops =       &osp_old_sync_processed_fops    },
+       { .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_prog_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    },
-       { 0 }
+       { .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);
@@ -495,95 +820,74 @@ 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[] = {
-       { .name =       "blocksize",
-         .fops =       &osp_dt_blksize_fops            },
-       { .name =       "kbytestotal",
-         .fops =       &osp_dt_kbytestotal_fops        },
-       { .name =       "kbytesfree",
-         .fops =       &osp_dt_kbytesfree_fops         },
-       { .name =       "kbytesavail",
-         .fops =       &osp_dt_kbytesavail_fops        },
-       { .name =       "filestotal",
-         .fops =       &osp_dt_filestotal_fops         },
-       { .name =       "filesfree",
-         .fops =       &osp_dt_filesfree_fops          },
-       { 0 }
+static struct lprocfs_vars lprocfs_osp_osd_vars[] = {
+       { .name =       "blocksize",
+         .fops =       &osp_dt_blksize_fops            },
+       { .name =       "kbytestotal",
+         .fops =       &osp_dt_kbytestotal_fops        },
+       { .name =       "kbytesfree",
+         .fops =       &osp_dt_kbytesfree_fops         },
+       { .name =       "kbytesavail",
+         .fops =       &osp_dt_kbytesavail_fops        },
+       { .name =       "filestotal",
+         .fops =       &osp_dt_filestotal_fops         },
+       { .name =       "filesfree",
+         .fops =       &osp_dt_filesfree_fops          },
+       { NULL }
 };
 
+/**
+ * Initialize OSP lprocfs
+ *
+ * param[in] osp       OSP device
+ */
 void osp_lprocfs_init(struct osp_device *osp)
 {
        struct obd_device       *obd = osp->opd_obd;
-       struct proc_dir_entry   *osc_proc_dir;
+       struct proc_dir_entry   *osc_proc_dir = NULL;
+       struct obd_type         *type;
        int                      rc;
 
-       obd->obd_proc_entry = lprocfs_seq_register(obd->obd_name,
-                                              obd->obd_type->typ_procroot,
-                                              lprocfs_osp_osd_vars,
-                                              &osp->opd_dt_dev);
-       if (IS_ERR(obd->obd_proc_entry)) {
-               CERROR("%s: can't register in lprocfs: %ld\n",
-                      obd->obd_name, PTR_ERR(obd->obd_proc_entry));
-               obd->obd_proc_entry = NULL;
+       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) != 0)
                return;
-       }
 
-       rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd);
+       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: %ld\n",
-                      obd->obd_name, PTR_ERR(obd->obd_proc_entry));
+               CERROR("%s: can't register in lprocfs, rc %d\n",
+                      obd->obd_name, rc);
                return;
        }
-       obd->obd_vars = lprocfs_osp_obd_vars;
 
+       sptlrpc_lprocfs_cliobd_attach(obd);
        ptlrpc_lprocfs_register_obd(obd);
 
-       if (osp->opd_connect_mdt)
+       if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
+               return;
+
+       /* 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)
+               osc_proc_dir = type->typ_procroot;
+       else
+               osc_proc_dir = obd->obd_type->typ_procsym;
+
+       if (osc_proc_dir == NULL)
                return;
 
        /* for compatibility we link old procfs's OSC entries to osp ones */
-       osc_proc_dir = obd->obd_proc_private;
-       if (osc_proc_dir == NULL) {
-               cfs_proc_dir_entry_t    *symlink = NULL;
-               struct obd_type         *type;
-               char                    *name;
-
-               type = class_search_type(LUSTRE_OSC_NAME);
-               if (type == NULL) {
-                       osc_proc_dir = lprocfs_seq_register("osc",
-                                                       proc_lustre_root,
-                                                       NULL, NULL);
-                       if (IS_ERR(osc_proc_dir)) {
-                               CERROR("osp: can't create compat entry \"osc\": %d\n",
-                                       (int) PTR_ERR(osc_proc_dir));
-                       } else {
-                               obd->obd_proc_private = osc_proc_dir;
-                       }
-               } else {
-                       osc_proc_dir = type->typ_procroot;
-               }
-
-               OBD_ALLOC(name, strlen(obd->obd_name) + 1);
-               if (name == NULL)
-                       return;
-
-               strcpy(name, obd->obd_name);
-               if (strstr(name, "osc")) {
-                       symlink = lprocfs_add_symlink(name, osc_proc_dir,
-                                                       "../osp/%s",
-                                                       obd->obd_name);
-                       OBD_FREE(name, strlen(obd->obd_name) + 1);
-                       if (symlink == NULL) {
-                               CERROR("could not register OSC symlink for "
-                                       "/proc/fs/lustre/osp/%s.",
-                                       obd->obd_name);
-                               lprocfs_remove(&osc_proc_dir);
-                       } else {
-                               osp->opd_symlink = symlink;
-                       }
-               }
-       }
+       osp->opd_symlink = lprocfs_add_symlink(obd->obd_name, osc_proc_dir,
+                                              "../osp/%s", obd->obd_name);
+       if (osp->opd_symlink == NULL)
+               CERROR("cannot create OSC symlink for /proc/fs/lustre/osp/%s\n",
+                      obd->obd_name);
 }
 
-#endif /* LPROCFS */
+#endif /* CONFIG_PROC_FS */