Skip to content

Commit cc3c0b5

Browse files
author
Al Viro
committed
add prefix to fs_context->log
... turning it into struct p_log embedded into fs_context. Initialize the prefix with fs_type->name, turning fs_parse() into a trivial inline wrapper for __fs_parse(). This makes fs_parameter_description->name completely unused. Signed-off-by: Al Viro <[email protected]>
1 parent c80c98f commit cc3c0b5

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

fs/ceph/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
250250
dout("server path '%s'\n", fsopt->server_path);
251251

252252
ret = ceph_parse_mon_ips(param->string, dev_name_end - dev_name,
253-
pctx->copts, fc->log);
253+
pctx->copts, fc->log.log);
254254
if (ret)
255255
return ret;
256256

@@ -268,7 +268,7 @@ static int ceph_parse_mount_param(struct fs_context *fc,
268268
unsigned int mode;
269269
int token, ret;
270270

271-
ret = ceph_parse_param(param, pctx->copts, fc->log);
271+
ret = ceph_parse_param(param, pctx->copts, fc->log.log);
272272
if (ret != -ENOPARAM)
273273
return ret;
274274

fs/fs_context.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ static struct fs_context *alloc_fs_context(struct file_system_type *fs_type,
271271
fc->fs_type = get_filesystem(fs_type);
272272
fc->cred = get_current_cred();
273273
fc->net_ns = get_net(current->nsproxy->net_ns);
274+
fc->log.prefix = fs_type->name;
274275

275276
mutex_init(&fc->uapi_mutex);
276277

@@ -364,8 +365,8 @@ struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc)
364365
get_net(fc->net_ns);
365366
get_user_ns(fc->user_ns);
366367
get_cred(fc->cred);
367-
if (fc->log)
368-
refcount_inc(&fc->log->usage);
368+
if (fc->log.log)
369+
refcount_inc(&fc->log.log->usage);
369370

370371
/* Can't call put until we've called ->dup */
371372
ret = fc->ops->dup(fc, src_fc);
@@ -442,12 +443,12 @@ EXPORT_SYMBOL(logfc);
442443
*/
443444
static void put_fc_log(struct fs_context *fc)
444445
{
445-
struct fc_log *log = fc->log;
446+
struct fc_log *log = fc->log.log;
446447
int i;
447448

448449
if (log) {
449450
if (refcount_dec_and_test(&log->usage)) {
450-
fc->log = NULL;
451+
fc->log.log = NULL;
451452
for (i = 0; i <= 7; i++)
452453
if (log->need_free & (1 << i))
453454
kfree(log->buffer[i]);

fs/fs_parser.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,6 @@ int __fs_parse(struct p_log *log,
243243
}
244244
EXPORT_SYMBOL(__fs_parse);
245245

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-
}
254-
EXPORT_SYMBOL(fs_parse);
255-
256246
/**
257247
* fs_lookup_param - Look up a path referred to by a parameter
258248
* @fc: The filesystem context to log errors through.

fs/fsopen.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static ssize_t fscontext_read(struct file *file,
2525
char __user *_buf, size_t len, loff_t *pos)
2626
{
2727
struct fs_context *fc = file->private_data;
28-
struct fc_log *log = fc->log;
28+
struct fc_log *log = fc->log.log;
2929
unsigned int logsize = ARRAY_SIZE(log->buffer);
3030
ssize_t ret;
3131
char *p;
@@ -97,11 +97,11 @@ static int fscontext_create_fd(struct fs_context *fc, unsigned int o_flags)
9797

9898
static int fscontext_alloc_log(struct fs_context *fc)
9999
{
100-
fc->log = kzalloc(sizeof(*fc->log), GFP_KERNEL);
101-
if (!fc->log)
100+
fc->log.log = kzalloc(sizeof(*fc->log.log), GFP_KERNEL);
101+
if (!fc->log.log)
102102
return -ENOMEM;
103-
refcount_set(&fc->log->usage, 1);
104-
fc->log->owner = fc->fs_type->owner;
103+
refcount_set(&fc->log.log->usage, 1);
104+
fc->log.log->owner = fc->fs_type->owner;
105105
return 0;
106106
}
107107

include/linux/fs_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct fs_context {
9797
struct user_namespace *user_ns; /* The user namespace for this mount */
9898
struct net *net_ns; /* The network namespace for this mount */
9999
const struct cred *cred; /* The mounter's credentials */
100-
struct fc_log *log; /* Logging buffer */
100+
struct p_log log; /* Logging buffer */
101101
const char *source; /* The source name (eg. dev path) */
102102
void *security; /* Linux S&M options */
103103
void *s_fs_info; /* Proposed s_fs_info */
@@ -189,7 +189,7 @@ 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, ...) logfc((fc)->log, NULL, \
192+
#define __logfc(fc, l, fmt, ...) logfc((fc)->log.log, NULL, \
193193
l, fmt, ## __VA_ARGS__)
194194
#define __plog(p, l, fmt, ...) logfc((p)->log, (p)->prefix, \
195195
l, fmt, ## __VA_ARGS__)

include/linux/fs_parser.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ extern int __fs_parse(struct p_log *log,
7878
const struct fs_parameter_description *desc,
7979
struct fs_parameter *value,
8080
struct fs_parse_result *result);
81-
extern int fs_parse(struct fs_context *fc,
82-
const struct fs_parameter_description *desc,
83-
struct fs_parameter *value,
84-
struct fs_parse_result *result);
81+
82+
static inline int fs_parse(struct fs_context *fc,
83+
const struct fs_parameter_description *desc,
84+
struct fs_parameter *param,
85+
struct fs_parse_result *result)
86+
{
87+
return __fs_parse(&fc->log, desc, param, result);
88+
}
89+
8590
extern int fs_lookup_param(struct fs_context *fc,
8691
struct fs_parameter *param,
8792
bool want_bdev,

0 commit comments

Comments
 (0)