xref: /openbmc/linux/fs/ceph/super.c (revision 985b9ee8)
109c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
216725b9dSSage Weil 
33d14c5d2SYehuda Sadeh #include <linux/ceph/ceph_debug.h>
416725b9dSSage Weil 
516725b9dSSage Weil #include <linux/backing-dev.h>
6c309f0abSSage Weil #include <linux/ctype.h>
716725b9dSSage Weil #include <linux/fs.h>
816725b9dSSage Weil #include <linux/inet.h>
916725b9dSSage Weil #include <linux/in6.h>
1016725b9dSSage Weil #include <linux/module.h>
1116725b9dSSage Weil #include <linux/mount.h>
1282995cc6SDavid Howells #include <linux/fs_context.h>
1382995cc6SDavid Howells #include <linux/fs_parser.h>
1416725b9dSSage Weil #include <linux/sched.h>
1516725b9dSSage Weil #include <linux/seq_file.h>
165a0e3ad6STejun Heo #include <linux/slab.h>
1716725b9dSSage Weil #include <linux/statfs.h>
1816725b9dSSage Weil #include <linux/string.h>
1916725b9dSSage Weil 
2016725b9dSSage Weil #include "super.h"
213d14c5d2SYehuda Sadeh #include "mds_client.h"
2299ccbd22SMilosz Tanski #include "cache.h"
232d332d5bSJeff Layton #include "crypto.h"
243d14c5d2SYehuda Sadeh 
251fe60e51SSage Weil #include <linux/ceph/ceph_features.h>
263d14c5d2SYehuda Sadeh #include <linux/ceph/decode.h>
273d14c5d2SYehuda Sadeh #include <linux/ceph/mon_client.h>
283d14c5d2SYehuda Sadeh #include <linux/ceph/auth.h>
293d14c5d2SYehuda Sadeh #include <linux/ceph/debugfs.h>
3016725b9dSSage Weil 
31a0b3a15eSJeff Layton #include <uapi/linux/magic.h>
32a0b3a15eSJeff Layton 
3318f473b3SXiubo Li static DEFINE_SPINLOCK(ceph_fsc_lock);
3418f473b3SXiubo Li static LIST_HEAD(ceph_fsc_list);
3518f473b3SXiubo Li 
3616725b9dSSage Weil /*
3716725b9dSSage Weil  * Ceph superblock operations
3816725b9dSSage Weil  *
3916725b9dSSage Weil  * Handle the basics of mounting, unmounting.
4016725b9dSSage Weil  */
4116725b9dSSage Weil 
4216725b9dSSage Weil /*
4316725b9dSSage Weil  * super ops
4416725b9dSSage Weil  */
ceph_put_super(struct super_block * s)4516725b9dSSage Weil static void ceph_put_super(struct super_block *s)
4616725b9dSSage Weil {
47985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(s);
4816725b9dSSage Weil 
4916725b9dSSage Weil 	dout("put_super\n");
506b5717bdSJeff Layton 	ceph_fscrypt_free_dummy_policy(fsc);
513d14c5d2SYehuda Sadeh 	ceph_mdsc_close_sessions(fsc->mdsc);
5216725b9dSSage Weil }
5316725b9dSSage Weil 
ceph_statfs(struct dentry * dentry,struct kstatfs * buf)5416725b9dSSage Weil static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
5516725b9dSSage Weil {
56985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_inode_to_fs_client(d_inode(dentry));
5773fb0949SLuis Henriques 	struct ceph_mon_client *monc = &fsc->client->monc;
5816725b9dSSage Weil 	struct ceph_statfs st;
598cfc0c7eSJeff Layton 	int i, err;
6006d74376SDouglas Fuller 	u64 data_pool;
6106d74376SDouglas Fuller 
6206d74376SDouglas Fuller 	if (fsc->mdsc->mdsmap->m_num_data_pg_pools == 1) {
6306d74376SDouglas Fuller 		data_pool = fsc->mdsc->mdsmap->m_data_pg_pools[0];
6406d74376SDouglas Fuller 	} else {
6506d74376SDouglas Fuller 		data_pool = CEPH_NOPOOL;
6606d74376SDouglas Fuller 	}
6716725b9dSSage Weil 
6816725b9dSSage Weil 	dout("statfs\n");
6973fb0949SLuis Henriques 	err = ceph_monc_do_statfs(monc, data_pool, &st);
7016725b9dSSage Weil 	if (err < 0)
7116725b9dSSage Weil 		return err;
7216725b9dSSage Weil 
7316725b9dSSage Weil 	/* fill in kstatfs */
7416725b9dSSage Weil 	buf->f_type = CEPH_SUPER_MAGIC;  /* ?? */
7516725b9dSSage Weil 
7616725b9dSSage Weil 	/*
770c04a117SXiubo Li 	 * Express utilization in terms of large blocks to avoid
7816725b9dSSage Weil 	 * overflow on 32-bit machines.
7916725b9dSSage Weil 	 */
8092a49fb0SSage Weil 	buf->f_frsize = 1 << CEPH_BLOCK_SHIFT;
819122eed5SLuis Henriques 
829122eed5SLuis Henriques 	/*
839122eed5SLuis Henriques 	 * By default use root quota for stats; fallback to overall filesystem
849122eed5SLuis Henriques 	 * usage if using 'noquotadf' mount option or if the root dir doesn't
859122eed5SLuis Henriques 	 * have max_bytes quota set.
869122eed5SLuis Henriques 	 */
879122eed5SLuis Henriques 	if (ceph_test_mount_opt(fsc, NOQUOTADF) ||
889122eed5SLuis Henriques 	    !ceph_quota_update_statfs(fsc, buf)) {
8916725b9dSSage Weil 		buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10);
908f04d422SGreg Farnum 		buf->f_bfree = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
9116725b9dSSage Weil 		buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
929122eed5SLuis Henriques 	}
9316725b9dSSage Weil 
940c04a117SXiubo Li 	/*
950c04a117SXiubo Li 	 * NOTE: for the time being, we make bsize == frsize to humor
960c04a117SXiubo Li 	 * not-yet-ancient versions of glibc that are broken.
970c04a117SXiubo Li 	 * Someday, we will probably want to report a real block
980c04a117SXiubo Li 	 * size...  whatever that may mean for a network file system!
990c04a117SXiubo Li 	 */
1000c04a117SXiubo Li 	buf->f_bsize = buf->f_frsize;
1010c04a117SXiubo Li 
10216725b9dSSage Weil 	buf->f_files = le64_to_cpu(st.num_objects);
10316725b9dSSage Weil 	buf->f_ffree = -1;
104558d3499SSage Weil 	buf->f_namelen = NAME_MAX;
10516725b9dSSage Weil 
106080a330eSJeff Layton 	/* Must convert the fsid, for consistent values across arches */
1078cfc0c7eSJeff Layton 	buf->f_fsid.val[0] = 0;
10873fb0949SLuis Henriques 	mutex_lock(&monc->mutex);
1098cfc0c7eSJeff Layton 	for (i = 0 ; i < sizeof(monc->monmap->fsid) / sizeof(__le32) ; ++i)
1108cfc0c7eSJeff Layton 		buf->f_fsid.val[0] ^= le32_to_cpu(((__le32 *)&monc->monmap->fsid)[i]);
11173fb0949SLuis Henriques 	mutex_unlock(&monc->mutex);
11273fb0949SLuis Henriques 
1138cfc0c7eSJeff Layton 	/* fold the fs_cluster_id into the upper bits */
1148cfc0c7eSJeff Layton 	buf->f_fsid.val[1] = monc->fs_cluster_id;
11516725b9dSSage Weil 
11616725b9dSSage Weil 	return 0;
11716725b9dSSage Weil }
11816725b9dSSage Weil 
ceph_sync_fs(struct super_block * sb,int wait)1192d9c98aeSSage Weil static int ceph_sync_fs(struct super_block *sb, int wait)
12016725b9dSSage Weil {
121985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
1222d9c98aeSSage Weil 
1232d9c98aeSSage Weil 	if (!wait) {
1242d9c98aeSSage Weil 		dout("sync_fs (non-blocking)\n");
1253d14c5d2SYehuda Sadeh 		ceph_flush_dirty_caps(fsc->mdsc);
1262d9c98aeSSage Weil 		dout("sync_fs (non-blocking) done\n");
1272d9c98aeSSage Weil 		return 0;
1282d9c98aeSSage Weil 	}
1292d9c98aeSSage Weil 
1302d9c98aeSSage Weil 	dout("sync_fs (blocking)\n");
1313d14c5d2SYehuda Sadeh 	ceph_osdc_sync(&fsc->client->osdc);
1323d14c5d2SYehuda Sadeh 	ceph_mdsc_sync(fsc->mdsc);
1332d9c98aeSSage Weil 	dout("sync_fs (blocking) done\n");
13416725b9dSSage Weil 	return 0;
13516725b9dSSage Weil }
13616725b9dSSage Weil 
1372baba250SYehuda Sadeh /*
1383d14c5d2SYehuda Sadeh  * mount options
1392baba250SYehuda Sadeh  */
1403d14c5d2SYehuda Sadeh enum {
1413d14c5d2SYehuda Sadeh 	Opt_wsize,
1423d14c5d2SYehuda Sadeh 	Opt_rsize,
14383817e35SSage Weil 	Opt_rasize,
1443d14c5d2SYehuda Sadeh 	Opt_caps_wanted_delay_min,
1453d14c5d2SYehuda Sadeh 	Opt_caps_wanted_delay_max,
146fe33032dSYan, Zheng 	Opt_caps_max,
1473d14c5d2SYehuda Sadeh 	Opt_readdir_max_entries,
1483d14c5d2SYehuda Sadeh 	Opt_readdir_max_bytes,
1493d14c5d2SYehuda Sadeh 	Opt_congestion_kb,
1503d14c5d2SYehuda Sadeh 	/* int args above */
1513d14c5d2SYehuda Sadeh 	Opt_snapdirname,
152430afbadSYan, Zheng 	Opt_mds_namespace,
153131d7eb4SYan, Zheng 	Opt_recover_session,
15482995cc6SDavid Howells 	Opt_source,
1557b19b4dbSVenky Shankar 	Opt_mon_addr,
1566b5717bdSJeff Layton 	Opt_test_dummy_encryption,
1573d14c5d2SYehuda Sadeh 	/* string args above */
1583d14c5d2SYehuda Sadeh 	Opt_dirstat,
1593d14c5d2SYehuda Sadeh 	Opt_rbytes,
160cffaba15SAlex Elder 	Opt_asyncreaddir,
161a40dc6ccSSage Weil 	Opt_dcache,
162ad1fee96SYehuda Sadeh 	Opt_ino32,
16399ccbd22SMilosz Tanski 	Opt_fscache,
16410183a69SYan, Zheng 	Opt_poolperm,
165e9e427f0SYan, Zheng 	Opt_require_active_mds,
16645195e42SSage Weil 	Opt_acl,
1679122eed5SLuis Henriques 	Opt_quotadf,
168ea4cdc54SLuis Henriques 	Opt_copyfrom,
1692ccb4546SJeff Layton 	Opt_wsync,
17094cc0877SJeff Layton 	Opt_pagecache,
17103bc06c7SJeff Layton 	Opt_sparseread,
1723d14c5d2SYehuda Sadeh };
1732baba250SYehuda Sadeh 
17482995cc6SDavid Howells enum ceph_recover_session_mode {
17582995cc6SDavid Howells 	ceph_recover_session_no,
17682995cc6SDavid Howells 	ceph_recover_session_clean
1773d14c5d2SYehuda Sadeh };
1783d14c5d2SYehuda Sadeh 
1795eede625SAl Viro static const struct constant_table ceph_param_recover[] = {
1802710c957SAl Viro 	{ "no",		ceph_recover_session_no },
1812710c957SAl Viro 	{ "clean",	ceph_recover_session_clean },
18282995cc6SDavid Howells 	{}
18382995cc6SDavid Howells };
18482995cc6SDavid Howells 
185d7167b14SAl Viro static const struct fs_parameter_spec ceph_mount_parameters[] = {
18682995cc6SDavid Howells 	fsparam_flag_no ("acl",				Opt_acl),
18782995cc6SDavid Howells 	fsparam_flag_no ("asyncreaddir",		Opt_asyncreaddir),
188ad8c28a9SJeff Layton 	fsparam_s32	("caps_max",			Opt_caps_max),
18982995cc6SDavid Howells 	fsparam_u32	("caps_wanted_delay_max",	Opt_caps_wanted_delay_max),
19082995cc6SDavid Howells 	fsparam_u32	("caps_wanted_delay_min",	Opt_caps_wanted_delay_min),
191ad8c28a9SJeff Layton 	fsparam_u32	("write_congestion_kb",		Opt_congestion_kb),
19282995cc6SDavid Howells 	fsparam_flag_no ("copyfrom",			Opt_copyfrom),
19382995cc6SDavid Howells 	fsparam_flag_no ("dcache",			Opt_dcache),
19482995cc6SDavid Howells 	fsparam_flag_no ("dirstat",			Opt_dirstat),
19548ce73b1SAl Viro 	fsparam_flag_no	("fsc",				Opt_fscache), // fsc|nofsc
19648ce73b1SAl Viro 	fsparam_string	("fsc",				Opt_fscache), // fsc=...
19782995cc6SDavid Howells 	fsparam_flag_no ("ino32",			Opt_ino32),
19882995cc6SDavid Howells 	fsparam_string	("mds_namespace",		Opt_mds_namespace),
1996b5717bdSJeff Layton 	fsparam_string	("mon_addr",			Opt_mon_addr),
20082995cc6SDavid Howells 	fsparam_flag_no ("poolperm",			Opt_poolperm),
20182995cc6SDavid Howells 	fsparam_flag_no ("quotadf",			Opt_quotadf),
20282995cc6SDavid Howells 	fsparam_u32	("rasize",			Opt_rasize),
20382995cc6SDavid Howells 	fsparam_flag_no ("rbytes",			Opt_rbytes),
204ad8c28a9SJeff Layton 	fsparam_u32	("readdir_max_bytes",		Opt_readdir_max_bytes),
205ad8c28a9SJeff Layton 	fsparam_u32	("readdir_max_entries",		Opt_readdir_max_entries),
2062710c957SAl Viro 	fsparam_enum	("recover_session",		Opt_recover_session, ceph_param_recover),
20782995cc6SDavid Howells 	fsparam_flag_no ("require_active_mds",		Opt_require_active_mds),
20882995cc6SDavid Howells 	fsparam_u32	("rsize",			Opt_rsize),
20982995cc6SDavid Howells 	fsparam_string	("snapdirname",			Opt_snapdirname),
21082995cc6SDavid Howells 	fsparam_string	("source",			Opt_source),
2116b5717bdSJeff Layton 	fsparam_flag	("test_dummy_encryption",	Opt_test_dummy_encryption),
2126b5717bdSJeff Layton 	fsparam_string	("test_dummy_encryption",	Opt_test_dummy_encryption),
21382995cc6SDavid Howells 	fsparam_u32	("wsize",			Opt_wsize),
2142ccb4546SJeff Layton 	fsparam_flag_no	("wsync",			Opt_wsync),
21594cc0877SJeff Layton 	fsparam_flag_no	("pagecache",			Opt_pagecache),
21603bc06c7SJeff Layton 	fsparam_flag_no	("sparseread",			Opt_sparseread),
21782995cc6SDavid Howells 	{}
21882995cc6SDavid Howells };
21982995cc6SDavid Howells 
22082995cc6SDavid Howells struct ceph_parse_opts_ctx {
22182995cc6SDavid Howells 	struct ceph_options		*copts;
22282995cc6SDavid Howells 	struct ceph_mount_options	*opts;
22382995cc6SDavid Howells };
22482995cc6SDavid Howells 
22582995cc6SDavid Howells /*
226b27a939eSIlya Dryomov  * Remove adjacent slashes and then the trailing slash, unless it is
227b27a939eSIlya Dryomov  * the only remaining character.
228b27a939eSIlya Dryomov  *
229b27a939eSIlya Dryomov  * E.g. "//dir1////dir2///" --> "/dir1/dir2", "///" --> "/".
230b27a939eSIlya Dryomov  */
canonicalize_path(char * path)231b27a939eSIlya Dryomov static void canonicalize_path(char *path)
232b27a939eSIlya Dryomov {
233b27a939eSIlya Dryomov 	int i, j = 0;
234b27a939eSIlya Dryomov 
235b27a939eSIlya Dryomov 	for (i = 0; path[i] != '\0'; i++) {
236b27a939eSIlya Dryomov 		if (path[i] != '/' || j < 1 || path[j - 1] != '/')
237b27a939eSIlya Dryomov 			path[j++] = path[i];
238b27a939eSIlya Dryomov 	}
239b27a939eSIlya Dryomov 
240b27a939eSIlya Dryomov 	if (j > 1 && path[j - 1] == '/')
241b27a939eSIlya Dryomov 		j--;
242b27a939eSIlya Dryomov 	path[j] = '\0';
243b27a939eSIlya Dryomov }
244b27a939eSIlya Dryomov 
245b27a939eSIlya Dryomov /*
2467b19b4dbSVenky Shankar  * Check if the mds namespace in ceph_mount_options matches
2477b19b4dbSVenky Shankar  * the passed in namespace string. First time match (when
2487b19b4dbSVenky Shankar  * ->mds_namespace is NULL) is treated specially, since
2497b19b4dbSVenky Shankar  * ->mds_namespace needs to be initialized by the caller.
2507b19b4dbSVenky Shankar  */
namespace_equals(struct ceph_mount_options * fsopt,const char * namespace,size_t len)2517b19b4dbSVenky Shankar static int namespace_equals(struct ceph_mount_options *fsopt,
2527b19b4dbSVenky Shankar 			    const char *namespace, size_t len)
2537b19b4dbSVenky Shankar {
2547b19b4dbSVenky Shankar 	return !(fsopt->mds_namespace &&
2557b19b4dbSVenky Shankar 		 (strlen(fsopt->mds_namespace) != len ||
2567b19b4dbSVenky Shankar 		  strncmp(fsopt->mds_namespace, namespace, len)));
2577b19b4dbSVenky Shankar }
2587b19b4dbSVenky Shankar 
ceph_parse_old_source(const char * dev_name,const char * dev_name_end,struct fs_context * fc)2597b19b4dbSVenky Shankar static int ceph_parse_old_source(const char *dev_name, const char *dev_name_end,
2607b19b4dbSVenky Shankar 				 struct fs_context *fc)
2617b19b4dbSVenky Shankar {
2627b19b4dbSVenky Shankar 	int r;
2637b19b4dbSVenky Shankar 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
2647b19b4dbSVenky Shankar 	struct ceph_mount_options *fsopt = pctx->opts;
2657b19b4dbSVenky Shankar 
2667b19b4dbSVenky Shankar 	if (*dev_name_end != ':')
2677b19b4dbSVenky Shankar 		return invalfc(fc, "separator ':' missing in source");
2687b19b4dbSVenky Shankar 
2697b19b4dbSVenky Shankar 	r = ceph_parse_mon_ips(dev_name, dev_name_end - dev_name,
2707b19b4dbSVenky Shankar 			       pctx->copts, fc->log.log, ',');
2717b19b4dbSVenky Shankar 	if (r)
2727b19b4dbSVenky Shankar 		return r;
2737b19b4dbSVenky Shankar 
2747b19b4dbSVenky Shankar 	fsopt->new_dev_syntax = false;
2757b19b4dbSVenky Shankar 	return 0;
2767b19b4dbSVenky Shankar }
2777b19b4dbSVenky Shankar 
ceph_parse_new_source(const char * dev_name,const char * dev_name_end,struct fs_context * fc)2787b19b4dbSVenky Shankar static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end,
2797b19b4dbSVenky Shankar 				 struct fs_context *fc)
2807b19b4dbSVenky Shankar {
2817b19b4dbSVenky Shankar 	size_t len;
2827b19b4dbSVenky Shankar 	struct ceph_fsid fsid;
2837b19b4dbSVenky Shankar 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
2847b19b4dbSVenky Shankar 	struct ceph_mount_options *fsopt = pctx->opts;
2857b19b4dbSVenky Shankar 	char *fsid_start, *fs_name_start;
2867b19b4dbSVenky Shankar 
2877b19b4dbSVenky Shankar 	if (*dev_name_end != '=') {
2887b19b4dbSVenky Shankar 		dout("separator '=' missing in source");
2897b19b4dbSVenky Shankar 		return -EINVAL;
2907b19b4dbSVenky Shankar 	}
2917b19b4dbSVenky Shankar 
2927b19b4dbSVenky Shankar 	fsid_start = strchr(dev_name, '@');
2937b19b4dbSVenky Shankar 	if (!fsid_start)
2947b19b4dbSVenky Shankar 		return invalfc(fc, "missing cluster fsid");
2957b19b4dbSVenky Shankar 	++fsid_start; /* start of cluster fsid */
2967b19b4dbSVenky Shankar 
2977b19b4dbSVenky Shankar 	fs_name_start = strchr(fsid_start, '.');
2987b19b4dbSVenky Shankar 	if (!fs_name_start)
2997b19b4dbSVenky Shankar 		return invalfc(fc, "missing file system name");
3007b19b4dbSVenky Shankar 
3017b19b4dbSVenky Shankar 	if (ceph_parse_fsid(fsid_start, &fsid))
3027b19b4dbSVenky Shankar 		return invalfc(fc, "Invalid FSID");
3037b19b4dbSVenky Shankar 
3047b19b4dbSVenky Shankar 	++fs_name_start; /* start of file system name */
3057b19b4dbSVenky Shankar 	len = dev_name_end - fs_name_start;
3067b19b4dbSVenky Shankar 
3077b19b4dbSVenky Shankar 	if (!namespace_equals(fsopt, fs_name_start, len))
3087b19b4dbSVenky Shankar 		return invalfc(fc, "Mismatching mds_namespace");
3097b19b4dbSVenky Shankar 	kfree(fsopt->mds_namespace);
3107b19b4dbSVenky Shankar 	fsopt->mds_namespace = kstrndup(fs_name_start, len, GFP_KERNEL);
3117b19b4dbSVenky Shankar 	if (!fsopt->mds_namespace)
3127b19b4dbSVenky Shankar 		return -ENOMEM;
3137b19b4dbSVenky Shankar 	dout("file system (mds namespace) '%s'\n", fsopt->mds_namespace);
3147b19b4dbSVenky Shankar 
3157b19b4dbSVenky Shankar 	fsopt->new_dev_syntax = true;
3167b19b4dbSVenky Shankar 	return 0;
3177b19b4dbSVenky Shankar }
3187b19b4dbSVenky Shankar 
3197b19b4dbSVenky Shankar /*
3207b19b4dbSVenky Shankar  * Parse the source parameter for new device format. Distinguish the device
3217b19b4dbSVenky Shankar  * spec from the path. Try parsing new device format and fallback to old
3227b19b4dbSVenky Shankar  * format if needed.
32382995cc6SDavid Howells  *
3247b19b4dbSVenky Shankar  * New device syntax will looks like:
3257b19b4dbSVenky Shankar  *     <device_spec>=/<path>
3267b19b4dbSVenky Shankar  * where
3277b19b4dbSVenky Shankar  *     <device_spec> is name@fsid.fsname
3287b19b4dbSVenky Shankar  *     <path> is optional, but if present must begin with '/'
3297b19b4dbSVenky Shankar  * (monitor addresses are passed via mount option)
3307b19b4dbSVenky Shankar  *
3317b19b4dbSVenky Shankar  * Old device syntax is:
33282995cc6SDavid Howells  *     <server_spec>[,<server_spec>...]:[<path>]
33382995cc6SDavid Howells  * where
33482995cc6SDavid Howells  *     <server_spec> is <ip>[:<port>]
33582995cc6SDavid Howells  *     <path> is optional, but if present must begin with '/'
33682995cc6SDavid Howells  */
ceph_parse_source(struct fs_parameter * param,struct fs_context * fc)33782995cc6SDavid Howells static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
3383d14c5d2SYehuda Sadeh {
33982995cc6SDavid Howells 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
34082995cc6SDavid Howells 	struct ceph_mount_options *fsopt = pctx->opts;
34182995cc6SDavid Howells 	char *dev_name = param->string, *dev_name_end;
34282995cc6SDavid Howells 	int ret;
3433d14c5d2SYehuda Sadeh 
34482995cc6SDavid Howells 	dout("%s '%s'\n", __func__, dev_name);
34582995cc6SDavid Howells 	if (!dev_name || !*dev_name)
346d53d0f74SAl Viro 		return invalfc(fc, "Empty source");
3473d14c5d2SYehuda Sadeh 
34882995cc6SDavid Howells 	dev_name_end = strchr(dev_name, '/');
34982995cc6SDavid Howells 	if (dev_name_end) {
3504fbc0c71SXiubo Li 		/*
3514fbc0c71SXiubo Li 		 * The server_path will include the whole chars from userland
3524fbc0c71SXiubo Li 		 * including the leading '/'.
3534fbc0c71SXiubo Li 		 */
354b27a939eSIlya Dryomov 		kfree(fsopt->server_path);
35582995cc6SDavid Howells 		fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL);
35682995cc6SDavid Howells 		if (!fsopt->server_path)
35782995cc6SDavid Howells 			return -ENOMEM;
358b27a939eSIlya Dryomov 
359b27a939eSIlya Dryomov 		canonicalize_path(fsopt->server_path);
3603d14c5d2SYehuda Sadeh 	} else {
36182995cc6SDavid Howells 		dev_name_end = dev_name + strlen(dev_name);
3623d14c5d2SYehuda Sadeh 	}
3633d14c5d2SYehuda Sadeh 
3647b19b4dbSVenky Shankar 	dev_name_end--;		/* back up to separator */
3657b19b4dbSVenky Shankar 	if (dev_name_end < dev_name)
3667b19b4dbSVenky Shankar 		return invalfc(fc, "Path missing in source");
36782995cc6SDavid Howells 
36882995cc6SDavid Howells 	dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
36982995cc6SDavid Howells 	if (fsopt->server_path)
37082995cc6SDavid Howells 		dout("server path '%s'\n", fsopt->server_path);
37182995cc6SDavid Howells 
3727b19b4dbSVenky Shankar 	dout("trying new device syntax");
3737b19b4dbSVenky Shankar 	ret = ceph_parse_new_source(dev_name, dev_name_end, fc);
3747b19b4dbSVenky Shankar 	if (ret) {
3757b19b4dbSVenky Shankar 		if (ret != -EINVAL)
3767b19b4dbSVenky Shankar 			return ret;
3777b19b4dbSVenky Shankar 		dout("trying old device syntax");
3787b19b4dbSVenky Shankar 		ret = ceph_parse_old_source(dev_name, dev_name_end, fc);
37982995cc6SDavid Howells 		if (ret)
38082995cc6SDavid Howells 			return ret;
3817b19b4dbSVenky Shankar 	}
38282995cc6SDavid Howells 
38382995cc6SDavid Howells 	fc->source = param->string;
38482995cc6SDavid Howells 	param->string = NULL;
38582995cc6SDavid Howells 	return 0;
38682995cc6SDavid Howells }
38782995cc6SDavid Howells 
ceph_parse_mon_addr(struct fs_parameter * param,struct fs_context * fc)3887b19b4dbSVenky Shankar static int ceph_parse_mon_addr(struct fs_parameter *param,
3897b19b4dbSVenky Shankar 			       struct fs_context *fc)
3907b19b4dbSVenky Shankar {
3917b19b4dbSVenky Shankar 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
3927b19b4dbSVenky Shankar 	struct ceph_mount_options *fsopt = pctx->opts;
3937b19b4dbSVenky Shankar 
3947b19b4dbSVenky Shankar 	kfree(fsopt->mon_addr);
3957b19b4dbSVenky Shankar 	fsopt->mon_addr = param->string;
3967b19b4dbSVenky Shankar 	param->string = NULL;
3977b19b4dbSVenky Shankar 
3987b19b4dbSVenky Shankar 	return ceph_parse_mon_ips(fsopt->mon_addr, strlen(fsopt->mon_addr),
3997b19b4dbSVenky Shankar 				  pctx->copts, fc->log.log, '/');
4007b19b4dbSVenky Shankar }
4017b19b4dbSVenky Shankar 
ceph_parse_mount_param(struct fs_context * fc,struct fs_parameter * param)40282995cc6SDavid Howells static int ceph_parse_mount_param(struct fs_context *fc,
40382995cc6SDavid Howells 				  struct fs_parameter *param)
40482995cc6SDavid Howells {
40582995cc6SDavid Howells 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
40682995cc6SDavid Howells 	struct ceph_mount_options *fsopt = pctx->opts;
40782995cc6SDavid Howells 	struct fs_parse_result result;
40882995cc6SDavid Howells 	unsigned int mode;
40982995cc6SDavid Howells 	int token, ret;
41082995cc6SDavid Howells 
411cc3c0b53SAl Viro 	ret = ceph_parse_param(param, pctx->copts, fc->log.log);
41282995cc6SDavid Howells 	if (ret != -ENOPARAM)
41382995cc6SDavid Howells 		return ret;
41482995cc6SDavid Howells 
415d7167b14SAl Viro 	token = fs_parse(fc, ceph_mount_parameters, param, &result);
41682995cc6SDavid Howells 	dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
41782995cc6SDavid Howells 	if (token < 0)
41882995cc6SDavid Howells 		return token;
41982995cc6SDavid Howells 
4203d14c5d2SYehuda Sadeh 	switch (token) {
4213d14c5d2SYehuda Sadeh 	case Opt_snapdirname:
4223d14c5d2SYehuda Sadeh 		kfree(fsopt->snapdir_name);
42382995cc6SDavid Howells 		fsopt->snapdir_name = param->string;
42482995cc6SDavid Howells 		param->string = NULL;
4253d14c5d2SYehuda Sadeh 		break;
426235a0982SYan, Zheng 	case Opt_mds_namespace:
4277b19b4dbSVenky Shankar 		if (!namespace_equals(fsopt, param->string, strlen(param->string)))
4287b19b4dbSVenky Shankar 			return invalfc(fc, "Mismatching mds_namespace");
429937441f3SChengguang Xu 		kfree(fsopt->mds_namespace);
43082995cc6SDavid Howells 		fsopt->mds_namespace = param->string;
43182995cc6SDavid Howells 		param->string = NULL;
432235a0982SYan, Zheng 		break;
433131d7eb4SYan, Zheng 	case Opt_recover_session:
43482995cc6SDavid Howells 		mode = result.uint_32;
43582995cc6SDavid Howells 		if (mode == ceph_recover_session_no)
436131d7eb4SYan, Zheng 			fsopt->flags &= ~CEPH_MOUNT_OPT_CLEANRECOVER;
43782995cc6SDavid Howells 		else if (mode == ceph_recover_session_clean)
438131d7eb4SYan, Zheng 			fsopt->flags |= CEPH_MOUNT_OPT_CLEANRECOVER;
43982995cc6SDavid Howells 		else
44082995cc6SDavid Howells 			BUG();
441131d7eb4SYan, Zheng 		break;
44282995cc6SDavid Howells 	case Opt_source:
44382995cc6SDavid Howells 		if (fc->source)
444d53d0f74SAl Viro 			return invalfc(fc, "Multiple sources specified");
44582995cc6SDavid Howells 		return ceph_parse_source(param, fc);
4467b19b4dbSVenky Shankar 	case Opt_mon_addr:
4477b19b4dbSVenky Shankar 		return ceph_parse_mon_addr(param, fc);
4483d14c5d2SYehuda Sadeh 	case Opt_wsize:
44982995cc6SDavid Howells 		if (result.uint_32 < PAGE_SIZE ||
45082995cc6SDavid Howells 		    result.uint_32 > CEPH_MAX_WRITE_SIZE)
45182995cc6SDavid Howells 			goto out_of_range;
45282995cc6SDavid Howells 		fsopt->wsize = ALIGN(result.uint_32, PAGE_SIZE);
4533d14c5d2SYehuda Sadeh 		break;
4543d14c5d2SYehuda Sadeh 	case Opt_rsize:
45582995cc6SDavid Howells 		if (result.uint_32 < PAGE_SIZE ||
45682995cc6SDavid Howells 		    result.uint_32 > CEPH_MAX_READ_SIZE)
45782995cc6SDavid Howells 			goto out_of_range;
45882995cc6SDavid Howells 		fsopt->rsize = ALIGN(result.uint_32, PAGE_SIZE);
4593d14c5d2SYehuda Sadeh 		break;
46083817e35SSage Weil 	case Opt_rasize:
46182995cc6SDavid Howells 		fsopt->rasize = ALIGN(result.uint_32, PAGE_SIZE);
46283817e35SSage Weil 		break;
4633d14c5d2SYehuda Sadeh 	case Opt_caps_wanted_delay_min:
46482995cc6SDavid Howells 		if (result.uint_32 < 1)
46582995cc6SDavid Howells 			goto out_of_range;
46682995cc6SDavid Howells 		fsopt->caps_wanted_delay_min = result.uint_32;
4673d14c5d2SYehuda Sadeh 		break;
4683d14c5d2SYehuda Sadeh 	case Opt_caps_wanted_delay_max:
46982995cc6SDavid Howells 		if (result.uint_32 < 1)
47082995cc6SDavid Howells 			goto out_of_range;
47182995cc6SDavid Howells 		fsopt->caps_wanted_delay_max = result.uint_32;
4723d14c5d2SYehuda Sadeh 		break;
473fe33032dSYan, Zheng 	case Opt_caps_max:
474ad8c28a9SJeff Layton 		if (result.int_32 < 0)
475ad8c28a9SJeff Layton 			goto out_of_range;
476ad8c28a9SJeff Layton 		fsopt->caps_max = result.int_32;
477fe33032dSYan, Zheng 		break;
4783d14c5d2SYehuda Sadeh 	case Opt_readdir_max_entries:
47982995cc6SDavid Howells 		if (result.uint_32 < 1)
48082995cc6SDavid Howells 			goto out_of_range;
48182995cc6SDavid Howells 		fsopt->max_readdir = result.uint_32;
4823d14c5d2SYehuda Sadeh 		break;
4833d14c5d2SYehuda Sadeh 	case Opt_readdir_max_bytes:
48482995cc6SDavid Howells 		if (result.uint_32 < PAGE_SIZE && result.uint_32 != 0)
48582995cc6SDavid Howells 			goto out_of_range;
48682995cc6SDavid Howells 		fsopt->max_readdir_bytes = result.uint_32;
4873d14c5d2SYehuda Sadeh 		break;
4883d14c5d2SYehuda Sadeh 	case Opt_congestion_kb:
48982995cc6SDavid Howells 		if (result.uint_32 < 1024) /* at least 1M */
49082995cc6SDavid Howells 			goto out_of_range;
49182995cc6SDavid Howells 		fsopt->congestion_kb = result.uint_32;
4923d14c5d2SYehuda Sadeh 		break;
4933d14c5d2SYehuda Sadeh 	case Opt_dirstat:
49482995cc6SDavid Howells 		if (!result.negated)
4953d14c5d2SYehuda Sadeh 			fsopt->flags |= CEPH_MOUNT_OPT_DIRSTAT;
49682995cc6SDavid Howells 		else
4973d14c5d2SYehuda Sadeh 			fsopt->flags &= ~CEPH_MOUNT_OPT_DIRSTAT;
4983d14c5d2SYehuda Sadeh 		break;
4993d14c5d2SYehuda Sadeh 	case Opt_rbytes:
50082995cc6SDavid Howells 		if (!result.negated)
5013d14c5d2SYehuda Sadeh 			fsopt->flags |= CEPH_MOUNT_OPT_RBYTES;
50282995cc6SDavid Howells 		else
5033d14c5d2SYehuda Sadeh 			fsopt->flags &= ~CEPH_MOUNT_OPT_RBYTES;
5043d14c5d2SYehuda Sadeh 		break;
505cffaba15SAlex Elder 	case Opt_asyncreaddir:
50682995cc6SDavid Howells 		if (!result.negated)
507cffaba15SAlex Elder 			fsopt->flags &= ~CEPH_MOUNT_OPT_NOASYNCREADDIR;
50882995cc6SDavid Howells 		else
5093d14c5d2SYehuda Sadeh 			fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR;
5103d14c5d2SYehuda Sadeh 		break;
511a40dc6ccSSage Weil 	case Opt_dcache:
51282995cc6SDavid Howells 		if (!result.negated)
513a40dc6ccSSage Weil 			fsopt->flags |= CEPH_MOUNT_OPT_DCACHE;
51482995cc6SDavid Howells 		else
515a40dc6ccSSage Weil 			fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE;
516a40dc6ccSSage Weil 		break;
517ad1fee96SYehuda Sadeh 	case Opt_ino32:
51882995cc6SDavid Howells 		if (!result.negated)
519ad1fee96SYehuda Sadeh 			fsopt->flags |= CEPH_MOUNT_OPT_INO32;
52082995cc6SDavid Howells 		else
521cffaba15SAlex Elder 			fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;
522cffaba15SAlex Elder 		break;
52382995cc6SDavid Howells 
52499ccbd22SMilosz Tanski 	case Opt_fscache:
525ff29fde8SJeff Layton #ifdef CONFIG_CEPH_FSCACHE
5267ae7a828SChengguang Xu 		kfree(fsopt->fscache_uniq);
5277ae7a828SChengguang Xu 		fsopt->fscache_uniq = NULL;
52882995cc6SDavid Howells 		if (result.negated) {
52982995cc6SDavid Howells 			fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
53082995cc6SDavid Howells 		} else {
53182995cc6SDavid Howells 			fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
53282995cc6SDavid Howells 			fsopt->fscache_uniq = param->string;
53382995cc6SDavid Howells 			param->string = NULL;
53482995cc6SDavid Howells 		}
53599ccbd22SMilosz Tanski 		break;
536ff29fde8SJeff Layton #else
537d53d0f74SAl Viro 		return invalfc(fc, "fscache support is disabled");
538ff29fde8SJeff Layton #endif
53910183a69SYan, Zheng 	case Opt_poolperm:
54082995cc6SDavid Howells 		if (!result.negated)
54110183a69SYan, Zheng 			fsopt->flags &= ~CEPH_MOUNT_OPT_NOPOOLPERM;
54282995cc6SDavid Howells 		else
54310183a69SYan, Zheng 			fsopt->flags |= CEPH_MOUNT_OPT_NOPOOLPERM;
54410183a69SYan, Zheng 		break;
545e9e427f0SYan, Zheng 	case Opt_require_active_mds:
54682995cc6SDavid Howells 		if (!result.negated)
547e9e427f0SYan, Zheng 			fsopt->flags &= ~CEPH_MOUNT_OPT_MOUNTWAIT;
54882995cc6SDavid Howells 		else
549e9e427f0SYan, Zheng 			fsopt->flags |= CEPH_MOUNT_OPT_MOUNTWAIT;
550e9e427f0SYan, Zheng 		break;
5519122eed5SLuis Henriques 	case Opt_quotadf:
55282995cc6SDavid Howells 		if (!result.negated)
5539122eed5SLuis Henriques 			fsopt->flags &= ~CEPH_MOUNT_OPT_NOQUOTADF;
55482995cc6SDavid Howells 		else
5559122eed5SLuis Henriques 			fsopt->flags |= CEPH_MOUNT_OPT_NOQUOTADF;
5569122eed5SLuis Henriques 		break;
557ea4cdc54SLuis Henriques 	case Opt_copyfrom:
55882995cc6SDavid Howells 		if (!result.negated)
559ea4cdc54SLuis Henriques 			fsopt->flags &= ~CEPH_MOUNT_OPT_NOCOPYFROM;
56082995cc6SDavid Howells 		else
561ea4cdc54SLuis Henriques 			fsopt->flags |= CEPH_MOUNT_OPT_NOCOPYFROM;
562ea4cdc54SLuis Henriques 		break;
56345195e42SSage Weil 	case Opt_acl:
56482995cc6SDavid Howells 		if (!result.negated) {
56582995cc6SDavid Howells #ifdef CONFIG_CEPH_FS_POSIX_ACL
56682995cc6SDavid Howells 			fc->sb_flags |= SB_POSIXACL;
56782995cc6SDavid Howells #else
568d53d0f74SAl Viro 			return invalfc(fc, "POSIX ACL support is disabled");
56945195e42SSage Weil #endif
57082995cc6SDavid Howells 		} else {
57182995cc6SDavid Howells 			fc->sb_flags &= ~SB_POSIXACL;
57282995cc6SDavid Howells 		}
57345195e42SSage Weil 		break;
5742ccb4546SJeff Layton 	case Opt_wsync:
5752ccb4546SJeff Layton 		if (!result.negated)
5762ccb4546SJeff Layton 			fsopt->flags &= ~CEPH_MOUNT_OPT_ASYNC_DIROPS;
5772ccb4546SJeff Layton 		else
5782ccb4546SJeff Layton 			fsopt->flags |= CEPH_MOUNT_OPT_ASYNC_DIROPS;
5792ccb4546SJeff Layton 		break;
58094cc0877SJeff Layton 	case Opt_pagecache:
58194cc0877SJeff Layton 		if (result.negated)
58294cc0877SJeff Layton 			fsopt->flags |= CEPH_MOUNT_OPT_NOPAGECACHE;
58394cc0877SJeff Layton 		else
58494cc0877SJeff Layton 			fsopt->flags &= ~CEPH_MOUNT_OPT_NOPAGECACHE;
58594cc0877SJeff Layton 		break;
58603bc06c7SJeff Layton 	case Opt_sparseread:
58703bc06c7SJeff Layton 		if (result.negated)
58803bc06c7SJeff Layton 			fsopt->flags &= ~CEPH_MOUNT_OPT_SPARSEREAD;
58903bc06c7SJeff Layton 		else
59003bc06c7SJeff Layton 			fsopt->flags |= CEPH_MOUNT_OPT_SPARSEREAD;
59103bc06c7SJeff Layton 		break;
5926b5717bdSJeff Layton 	case Opt_test_dummy_encryption:
5936b5717bdSJeff Layton #ifdef CONFIG_FS_ENCRYPTION
5946b5717bdSJeff Layton 		fscrypt_free_dummy_policy(&fsopt->dummy_enc_policy);
5956b5717bdSJeff Layton 		ret = fscrypt_parse_test_dummy_encryption(param,
5966b5717bdSJeff Layton 						&fsopt->dummy_enc_policy);
5976b5717bdSJeff Layton 		if (ret == -EINVAL) {
5986b5717bdSJeff Layton 			warnfc(fc, "Value of option \"%s\" is unrecognized",
5996b5717bdSJeff Layton 			       param->key);
6006b5717bdSJeff Layton 		} else if (ret == -EEXIST) {
6016b5717bdSJeff Layton 			warnfc(fc, "Conflicting test_dummy_encryption options");
6026b5717bdSJeff Layton 			ret = -EINVAL;
6036b5717bdSJeff Layton 		}
6046b5717bdSJeff Layton #else
6056b5717bdSJeff Layton 		warnfc(fc,
6066b5717bdSJeff Layton 		       "FS encryption not supported: test_dummy_encryption mount option ignored");
6076b5717bdSJeff Layton #endif
6086b5717bdSJeff Layton 		break;
6093d14c5d2SYehuda Sadeh 	default:
61082995cc6SDavid Howells 		BUG();
6113d14c5d2SYehuda Sadeh 	}
6123d14c5d2SYehuda Sadeh 	return 0;
61382995cc6SDavid Howells 
61482995cc6SDavid Howells out_of_range:
615d53d0f74SAl Viro 	return invalfc(fc, "%s out of range", param->key);
6163d14c5d2SYehuda Sadeh }
6173d14c5d2SYehuda Sadeh 
destroy_mount_options(struct ceph_mount_options * args)6183d14c5d2SYehuda Sadeh static void destroy_mount_options(struct ceph_mount_options *args)
6193d14c5d2SYehuda Sadeh {
6203d14c5d2SYehuda Sadeh 	dout("destroy_mount_options %p\n", args);
62182995cc6SDavid Howells 	if (!args)
62282995cc6SDavid Howells 		return;
62382995cc6SDavid Howells 
6243d14c5d2SYehuda Sadeh 	kfree(args->snapdir_name);
625430afbadSYan, Zheng 	kfree(args->mds_namespace);
6263f384954SYan, Zheng 	kfree(args->server_path);
6271d8f8360SYan, Zheng 	kfree(args->fscache_uniq);
6287b19b4dbSVenky Shankar 	kfree(args->mon_addr);
6296b5717bdSJeff Layton 	fscrypt_free_dummy_policy(&args->dummy_enc_policy);
6303d14c5d2SYehuda Sadeh 	kfree(args);
6313d14c5d2SYehuda Sadeh }
6323d14c5d2SYehuda Sadeh 
strcmp_null(const char * s1,const char * s2)6333d14c5d2SYehuda Sadeh static int strcmp_null(const char *s1, const char *s2)
6343d14c5d2SYehuda Sadeh {
6353d14c5d2SYehuda Sadeh 	if (!s1 && !s2)
6363d14c5d2SYehuda Sadeh 		return 0;
6373d14c5d2SYehuda Sadeh 	if (s1 && !s2)
6383d14c5d2SYehuda Sadeh 		return -1;
6393d14c5d2SYehuda Sadeh 	if (!s1 && s2)
6403d14c5d2SYehuda Sadeh 		return 1;
6413d14c5d2SYehuda Sadeh 	return strcmp(s1, s2);
6423d14c5d2SYehuda Sadeh }
6433d14c5d2SYehuda Sadeh 
compare_mount_options(struct ceph_mount_options * new_fsopt,struct ceph_options * new_opt,struct ceph_fs_client * fsc)6443d14c5d2SYehuda Sadeh static int compare_mount_options(struct ceph_mount_options *new_fsopt,
6453d14c5d2SYehuda Sadeh 				 struct ceph_options *new_opt,
6463d14c5d2SYehuda Sadeh 				 struct ceph_fs_client *fsc)
6473d14c5d2SYehuda Sadeh {
6483d14c5d2SYehuda Sadeh 	struct ceph_mount_options *fsopt1 = new_fsopt;
6493d14c5d2SYehuda Sadeh 	struct ceph_mount_options *fsopt2 = fsc->mount_options;
6503d14c5d2SYehuda Sadeh 	int ofs = offsetof(struct ceph_mount_options, snapdir_name);
6513d14c5d2SYehuda Sadeh 	int ret;
6523d14c5d2SYehuda Sadeh 
6533d14c5d2SYehuda Sadeh 	ret = memcmp(fsopt1, fsopt2, ofs);
6543d14c5d2SYehuda Sadeh 	if (ret)
6553d14c5d2SYehuda Sadeh 		return ret;
6563d14c5d2SYehuda Sadeh 
6573d14c5d2SYehuda Sadeh 	ret = strcmp_null(fsopt1->snapdir_name, fsopt2->snapdir_name);
6583d14c5d2SYehuda Sadeh 	if (ret)
6593d14c5d2SYehuda Sadeh 		return ret;
660b27a939eSIlya Dryomov 
661430afbadSYan, Zheng 	ret = strcmp_null(fsopt1->mds_namespace, fsopt2->mds_namespace);
662430afbadSYan, Zheng 	if (ret)
663430afbadSYan, Zheng 		return ret;
6644fbc0c71SXiubo Li 
665b27a939eSIlya Dryomov 	ret = strcmp_null(fsopt1->server_path, fsopt2->server_path);
6663f384954SYan, Zheng 	if (ret)
6673f384954SYan, Zheng 		return ret;
6684fbc0c71SXiubo Li 
6691d8f8360SYan, Zheng 	ret = strcmp_null(fsopt1->fscache_uniq, fsopt2->fscache_uniq);
6701d8f8360SYan, Zheng 	if (ret)
6711d8f8360SYan, Zheng 		return ret;
6723f384954SYan, Zheng 
6737b19b4dbSVenky Shankar 	ret = strcmp_null(fsopt1->mon_addr, fsopt2->mon_addr);
6747b19b4dbSVenky Shankar 	if (ret)
6757b19b4dbSVenky Shankar 		return ret;
6767b19b4dbSVenky Shankar 
6773d14c5d2SYehuda Sadeh 	return ceph_compare_options(new_opt, fsc->client);
6783d14c5d2SYehuda Sadeh }
6793d14c5d2SYehuda Sadeh 
6806e19a16eSSage Weil /**
6816e19a16eSSage Weil  * ceph_show_options - Show mount options in /proc/mounts
6826e19a16eSSage Weil  * @m: seq_file to write to
68334c80b1dSAl Viro  * @root: root of that (sub)tree
6846e19a16eSSage Weil  */
ceph_show_options(struct seq_file * m,struct dentry * root)68534c80b1dSAl Viro static int ceph_show_options(struct seq_file *m, struct dentry *root)
6866e19a16eSSage Weil {
687985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(root->d_sb);
6883d14c5d2SYehuda Sadeh 	struct ceph_mount_options *fsopt = fsc->mount_options;
689ff40f9aeSIlya Dryomov 	size_t pos;
690ff40f9aeSIlya Dryomov 	int ret;
6916e19a16eSSage Weil 
692ff40f9aeSIlya Dryomov 	/* a comma between MNT/MS and client options */
693ff40f9aeSIlya Dryomov 	seq_putc(m, ',');
694ff40f9aeSIlya Dryomov 	pos = m->count;
6953d14c5d2SYehuda Sadeh 
69602b2f549SDongsheng Yang 	ret = ceph_print_client_options(m, fsc->client, false);
697ff40f9aeSIlya Dryomov 	if (ret)
698ff40f9aeSIlya Dryomov 		return ret;
6993d14c5d2SYehuda Sadeh 
700ff40f9aeSIlya Dryomov 	/* retract our comma if no client options */
701ff40f9aeSIlya Dryomov 	if (m->count == pos)
702ff40f9aeSIlya Dryomov 		m->count--;
7033d14c5d2SYehuda Sadeh 
7043d14c5d2SYehuda Sadeh 	if (fsopt->flags & CEPH_MOUNT_OPT_DIRSTAT)
7053d14c5d2SYehuda Sadeh 		seq_puts(m, ",dirstat");
706133e9156SYan, Zheng 	if ((fsopt->flags & CEPH_MOUNT_OPT_RBYTES))
707133e9156SYan, Zheng 		seq_puts(m, ",rbytes");
7083d14c5d2SYehuda Sadeh 	if (fsopt->flags & CEPH_MOUNT_OPT_NOASYNCREADDIR)
7096e19a16eSSage Weil 		seq_puts(m, ",noasyncreaddir");
710ff7eeb82SIlya Dryomov 	if ((fsopt->flags & CEPH_MOUNT_OPT_DCACHE) == 0)
711a40dc6ccSSage Weil 		seq_puts(m, ",nodcache");
7123619aa8bSChengguang Xu 	if (fsopt->flags & CEPH_MOUNT_OPT_INO32)
7133619aa8bSChengguang Xu 		seq_puts(m, ",ino32");
7141d8f8360SYan, Zheng 	if (fsopt->flags & CEPH_MOUNT_OPT_FSCACHE) {
7154d8969afSChengguang Xu 		seq_show_option(m, "fsc", fsopt->fscache_uniq);
7161d8f8360SYan, Zheng 	}
71710183a69SYan, Zheng 	if (fsopt->flags & CEPH_MOUNT_OPT_NOPOOLPERM)
71810183a69SYan, Zheng 		seq_puts(m, ",nopoolperm");
7199122eed5SLuis Henriques 	if (fsopt->flags & CEPH_MOUNT_OPT_NOQUOTADF)
7209122eed5SLuis Henriques 		seq_puts(m, ",noquotadf");
7216e19a16eSSage Weil 
72245195e42SSage Weil #ifdef CONFIG_CEPH_FS_POSIX_ACL
72382995cc6SDavid Howells 	if (root->d_sb->s_flags & SB_POSIXACL)
72445195e42SSage Weil 		seq_puts(m, ",acl");
72545195e42SSage Weil 	else
72645195e42SSage Weil 		seq_puts(m, ",noacl");
72745195e42SSage Weil #endif
72845195e42SSage Weil 
7296f9718feSLuis Henriques 	if ((fsopt->flags & CEPH_MOUNT_OPT_NOCOPYFROM) == 0)
7306f9718feSLuis Henriques 		seq_puts(m, ",copyfrom");
731ea4cdc54SLuis Henriques 
7327b19b4dbSVenky Shankar 	/* dump mds_namespace when old device syntax is in use */
7337b19b4dbSVenky Shankar 	if (fsopt->mds_namespace && !fsopt->new_dev_syntax)
7344d8969afSChengguang Xu 		seq_show_option(m, "mds_namespace", fsopt->mds_namespace);
735131d7eb4SYan, Zheng 
7367b19b4dbSVenky Shankar 	if (fsopt->mon_addr)
7377b19b4dbSVenky Shankar 		seq_printf(m, ",mon_addr=%s", fsopt->mon_addr);
7387b19b4dbSVenky Shankar 
739131d7eb4SYan, Zheng 	if (fsopt->flags & CEPH_MOUNT_OPT_CLEANRECOVER)
740131d7eb4SYan, Zheng 		seq_show_option(m, "recover_session", "clean");
741131d7eb4SYan, Zheng 
742f7a67b46SJeff Layton 	if (!(fsopt->flags & CEPH_MOUNT_OPT_ASYNC_DIROPS))
743f7a67b46SJeff Layton 		seq_puts(m, ",wsync");
74494cc0877SJeff Layton 	if (fsopt->flags & CEPH_MOUNT_OPT_NOPAGECACHE)
74594cc0877SJeff Layton 		seq_puts(m, ",nopagecache");
74603bc06c7SJeff Layton 	if (fsopt->flags & CEPH_MOUNT_OPT_SPARSEREAD)
74703bc06c7SJeff Layton 		seq_puts(m, ",sparseread");
74894cc0877SJeff Layton 
7496b5717bdSJeff Layton 	fscrypt_show_test_dummy_encryption(m, ',', root->d_sb);
7506b5717bdSJeff Layton 
7516dd4940bSIlya Dryomov 	if (fsopt->wsize != CEPH_MAX_WRITE_SIZE)
752ad8c28a9SJeff Layton 		seq_printf(m, ",wsize=%u", fsopt->wsize);
753aa187926SYan, Zheng 	if (fsopt->rsize != CEPH_MAX_READ_SIZE)
754ad8c28a9SJeff Layton 		seq_printf(m, ",rsize=%u", fsopt->rsize);
75583817e35SSage Weil 	if (fsopt->rasize != CEPH_RASIZE_DEFAULT)
756ad8c28a9SJeff Layton 		seq_printf(m, ",rasize=%u", fsopt->rasize);
7573d14c5d2SYehuda Sadeh 	if (fsopt->congestion_kb != default_congestion_kb())
758ad8c28a9SJeff Layton 		seq_printf(m, ",write_congestion_kb=%u", fsopt->congestion_kb);
759fe33032dSYan, Zheng 	if (fsopt->caps_max)
760fe33032dSYan, Zheng 		seq_printf(m, ",caps_max=%d", fsopt->caps_max);
7613d14c5d2SYehuda Sadeh 	if (fsopt->caps_wanted_delay_min != CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT)
762ad8c28a9SJeff Layton 		seq_printf(m, ",caps_wanted_delay_min=%u",
7633d14c5d2SYehuda Sadeh 			 fsopt->caps_wanted_delay_min);
7643d14c5d2SYehuda Sadeh 	if (fsopt->caps_wanted_delay_max != CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT)
765ad8c28a9SJeff Layton 		seq_printf(m, ",caps_wanted_delay_max=%u",
7663d14c5d2SYehuda Sadeh 			   fsopt->caps_wanted_delay_max);
7673d14c5d2SYehuda Sadeh 	if (fsopt->max_readdir != CEPH_MAX_READDIR_DEFAULT)
768ad8c28a9SJeff Layton 		seq_printf(m, ",readdir_max_entries=%u", fsopt->max_readdir);
7693d14c5d2SYehuda Sadeh 	if (fsopt->max_readdir_bytes != CEPH_MAX_READDIR_BYTES_DEFAULT)
770ad8c28a9SJeff Layton 		seq_printf(m, ",readdir_max_bytes=%u", fsopt->max_readdir_bytes);
7713d14c5d2SYehuda Sadeh 	if (strcmp(fsopt->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT))
772a068acf2SKees Cook 		seq_show_option(m, "snapdirname", fsopt->snapdir_name);
773ff40f9aeSIlya Dryomov 
7746e19a16eSSage Weil 	return 0;
7756e19a16eSSage Weil }
7766e19a16eSSage Weil 
7776e19a16eSSage Weil /*
7783d14c5d2SYehuda Sadeh  * handle any mon messages the standard library doesn't understand.
7793d14c5d2SYehuda Sadeh  * return error if we don't either.
7803d14c5d2SYehuda Sadeh  */
extra_mon_dispatch(struct ceph_client * client,struct ceph_msg * msg)7813d14c5d2SYehuda Sadeh static int extra_mon_dispatch(struct ceph_client *client, struct ceph_msg *msg)
7823d14c5d2SYehuda Sadeh {
7833d14c5d2SYehuda Sadeh 	struct ceph_fs_client *fsc = client->private;
7843d14c5d2SYehuda Sadeh 	int type = le16_to_cpu(msg->hdr.type);
7853d14c5d2SYehuda Sadeh 
7863d14c5d2SYehuda Sadeh 	switch (type) {
7873d14c5d2SYehuda Sadeh 	case CEPH_MSG_MDS_MAP:
788430afbadSYan, Zheng 		ceph_mdsc_handle_mdsmap(fsc->mdsc, msg);
7893d14c5d2SYehuda Sadeh 		return 0;
790430afbadSYan, Zheng 	case CEPH_MSG_FS_MAP_USER:
791430afbadSYan, Zheng 		ceph_mdsc_handle_fsmap(fsc->mdsc, msg);
792430afbadSYan, Zheng 		return 0;
7933d14c5d2SYehuda Sadeh 	default:
7943d14c5d2SYehuda Sadeh 		return -1;
7953d14c5d2SYehuda Sadeh 	}
7963d14c5d2SYehuda Sadeh }
7973d14c5d2SYehuda Sadeh 
7983d14c5d2SYehuda Sadeh /*
7993d14c5d2SYehuda Sadeh  * create a new fs client
8008aaff151SIlya Dryomov  *
8018aaff151SIlya Dryomov  * Success or not, this function consumes @fsopt and @opt.
8023d14c5d2SYehuda Sadeh  */
create_fs_client(struct ceph_mount_options * fsopt,struct ceph_options * opt)8030c6d4b4eSH Hartley Sweeten static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
8043d14c5d2SYehuda Sadeh 					struct ceph_options *opt)
8053d14c5d2SYehuda Sadeh {
8063d14c5d2SYehuda Sadeh 	struct ceph_fs_client *fsc;
8078aaff151SIlya Dryomov 	int err;
8083d14c5d2SYehuda Sadeh 
8093d14c5d2SYehuda Sadeh 	fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
8108aaff151SIlya Dryomov 	if (!fsc) {
8118aaff151SIlya Dryomov 		err = -ENOMEM;
8128aaff151SIlya Dryomov 		goto fail;
8138aaff151SIlya Dryomov 	}
8143d14c5d2SYehuda Sadeh 
81574da4a0fSIlya Dryomov 	fsc->client = ceph_create_client(opt, fsc);
8163d14c5d2SYehuda Sadeh 	if (IS_ERR(fsc->client)) {
8173d14c5d2SYehuda Sadeh 		err = PTR_ERR(fsc->client);
8183d14c5d2SYehuda Sadeh 		goto fail;
8193d14c5d2SYehuda Sadeh 	}
8208aaff151SIlya Dryomov 	opt = NULL; /* fsc->client now owns this */
821c843d13cSIlya Dryomov 
8223d14c5d2SYehuda Sadeh 	fsc->client->extra_mon_dispatch = extra_mon_dispatch;
82302b2f549SDongsheng Yang 	ceph_set_opt(fsc->client, ABORT_ON_FULL);
824430afbadSYan, Zheng 
825d37b1d99SMarkus Elfring 	if (!fsopt->mds_namespace) {
826430afbadSYan, Zheng 		ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
827430afbadSYan, Zheng 				   0, true);
828430afbadSYan, Zheng 	} else {
829430afbadSYan, Zheng 		ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
830430afbadSYan, Zheng 				   0, false);
831430afbadSYan, Zheng 	}
8323d14c5d2SYehuda Sadeh 
8333d14c5d2SYehuda Sadeh 	fsc->mount_options = fsopt;
8343d14c5d2SYehuda Sadeh 
8353d14c5d2SYehuda Sadeh 	fsc->sb = NULL;
8363d14c5d2SYehuda Sadeh 	fsc->mount_state = CEPH_MOUNT_MOUNTING;
83781f148a9SYan, Zheng 	fsc->filp_gen = 1;
83878beb0ffSLuis Henriques 	fsc->have_copy_from2 = true;
8393d14c5d2SYehuda Sadeh 
8403d14c5d2SYehuda Sadeh 	atomic_long_set(&fsc->writeback_count, 0);
841503d4fa6SNeilBrown 	fsc->write_congested = false;
8423d14c5d2SYehuda Sadeh 
8433d14c5d2SYehuda Sadeh 	err = -ENOMEM;
84401e6acc4STejun Heo 	/*
84501e6acc4STejun Heo 	 * The number of concurrent works can be high but they don't need
84601e6acc4STejun Heo 	 * to be processed in parallel, limit concurrency.
84701e6acc4STejun Heo 	 */
8481cf89a8dSYan, Zheng 	fsc->inode_wq = alloc_workqueue("ceph-inode", WQ_UNBOUND, 0);
8491cf89a8dSYan, Zheng 	if (!fsc->inode_wq)
85009dc9fc2SJan Kara 		goto fail_client;
851e3ec8d68SYan, Zheng 	fsc->cap_wq = alloc_workqueue("ceph-cap", 0, 1);
852e3ec8d68SYan, Zheng 	if (!fsc->cap_wq)
8531cf89a8dSYan, Zheng 		goto fail_inode_wq;
8543d14c5d2SYehuda Sadeh 
8554868e537SXiubo Li 	hash_init(fsc->async_unlink_conflict);
8564868e537SXiubo Li 	spin_lock_init(&fsc->async_unlink_conflict_lock);
8574868e537SXiubo Li 
85818f473b3SXiubo Li 	spin_lock(&ceph_fsc_lock);
85918f473b3SXiubo Li 	list_add_tail(&fsc->metric_wakeup, &ceph_fsc_list);
86018f473b3SXiubo Li 	spin_unlock(&ceph_fsc_lock);
86118f473b3SXiubo Li 
8623d14c5d2SYehuda Sadeh 	return fsc;
8633d14c5d2SYehuda Sadeh 
8641cf89a8dSYan, Zheng fail_inode_wq:
8651cf89a8dSYan, Zheng 	destroy_workqueue(fsc->inode_wq);
8663d14c5d2SYehuda Sadeh fail_client:
8673d14c5d2SYehuda Sadeh 	ceph_destroy_client(fsc->client);
8683d14c5d2SYehuda Sadeh fail:
8693d14c5d2SYehuda Sadeh 	kfree(fsc);
8708aaff151SIlya Dryomov 	if (opt)
8718aaff151SIlya Dryomov 		ceph_destroy_options(opt);
8728aaff151SIlya Dryomov 	destroy_mount_options(fsopt);
8733d14c5d2SYehuda Sadeh 	return ERR_PTR(err);
8743d14c5d2SYehuda Sadeh }
8753d14c5d2SYehuda Sadeh 
flush_fs_workqueues(struct ceph_fs_client * fsc)876a57d9064SYan, Zheng static void flush_fs_workqueues(struct ceph_fs_client *fsc)
877a57d9064SYan, Zheng {
8781cf89a8dSYan, Zheng 	flush_workqueue(fsc->inode_wq);
879e3ec8d68SYan, Zheng 	flush_workqueue(fsc->cap_wq);
880a57d9064SYan, Zheng }
881a57d9064SYan, Zheng 
destroy_fs_client(struct ceph_fs_client * fsc)8820c6d4b4eSH Hartley Sweeten static void destroy_fs_client(struct ceph_fs_client *fsc)
8833d14c5d2SYehuda Sadeh {
8843d14c5d2SYehuda Sadeh 	dout("destroy_fs_client %p\n", fsc);
8853d14c5d2SYehuda Sadeh 
88618f473b3SXiubo Li 	spin_lock(&ceph_fsc_lock);
88718f473b3SXiubo Li 	list_del(&fsc->metric_wakeup);
88818f473b3SXiubo Li 	spin_unlock(&ceph_fsc_lock);
88918f473b3SXiubo Li 
8903ee5a701SJeff Layton 	ceph_mdsc_destroy(fsc);
8911cf89a8dSYan, Zheng 	destroy_workqueue(fsc->inode_wq);
892e3ec8d68SYan, Zheng 	destroy_workqueue(fsc->cap_wq);
8933d14c5d2SYehuda Sadeh 
8943d14c5d2SYehuda Sadeh 	destroy_mount_options(fsc->mount_options);
8953d14c5d2SYehuda Sadeh 
8963d14c5d2SYehuda Sadeh 	ceph_destroy_client(fsc->client);
8973d14c5d2SYehuda Sadeh 
8983d14c5d2SYehuda Sadeh 	kfree(fsc);
8993d14c5d2SYehuda Sadeh 	dout("destroy_fs_client %p done\n", fsc);
9003d14c5d2SYehuda Sadeh }
9013d14c5d2SYehuda Sadeh 
9023d14c5d2SYehuda Sadeh /*
9036e19a16eSSage Weil  * caches
9046e19a16eSSage Weil  */
9056e19a16eSSage Weil struct kmem_cache *ceph_inode_cachep;
9066e19a16eSSage Weil struct kmem_cache *ceph_cap_cachep;
907ab58a5a1SXiubo Li struct kmem_cache *ceph_cap_snap_cachep;
908f66fd9f0SYan, Zheng struct kmem_cache *ceph_cap_flush_cachep;
9096e19a16eSSage Weil struct kmem_cache *ceph_dentry_cachep;
9106e19a16eSSage Weil struct kmem_cache *ceph_file_cachep;
911bb48bd4dSChengguang Xu struct kmem_cache *ceph_dir_file_cachep;
912058daab7SJeff Layton struct kmem_cache *ceph_mds_request_cachep;
913a0102bdaSJeff Layton mempool_t *ceph_wb_pagevec_pool;
9146e19a16eSSage Weil 
ceph_inode_init_once(void * foo)9156e19a16eSSage Weil static void ceph_inode_init_once(void *foo)
9166e19a16eSSage Weil {
9176e19a16eSSage Weil 	struct ceph_inode_info *ci = foo;
918874c8ca1SDavid Howells 	inode_init_once(&ci->netfs.inode);
9196e19a16eSSage Weil }
9206e19a16eSSage Weil 
init_caches(void)92116725b9dSSage Weil static int __init init_caches(void)
92216725b9dSSage Weil {
92399ccbd22SMilosz Tanski 	int error = -ENOMEM;
92499ccbd22SMilosz Tanski 
92516725b9dSSage Weil 	ceph_inode_cachep = kmem_cache_create("ceph_inode_info",
92616725b9dSSage Weil 				      sizeof(struct ceph_inode_info),
92716725b9dSSage Weil 				      __alignof__(struct ceph_inode_info),
9285d097056SVladimir Davydov 				      SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
9295d097056SVladimir Davydov 				      SLAB_ACCOUNT, ceph_inode_init_once);
930d37b1d99SMarkus Elfring 	if (!ceph_inode_cachep)
93116725b9dSSage Weil 		return -ENOMEM;
93216725b9dSSage Weil 
933bc4b5ad3SChengguang Xu 	ceph_cap_cachep = KMEM_CACHE(ceph_cap, SLAB_MEM_SPREAD);
934d37b1d99SMarkus Elfring 	if (!ceph_cap_cachep)
93516725b9dSSage Weil 		goto bad_cap;
936ab58a5a1SXiubo Li 	ceph_cap_snap_cachep = KMEM_CACHE(ceph_cap_snap, SLAB_MEM_SPREAD);
937ab58a5a1SXiubo Li 	if (!ceph_cap_snap_cachep)
938ab58a5a1SXiubo Li 		goto bad_cap_snap;
939f66fd9f0SYan, Zheng 	ceph_cap_flush_cachep = KMEM_CACHE(ceph_cap_flush,
940f66fd9f0SYan, Zheng 					   SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
941d37b1d99SMarkus Elfring 	if (!ceph_cap_flush_cachep)
942f66fd9f0SYan, Zheng 		goto bad_cap_flush;
94316725b9dSSage Weil 
94416725b9dSSage Weil 	ceph_dentry_cachep = KMEM_CACHE(ceph_dentry_info,
94516725b9dSSage Weil 					SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
946d37b1d99SMarkus Elfring 	if (!ceph_dentry_cachep)
94716725b9dSSage Weil 		goto bad_dentry;
94816725b9dSSage Weil 
9496b1a9a6cSNikolay Borisov 	ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD);
950d37b1d99SMarkus Elfring 	if (!ceph_file_cachep)
95116725b9dSSage Weil 		goto bad_file;
95216725b9dSSage Weil 
953bb48bd4dSChengguang Xu 	ceph_dir_file_cachep = KMEM_CACHE(ceph_dir_file_info, SLAB_MEM_SPREAD);
954bb48bd4dSChengguang Xu 	if (!ceph_dir_file_cachep)
955bb48bd4dSChengguang Xu 		goto bad_dir_file;
956bb48bd4dSChengguang Xu 
957058daab7SJeff Layton 	ceph_mds_request_cachep = KMEM_CACHE(ceph_mds_request, SLAB_MEM_SPREAD);
958058daab7SJeff Layton 	if (!ceph_mds_request_cachep)
959058daab7SJeff Layton 		goto bad_mds_req;
960058daab7SJeff Layton 
961a0102bdaSJeff Layton 	ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT);
962a0102bdaSJeff Layton 	if (!ceph_wb_pagevec_pool)
963a0102bdaSJeff Layton 		goto bad_pagevec_pool;
964a0102bdaSJeff Layton 
96599ccbd22SMilosz Tanski 	return 0;
9661c789249SChengguang Xu 
967a0102bdaSJeff Layton bad_pagevec_pool:
968400e1286SJeff Layton 	kmem_cache_destroy(ceph_mds_request_cachep);
969058daab7SJeff Layton bad_mds_req:
970bb48bd4dSChengguang Xu 	kmem_cache_destroy(ceph_dir_file_cachep);
971bb48bd4dSChengguang Xu bad_dir_file:
9721c789249SChengguang Xu 	kmem_cache_destroy(ceph_file_cachep);
97316725b9dSSage Weil bad_file:
97416725b9dSSage Weil 	kmem_cache_destroy(ceph_dentry_cachep);
97516725b9dSSage Weil bad_dentry:
976f66fd9f0SYan, Zheng 	kmem_cache_destroy(ceph_cap_flush_cachep);
977f66fd9f0SYan, Zheng bad_cap_flush:
978ab58a5a1SXiubo Li 	kmem_cache_destroy(ceph_cap_snap_cachep);
979ab58a5a1SXiubo Li bad_cap_snap:
98016725b9dSSage Weil 	kmem_cache_destroy(ceph_cap_cachep);
98116725b9dSSage Weil bad_cap:
98216725b9dSSage Weil 	kmem_cache_destroy(ceph_inode_cachep);
98399ccbd22SMilosz Tanski 	return error;
98416725b9dSSage Weil }
98516725b9dSSage Weil 
destroy_caches(void)98616725b9dSSage Weil static void destroy_caches(void)
98716725b9dSSage Weil {
9888c0a8537SKirill A. Shutemov 	/*
9898c0a8537SKirill A. Shutemov 	 * Make sure all delayed rcu free inodes are flushed before we
9908c0a8537SKirill A. Shutemov 	 * destroy cache.
9918c0a8537SKirill A. Shutemov 	 */
9928c0a8537SKirill A. Shutemov 	rcu_barrier();
99399ccbd22SMilosz Tanski 
99416725b9dSSage Weil 	kmem_cache_destroy(ceph_inode_cachep);
99516725b9dSSage Weil 	kmem_cache_destroy(ceph_cap_cachep);
996ab58a5a1SXiubo Li 	kmem_cache_destroy(ceph_cap_snap_cachep);
997f66fd9f0SYan, Zheng 	kmem_cache_destroy(ceph_cap_flush_cachep);
99816725b9dSSage Weil 	kmem_cache_destroy(ceph_dentry_cachep);
99916725b9dSSage Weil 	kmem_cache_destroy(ceph_file_cachep);
1000bb48bd4dSChengguang Xu 	kmem_cache_destroy(ceph_dir_file_cachep);
1001058daab7SJeff Layton 	kmem_cache_destroy(ceph_mds_request_cachep);
1002a0102bdaSJeff Layton 	mempool_destroy(ceph_wb_pagevec_pool);
100316725b9dSSage Weil }
100416725b9dSSage Weil 
__ceph_umount_begin(struct ceph_fs_client * fsc)100550c9132dSJeff Layton static void __ceph_umount_begin(struct ceph_fs_client *fsc)
100650c9132dSJeff Layton {
100750c9132dSJeff Layton 	ceph_osdc_abort_requests(&fsc->client->osdc, -EIO);
100850c9132dSJeff Layton 	ceph_mdsc_force_umount(fsc->mdsc);
100950c9132dSJeff Layton 	fsc->filp_gen++; // invalidate open files
101050c9132dSJeff Layton }
101150c9132dSJeff Layton 
101216725b9dSSage Weil /*
1013f1f565a2SRandy Dunlap  * ceph_umount_begin - initiate forced umount.  Tear down the
101416725b9dSSage Weil  * mount, skipping steps that may hang while waiting for server(s).
101516725b9dSSage Weil  */
ceph_umount_begin(struct super_block * sb)1016631ed4b0SJeff Layton void ceph_umount_begin(struct super_block *sb)
101716725b9dSSage Weil {
1018985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
101916725b9dSSage Weil 
102016725b9dSSage Weil 	dout("ceph_umount_begin - starting forced umount\n");
10213d14c5d2SYehuda Sadeh 	if (!fsc)
102216725b9dSSage Weil 		return;
10233d14c5d2SYehuda Sadeh 	fsc->mount_state = CEPH_MOUNT_SHUTDOWN;
102450c9132dSJeff Layton 	__ceph_umount_begin(fsc);
102516725b9dSSage Weil }
102616725b9dSSage Weil 
102716725b9dSSage Weil static const struct super_operations ceph_super_ops = {
102816725b9dSSage Weil 	.alloc_inode	= ceph_alloc_inode,
1029cfa6d412SAl Viro 	.free_inode	= ceph_free_inode,
103016725b9dSSage Weil 	.write_inode    = ceph_write_inode,
103152dd0f1bSLuis Henriques 	.drop_inode	= generic_delete_inode,
103287bc5b89SYan, Zheng 	.evict_inode	= ceph_evict_inode,
10332d9c98aeSSage Weil 	.sync_fs        = ceph_sync_fs,
103416725b9dSSage Weil 	.put_super	= ceph_put_super,
103516725b9dSSage Weil 	.show_options   = ceph_show_options,
103616725b9dSSage Weil 	.statfs		= ceph_statfs,
103716725b9dSSage Weil 	.umount_begin   = ceph_umount_begin,
103816725b9dSSage Weil };
103916725b9dSSage Weil 
104016725b9dSSage Weil /*
104116725b9dSSage Weil  * Bootstrap mount by opening the root directory.  Note the mount
104216725b9dSSage Weil  * @started time from caller, and time out if this takes too long.
104316725b9dSSage Weil  */
open_root_dentry(struct ceph_fs_client * fsc,const char * path,unsigned long started)10443d14c5d2SYehuda Sadeh static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
104516725b9dSSage Weil 				       const char *path,
104616725b9dSSage Weil 				       unsigned long started)
104716725b9dSSage Weil {
10483d14c5d2SYehuda Sadeh 	struct ceph_mds_client *mdsc = fsc->mdsc;
104916725b9dSSage Weil 	struct ceph_mds_request *req = NULL;
105016725b9dSSage Weil 	int err;
105116725b9dSSage Weil 	struct dentry *root;
105216725b9dSSage Weil 
105316725b9dSSage Weil 	/* open dir */
105416725b9dSSage Weil 	dout("open_root_inode opening '%s'\n", path);
105516725b9dSSage Weil 	req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
105616725b9dSSage Weil 	if (IS_ERR(req))
10577e34bc52SJulia Lawall 		return ERR_CAST(req);
105816725b9dSSage Weil 	req->r_path1 = kstrdup(path, GFP_NOFS);
1059a149bb9aSSanidhya Kashyap 	if (!req->r_path1) {
1060a149bb9aSSanidhya Kashyap 		root = ERR_PTR(-ENOMEM);
1061a149bb9aSSanidhya Kashyap 		goto out;
1062a149bb9aSSanidhya Kashyap 	}
1063a149bb9aSSanidhya Kashyap 
106416725b9dSSage Weil 	req->r_ino1.ino = CEPH_INO_ROOT;
106516725b9dSSage Weil 	req->r_ino1.snap = CEPH_NOSNAP;
106616725b9dSSage Weil 	req->r_started = started;
1067a319bf56SIlya Dryomov 	req->r_timeout = fsc->client->options->mount_timeout;
106816725b9dSSage Weil 	req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
106916725b9dSSage Weil 	req->r_num_caps = 2;
107016725b9dSSage Weil 	err = ceph_mdsc_do_request(mdsc, NULL, req);
107116725b9dSSage Weil 	if (err == 0) {
10723c5184efSAl Viro 		struct inode *inode = req->r_target_inode;
10733c5184efSAl Viro 		req->r_target_inode = NULL;
107416725b9dSSage Weil 		dout("open_root_inode success\n");
107548fde701SAl Viro 		root = d_make_root(inode);
10763c5184efSAl Viro 		if (!root) {
10773c5184efSAl Viro 			root = ERR_PTR(-ENOMEM);
10783c5184efSAl Viro 			goto out;
10793c5184efSAl Viro 		}
108016725b9dSSage Weil 		dout("open_root_inode success, root dentry is %p\n", root);
108116725b9dSSage Weil 	} else {
108216725b9dSSage Weil 		root = ERR_PTR(err);
108316725b9dSSage Weil 	}
10843c5184efSAl Viro out:
108516725b9dSSage Weil 	ceph_mdsc_put_request(req);
108616725b9dSSage Weil 	return root;
108716725b9dSSage Weil }
108816725b9dSSage Weil 
10896b5717bdSJeff Layton #ifdef CONFIG_FS_ENCRYPTION
ceph_apply_test_dummy_encryption(struct super_block * sb,struct fs_context * fc,struct ceph_mount_options * fsopt)10906b5717bdSJeff Layton static int ceph_apply_test_dummy_encryption(struct super_block *sb,
10916b5717bdSJeff Layton 					    struct fs_context *fc,
10926b5717bdSJeff Layton 					    struct ceph_mount_options *fsopt)
10936b5717bdSJeff Layton {
10946b5717bdSJeff Layton 	struct ceph_fs_client *fsc = sb->s_fs_info;
10956b5717bdSJeff Layton 
10966b5717bdSJeff Layton 	if (!fscrypt_is_dummy_policy_set(&fsopt->dummy_enc_policy))
10976b5717bdSJeff Layton 		return 0;
10986b5717bdSJeff Layton 
10996b5717bdSJeff Layton 	/* No changing encryption context on remount. */
11006b5717bdSJeff Layton 	if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE &&
11016b5717bdSJeff Layton 	    !fscrypt_is_dummy_policy_set(&fsc->fsc_dummy_enc_policy)) {
11026b5717bdSJeff Layton 		if (fscrypt_dummy_policies_equal(&fsopt->dummy_enc_policy,
11036b5717bdSJeff Layton 						 &fsc->fsc_dummy_enc_policy))
11046b5717bdSJeff Layton 			return 0;
11056b5717bdSJeff Layton 		errorfc(fc, "Can't set test_dummy_encryption on remount");
11066b5717bdSJeff Layton 		return -EINVAL;
11076b5717bdSJeff Layton 	}
11086b5717bdSJeff Layton 
11096b5717bdSJeff Layton 	/* Also make sure fsopt doesn't contain a conflicting value. */
11106b5717bdSJeff Layton 	if (fscrypt_is_dummy_policy_set(&fsc->fsc_dummy_enc_policy)) {
11116b5717bdSJeff Layton 		if (fscrypt_dummy_policies_equal(&fsopt->dummy_enc_policy,
11126b5717bdSJeff Layton 						 &fsc->fsc_dummy_enc_policy))
11136b5717bdSJeff Layton 			return 0;
11146b5717bdSJeff Layton 		errorfc(fc, "Conflicting test_dummy_encryption options");
11156b5717bdSJeff Layton 		return -EINVAL;
11166b5717bdSJeff Layton 	}
11176b5717bdSJeff Layton 
11186b5717bdSJeff Layton 	fsc->fsc_dummy_enc_policy = fsopt->dummy_enc_policy;
11196b5717bdSJeff Layton 	memset(&fsopt->dummy_enc_policy, 0, sizeof(fsopt->dummy_enc_policy));
11206b5717bdSJeff Layton 
11216b5717bdSJeff Layton 	warnfc(fc, "test_dummy_encryption mode enabled");
11226b5717bdSJeff Layton 	return 0;
11236b5717bdSJeff Layton }
11246b5717bdSJeff Layton #else
ceph_apply_test_dummy_encryption(struct super_block * sb,struct fs_context * fc,struct ceph_mount_options * fsopt)11256b5717bdSJeff Layton static int ceph_apply_test_dummy_encryption(struct super_block *sb,
11266b5717bdSJeff Layton 					    struct fs_context *fc,
11276b5717bdSJeff Layton 					    struct ceph_mount_options *fsopt)
11286b5717bdSJeff Layton {
11296b5717bdSJeff Layton 	return 0;
11306b5717bdSJeff Layton }
11316b5717bdSJeff Layton #endif
11326b5717bdSJeff Layton 
113316725b9dSSage Weil /*
113416725b9dSSage Weil  * mount: join the ceph cluster, and open root directory.
113516725b9dSSage Weil  */
ceph_real_mount(struct ceph_fs_client * fsc,struct fs_context * fc)113682995cc6SDavid Howells static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
113782995cc6SDavid Howells 				      struct fs_context *fc)
113816725b9dSSage Weil {
113916725b9dSSage Weil 	int err;
114016725b9dSSage Weil 	unsigned long started = jiffies;  /* note the start time */
114116725b9dSSage Weil 	struct dentry *root;
114216725b9dSSage Weil 
1143132ca7e1SYan, Zheng 	dout("mount start %p\n", fsc);
11443d14c5d2SYehuda Sadeh 	mutex_lock(&fsc->client->mount_mutex);
114516725b9dSSage Weil 
1146132ca7e1SYan, Zheng 	if (!fsc->sb->s_root) {
1147b27a939eSIlya Dryomov 		const char *path = fsc->mount_options->server_path ?
1148b27a939eSIlya Dryomov 				     fsc->mount_options->server_path + 1 : "";
1149b27a939eSIlya Dryomov 
11503d14c5d2SYehuda Sadeh 		err = __ceph_open_session(fsc->client, started);
115116725b9dSSage Weil 		if (err < 0)
115216725b9dSSage Weil 			goto out;
115316725b9dSSage Weil 
11541d8f8360SYan, Zheng 		/* setup fscache */
11551d8f8360SYan, Zheng 		if (fsc->mount_options->flags & CEPH_MOUNT_OPT_FSCACHE) {
115682995cc6SDavid Howells 			err = ceph_fscache_register_fs(fsc, fc);
11571d8f8360SYan, Zheng 			if (err < 0)
11581d8f8360SYan, Zheng 				goto out;
11591d8f8360SYan, Zheng 		}
11601d8f8360SYan, Zheng 
11616b5717bdSJeff Layton 		err = ceph_apply_test_dummy_encryption(fsc->sb, fc,
11626b5717bdSJeff Layton 						       fsc->mount_options);
11636b5717bdSJeff Layton 		if (err)
11646b5717bdSJeff Layton 			goto out;
11656b5717bdSJeff Layton 
11664fbc0c71SXiubo Li 		dout("mount opening path '%s'\n", path);
116718106734SChengguang Xu 
11681a829ff2SGreg Kroah-Hartman 		ceph_fs_debugfs_init(fsc);
116918106734SChengguang Xu 
1170ce2728aaSYan, Zheng 		root = open_root_dentry(fsc, path, started);
117116725b9dSSage Weil 		if (IS_ERR(root)) {
117216725b9dSSage Weil 			err = PTR_ERR(root);
117316725b9dSSage Weil 			goto out;
117416725b9dSSage Weil 		}
1175ce2728aaSYan, Zheng 		fsc->sb->s_root = dget(root);
117631ca5878SGeert Uytterhoeven 	} else {
117731ca5878SGeert Uytterhoeven 		root = dget(fsc->sb->s_root);
11783d14c5d2SYehuda Sadeh 	}
117916725b9dSSage Weil 
11803d14c5d2SYehuda Sadeh 	fsc->mount_state = CEPH_MOUNT_MOUNTED;
118116725b9dSSage Weil 	dout("mount success\n");
1182a7f9fb20SAl Viro 	mutex_unlock(&fsc->client->mount_mutex);
1183a7f9fb20SAl Viro 	return root;
118416725b9dSSage Weil 
1185132ca7e1SYan, Zheng out:
1186132ca7e1SYan, Zheng 	mutex_unlock(&fsc->client->mount_mutex);
11876b5717bdSJeff Layton 	ceph_fscrypt_free_dummy_policy(fsc);
1188132ca7e1SYan, Zheng 	return ERR_PTR(err);
118916725b9dSSage Weil }
119016725b9dSSage Weil 
ceph_set_super(struct super_block * s,struct fs_context * fc)119182995cc6SDavid Howells static int ceph_set_super(struct super_block *s, struct fs_context *fc)
119216725b9dSSage Weil {
119382995cc6SDavid Howells 	struct ceph_fs_client *fsc = s->s_fs_info;
119416725b9dSSage Weil 	int ret;
119516725b9dSSage Weil 
119682995cc6SDavid Howells 	dout("set_super %p\n", s);
119716725b9dSSage Weil 
1198719784baSChengguang Xu 	s->s_maxbytes = MAX_LFS_FILESIZE;
119916725b9dSSage Weil 
12007221fe4cSGuangliang Zhao 	s->s_xattr = ceph_xattr_handlers;
12013d14c5d2SYehuda Sadeh 	fsc->sb = s;
1202719784baSChengguang Xu 	fsc->max_file_size = 1ULL << 40; /* temp value until we get mdsmap */
120316725b9dSSage Weil 
120416725b9dSSage Weil 	s->s_op = &ceph_super_ops;
120518fc8abdSAl Viro 	s->s_d_op = &ceph_dentry_ops;
120616725b9dSSage Weil 	s->s_export_op = &ceph_export_ops;
120716725b9dSSage Weil 
12080f7cf80aSLuis Henriques 	s->s_time_gran = 1;
1209028ca4dbSDeepa Dinamani 	s->s_time_min = 0;
1210028ca4dbSDeepa Dinamani 	s->s_time_max = U32_MAX;
1211f7a2d068SXiubo Li 	s->s_flags |= SB_NODIRATIME | SB_NOATIME;
121216725b9dSSage Weil 
12132d332d5bSJeff Layton 	ceph_fscrypt_set_ops(s);
12142d332d5bSJeff Layton 
121582995cc6SDavid Howells 	ret = set_anon_super_fc(s, fc);
121616725b9dSSage Weil 	if (ret != 0)
12173d14c5d2SYehuda Sadeh 		fsc->sb = NULL;
121816725b9dSSage Weil 	return ret;
121916725b9dSSage Weil }
122016725b9dSSage Weil 
122116725b9dSSage Weil /*
122216725b9dSSage Weil  * share superblock if same fs AND options
122316725b9dSSage Weil  */
ceph_compare_super(struct super_block * sb,struct fs_context * fc)122482995cc6SDavid Howells static int ceph_compare_super(struct super_block *sb, struct fs_context *fc)
122516725b9dSSage Weil {
122682995cc6SDavid Howells 	struct ceph_fs_client *new = fc->s_fs_info;
12273d14c5d2SYehuda Sadeh 	struct ceph_mount_options *fsopt = new->mount_options;
12283d14c5d2SYehuda Sadeh 	struct ceph_options *opt = new->client->options;
1229985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
123016725b9dSSage Weil 
123116725b9dSSage Weil 	dout("ceph_compare_super %p\n", sb);
12323d14c5d2SYehuda Sadeh 
123398d0a6fbSJeff Layton 	if (compare_mount_options(fsopt, opt, fsc)) {
12343d14c5d2SYehuda Sadeh 		dout("monitor(s)/mount options don't match\n");
12353d14c5d2SYehuda Sadeh 		return 0;
12363d14c5d2SYehuda Sadeh 	}
12373d14c5d2SYehuda Sadeh 	if ((opt->flags & CEPH_OPT_FSID) &&
123898d0a6fbSJeff Layton 	    ceph_fsid_compare(&opt->fsid, &fsc->client->fsid)) {
123916725b9dSSage Weil 		dout("fsid doesn't match\n");
124016725b9dSSage Weil 		return 0;
124116725b9dSSage Weil 	}
124282995cc6SDavid Howells 	if (fc->sb_flags != (sb->s_flags & ~SB_BORN)) {
124316725b9dSSage Weil 		dout("flags differ\n");
124416725b9dSSage Weil 		return 0;
124516725b9dSSage Weil 	}
124698d0a6fbSJeff Layton 
124798d0a6fbSJeff Layton 	if (fsc->blocklisted && !ceph_test_mount_opt(fsc, CLEANRECOVER)) {
124898d0a6fbSJeff Layton 		dout("client is blocklisted (and CLEANRECOVER is not set)\n");
124998d0a6fbSJeff Layton 		return 0;
125098d0a6fbSJeff Layton 	}
125198d0a6fbSJeff Layton 
125298d0a6fbSJeff Layton 	if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) {
125398d0a6fbSJeff Layton 		dout("client has been forcibly unmounted\n");
125498d0a6fbSJeff Layton 		return 0;
125598d0a6fbSJeff Layton 	}
125698d0a6fbSJeff Layton 
125716725b9dSSage Weil 	return 1;
125816725b9dSSage Weil }
125916725b9dSSage Weil 
126016725b9dSSage Weil /*
126116725b9dSSage Weil  * construct our own bdi so we can control readahead, etc.
126216725b9dSSage Weil  */
126300d5643eSJeff Mahoney static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
126431e0cf8fSSage Weil 
ceph_setup_bdi(struct super_block * sb,struct ceph_fs_client * fsc)126509dc9fc2SJan Kara static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
126616725b9dSSage Weil {
126716725b9dSSage Weil 	int err;
126816725b9dSSage Weil 
126909dc9fc2SJan Kara 	err = super_setup_bdi_name(sb, "ceph-%ld",
127009dc9fc2SJan Kara 				   atomic_long_inc_return(&bdi_seq));
127109dc9fc2SJan Kara 	if (err)
127209dc9fc2SJan Kara 		return err;
127309dc9fc2SJan Kara 
127483817e35SSage Weil 	/* set ra_pages based on rasize mount option? */
12754214fb15SYan, Zheng 	sb->s_bdi->ra_pages = fsc->mount_options->rasize >> PAGE_SHIFT;
1276e9852227SYehuda Sadeh 
1277aa187926SYan, Zheng 	/* set io_pages based on max osd read size */
1278aa187926SYan, Zheng 	sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT;
12797c94ba27SAndreas Gerstmayr 
128009dc9fc2SJan Kara 	return 0;
128116725b9dSSage Weil }
128216725b9dSSage Weil 
ceph_get_tree(struct fs_context * fc)128382995cc6SDavid Howells static int ceph_get_tree(struct fs_context *fc)
128416725b9dSSage Weil {
128582995cc6SDavid Howells 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
12867b19b4dbSVenky Shankar 	struct ceph_mount_options *fsopt = pctx->opts;
128716725b9dSSage Weil 	struct super_block *sb;
12883d14c5d2SYehuda Sadeh 	struct ceph_fs_client *fsc;
1289a7f9fb20SAl Viro 	struct dentry *res;
129082995cc6SDavid Howells 	int (*compare_super)(struct super_block *, struct fs_context *) =
129182995cc6SDavid Howells 		ceph_compare_super;
129216725b9dSSage Weil 	int err;
129316725b9dSSage Weil 
129482995cc6SDavid Howells 	dout("ceph_get_tree\n");
129582995cc6SDavid Howells 
129682995cc6SDavid Howells 	if (!fc->source)
1297d53d0f74SAl Viro 		return invalfc(fc, "No source");
12987b19b4dbSVenky Shankar 	if (fsopt->new_dev_syntax && !fsopt->mon_addr)
12997b19b4dbSVenky Shankar 		return invalfc(fc, "No monitor address");
130045195e42SSage Weil 
130116725b9dSSage Weil 	/* create client (which we may/may not use) */
130282995cc6SDavid Howells 	fsc = create_fs_client(pctx->opts, pctx->copts);
130382995cc6SDavid Howells 	pctx->opts = NULL;
130482995cc6SDavid Howells 	pctx->copts = NULL;
13053d14c5d2SYehuda Sadeh 	if (IS_ERR(fsc)) {
130682995cc6SDavid Howells 		err = PTR_ERR(fsc);
13076b805185SSage Weil 		goto out_final;
13086b805185SSage Weil 	}
130916725b9dSSage Weil 
13103d14c5d2SYehuda Sadeh 	err = ceph_mdsc_init(fsc);
131182995cc6SDavid Howells 	if (err < 0)
13123d14c5d2SYehuda Sadeh 		goto out;
13133d14c5d2SYehuda Sadeh 
13143d14c5d2SYehuda Sadeh 	if (ceph_test_opt(fsc->client, NOSHARE))
131516725b9dSSage Weil 		compare_super = NULL;
131682995cc6SDavid Howells 
131782995cc6SDavid Howells 	fc->s_fs_info = fsc;
131882995cc6SDavid Howells 	sb = sget_fc(fc, compare_super, ceph_set_super);
131982995cc6SDavid Howells 	fc->s_fs_info = NULL;
132016725b9dSSage Weil 	if (IS_ERR(sb)) {
132182995cc6SDavid Howells 		err = PTR_ERR(sb);
132216725b9dSSage Weil 		goto out;
132316725b9dSSage Weil 	}
132416725b9dSSage Weil 
1325985b9ee8SXiubo Li 	if (ceph_sb_to_fs_client(sb) != fsc) {
13263d14c5d2SYehuda Sadeh 		destroy_fs_client(fsc);
1327985b9ee8SXiubo Li 		fsc = ceph_sb_to_fs_client(sb);
13283d14c5d2SYehuda Sadeh 		dout("get_sb got existing client %p\n", fsc);
132916725b9dSSage Weil 	} else {
13303d14c5d2SYehuda Sadeh 		dout("get_sb using new client %p\n", fsc);
133109dc9fc2SJan Kara 		err = ceph_setup_bdi(sb, fsc);
133282995cc6SDavid Howells 		if (err < 0)
133316725b9dSSage Weil 			goto out_splat;
133416725b9dSSage Weil 	}
133516725b9dSSage Weil 
133682995cc6SDavid Howells 	res = ceph_real_mount(fsc, fc);
133782995cc6SDavid Howells 	if (IS_ERR(res)) {
133882995cc6SDavid Howells 		err = PTR_ERR(res);
133916725b9dSSage Weil 		goto out_splat;
134082995cc6SDavid Howells 	}
1341a7f9fb20SAl Viro 	dout("root %p inode %p ino %llx.%llx\n", res,
13422b0143b5SDavid Howells 	     d_inode(res), ceph_vinop(d_inode(res)));
134382995cc6SDavid Howells 	fc->root = fsc->sb->s_root;
134482995cc6SDavid Howells 	return 0;
134516725b9dSSage Weil 
134616725b9dSSage Weil out_splat:
134797820058SXiubo Li 	if (!ceph_mdsmap_is_cluster_available(fsc->mdsc->mdsmap)) {
134897820058SXiubo Li 		pr_info("No mds server is up or the cluster is laggy\n");
134997820058SXiubo Li 		err = -EHOSTUNREACH;
135097820058SXiubo Li 	}
135197820058SXiubo Li 
13523d14c5d2SYehuda Sadeh 	ceph_mdsc_close_sessions(fsc->mdsc);
13533981f2e2SAl Viro 	deactivate_locked_super(sb);
135416725b9dSSage Weil 	goto out_final;
135516725b9dSSage Weil 
135616725b9dSSage Weil out:
13573d14c5d2SYehuda Sadeh 	destroy_fs_client(fsc);
135816725b9dSSage Weil out_final:
135982995cc6SDavid Howells 	dout("ceph_get_tree fail %d\n", err);
136082995cc6SDavid Howells 	return err;
136182995cc6SDavid Howells }
136282995cc6SDavid Howells 
ceph_free_fc(struct fs_context * fc)136382995cc6SDavid Howells static void ceph_free_fc(struct fs_context *fc)
136482995cc6SDavid Howells {
136582995cc6SDavid Howells 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
136682995cc6SDavid Howells 
136782995cc6SDavid Howells 	if (pctx) {
136882995cc6SDavid Howells 		destroy_mount_options(pctx->opts);
136982995cc6SDavid Howells 		ceph_destroy_options(pctx->copts);
137082995cc6SDavid Howells 		kfree(pctx);
137182995cc6SDavid Howells 	}
137282995cc6SDavid Howells }
137382995cc6SDavid Howells 
ceph_reconfigure_fc(struct fs_context * fc)137482995cc6SDavid Howells static int ceph_reconfigure_fc(struct fs_context *fc)
137582995cc6SDavid Howells {
13766b5717bdSJeff Layton 	int err;
13772ccb4546SJeff Layton 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
13782ccb4546SJeff Layton 	struct ceph_mount_options *fsopt = pctx->opts;
13796b5717bdSJeff Layton 	struct super_block *sb = fc->root->d_sb;
1380985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
13816b5717bdSJeff Layton 
13826b5717bdSJeff Layton 	err = ceph_apply_test_dummy_encryption(sb, fc, fsopt);
13836b5717bdSJeff Layton 	if (err)
13846b5717bdSJeff Layton 		return err;
13852ccb4546SJeff Layton 
13862ccb4546SJeff Layton 	if (fsopt->flags & CEPH_MOUNT_OPT_ASYNC_DIROPS)
13872ccb4546SJeff Layton 		ceph_set_mount_opt(fsc, ASYNC_DIROPS);
13882ccb4546SJeff Layton 	else
13892ccb4546SJeff Layton 		ceph_clear_mount_opt(fsc, ASYNC_DIROPS);
13902ccb4546SJeff Layton 
139103bc06c7SJeff Layton 	if (fsopt->flags & CEPH_MOUNT_OPT_SPARSEREAD)
139203bc06c7SJeff Layton 		ceph_set_mount_opt(fsc, SPARSEREAD);
139303bc06c7SJeff Layton 	else
139403bc06c7SJeff Layton 		ceph_clear_mount_opt(fsc, SPARSEREAD);
139503bc06c7SJeff Layton 
13962167f2ccSVenky Shankar 	if (strcmp_null(fsc->mount_options->mon_addr, fsopt->mon_addr)) {
13972167f2ccSVenky Shankar 		kfree(fsc->mount_options->mon_addr);
13982167f2ccSVenky Shankar 		fsc->mount_options->mon_addr = fsopt->mon_addr;
13992167f2ccSVenky Shankar 		fsopt->mon_addr = NULL;
14002167f2ccSVenky Shankar 		pr_notice("ceph: monitor addresses recorded, but not used for reconnection");
14012167f2ccSVenky Shankar 	}
14022167f2ccSVenky Shankar 
14036b5717bdSJeff Layton 	sync_filesystem(sb);
140482995cc6SDavid Howells 	return 0;
140582995cc6SDavid Howells }
140682995cc6SDavid Howells 
140782995cc6SDavid Howells static const struct fs_context_operations ceph_context_ops = {
140882995cc6SDavid Howells 	.free		= ceph_free_fc,
140982995cc6SDavid Howells 	.parse_param	= ceph_parse_mount_param,
141082995cc6SDavid Howells 	.get_tree	= ceph_get_tree,
141182995cc6SDavid Howells 	.reconfigure	= ceph_reconfigure_fc,
141282995cc6SDavid Howells };
141382995cc6SDavid Howells 
141482995cc6SDavid Howells /*
141582995cc6SDavid Howells  * Set up the filesystem mount context.
141682995cc6SDavid Howells  */
ceph_init_fs_context(struct fs_context * fc)141782995cc6SDavid Howells static int ceph_init_fs_context(struct fs_context *fc)
141882995cc6SDavid Howells {
141982995cc6SDavid Howells 	struct ceph_parse_opts_ctx *pctx;
142082995cc6SDavid Howells 	struct ceph_mount_options *fsopt;
142182995cc6SDavid Howells 
142282995cc6SDavid Howells 	pctx = kzalloc(sizeof(*pctx), GFP_KERNEL);
142382995cc6SDavid Howells 	if (!pctx)
142482995cc6SDavid Howells 		return -ENOMEM;
142582995cc6SDavid Howells 
142682995cc6SDavid Howells 	pctx->copts = ceph_alloc_options();
142782995cc6SDavid Howells 	if (!pctx->copts)
142882995cc6SDavid Howells 		goto nomem;
142982995cc6SDavid Howells 
143082995cc6SDavid Howells 	pctx->opts = kzalloc(sizeof(*pctx->opts), GFP_KERNEL);
143182995cc6SDavid Howells 	if (!pctx->opts)
143282995cc6SDavid Howells 		goto nomem;
143382995cc6SDavid Howells 
143482995cc6SDavid Howells 	fsopt = pctx->opts;
143582995cc6SDavid Howells 	fsopt->flags = CEPH_MOUNT_OPT_DEFAULT;
143682995cc6SDavid Howells 
143782995cc6SDavid Howells 	fsopt->wsize = CEPH_MAX_WRITE_SIZE;
143882995cc6SDavid Howells 	fsopt->rsize = CEPH_MAX_READ_SIZE;
143982995cc6SDavid Howells 	fsopt->rasize = CEPH_RASIZE_DEFAULT;
144082995cc6SDavid Howells 	fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
144182995cc6SDavid Howells 	if (!fsopt->snapdir_name)
144282995cc6SDavid Howells 		goto nomem;
144382995cc6SDavid Howells 
144482995cc6SDavid Howells 	fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT;
144582995cc6SDavid Howells 	fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT;
144682995cc6SDavid Howells 	fsopt->max_readdir = CEPH_MAX_READDIR_DEFAULT;
144782995cc6SDavid Howells 	fsopt->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT;
144882995cc6SDavid Howells 	fsopt->congestion_kb = default_congestion_kb();
144982995cc6SDavid Howells 
14503b20bc2fSXiubo Li #ifdef CONFIG_CEPH_FS_POSIX_ACL
14513b20bc2fSXiubo Li 	fc->sb_flags |= SB_POSIXACL;
14523b20bc2fSXiubo Li #endif
14533b20bc2fSXiubo Li 
145482995cc6SDavid Howells 	fc->fs_private = pctx;
145582995cc6SDavid Howells 	fc->ops = &ceph_context_ops;
145682995cc6SDavid Howells 	return 0;
145782995cc6SDavid Howells 
145882995cc6SDavid Howells nomem:
145982995cc6SDavid Howells 	destroy_mount_options(pctx->opts);
146082995cc6SDavid Howells 	ceph_destroy_options(pctx->copts);
146182995cc6SDavid Howells 	kfree(pctx);
146282995cc6SDavid Howells 	return -ENOMEM;
146316725b9dSSage Weil }
146416725b9dSSage Weil 
1465e3dfcab2SXiubo Li /*
1466e3dfcab2SXiubo Li  * Return true if it successfully increases the blocker counter,
1467e3dfcab2SXiubo Li  * or false if the mdsc is in stopping and flushed state.
1468e3dfcab2SXiubo Li  */
__inc_stopping_blocker(struct ceph_mds_client * mdsc)1469e3dfcab2SXiubo Li static bool __inc_stopping_blocker(struct ceph_mds_client *mdsc)
1470e3dfcab2SXiubo Li {
1471e3dfcab2SXiubo Li 	spin_lock(&mdsc->stopping_lock);
1472e3dfcab2SXiubo Li 	if (mdsc->stopping >= CEPH_MDSC_STOPPING_FLUSHING) {
1473e3dfcab2SXiubo Li 		spin_unlock(&mdsc->stopping_lock);
1474e3dfcab2SXiubo Li 		return false;
1475e3dfcab2SXiubo Li 	}
1476e3dfcab2SXiubo Li 	atomic_inc(&mdsc->stopping_blockers);
1477e3dfcab2SXiubo Li 	spin_unlock(&mdsc->stopping_lock);
1478e3dfcab2SXiubo Li 	return true;
1479e3dfcab2SXiubo Li }
1480e3dfcab2SXiubo Li 
__dec_stopping_blocker(struct ceph_mds_client * mdsc)1481e3dfcab2SXiubo Li static void __dec_stopping_blocker(struct ceph_mds_client *mdsc)
1482e3dfcab2SXiubo Li {
1483e3dfcab2SXiubo Li 	spin_lock(&mdsc->stopping_lock);
1484e3dfcab2SXiubo Li 	if (!atomic_dec_return(&mdsc->stopping_blockers) &&
1485e3dfcab2SXiubo Li 	    mdsc->stopping >= CEPH_MDSC_STOPPING_FLUSHING)
1486e3dfcab2SXiubo Li 		complete_all(&mdsc->stopping_waiter);
1487e3dfcab2SXiubo Li 	spin_unlock(&mdsc->stopping_lock);
1488e3dfcab2SXiubo Li }
1489e3dfcab2SXiubo Li 
1490e3dfcab2SXiubo Li /* For metadata IO requests */
ceph_inc_mds_stopping_blocker(struct ceph_mds_client * mdsc,struct ceph_mds_session * session)1491e3dfcab2SXiubo Li bool ceph_inc_mds_stopping_blocker(struct ceph_mds_client *mdsc,
1492e3dfcab2SXiubo Li 				   struct ceph_mds_session *session)
1493e3dfcab2SXiubo Li {
1494e3dfcab2SXiubo Li 	mutex_lock(&session->s_mutex);
1495e3dfcab2SXiubo Li 	inc_session_sequence(session);
1496e3dfcab2SXiubo Li 	mutex_unlock(&session->s_mutex);
1497e3dfcab2SXiubo Li 
1498e3dfcab2SXiubo Li 	return __inc_stopping_blocker(mdsc);
1499e3dfcab2SXiubo Li }
1500e3dfcab2SXiubo Li 
ceph_dec_mds_stopping_blocker(struct ceph_mds_client * mdsc)1501e3dfcab2SXiubo Li void ceph_dec_mds_stopping_blocker(struct ceph_mds_client *mdsc)
1502e3dfcab2SXiubo Li {
1503e3dfcab2SXiubo Li 	__dec_stopping_blocker(mdsc);
1504e3dfcab2SXiubo Li }
1505e3dfcab2SXiubo Li 
15061464de9fSXiubo Li /* For data IO requests */
ceph_inc_osd_stopping_blocker(struct ceph_mds_client * mdsc)15071464de9fSXiubo Li bool ceph_inc_osd_stopping_blocker(struct ceph_mds_client *mdsc)
15081464de9fSXiubo Li {
15091464de9fSXiubo Li 	return __inc_stopping_blocker(mdsc);
15101464de9fSXiubo Li }
15111464de9fSXiubo Li 
ceph_dec_osd_stopping_blocker(struct ceph_mds_client * mdsc)15121464de9fSXiubo Li void ceph_dec_osd_stopping_blocker(struct ceph_mds_client *mdsc)
15131464de9fSXiubo Li {
15141464de9fSXiubo Li 	__dec_stopping_blocker(mdsc);
15151464de9fSXiubo Li }
15161464de9fSXiubo Li 
ceph_kill_sb(struct super_block * s)151716725b9dSSage Weil static void ceph_kill_sb(struct super_block *s)
151816725b9dSSage Weil {
1519985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(s);
1520e3dfcab2SXiubo Li 	struct ceph_mds_client *mdsc = fsc->mdsc;
1521e3dfcab2SXiubo Li 	bool wait;
1522e4d27509SChristoph Hellwig 
152316725b9dSSage Weil 	dout("kill_sb %p\n", s);
1524e4d27509SChristoph Hellwig 
1525e3dfcab2SXiubo Li 	ceph_mdsc_pre_umount(mdsc);
1526a57d9064SYan, Zheng 	flush_fs_workqueues(fsc);
1527a57d9064SYan, Zheng 
1528e7e607bdSXiubo Li 	/*
1529e7e607bdSXiubo Li 	 * Though the kill_anon_super() will finally trigger the
1530e3dfcab2SXiubo Li 	 * sync_filesystem() anyway, we still need to do it here and
1531e3dfcab2SXiubo Li 	 * then bump the stage of shutdown. This will allow us to
1532e3dfcab2SXiubo Li 	 * drop any further message, which will increase the inodes'
1533e3dfcab2SXiubo Li 	 * i_count reference counters but makes no sense any more,
1534e3dfcab2SXiubo Li 	 * from MDSs.
1535e3dfcab2SXiubo Li 	 *
1536e3dfcab2SXiubo Li 	 * Without this when evicting the inodes it may fail in the
1537e3dfcab2SXiubo Li 	 * kill_anon_super(), which will trigger a warning when
1538e3dfcab2SXiubo Li 	 * destroying the fscrypt keyring and then possibly trigger
1539e3dfcab2SXiubo Li 	 * a further crash in ceph module when the iput() tries to
1540e3dfcab2SXiubo Li 	 * evict the inodes later.
1541e7e607bdSXiubo Li 	 */
1542e7e607bdSXiubo Li 	sync_filesystem(s);
1543e7e607bdSXiubo Li 
1544e3dfcab2SXiubo Li 	spin_lock(&mdsc->stopping_lock);
1545e3dfcab2SXiubo Li 	mdsc->stopping = CEPH_MDSC_STOPPING_FLUSHING;
1546e3dfcab2SXiubo Li 	wait = !!atomic_read(&mdsc->stopping_blockers);
1547e3dfcab2SXiubo Li 	spin_unlock(&mdsc->stopping_lock);
1548e7e607bdSXiubo Li 
1549e3dfcab2SXiubo Li 	if (wait && atomic_read(&mdsc->stopping_blockers)) {
1550e3dfcab2SXiubo Li 		long timeleft = wait_for_completion_killable_timeout(
1551e3dfcab2SXiubo Li 					&mdsc->stopping_waiter,
1552e3dfcab2SXiubo Li 					fsc->client->options->mount_timeout);
1553e3dfcab2SXiubo Li 		if (!timeleft) /* timed out */
1554e3dfcab2SXiubo Li 			pr_warn("umount timed out, %ld\n", timeleft);
1555e3dfcab2SXiubo Li 		else if (timeleft < 0) /* killed */
1556e3dfcab2SXiubo Li 			pr_warn("umount was killed, %ld\n", timeleft);
1557e3dfcab2SXiubo Li 	}
1558e3dfcab2SXiubo Li 
1559e3dfcab2SXiubo Li 	mdsc->stopping = CEPH_MDSC_STOPPING_FLUSHED;
1560470a5c77SJeff Layton 	kill_anon_super(s);
156162a65f36SYan, Zheng 
156262a65f36SYan, Zheng 	fsc->client->extra_mon_dispatch = NULL;
156362a65f36SYan, Zheng 	ceph_fs_debugfs_cleanup(fsc);
156462a65f36SYan, Zheng 
15651d8f8360SYan, Zheng 	ceph_fscache_unregister_fs(fsc);
15661d8f8360SYan, Zheng 
15673d14c5d2SYehuda Sadeh 	destroy_fs_client(fsc);
156816725b9dSSage Weil }
156916725b9dSSage Weil 
157016725b9dSSage Weil static struct file_system_type ceph_fs_type = {
157116725b9dSSage Weil 	.owner		= THIS_MODULE,
157216725b9dSSage Weil 	.name		= "ceph",
157382995cc6SDavid Howells 	.init_fs_context = ceph_init_fs_context,
157416725b9dSSage Weil 	.kill_sb	= ceph_kill_sb,
157516725b9dSSage Weil 	.fs_flags	= FS_RENAME_DOES_D_MOVE,
157616725b9dSSage Weil };
15777f78e035SEric W. Biederman MODULE_ALIAS_FS("ceph");
157816725b9dSSage Weil 
ceph_force_reconnect(struct super_block * sb)1579d468e729SYan, Zheng int ceph_force_reconnect(struct super_block *sb)
1580d468e729SYan, Zheng {
1581985b9ee8SXiubo Li 	struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
1582d468e729SYan, Zheng 	int err = 0;
1583d468e729SYan, Zheng 
158450c9132dSJeff Layton 	fsc->mount_state = CEPH_MOUNT_RECOVER;
158550c9132dSJeff Layton 	__ceph_umount_begin(fsc);
1586d468e729SYan, Zheng 
1587d468e729SYan, Zheng 	/* Make sure all page caches get invalidated.
1588d468e729SYan, Zheng 	 * see remove_session_caps_cb() */
1589d468e729SYan, Zheng 	flush_workqueue(fsc->inode_wq);
1590d468e729SYan, Zheng 
15910b98acd6SIlya Dryomov 	/* In case that we were blocklisted. This also reset
1592d468e729SYan, Zheng 	 * all mon/osd connections */
1593d468e729SYan, Zheng 	ceph_reset_client_addr(fsc->client);
1594d468e729SYan, Zheng 
1595d468e729SYan, Zheng 	ceph_osdc_clear_abort_err(&fsc->client->osdc);
1596131d7eb4SYan, Zheng 
15970b98acd6SIlya Dryomov 	fsc->blocklisted = false;
1598d468e729SYan, Zheng 	fsc->mount_state = CEPH_MOUNT_MOUNTED;
1599d468e729SYan, Zheng 
1600d468e729SYan, Zheng 	if (sb->s_root) {
1601d468e729SYan, Zheng 		err = __ceph_do_getattr(d_inode(sb->s_root), NULL,
1602d468e729SYan, Zheng 					CEPH_STAT_CAP_INODE, true);
1603d468e729SYan, Zheng 	}
1604d468e729SYan, Zheng 	return err;
1605d468e729SYan, Zheng }
1606d468e729SYan, Zheng 
init_ceph(void)160716725b9dSSage Weil static int __init init_ceph(void)
160816725b9dSSage Weil {
16093d14c5d2SYehuda Sadeh 	int ret = init_caches();
161016725b9dSSage Weil 	if (ret)
16113d14c5d2SYehuda Sadeh 		goto out;
161216725b9dSSage Weil 
1613eb13e832SYan, Zheng 	ceph_flock_init();
161416725b9dSSage Weil 	ret = register_filesystem(&ceph_fs_type);
161516725b9dSSage Weil 	if (ret)
1616d0f191d2SDavid Disseldorp 		goto out_caches;
161716725b9dSSage Weil 
16183d14c5d2SYehuda Sadeh 	pr_info("loaded (mds proto %d)\n", CEPH_MDSC_PROTOCOL);
16193d14c5d2SYehuda Sadeh 
162016725b9dSSage Weil 	return 0;
162116725b9dSSage Weil 
1622d0f191d2SDavid Disseldorp out_caches:
162316725b9dSSage Weil 	destroy_caches();
162416725b9dSSage Weil out:
162516725b9dSSage Weil 	return ret;
162616725b9dSSage Weil }
162716725b9dSSage Weil 
exit_ceph(void)162816725b9dSSage Weil static void __exit exit_ceph(void)
162916725b9dSSage Weil {
163016725b9dSSage Weil 	dout("exit_ceph\n");
163116725b9dSSage Weil 	unregister_filesystem(&ceph_fs_type);
163216725b9dSSage Weil 	destroy_caches();
163316725b9dSSage Weil }
163416725b9dSSage Weil 
param_set_metrics(const char * val,const struct kernel_param * kp)163518f473b3SXiubo Li static int param_set_metrics(const char *val, const struct kernel_param *kp)
163618f473b3SXiubo Li {
163718f473b3SXiubo Li 	struct ceph_fs_client *fsc;
163818f473b3SXiubo Li 	int ret;
163918f473b3SXiubo Li 
164018f473b3SXiubo Li 	ret = param_set_bool(val, kp);
164118f473b3SXiubo Li 	if (ret) {
164218f473b3SXiubo Li 		pr_err("Failed to parse sending metrics switch value '%s'\n",
164318f473b3SXiubo Li 		       val);
164418f473b3SXiubo Li 		return ret;
164518f473b3SXiubo Li 	} else if (!disable_send_metrics) {
164618f473b3SXiubo Li 		// wake up all the mds clients
164718f473b3SXiubo Li 		spin_lock(&ceph_fsc_lock);
164818f473b3SXiubo Li 		list_for_each_entry(fsc, &ceph_fsc_list, metric_wakeup) {
164918f473b3SXiubo Li 			metric_schedule_delayed(&fsc->mdsc->metric);
165018f473b3SXiubo Li 		}
165118f473b3SXiubo Li 		spin_unlock(&ceph_fsc_lock);
165218f473b3SXiubo Li 	}
165318f473b3SXiubo Li 
165418f473b3SXiubo Li 	return 0;
165518f473b3SXiubo Li }
165618f473b3SXiubo Li 
165718f473b3SXiubo Li static const struct kernel_param_ops param_ops_metrics = {
165818f473b3SXiubo Li 	.set = param_set_metrics,
165918f473b3SXiubo Li 	.get = param_get_bool,
166018f473b3SXiubo Li };
166118f473b3SXiubo Li 
166218f473b3SXiubo Li bool disable_send_metrics = false;
166318f473b3SXiubo Li module_param_cb(disable_send_metrics, &param_ops_metrics, &disable_send_metrics, 0644);
166418f473b3SXiubo Li MODULE_PARM_DESC(disable_send_metrics, "Enable sending perf metrics to ceph cluster (default: on)");
166518f473b3SXiubo Li 
1666adbed05eSVenky Shankar /* for both v1 and v2 syntax */
1667adbed05eSVenky Shankar static bool mount_support = true;
1668adbed05eSVenky Shankar static const struct kernel_param_ops param_ops_mount_syntax = {
1669adbed05eSVenky Shankar 	.get = param_get_bool,
1670adbed05eSVenky Shankar };
1671adbed05eSVenky Shankar module_param_cb(mount_syntax_v1, &param_ops_mount_syntax, &mount_support, 0444);
1672adbed05eSVenky Shankar module_param_cb(mount_syntax_v2, &param_ops_mount_syntax, &mount_support, 0444);
1673adbed05eSVenky Shankar 
167416725b9dSSage Weil module_init(init_ceph);
167516725b9dSSage Weil module_exit(exit_ceph);
167616725b9dSSage Weil 
167716725b9dSSage Weil MODULE_AUTHOR("Sage Weil <sage@newdream.net>");
167816725b9dSSage Weil MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>");
167916725b9dSSage Weil MODULE_AUTHOR("Patience Warnick <patience@newdream.net>");
168016725b9dSSage Weil MODULE_DESCRIPTION("Ceph filesystem for Linux");
168116725b9dSSage Weil MODULE_LICENSE("GPL");
1682