Whamcloud - gitweb
LU-7727 mdt: fail FMODE_WRITE open if the client is read only
[fs/lustre-release.git] / lustre / lod / lproc_lod.c
index 08c5673..b02697f 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -47,7 +47,7 @@
  * called by Linux kernel's procfs.
  */
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
 
 /**
  * Show default stripe size.
@@ -83,7 +83,7 @@ static int lod_stripesize_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_stripesize_seq_write(struct file *file, const char *buffer,
+lod_stripesize_seq_write(struct file *file, const char __user *buffer,
                         size_t count, loff_t *off)
 {
        struct seq_file   *m = file->private_data;
@@ -139,7 +139,7 @@ static int lod_stripeoffset_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_stripeoffset_seq_write(struct file *file, const char *buffer,
+lod_stripeoffset_seq_write(struct file *file, const char __user *buffer,
                           size_t count, loff_t *off)
 {
        struct seq_file   *m = file->private_data;
@@ -191,7 +191,7 @@ static int lod_stripetype_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_stripetype_seq_write(struct file *file, const char *buffer,
+lod_stripetype_seq_write(struct file *file, const char __user *buffer,
                         size_t count, loff_t *off)
 {
        struct seq_file   *m = file->private_data;
@@ -244,7 +244,7 @@ static int lod_stripecount_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code otherwise
  */
 static ssize_t
-lod_stripecount_seq_write(struct file *file, const char *buffer,
+lod_stripecount_seq_write(struct file *file, const char __user *buffer,
                          size_t count, loff_t *off)
 {
        struct seq_file   *m = file->private_data;
@@ -427,7 +427,7 @@ static int lod_qos_thresholdrr_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_qos_thresholdrr_seq_write(struct file *file, const char *buffer,
+lod_qos_thresholdrr_seq_write(struct file *file, const char __user *buffer,
                              size_t count, loff_t *off)
 {
        struct seq_file   *m = file->private_data;
@@ -483,7 +483,7 @@ static int lod_qos_maxage_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_qos_maxage_seq_write(struct file *file, const char *buffer,
+lod_qos_maxage_seq_write(struct file *file, const char __user *buffer,
                         size_t count, loff_t *off)
 {
        struct seq_file         *m = file->private_data;
@@ -514,6 +514,9 @@ lod_qos_maxage_seq_write(struct file *file, const char *buffer,
        sprintf(str, "%smaxage=%d", PARAM_OSP, val);
        lustre_cfg_bufs_set_string(&bufs, 1, str);
        lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
+       if (lcfg == NULL)
+               return -ENOMEM;
+
        lod_getref(&lod->lod_ost_descs);
        lod_foreach_ost(lod, i) {
                next = &OST_TGT(lod,i)->ltd_ost->dd_lu_dev;
@@ -680,7 +683,7 @@ static int lod_lmv_failout_seq_show(struct seq_file *m, void *v)
  * \retval negative    error code if failed
  */
 static ssize_t
-lod_lmv_failout_seq_write(struct file *file, const char *buffer,
+lod_lmv_failout_seq_write(struct file *file, const char __user *buffer,
                          size_t count, loff_t *off)
 {
        struct seq_file         *m      = file->private_data;
@@ -705,7 +708,7 @@ lod_lmv_failout_seq_write(struct file *file, const char *buffer,
 }
 LPROC_SEQ_FOPS(lod_lmv_failout);
 
-static struct lprocfs_seq_vars lprocfs_lod_obd_vars[] = {
+static struct lprocfs_vars lprocfs_lod_obd_vars[] = {
        { .name =       "uuid",
          .fops =       &lod_uuid_fops          },
        { .name =       "stripesize",
@@ -730,17 +733,17 @@ static struct lprocfs_seq_vars lprocfs_lod_obd_vars[] = {
          .fops =       &lod_qos_maxage_fops    },
        { .name =       "lmv_failout",
          .fops =       &lod_lmv_failout_fops   },
-       { 0 }
+       { NULL }
 };
 
-static struct lprocfs_seq_vars lprocfs_lod_osd_vars[] = {
+static struct lprocfs_vars lprocfs_lod_osd_vars[] = {
        { "blocksize",          &lod_dt_blksize_fops            },
        { "kbytestotal",        &lod_dt_kbytestotal_fops        },
        { "kbytesfree",         &lod_dt_kbytesfree_fops         },
        { "kbytesavail",        &lod_dt_kbytesavail_fops        },
        { "filestotal",         &lod_dt_filestotal_fops         },
        { "filesfree",          &lod_dt_filesfree_fops          },
-       { 0 }
+       { NULL }
 };
 
 static const struct file_operations lod_proc_target_fops = {
@@ -774,8 +777,8 @@ int lod_procfs_init(struct lod_device *lod)
                RETURN(rc);
        }
 
-       rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars,
-                                 &lod->lod_dt_dev);
+       rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars,
+                             &lod->lod_dt_dev);
        if (rc) {
                CERROR("%s: cannot setup procfs entry: %d\n",
                       obd->obd_name, rc);
@@ -790,9 +793,9 @@ int lod_procfs_init(struct lod_device *lod)
                GOTO(out, rc);
        }
 
-       lod->lod_pool_proc_entry = lprocfs_seq_register("pools",
-                                                       obd->obd_proc_entry,
-                                                       NULL, NULL);
+       lod->lod_pool_proc_entry = lprocfs_register("pools",
+                                                   obd->obd_proc_entry,
+                                                   NULL, NULL);
        if (IS_ERR(lod->lod_pool_proc_entry)) {
                rc = PTR_ERR(lod->lod_pool_proc_entry);
                lod->lod_pool_proc_entry = NULL;
@@ -836,8 +839,10 @@ void lod_procfs_fini(struct lod_device *lod)
 {
        struct obd_device *obd = lod2obd(lod);
 
-       if (lod->lod_symlink != NULL)
+       if (lod->lod_symlink != NULL) {
                lprocfs_remove(&lod->lod_symlink);
+               lod->lod_symlink = NULL;
+       }
 
        if (lod->lod_pool_proc_entry != NULL) {
                lprocfs_remove(&lod->lod_pool_proc_entry);
@@ -847,5 +852,5 @@ void lod_procfs_fini(struct lod_device *lod)
        lprocfs_obd_cleanup(obd);
 }
 
-#endif /* LPROCFS */
+#endif /* CONFIG_PROC_FS */