Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b805185 authored by Sage Weil's avatar Sage Weil
Browse files

ceph: allocate and parse mount args before client instance



This simplifies much of the error handling during mount.  It also means
that we have the mount args before client creation, and we can initialize
based on those options.

Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent e53c2fe0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -600,8 +600,8 @@ static int ceph_writepages_start(struct address_space *mapping,
		pr_warning("writepage_start %p on forced umount\n", inode);
		return -EIO; /* we're in a forced umount, don't write! */
	}
	if (client->mount_args.wsize && client->mount_args.wsize < wsize)
		wsize = client->mount_args.wsize;
	if (client->mount_args->wsize && client->mount_args->wsize < wsize)
		wsize = client->mount_args->wsize;
	if (wsize < PAGE_CACHE_SIZE)
		wsize = PAGE_CACHE_SIZE;
	max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
+2 −2
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ static void put_cap(struct ceph_cap *cap,
	 * lots of free/alloc churn.
	 */
	if (caps_avail_count >= caps_reserve_count +
	    ceph_client(cap->ci->vfs_inode.i_sb)->mount_args.max_readdir) {
	    ceph_client(cap->ci->vfs_inode.i_sb)->mount_args->max_readdir) {
		caps_total_count--;
		kmem_cache_free(ceph_cap_cachep, cap);
	} else {
@@ -388,7 +388,7 @@ static void __insert_cap_node(struct ceph_inode_info *ci,
static void __cap_set_timeouts(struct ceph_mds_client *mdsc,
			       struct ceph_inode_info *ci)
{
	struct ceph_mount_args *ma = &mdsc->client->mount_args;
	struct ceph_mount_args *ma = mdsc->client->mount_args;

	ci->i_hold_caps_min = round_jiffies(jiffies +
					    ma->caps_wanted_delay_min * HZ);
+4 −3
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
	int err;
	u32 ftype;
	struct ceph_mds_reply_info_parsed *rinfo;
	const int max_entries = client->mount_args.max_readdir;
	const int max_entries = client->mount_args->max_readdir;

	dout("readdir %p filp %p frag %u off %u\n", inode, filp, frag, off);
	if (fi->at_end)
@@ -479,7 +479,8 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
	/* .snap dir? */
	if (err == -ENOENT &&
	    ceph_vino(parent).ino != CEPH_INO_ROOT && /* no .snap in root dir */
	    strcmp(dentry->d_name.name, client->mount_args.snapdir_name) == 0) {
	    strcmp(dentry->d_name.name,
		   client->mount_args->snapdir_name) == 0) {
		struct inode *inode = ceph_get_snapdir(parent);
		dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n",
		     dentry, dentry->d_name.len, dentry->d_name.name, inode);
@@ -550,7 +551,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
		spin_lock(&dir->i_lock);
		dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags);
		if (strncmp(dentry->d_name.name,
			    client->mount_args.snapdir_name,
			    client->mount_args->snapdir_name,
			    dentry->d_name.len) &&
		    (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
		    (__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1))) {
+3 −3
Original line number Diff line number Diff line
@@ -943,7 +943,7 @@ static int add_cap_releases(struct ceph_mds_client *mdsc,
	int err = -ENOMEM;

	if (extra < 0)
		extra = mdsc->client->mount_args.cap_release_safety;
		extra = mdsc->client->mount_args->cap_release_safety;

	spin_lock(&session->s_cap_lock);

@@ -2601,7 +2601,7 @@ static void wait_requests(struct ceph_mds_client *mdsc)
		mutex_unlock(&mdsc->mutex);
		dout("wait_requests waiting for requests\n");
		wait_for_completion_timeout(&mdsc->safe_umount_waiters,
				    client->mount_args.mount_timeout * HZ);
				    client->mount_args->mount_timeout * HZ);
		mutex_lock(&mdsc->mutex);

		/* tear down remaining requests */
@@ -2693,7 +2693,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc)
	int i;
	int n;
	struct ceph_client *client = mdsc->client;
	unsigned long started, timeout = client->mount_args.mount_timeout * HZ;
	unsigned long started, timeout = client->mount_args->mount_timeout * HZ;

	dout("close_sessions\n");

+38 −0
Original line number Diff line number Diff line
@@ -527,6 +527,40 @@ static void delayed_work(struct work_struct *work)
	mutex_unlock(&monc->mutex);
}

/*
 * On startup, we build a temporary monmap populated with the IPs
 * provided by mount(2).
 */
static int build_initial_monmap(struct ceph_mon_client *monc)
{
	struct ceph_mount_args *args = monc->client->mount_args;
	struct ceph_entity_addr *mon_addr = args->mon_addr;
	int num_mon = args->num_mon;
	int i;

	/* build initial monmap */
	monc->monmap = kzalloc(sizeof(*monc->monmap) +
			       num_mon*sizeof(monc->monmap->mon_inst[0]),
			       GFP_KERNEL);
	if (!monc->monmap)
		return -ENOMEM;
	for (i = 0; i < num_mon; i++) {
		monc->monmap->mon_inst[i].addr = mon_addr[i];
		monc->monmap->mon_inst[i].addr.erank = 0;
		monc->monmap->mon_inst[i].addr.nonce = 0;
		monc->monmap->mon_inst[i].name.type =
			CEPH_ENTITY_TYPE_MON;
		monc->monmap->mon_inst[i].name.num = cpu_to_le64(i);
	}
	monc->monmap->num_mon = num_mon;

	/* release addr memory */
	kfree(args->mon_addr);
	args->mon_addr = NULL;
	args->num_mon = 0;
	return 0;
}

int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
{
	int err = 0;
@@ -537,6 +571,10 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
	monc->monmap = NULL;
	mutex_init(&monc->mutex);

	err = build_initial_monmap(monc);
	if (err)
		goto out;

	monc->con = NULL;

	/* msg pools */
Loading