Whamcloud - gitweb
LU-7702 ldlm: skip lock if export failed
[fs/lustre-release.git] / lustre / ptlrpc / nodemap_lproc.c
index 0c8db40..fa6a6a7 100644 (file)
@@ -22,7 +22,7 @@
 /*
  * Copyright (C) 2013, Trustees of Indiana University
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014, 2015, Intel Corporation.
  *
  * Author: Joshua Walgenbach <jjw@iu.edu>
  */
 #include <interval_tree.h>
 #include "nodemap_internal.h"
 
-/* Turn on proc debug interface to allow OSS and
- * MDS nodes to configure nodemap independently of
- * MGS (since the nodemap distribution is not written
- * yet */
-#define NODEMAP_PROC_DEBUG 1
-
 static LIST_HEAD(nodemap_pde_list);
 
 /**
@@ -174,6 +168,61 @@ static int nodemap_ranges_open(struct inode *inode, struct file *file)
 }
 
 /**
+ * Reads and prints the fileset for the given nodemap.
+ *
+ * \param      m               seq file in proc fs
+ * \param      data            unused
+ * \retval     0               success
+ */
+static int nodemap_fileset_seq_show(struct seq_file *m, void *data)
+{
+       struct lu_nodemap *nodemap;
+       int rc;
+
+       mutex_lock(&active_config_lock);
+       nodemap = nodemap_lookup(m->private);
+       mutex_unlock(&active_config_lock);
+       if (IS_ERR(nodemap)) {
+               rc = PTR_ERR(nodemap);
+               CERROR("cannot find nodemap '%s': rc = %d\n",
+                       (char *)m->private, rc);
+               return rc;
+       }
+
+       rc = seq_printf(m, "%s\n", nodemap->nm_fileset);
+       nodemap_putref(nodemap);
+       return rc;
+}
+
+/**
+ * Set a fileset on a nodemap.
+ *
+ * \param[in] file      proc file
+ * \param[in] buffer    string, "<fileset>"
+ * \param[in] count     \a buffer length
+ * \param[in] off       unused
+ * \retval              \a count on success
+ * \retval              negative number on error
+ */
+static ssize_t
+nodemap_fileset_seq_write(struct file *file,
+                                     const char __user *buffer,
+                                     size_t count, loff_t *off)
+{
+       struct seq_file *m = file->private_data;
+       int rc = 0;
+
+       if (count > 0)
+               rc = nodemap_set_fileset(m->private, buffer);
+
+       if (rc != 0)
+               return -EINVAL;
+
+       return count;
+}
+LPROC_SEQ_FOPS(nodemap_fileset);
+
+/**
  * Reads and prints the exports attached to the given nodemap.
  *
  * \param      m               seq file in proc fs, stores nodemap
@@ -239,7 +288,8 @@ static int nodemap_exports_open(struct inode *inode, struct file *file)
  */
 static int nodemap_active_seq_show(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%u\n", (unsigned int)nodemap_active);
+       seq_printf(m, "%u\n", (unsigned int)nodemap_active);
+       return 0;
 }
 
 /**
@@ -290,21 +340,20 @@ LPROC_SEQ_FOPS(nodemap_active);
 static int nodemap_id_seq_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap *nodemap;
-       int rc;
 
        mutex_lock(&active_config_lock);
        nodemap = nodemap_lookup(m->private);
        mutex_unlock(&active_config_lock);
        if (IS_ERR(nodemap)) {
-               rc = PTR_ERR(nodemap);
+               int rc = PTR_ERR(nodemap);
                CERROR("cannot find nodemap '%s': rc = %d\n",
                        (char *)m->private, rc);
                return rc;
        }
 
-       rc = seq_printf(m, "%u\n", nodemap->nm_id);
+       seq_printf(m, "%u\n", nodemap->nm_id);
        nodemap_putref(nodemap);
-       return rc;
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(nodemap_id);
 
@@ -318,21 +367,20 @@ LPROC_SEQ_FOPS_RO(nodemap_id);
 static int nodemap_squash_uid_seq_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap *nodemap;
-       int rc;
 
        mutex_lock(&active_config_lock);
        nodemap = nodemap_lookup(m->private);
        mutex_unlock(&active_config_lock);
        if (IS_ERR(nodemap)) {
-               rc = PTR_ERR(nodemap);
+               int rc = PTR_ERR(nodemap);
                CERROR("cannot find nodemap '%s': rc = %d\n",
                        (char *)m->private, rc);
                return rc;
        }
 
-       rc = seq_printf(m, "%u\n", nodemap->nm_squash_uid);
+       seq_printf(m, "%u\n", nodemap->nm_squash_uid);
        nodemap_putref(nodemap);
-       return rc;
+       return 0;
 }
 
 /**
@@ -345,21 +393,20 @@ static int nodemap_squash_uid_seq_show(struct seq_file *m, void *data)
 static int nodemap_squash_gid_seq_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap *nodemap;
-       int rc;
 
        mutex_lock(&active_config_lock);
        nodemap = nodemap_lookup(m->private);
        mutex_unlock(&active_config_lock);
        if (IS_ERR(nodemap)) {
-               rc = PTR_ERR(nodemap);
+               int rc = PTR_ERR(nodemap);
                CERROR("cannot find nodemap '%s': rc = %d\n",
                        (char *)m->private, rc);
                return rc;
        }
 
-       rc = seq_printf(m, "%u\n", nodemap->nm_squash_gid);
+       seq_printf(m, "%u\n", nodemap->nm_squash_gid);
        nodemap_putref(nodemap);
-       return rc;
+       return 0;
 }
 
 /**
@@ -372,21 +419,21 @@ static int nodemap_squash_gid_seq_show(struct seq_file *m, void *data)
 static int nodemap_trusted_seq_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap *nodemap;
-       int rc;
 
        mutex_lock(&active_config_lock);
        nodemap = nodemap_lookup(m->private);
        mutex_unlock(&active_config_lock);
        if (IS_ERR(nodemap)) {
-               rc = PTR_ERR(nodemap);
+               int rc = PTR_ERR(nodemap);
+
                CERROR("cannot find nodemap '%s': rc = %d\n",
                        (char *)m->private, rc);
                return rc;
        }
 
-       rc = seq_printf(m, "%d\n", (int)nodemap->nmf_trust_client_ids);
+       seq_printf(m, "%d\n", (int)nodemap->nmf_trust_client_ids);
        nodemap_putref(nodemap);
-       return rc;
+       return 0;
 }
 
 /**
@@ -411,9 +458,9 @@ static int nodemap_admin_seq_show(struct seq_file *m, void *data)
                return rc;
        }
 
-       rc = seq_printf(m, "%d\n", (int)nodemap->nmf_allow_root_access);
+       seq_printf(m, "%d\n", (int)nodemap->nmf_allow_root_access);
        nodemap_putref(nodemap);
-       return rc;
+       return 0;
 }
 
 #ifdef NODEMAP_PROC_DEBUG
@@ -1067,6 +1114,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = {
                .fops           = &nodemap_ranges_fops,
        },
        {
+               .name           = "fileset",
+               .fops           = &nodemap_fileset_fops,
+       },
+       {
                .name           = "exports",
                .fops           = &nodemap_exports_fops,
        },