ceph: report mount root in session metadata
Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
parent
aeda081c5e
commit
3f38495409
|
@ -839,12 +839,14 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
|
||||||
int metadata_bytes = 0;
|
int metadata_bytes = 0;
|
||||||
int metadata_key_count = 0;
|
int metadata_key_count = 0;
|
||||||
struct ceph_options *opt = mdsc->fsc->client->options;
|
struct ceph_options *opt = mdsc->fsc->client->options;
|
||||||
|
struct ceph_mount_options *fsopt = mdsc->fsc->mount_options;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
const char* metadata[][2] = {
|
const char* metadata[][2] = {
|
||||||
{"hostname", utsname()->nodename},
|
{"hostname", utsname()->nodename},
|
||||||
{"kernel_version", utsname()->release},
|
{"kernel_version", utsname()->release},
|
||||||
{"entity_id", opt->name ? opt->name : ""},
|
{"entity_id", opt->name ? : ""},
|
||||||
|
{"root", fsopt->server_path ? : "/"},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -302,6 +302,7 @@ static void destroy_mount_options(struct ceph_mount_options *args)
|
||||||
{
|
{
|
||||||
dout("destroy_mount_options %p\n", args);
|
dout("destroy_mount_options %p\n", args);
|
||||||
kfree(args->snapdir_name);
|
kfree(args->snapdir_name);
|
||||||
|
kfree(args->server_path);
|
||||||
kfree(args);
|
kfree(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,14 +334,17 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = strcmp_null(fsopt1->server_path, fsopt2->server_path);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return ceph_compare_options(new_opt, fsc->client);
|
return ceph_compare_options(new_opt, fsc->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_mount_options(struct ceph_mount_options **pfsopt,
|
static int parse_mount_options(struct ceph_mount_options **pfsopt,
|
||||||
struct ceph_options **popt,
|
struct ceph_options **popt,
|
||||||
int flags, char *options,
|
int flags, char *options,
|
||||||
const char *dev_name,
|
const char *dev_name)
|
||||||
const char **path)
|
|
||||||
{
|
{
|
||||||
struct ceph_mount_options *fsopt;
|
struct ceph_mount_options *fsopt;
|
||||||
const char *dev_name_end;
|
const char *dev_name_end;
|
||||||
|
@ -386,12 +390,13 @@ static int parse_mount_options(struct ceph_mount_options **pfsopt,
|
||||||
*/
|
*/
|
||||||
dev_name_end = strchr(dev_name, '/');
|
dev_name_end = strchr(dev_name, '/');
|
||||||
if (dev_name_end) {
|
if (dev_name_end) {
|
||||||
/* skip over leading '/' for path */
|
fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL);
|
||||||
*path = dev_name_end + 1;
|
if (!fsopt->server_path) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* path is empty */
|
|
||||||
dev_name_end = dev_name + strlen(dev_name);
|
dev_name_end = dev_name + strlen(dev_name);
|
||||||
*path = dev_name_end;
|
|
||||||
}
|
}
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
dev_name_end--; /* back up to ':' separator */
|
dev_name_end--; /* back up to ':' separator */
|
||||||
|
@ -401,7 +406,8 @@ static int parse_mount_options(struct ceph_mount_options **pfsopt,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
|
dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
|
||||||
dout("server path '%s'\n", *path);
|
if (fsopt->server_path)
|
||||||
|
dout("server path '%s'\n", fsopt->server_path);
|
||||||
|
|
||||||
*popt = ceph_parse_options(options, dev_name, dev_name_end,
|
*popt = ceph_parse_options(options, dev_name, dev_name_end,
|
||||||
parse_fsopt_token, (void *)fsopt);
|
parse_fsopt_token, (void *)fsopt);
|
||||||
|
@ -793,8 +799,7 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
|
||||||
/*
|
/*
|
||||||
* mount: join the ceph cluster, and open root directory.
|
* mount: join the ceph cluster, and open root directory.
|
||||||
*/
|
*/
|
||||||
static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
|
static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
|
||||||
const char *path)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned long started = jiffies; /* note the start time */
|
unsigned long started = jiffies; /* note the start time */
|
||||||
|
@ -823,11 +828,12 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path[0] == 0) {
|
if (!fsc->mount_options->server_path) {
|
||||||
root = fsc->sb->s_root;
|
root = fsc->sb->s_root;
|
||||||
dget(root);
|
dget(root);
|
||||||
} else {
|
} else {
|
||||||
dout("mount opening base mountpoint\n");
|
const char *path = fsc->mount_options->server_path + 1;
|
||||||
|
dout("mount opening path %s\n", path);
|
||||||
root = open_root_dentry(fsc, path, started);
|
root = open_root_dentry(fsc, path, started);
|
||||||
if (IS_ERR(root)) {
|
if (IS_ERR(root)) {
|
||||||
err = PTR_ERR(root);
|
err = PTR_ERR(root);
|
||||||
|
@ -943,7 +949,6 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
|
||||||
struct dentry *res;
|
struct dentry *res;
|
||||||
int err;
|
int err;
|
||||||
int (*compare_super)(struct super_block *, void *) = ceph_compare_super;
|
int (*compare_super)(struct super_block *, void *) = ceph_compare_super;
|
||||||
const char *path = NULL;
|
|
||||||
struct ceph_mount_options *fsopt = NULL;
|
struct ceph_mount_options *fsopt = NULL;
|
||||||
struct ceph_options *opt = NULL;
|
struct ceph_options *opt = NULL;
|
||||||
|
|
||||||
|
@ -952,7 +957,7 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
|
||||||
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
||||||
flags |= MS_POSIXACL;
|
flags |= MS_POSIXACL;
|
||||||
#endif
|
#endif
|
||||||
err = parse_mount_options(&fsopt, &opt, flags, data, dev_name, &path);
|
err = parse_mount_options(&fsopt, &opt, flags, data, dev_name);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
res = ERR_PTR(err);
|
res = ERR_PTR(err);
|
||||||
goto out_final;
|
goto out_final;
|
||||||
|
@ -995,7 +1000,7 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ceph_real_mount(fsc, path);
|
res = ceph_real_mount(fsc);
|
||||||
if (IS_ERR(res))
|
if (IS_ERR(res))
|
||||||
goto out_splat;
|
goto out_splat;
|
||||||
dout("root %p inode %p ino %llx.%llx\n", res,
|
dout("root %p inode %p ino %llx.%llx\n", res,
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct ceph_mount_options {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *snapdir_name; /* default ".snap" */
|
char *snapdir_name; /* default ".snap" */
|
||||||
|
char *server_path; /* default "/" */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ceph_fs_client {
|
struct ceph_fs_client {
|
||||||
|
|
Loading…
Reference in New Issue