X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnodemap_lproc.c;h=fc13b004cd2945c01769322ca64da85d6f945dae;hb=3af10d510078ddf050fbda2ef80bdc6920d89f8d;hp=e5c4b0ca97cea41eead407416aefc41c7d3d7741;hpb=0754bc8f2623bea184111af216f7567608db35b6;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nodemap_lproc.c b/lustre/ptlrpc/nodemap_lproc.c index e5c4b0c..fc13b00 100644 --- a/lustre/ptlrpc/nodemap_lproc.c +++ b/lustre/ptlrpc/nodemap_lproc.c @@ -37,12 +37,6 @@ #include #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,79 @@ 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 = 0; + + 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, "%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, "" + * \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; + char *nm_fileset; + int rc = 0; + ENTRY; + + if (count == 0) + RETURN(0); + + if (count > PATH_MAX) + RETURN(-EINVAL); + + OBD_ALLOC(nm_fileset, count + 1); + /* OBD_ALLOC zero-fills the buffer */ + if (nm_fileset == NULL) + RETURN(-ENOMEM); + + if (copy_from_user(nm_fileset, buffer, count)) + GOTO(out, rc = -EFAULT); + + rc = nodemap_set_fileset(m->private, nm_fileset); + if (rc != 0) + GOTO(out, rc = -EINVAL); + + rc = count; +out: + OBD_FREE(nm_fileset, count + 1); + + return rc; +} +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 +306,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 +358,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 +385,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 +411,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 +437,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 +476,69 @@ 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; +} + +/** + * Reads and prints the mapping mode for the given nodemap. + * + * \param m seq file in proc fs + * \param data unused + * \retval 0 success + */ +static int nodemap_map_mode_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; + } + + if (nodemap->nmf_map_uid_only) + seq_printf(m, "uid_only\n"); + else if (nodemap->nmf_map_gid_only) + seq_printf(m, "gid_only\n"); + else + seq_printf(m, "both\n"); + + nodemap_putref(nodemap); + return 0; +} + +/** + * Reads and prints the deny_unknown flag for the given nodemap. + * + * \param m seq file in proc fs + * \param data unused + * \retval 0 success + */ +static int nodemap_deny_unknown_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_deny_unknown); + nodemap_putref(nodemap); + return 0; } #ifdef NODEMAP_PROC_DEBUG @@ -631,7 +756,7 @@ lprocfs_add_nodemap_seq_write(struct file *file, const char __user *buffer, return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, add_nodemap); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, add_nodemap); /** * Delete a nodemap. @@ -675,7 +800,7 @@ lprocfs_del_nodemap_seq_write(struct file *file, const char __user *buffer, return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, del_nodemap); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, del_nodemap); /** * Helper function to parse a NID string. @@ -772,7 +897,7 @@ lprocfs_add_nodemap_range_seq_write(struct file *file, out: return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, add_nodemap_range); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, add_nodemap_range); /** * Delete a NID range from nodemap. @@ -831,7 +956,7 @@ lprocfs_del_nodemap_range_seq_write(struct file *file, out: return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, del_nodemap_range); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, del_nodemap_range); /** * Add an idmap to nodemap. @@ -900,7 +1025,7 @@ lprocfs_add_nodemap_idmap_seq_write(struct file *file, out: return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, add_nodemap_idmap); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, add_nodemap_idmap); /** * Delete an idmap from nodemap. @@ -969,7 +1094,7 @@ lprocfs_del_nodemap_idmap_seq_write(struct file *file, out: return rc; } -LPROC_SEQ_FOPS_WO_TYPE(nodemap, del_nodemap_idmap); +LPROC_SEQ_FOPS_WR_ONLY(nodemap, del_nodemap_idmap); #endif /* NODEMAP_PROC_DEBUG */ static struct lprocfs_vars lprocfs_nm_module_vars[] = { @@ -1020,6 +1145,9 @@ LPROC_SEQ_FOPS_RO(nodemap_squash_uid); LPROC_SEQ_FOPS_RO(nodemap_squash_gid); #endif +LPROC_SEQ_FOPS_RO(nodemap_deny_unknown); +LPROC_SEQ_FOPS_RO(nodemap_map_mode); + const struct file_operations nodemap_ranges_fops = { .open = nodemap_ranges_open, .read = seq_read, @@ -1055,6 +1183,14 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = { .fops = &nodemap_admin_fops, }, { + .name = "deny_unknown", + .fops = &nodemap_deny_unknown_fops, + }, + { + .name = "map_mode", + .fops = &nodemap_map_mode_fops, + }, + { .name = "squash_uid", .fops = &nodemap_squash_uid_fops, }, @@ -1067,6 +1203,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = { .fops = &nodemap_ranges_fops, }, { + .name = "fileset", + .fops = &nodemap_fileset_fops, + }, + { .name = "exports", .fops = &nodemap_exports_fops, },