}
EXPORT_SYMBOL(class_modify_config);
-int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
- struct lustre_cfg *lcfg, void *data)
-{
- struct lprocfs_vars *var;
- struct file fakefile;
- struct seq_file fake_seqfile;
- char *key, *sval;
- int i, keylen, vallen;
- int matched = 0, j = 0;
- int rc = 0;
- int skip = 0;
-
- ENTRY;
-
- if (lcfg->lcfg_command != LCFG_PARAM) {
- CERROR("Unknown command: %d\n", lcfg->lcfg_command);
- RETURN(-EINVAL);
- }
-
- /* fake a seq file so that var->fops->write can work... */
- fakefile.private_data = &fake_seqfile;
- fake_seqfile.private = data;
- /*
- * e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt
- * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar
- * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36
- */
- for (i = 1; i < lcfg->lcfg_bufcount; i++) {
- key = lustre_cfg_buf(lcfg, i);
- /* Strip off prefix */
- if (class_match_param(key, prefix, &key))
- /*
- * If the prefix doesn't match, return error so we
- * can pass it down the stack
- */
- RETURN(-ENOSYS);
- sval = strchr(key, '=');
- if (!sval || *(sval + 1) == 0) {
- CERROR("%s: can't parse param '%s' (missing '=')\n",
- lustre_cfg_string(lcfg, 0),
- lustre_cfg_string(lcfg, i));
- /* rc = -EINVAL; continue parsing other params */
- continue;
- }
- keylen = sval - key;
- sval++;
- vallen = strlen(sval);
- matched = 0;
- j = 0;
- /* Search proc entries */
- while (lvars[j].name) {
- var = &lvars[j];
- if (class_match_param(key, var->name, NULL) == 0 &&
- keylen == strlen(var->name)) {
- matched++;
- rc = -EROFS;
-
- if (var->fops && var->fops->write) {
- mm_segment_t oldfs;
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- rc = (var->fops->write)(&fakefile, sval,
- vallen, NULL);
- set_fs(oldfs);
- }
- break;
- }
- j++;
- }
- if (!matched) {
- /*
- * It was upgraded from old MDT/OST device,
- * ignore the obsolete "sec_level" parameter.
- */
- if (strncmp("sec_level", key, keylen) == 0)
- continue;
-
- CERROR("%s: unknown config parameter '%s'\n",
- lustre_cfg_string(lcfg, 0),
- lustre_cfg_string(lcfg, i));
- /* rc = -EINVAL; continue parsing other params */
- skip++;
- } else if (rc < 0) {
- CERROR("%s: error writing parameter '%s': rc = %d\n",
- lustre_cfg_string(lcfg, 0), key, rc);
- rc = 0;
- } else {
- CDEBUG(D_CONFIG, "%s: set parameter '%s'\n",
- lustre_cfg_string(lcfg, 0), key);
- }
- }
-
- if (rc > 0)
- rc = 0;
- if (!rc && skip)
- rc = skip;
- RETURN(rc);
-}
-EXPORT_SYMBOL(class_process_proc_param);
-
/*
* Supplemental functions for config logs, it allocates lustre_cfg
* buffers plus initialized llog record header at the beginning.