/*
* Copyright (C) 2013, Trustees of Indiana University
*
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2017, Intel Corporation.
*
* Author: Joshua Walgenbach <jjw@iu.edu>
*/
{
int rc = 0;
- /* we allow fileset = "" which means clear fileset info */
- if (fileset == NULL || (fileset[0] != 0 && fileset[0] != '/'))
+ /* Allow 'fileset=clear' in addition to 'fileset=""' to clear fileset
+ * because either command 'lctl set_param -P *.*.fileset=""' or
+ * 'lctl nodemap_set_fileset --fileset ""' can only work correctly
+ * on MGS, while on other servers, both commands will invoke upcall
+ * "/usr/sbin/lctl set_param nodemap.default.fileset=" by function
+ * process_param2_config(), which will cause "no value" error and
+ * won't clear fileset.
+ * 'fileset=""' is still kept for compatibility reason.
+ */
+ if (fileset == NULL)
+ rc = -EINVAL;
+ else if (fileset[0] == '\0' || strcmp(fileset, "clear") == 0)
+ nodemap->nm_fileset[0] = '\0';
+ else if (fileset[0] != '/')
rc = -EINVAL;
else if (strlcpy(nodemap->nm_fileset, fileset,
sizeof(nodemap->nm_fileset)) >=
GOTO(out, rc = PTR_ERR(nodemap));
}
- rc = nodemap_set_fileset_helper(active_config, nodemap,
- fileset);
+ rc = nodemap_set_fileset_helper(active_config, nodemap, fileset);
mutex_unlock(&active_config_lock);
nodemap_putref(nodemap);
struct lu_nodemap *default_nodemap;
struct cfs_hash *hash = config->nmc_nodemap_hash;
int rc = 0;
+ ENTRY;
default_nodemap = config->nmc_default_nodemap;
nodemap->nmf_deny_unknown = 0;
nodemap->nmf_map_uid_only = 0;
nodemap->nmf_map_gid_only = 0;
+ nodemap->nmf_enable_audit = 1;
nodemap->nm_squash_uid = NODEMAP_NOBODY_UID;
nodemap->nm_squash_gid = NODEMAP_NOBODY_GID;
default_nodemap->nmf_map_uid_only;
nodemap->nmf_map_gid_only =
default_nodemap->nmf_map_gid_only;
+ nodemap->nmf_enable_audit =
+ default_nodemap->nmf_enable_audit;
nodemap->nm_squash_uid = default_nodemap->nm_squash_uid;
nodemap->nm_squash_gid = default_nodemap->nm_squash_gid;
nodemap->nm_fileset[0] = '\0';
}
- return nodemap;
+ RETURN(nodemap);
out:
CERROR("cannot add nodemap: '%s': rc = %d\n", name, rc);
- return ERR_PTR(rc);
+ RETURN(ERR_PTR(rc));
}
/**
EXPORT_SYMBOL(nodemap_can_setquota);
/**
+ * Set the nmf_enable_audit flag to true or false.
+ * \param name nodemap name
+ * \param audit_mode if true, allow audit
+ * \retval 0 on success
+ *
+ */
+int nodemap_set_audit_mode(const char *name, bool enable_audit)
+{
+ struct lu_nodemap *nodemap = NULL;
+ int rc = 0;
+
+ mutex_lock(&active_config_lock);
+ nodemap = nodemap_lookup(name);
+ mutex_unlock(&active_config_lock);
+ if (IS_ERR(nodemap))
+ GOTO(out, rc = PTR_ERR(nodemap));
+
+ nodemap->nmf_enable_audit = enable_audit;
+ rc = nodemap_idx_nodemap_update(nodemap);
+
+ nm_member_revoke_locks(nodemap);
+ nodemap_putref(nodemap);
+out:
+ return rc;
+}
+EXPORT_SYMBOL(nodemap_set_audit_mode);
+
+
+/**
* Add a nodemap
*
* \param name name of nodemap