mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	new primitive: __fs_parse()
fs_parse() analogue taking p_log instead of fs_context. fs_parse() turned into a wrapper, callers in ceph_common and rbd switched to __fs_parse(). As the result, fs_parse() never gets NULL fs_context and neither do fs_context-based logging primitives Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									2c3f3dc315
								
							
						
					
					
						commit
						7f5d38141e
					
				
					 5 changed files with 23 additions and 12 deletions
				
			
		|  | @ -6360,7 +6360,7 @@ static int rbd_parse_param(struct fs_parameter *param, | ||||||
| 	if (ret != -ENOPARAM) | 	if (ret != -ENOPARAM) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	token = fs_parse(NULL, &rbd_parameters, param, &result); | 	token = __fs_parse(&log, &rbd_parameters, param, &result); | ||||||
| 	dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); | 	dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); | ||||||
| 	if (token < 0) { | 	if (token < 0) { | ||||||
| 		if (token == -ENOPARAM) | 		if (token == -ENOPARAM) | ||||||
|  |  | ||||||
|  | @ -80,7 +80,7 @@ static const struct fs_parameter_spec *fs_lookup_key( | ||||||
|  * unknown parameters are okay and -EINVAL if there was a conversion issue or |  * unknown parameters are okay and -EINVAL if there was a conversion issue or | ||||||
|  * the parameter wasn't recognised and unknowns aren't okay. |  * the parameter wasn't recognised and unknowns aren't okay. | ||||||
|  */ |  */ | ||||||
| int fs_parse(struct fs_context *fc, | int __fs_parse(struct p_log *log, | ||||||
| 	     const struct fs_parameter_description *desc, | 	     const struct fs_parameter_description *desc, | ||||||
| 	     struct fs_parameter *param, | 	     struct fs_parameter *param, | ||||||
| 	     struct fs_parse_result *result) | 	     struct fs_parse_result *result) | ||||||
|  | @ -113,8 +113,7 @@ int fs_parse(struct fs_context *fc, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (p->flags & fs_param_deprecated) | 	if (p->flags & fs_param_deprecated) | ||||||
| 		warnf(fc, "%s: Deprecated parameter '%s'", | 		warn_plog(log, "Deprecated parameter '%s'", param->key); | ||||||
| 		      desc->name, param->key); |  | ||||||
| 
 | 
 | ||||||
| 	if (result->negated) | 	if (result->negated) | ||||||
| 		goto okay; | 		goto okay; | ||||||
|  | @ -152,8 +151,8 @@ int fs_parse(struct fs_context *fc, | ||||||
| 	switch (p->type) { | 	switch (p->type) { | ||||||
| 	case fs_param_is_flag: | 	case fs_param_is_flag: | ||||||
| 		if (param->type != fs_value_is_flag) | 		if (param->type != fs_value_is_flag) | ||||||
| 			return invalf(fc, "%s: Unexpected value for '%s'", | 			return inval_plog(log, "Unexpected value for '%s'", | ||||||
| 				      desc->name, param->key); | 				      param->key); | ||||||
| 		result->boolean = true; | 		result->boolean = true; | ||||||
| 		goto okay; | 		goto okay; | ||||||
| 
 | 
 | ||||||
|  | @ -238,10 +237,20 @@ int fs_parse(struct fs_context *fc, | ||||||
| 	return p->opt; | 	return p->opt; | ||||||
| 
 | 
 | ||||||
| bad_value: | bad_value: | ||||||
| 	return invalf(fc, "%s: Bad value for '%s'", desc->name, param->key); | 	return inval_plog(log, "Bad value for '%s'", param->key); | ||||||
| unknown_parameter: | unknown_parameter: | ||||||
| 	return -ENOPARAM; | 	return -ENOPARAM; | ||||||
| } | } | ||||||
|  | EXPORT_SYMBOL(__fs_parse); | ||||||
|  | 
 | ||||||
|  | int fs_parse(struct fs_context *fc, | ||||||
|  | 	     const struct fs_parameter_description *desc, | ||||||
|  | 	     struct fs_parameter *param, | ||||||
|  | 	     struct fs_parse_result *result) | ||||||
|  | { | ||||||
|  | 	struct p_log log = {.prefix = desc->name, .log = fc->log}; | ||||||
|  | 	return __fs_parse(&log, desc, param, result); | ||||||
|  | } | ||||||
| EXPORT_SYMBOL(fs_parse); | EXPORT_SYMBOL(fs_parse); | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -189,10 +189,8 @@ struct fc_log { | ||||||
| extern __attribute__((format(printf, 4, 5))) | extern __attribute__((format(printf, 4, 5))) | ||||||
| void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...); | void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...); | ||||||
| 
 | 
 | ||||||
| #define __logfc(fc, l, fmt, ...) ({		\ | #define __logfc(fc, l, fmt, ...) logfc((fc)->log, NULL, \ | ||||||
| 	struct fs_context *__fc = (fc);		\ | 					l, fmt, ## __VA_ARGS__) | ||||||
| 	logfc(__fc ? __fc->log : NULL, NULL,	\ |  | ||||||
| 		l, fmt, ## __VA_ARGS__);}) |  | ||||||
| #define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \ | #define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \ | ||||||
| 					l, fmt, ## __VA_ARGS__) | 					l, fmt, ## __VA_ARGS__) | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -74,6 +74,10 @@ struct fs_parse_result { | ||||||
| 	}; | 	}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | extern int __fs_parse(struct p_log *log, | ||||||
|  | 		    const struct fs_parameter_description *desc, | ||||||
|  | 		    struct fs_parameter *value, | ||||||
|  | 		    struct fs_parse_result *result); | ||||||
| extern int fs_parse(struct fs_context *fc, | extern int fs_parse(struct fs_context *fc, | ||||||
| 		    const struct fs_parameter_description *desc, | 		    const struct fs_parameter_description *desc, | ||||||
| 		    struct fs_parameter *value, | 		    struct fs_parameter *value, | ||||||
|  |  | ||||||
|  | @ -407,7 +407,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, | ||||||
| 	int token, err; | 	int token, err; | ||||||
| 	struct p_log log = {.prefix = "libceph", .log = fc ? fc->log : NULL}; | 	struct p_log log = {.prefix = "libceph", .log = fc ? fc->log : NULL}; | ||||||
| 
 | 
 | ||||||
| 	token = fs_parse(fc, &ceph_parameters, param, &result); | 	token = __fs_parse(&log, &ceph_parameters, param, &result); | ||||||
| 	dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); | 	dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); | ||||||
| 	if (token < 0) | 	if (token < 0) | ||||||
| 		return token; | 		return token; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Al Viro
						Al Viro