Whamcloud - gitweb
LU-13811 client: don't panic for mgs evictions
[fs/lustre-release.git] / lustre / ptlrpc / nodemap_lproc.c
index 8167883..e6f109c 100644 (file)
@@ -118,7 +118,6 @@ static int nodemap_ranges_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap               *nodemap;
        struct lu_nid_range             *range;
-       struct interval_node_extent     ext;
        char                            start_nidstr[LNET_NIDSTR_SIZE];
        char                            end_nidstr[LNET_NIDSTR_SIZE];
        bool                            cont = false;
@@ -140,9 +139,8 @@ static int nodemap_ranges_show(struct seq_file *m, void *data)
                if (cont)
                        seq_printf(m, ",\n");
                cont = 1;
-               ext = range->rn_node.in_extent;
-               libcfs_nid2str_r(ext.start, start_nidstr, sizeof(start_nidstr));
-               libcfs_nid2str_r(ext.end, end_nidstr, sizeof(end_nidstr));
+               libcfs_nid2str_r(range->rn_start, start_nidstr, sizeof(start_nidstr));
+               libcfs_nid2str_r(range->rn_end, end_nidstr, sizeof(end_nidstr));
                seq_printf(m, " { id: %u, start_nid: %s, end_nid: %s }",
                           range->rn_id, start_nidstr, end_nidstr);
        }
@@ -286,7 +284,8 @@ nodemap_sepol_seq_write(struct file *file,
        char sepol[LUSTRE_NODEMAP_SEPOL_LENGTH + 1];
        int rc = 0;
 
-       CLASSERT(sizeof(sepol) == sizeof(((struct lu_nodemap *)0)->nm_sepol));
+       BUILD_BUG_ON(sizeof(sepol) !=
+                    sizeof(((struct lu_nodemap *)0)->nm_sepol));
 
        if (count > 0) {
                if (count >= sizeof(sepol))
@@ -636,6 +635,33 @@ static int nodemap_audit_mode_seq_show(struct seq_file *m, void *data)
        return 0;
 }
 
+/**
+ * Reads and prints the forbid_encryption flag for the given nodemap.
+ *
+ * \param      m               seq file in proc fs
+ * \param      data            unused
+ * \retval     0               success
+ */
+static int nodemap_forbid_encryption_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;
+       }
+
+       seq_printf(m, "%d\n", (int)nodemap->nmf_forbid_encryption);
+       nodemap_putref(nodemap);
+       return 0;
+}
+
 static struct lprocfs_vars lprocfs_nm_module_vars[] = {
        {
                .name           = "active",
@@ -654,26 +680,27 @@ LPROC_SEQ_FOPS_RO(nodemap_squash_gid);
 LPROC_SEQ_FOPS_RO(nodemap_deny_unknown);
 LPROC_SEQ_FOPS_RO(nodemap_map_mode);
 LPROC_SEQ_FOPS_RO(nodemap_audit_mode);
+LPROC_SEQ_FOPS_RO(nodemap_forbid_encryption);
 
-const struct file_operations nodemap_ranges_fops = {
-       .open                   = nodemap_ranges_open,
-       .read                   = seq_read,
-       .llseek                 = seq_lseek,
-       .release                = single_release
+static const struct proc_ops nodemap_ranges_fops = {
+       .proc_open              = nodemap_ranges_open,
+       .proc_read              = seq_read,
+       .proc_lseek             = seq_lseek,
+       .proc_release           = single_release
 };
 
-const struct file_operations nodemap_idmap_fops = {
-       .open                   = nodemap_idmap_open,
-       .read                   = seq_read,
-       .llseek                 = seq_lseek,
-       .release                = single_release
+static const struct proc_ops nodemap_idmap_fops = {
+       .proc_open              = nodemap_idmap_open,
+       .proc_read              = seq_read,
+       .proc_lseek             = seq_lseek,
+       .proc_release           = single_release
 };
 
-const struct file_operations nodemap_exports_fops = {
-       .open                   = nodemap_exports_open,
-       .read                   = seq_read,
-       .llseek                 = seq_lseek,
-       .release                = single_release
+static const struct proc_ops nodemap_exports_fops = {
+       .proc_open              = nodemap_exports_open,
+       .proc_read              = seq_read,
+       .proc_lseek             = seq_lseek,
+       .proc_release           = single_release
 };
 
 static struct lprocfs_vars lprocfs_nodemap_vars[] = {
@@ -702,6 +729,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = {
                .fops           = &nodemap_audit_mode_fops,
        },
        {
+               .name           = "forbid_encryption",
+               .fops           = &nodemap_forbid_encryption_fops,
+       },
+       {
                .name           = "squash_uid",
                .fops           = &nodemap_squash_uid_fops,
        },
@@ -772,6 +803,10 @@ static struct lprocfs_vars lprocfs_default_nodemap_vars[] = {
                .fops           = &nodemap_audit_mode_fops,
        },
        {
+               .name           = "forbid_encryption",
+               .fops           = &nodemap_forbid_encryption_fops,
+       },
+       {
                NULL
        }
 };