mirror of https://gitee.com/openkylin/linux.git
NFS: Attach supplementary error information to fs_context.
Split out from commit "NFS: Add fs_context support." Add wrappers nfs_errorf(), nfs_invalf(), and nfs_warnf() which log error information to the fs_context. Convert some printk's to use these new wrappers instead. Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
62a55d088c
commit
ce8866f091
|
@ -318,10 +318,8 @@ static int nfs_auth_info_add(struct fs_context *fc,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth_info->flavor_len + 1 >= max_flavor_len) {
|
if (auth_info->flavor_len + 1 >= max_flavor_len)
|
||||||
dfprintk(MOUNT, "NFS: too many sec= flavors\n");
|
return nfs_invalf(fc, "NFS: too many sec= flavors");
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
auth_info->flavors[auth_info->flavor_len++] = flavor;
|
auth_info->flavors[auth_info->flavor_len++] = flavor;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -378,9 +376,7 @@ static int nfs_parse_security_flavors(struct fs_context *fc,
|
||||||
pseudoflavor = RPC_AUTH_GSS_SPKMP;
|
pseudoflavor = RPC_AUTH_GSS_SPKMP;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dfprintk(MOUNT,
|
return nfs_invalf(fc, "NFS: sec=%s option not recognized", p);
|
||||||
"NFS: sec= option '%s' not recognized\n", p);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nfs_auth_info_add(fc, &ctx->auth_info, pseudoflavor);
|
ret = nfs_auth_info_add(fc, &ctx->auth_info, pseudoflavor);
|
||||||
|
@ -425,8 +421,7 @@ static int nfs_parse_version_string(struct fs_context *fc,
|
||||||
ctx->minorversion = 2;
|
ctx->minorversion = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dfprintk(MOUNT, "NFS: Unsupported NFS version\n");
|
return nfs_invalf(fc, "NFS: Unsupported NFS version");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -451,10 +446,8 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case Opt_source:
|
case Opt_source:
|
||||||
if (fc->source) {
|
if (fc->source)
|
||||||
dfprintk(MOUNT, "NFS: Multiple sources not supported\n");
|
return nfs_invalf(fc, "NFS: Multiple sources not supported");
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
fc->source = param->string;
|
fc->source = param->string;
|
||||||
param->string = NULL;
|
param->string = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -664,8 +657,7 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
|
||||||
xprt_load_transport(param->string);
|
xprt_load_transport(param->string);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dfprintk(MOUNT, "NFS: unrecognized transport protocol\n");
|
return nfs_invalf(fc, "NFS: Unrecognized transport protocol");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->protofamily = protofamily;
|
ctx->protofamily = protofamily;
|
||||||
|
@ -688,8 +680,7 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
|
||||||
break;
|
break;
|
||||||
case Opt_xprt_rdma: /* not used for side protocols */
|
case Opt_xprt_rdma: /* not used for side protocols */
|
||||||
default:
|
default:
|
||||||
dfprintk(MOUNT, "NFS: unrecognized transport protocol\n");
|
return nfs_invalf(fc, "NFS: Unrecognized transport protocol");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
ctx->mountfamily = mountfamily;
|
ctx->mountfamily = mountfamily;
|
||||||
break;
|
break;
|
||||||
|
@ -774,13 +765,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_invalid_value:
|
out_invalid_value:
|
||||||
printk(KERN_INFO "NFS: Bad mount option value specified\n");
|
return nfs_invalf(fc, "NFS: Bad mount option value specified");
|
||||||
return -EINVAL;
|
|
||||||
out_invalid_address:
|
out_invalid_address:
|
||||||
printk(KERN_INFO "NFS: Bad IP address specified\n");
|
return nfs_invalf(fc, "NFS: Bad IP address specified");
|
||||||
return -EINVAL;
|
|
||||||
out_of_bounds:
|
out_of_bounds:
|
||||||
printk(KERN_INFO "NFS: Value for '%s' out of range\n", param->key);
|
nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,19 +835,15 @@ static int nfs_parse_source(struct fs_context *fc,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_bad_devname:
|
out_bad_devname:
|
||||||
dfprintk(MOUNT, "NFS: device name not in host:path format\n");
|
return nfs_invalf(fc, "NFS: device name not in host:path format");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_nomem:
|
out_nomem:
|
||||||
dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
|
nfs_errorf(fc, "NFS: not enough memory to parse device name");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
out_hostname:
|
out_hostname:
|
||||||
dfprintk(MOUNT, "NFS: server hostname too long\n");
|
nfs_errorf(fc, "NFS: server hostname too long");
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
|
|
||||||
out_path:
|
out_path:
|
||||||
dfprintk(MOUNT, "NFS: export pathname too long\n");
|
nfs_errorf(fc, "NFS: export pathname too long");
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,29 +1000,23 @@ static int nfs23_parse_monolithic(struct fs_context *fc,
|
||||||
ctx->skip_reconfig_option_check = true;
|
ctx->skip_reconfig_option_check = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n");
|
return nfs_invalf(fc, "NFS: mount program didn't pass any mount data");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_no_v3:
|
out_no_v3:
|
||||||
dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n",
|
return nfs_invalf(fc, "NFS: nfs_mount_data version does not support v3");
|
||||||
data->version);
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_no_sec:
|
out_no_sec:
|
||||||
dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
|
return nfs_invalf(fc, "NFS: nfs_mount_data version supports only AUTH_SYS");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_nomem:
|
out_nomem:
|
||||||
dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
|
dfprintk(MOUNT, "NFS: not enough memory to handle mount options");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
out_no_address:
|
out_no_address:
|
||||||
dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
|
return nfs_invalf(fc, "NFS: mount program didn't pass remote address");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_invalid_fh:
|
out_invalid_fh:
|
||||||
dfprintk(MOUNT, "NFS: invalid root filehandle\n");
|
return nfs_invalf(fc, "NFS: invalid root filehandle");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_NFS_V4)
|
#if IS_ENABLED(CONFIG_NFS_V4)
|
||||||
|
@ -1132,21 +1111,17 @@ static int nfs4_parse_monolithic(struct fs_context *fc,
|
||||||
ctx->skip_reconfig_option_check = true;
|
ctx->skip_reconfig_option_check = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
|
return nfs_invalf(fc, "NFS4: mount program didn't pass any mount data");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_inval_auth:
|
out_inval_auth:
|
||||||
dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
|
return nfs_invalf(fc, "NFS4: Invalid number of RPC auth flavours %d",
|
||||||
data->auth_flavourlen);
|
data->auth_flavourlen);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_no_address:
|
out_no_address:
|
||||||
dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
|
return nfs_invalf(fc, "NFS4: mount program didn't pass remote address");
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
out_invalid_transport_udp:
|
out_invalid_transport_udp:
|
||||||
dfprintk(MOUNT, "NFSv4: Unsupported transport protocol udp\n");
|
return nfs_invalf(fc, "NFSv4: Unsupported transport protocol udp");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1164,8 +1139,7 @@ static int nfs_fs_context_parse_monolithic(struct fs_context *fc,
|
||||||
return nfs4_parse_monolithic(fc, data);
|
return nfs4_parse_monolithic(fc, data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dfprintk(MOUNT, "NFS: Unsupported monolithic data version\n");
|
return nfs_invalf(fc, "NFS: Unsupported monolithic data version");
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1253,32 +1227,25 @@ static int nfs_fs_context_validate(struct fs_context *fc)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_no_device_name:
|
out_no_device_name:
|
||||||
dfprintk(MOUNT, "NFS: Device name not specified\n");
|
return nfs_invalf(fc, "NFS: Device name not specified");
|
||||||
return -EINVAL;
|
|
||||||
out_v4_not_compiled:
|
out_v4_not_compiled:
|
||||||
dfprintk(MOUNT, "NFS: NFSv4 is not compiled into kernel\n");
|
nfs_errorf(fc, "NFS: NFSv4 is not compiled into kernel");
|
||||||
return -EPROTONOSUPPORT;
|
return -EPROTONOSUPPORT;
|
||||||
out_invalid_transport_udp:
|
out_invalid_transport_udp:
|
||||||
dfprintk(MOUNT, "NFSv4: Unsupported transport protocol udp\n");
|
return nfs_invalf(fc, "NFSv4: Unsupported transport protocol udp");
|
||||||
return -EINVAL;
|
|
||||||
out_no_address:
|
out_no_address:
|
||||||
dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
|
return nfs_invalf(fc, "NFS: mount program didn't pass remote address");
|
||||||
return -EINVAL;
|
|
||||||
out_mountproto_mismatch:
|
out_mountproto_mismatch:
|
||||||
dfprintk(MOUNT, "NFS: Mount server address does not match mountproto= option\n");
|
return nfs_invalf(fc, "NFS: Mount server address does not match mountproto= option");
|
||||||
return -EINVAL;
|
|
||||||
out_proto_mismatch:
|
out_proto_mismatch:
|
||||||
dfprintk(MOUNT, "NFS: Server address does not match proto= option\n");
|
return nfs_invalf(fc, "NFS: Server address does not match proto= option");
|
||||||
return -EINVAL;
|
|
||||||
out_minorversion_mismatch:
|
out_minorversion_mismatch:
|
||||||
dfprintk(MOUNT, "NFS: Mount option vers=%u does not support minorversion=%u\n",
|
return nfs_invalf(fc, "NFS: Mount option vers=%u does not support minorversion=%u",
|
||||||
ctx->version, ctx->minorversion);
|
ctx->version, ctx->minorversion);
|
||||||
return -EINVAL;
|
|
||||||
out_migration_misuse:
|
out_migration_misuse:
|
||||||
dfprintk(MOUNT, "NFS: 'Migration' not supported for this NFS version\n");
|
return nfs_invalf(fc, "NFS: 'Migration' not supported for this NFS version");
|
||||||
return -EINVAL;
|
|
||||||
out_version_unavailable:
|
out_version_unavailable:
|
||||||
dfprintk(MOUNT, "NFS: Version unavailable\n");
|
nfs_errorf(fc, "NFS: Version unavailable");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
error = server->nfs_client->rpc_ops->getroot(server, ctx->mntfh, &fsinfo);
|
error = server->nfs_client->rpc_ops->getroot(server, ctx->mntfh, &fsinfo);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
dprintk("nfs_get_root: getattr error = %d\n", -error);
|
dprintk("nfs_get_root: getattr error = %d\n", -error);
|
||||||
|
nfs_errorf(fc, "NFS: Couldn't getattr on root");
|
||||||
goto out_fattr;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +94,7 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
if (IS_ERR(inode)) {
|
if (IS_ERR(inode)) {
|
||||||
dprintk("nfs_get_root: get root inode failed\n");
|
dprintk("nfs_get_root: get root inode failed\n");
|
||||||
error = PTR_ERR(inode);
|
error = PTR_ERR(inode);
|
||||||
|
nfs_errorf(fc, "NFS: Couldn't get root inode");
|
||||||
goto out_fattr;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)
|
||||||
if (IS_ERR(root)) {
|
if (IS_ERR(root)) {
|
||||||
dprintk("nfs_get_root: get root dentry failed\n");
|
dprintk("nfs_get_root: get root dentry failed\n");
|
||||||
error = PTR_ERR(root);
|
error = PTR_ERR(root);
|
||||||
|
nfs_errorf(fc, "NFS: Couldn't get root dentry");
|
||||||
goto out_fattr;
|
goto out_fattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,10 @@ struct nfs_fs_context {
|
||||||
} clone_data;
|
} clone_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define nfs_errorf(fc, fmt, ...) errorf(fc, fmt, ## __VA_ARGS__)
|
||||||
|
#define nfs_invalf(fc, fmt, ...) invalf(fc, fmt, ## __VA_ARGS__)
|
||||||
|
#define nfs_warnf(fc, fmt, ...) warnf(fc, fmt, ## __VA_ARGS__)
|
||||||
|
|
||||||
static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc)
|
static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc)
|
||||||
{
|
{
|
||||||
return fc->fs_private;
|
return fc->fs_private;
|
||||||
|
|
|
@ -281,7 +281,7 @@ int nfs_do_submount(struct fs_context *fc)
|
||||||
|
|
||||||
p = nfs_devname(dentry, buffer, 4096);
|
p = nfs_devname(dentry, buffer, 4096);
|
||||||
if (IS_ERR(p)) {
|
if (IS_ERR(p)) {
|
||||||
dprintk("NFS: Couldn't determine submount pathname\n");
|
nfs_errorf(fc, "NFS: Couldn't determine submount pathname");
|
||||||
ret = PTR_ERR(p);
|
ret = PTR_ERR(p);
|
||||||
} else {
|
} else {
|
||||||
ret = vfs_parse_fs_string(fc, "source", p, buffer + 4096 - p);
|
ret = vfs_parse_fs_string(fc, "source", p, buffer + 4096 - p);
|
||||||
|
|
|
@ -225,6 +225,7 @@ int nfs4_try_get_tree(struct fs_context *fc)
|
||||||
fc, ctx->nfs_server.hostname,
|
fc, ctx->nfs_server.hostname,
|
||||||
ctx->nfs_server.export_path);
|
ctx->nfs_server.export_path);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
nfs_errorf(fc, "NFS4: Couldn't follow remote path");
|
||||||
dfprintk(MOUNT, "<-- nfs4_try_get_tree() = %d [error]\n", err);
|
dfprintk(MOUNT, "<-- nfs4_try_get_tree() = %d [error]\n", err);
|
||||||
} else {
|
} else {
|
||||||
dfprintk(MOUNT, "<-- nfs4_try_get_tree() = 0\n");
|
dfprintk(MOUNT, "<-- nfs4_try_get_tree() = 0\n");
|
||||||
|
@ -247,6 +248,7 @@ int nfs4_get_referral_tree(struct fs_context *fc)
|
||||||
fc, ctx->nfs_server.hostname,
|
fc, ctx->nfs_server.hostname,
|
||||||
ctx->nfs_server.export_path);
|
ctx->nfs_server.export_path);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
nfs_errorf(fc, "NFS4: Couldn't follow remote path");
|
||||||
dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = %d [error]\n", err);
|
dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = %d [error]\n", err);
|
||||||
} else {
|
} else {
|
||||||
dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = 0\n");
|
dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = 0\n");
|
||||||
|
|
|
@ -1205,7 +1205,7 @@ int nfs_get_tree_common(struct fs_context *fc)
|
||||||
fc->s_fs_info = NULL;
|
fc->s_fs_info = NULL;
|
||||||
if (IS_ERR(s)) {
|
if (IS_ERR(s)) {
|
||||||
error = PTR_ERR(s);
|
error = PTR_ERR(s);
|
||||||
dfprintk(MOUNT, "NFS: Couldn't get superblock\n");
|
nfs_errorf(fc, "NFS: Couldn't get superblock");
|
||||||
goto out_err_nosb;
|
goto out_err_nosb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1234,7 +1234,7 @@ int nfs_get_tree_common(struct fs_context *fc)
|
||||||
|
|
||||||
error = nfs_get_root(s, fc);
|
error = nfs_get_root(s, fc);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
dfprintk(MOUNT, "NFS: Couldn't get root dentry\n");
|
nfs_errorf(fc, "NFS: Couldn't get root dentry");
|
||||||
goto error_splat_super;
|
goto error_splat_super;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue