Skip to content

Commit 7f5d381

Browse files
author
Al Viro
committed
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 <[email protected]>
1 parent 2c3f3dc commit 7f5d381

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

drivers/block/rbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6360,7 +6360,7 @@ static int rbd_parse_param(struct fs_parameter *param,
63606360
if (ret != -ENOPARAM)
63616361
return ret;
63626362

6363-
token = fs_parse(NULL, &rbd_parameters, param, &result);
6363+
token = __fs_parse(&log, &rbd_parameters, param, &result);
63646364
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
63656365
if (token < 0) {
63666366
if (token == -ENOPARAM)

fs/fs_parser.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static const struct fs_parameter_spec *fs_lookup_key(
8080
* unknown parameters are okay and -EINVAL if there was a conversion issue or
8181
* the parameter wasn't recognised and unknowns aren't okay.
8282
*/
83-
int fs_parse(struct fs_context *fc,
83+
int __fs_parse(struct p_log *log,
8484
const struct fs_parameter_description *desc,
8585
struct fs_parameter *param,
8686
struct fs_parse_result *result)
@@ -113,8 +113,7 @@ int fs_parse(struct fs_context *fc,
113113
}
114114

115115
if (p->flags & fs_param_deprecated)
116-
warnf(fc, "%s: Deprecated parameter '%s'",
117-
desc->name, param->key);
116+
warn_plog(log, "Deprecated parameter '%s'", param->key);
118117

119118
if (result->negated)
120119
goto okay;
@@ -152,8 +151,8 @@ int fs_parse(struct fs_context *fc,
152151
switch (p->type) {
153152
case fs_param_is_flag:
154153
if (param->type != fs_value_is_flag)
155-
return invalf(fc, "%s: Unexpected value for '%s'",
156-
desc->name, param->key);
154+
return inval_plog(log, "Unexpected value for '%s'",
155+
param->key);
157156
result->boolean = true;
158157
goto okay;
159158

@@ -238,10 +237,20 @@ int fs_parse(struct fs_context *fc,
238237
return p->opt;
239238

240239
bad_value:
241-
return invalf(fc, "%s: Bad value for '%s'", desc->name, param->key);
240+
return inval_plog(log, "Bad value for '%s'", param->key);
242241
unknown_parameter:
243242
return -ENOPARAM;
244243
}
244+
EXPORT_SYMBOL(__fs_parse);
245+
246+
int fs_parse(struct fs_context *fc,
247+
const struct fs_parameter_description *desc,
248+
struct fs_parameter *param,
249+
struct fs_parse_result *result)
250+
{
251+
struct p_log log = {.prefix = desc->name, .log = fc->log};
252+
return __fs_parse(&log, desc, param, result);
253+
}
245254
EXPORT_SYMBOL(fs_parse);
246255

247256
/**

include/linux/fs_context.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,8 @@ struct fc_log {
189189
extern __attribute__((format(printf, 4, 5)))
190190
void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...);
191191

192-
#define __logfc(fc, l, fmt, ...) ({ \
193-
struct fs_context *__fc = (fc); \
194-
logfc(__fc ? __fc->log : NULL, NULL, \
195-
l, fmt, ## __VA_ARGS__);})
192+
#define __logfc(fc, l, fmt, ...) logfc((fc)->log, NULL, \
193+
l, fmt, ## __VA_ARGS__)
196194
#define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \
197195
l, fmt, ## __VA_ARGS__)
198196
/**

include/linux/fs_parser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ struct fs_parse_result {
7474
};
7575
};
7676

77+
extern int __fs_parse(struct p_log *log,
78+
const struct fs_parameter_description *desc,
79+
struct fs_parameter *value,
80+
struct fs_parse_result *result);
7781
extern int fs_parse(struct fs_context *fc,
7882
const struct fs_parameter_description *desc,
7983
struct fs_parameter *value,

net/ceph/ceph_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
407407
int token, err;
408408
struct p_log log = {.prefix = "libceph", .log = fc ? fc->log : NULL};
409409

410-
token = fs_parse(fc, &ceph_parameters, param, &result);
410+
token = __fs_parse(&log, &ceph_parameters, param, &result);
411411
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
412412
if (token < 0)
413413
return token;

0 commit comments

Comments
 (0)