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

Commit ca18bede authored by Yan, Zheng's avatar Yan, Zheng
Browse files

ceph: handle -ESTALE reply



Send requests that operate on path to directory's auth MDS if
mode == USE_AUTH_MDS. Always retry using the auth MDS if got
-ESTALE reply from non-auth MDS. Also clean up the code that
handles auth MDS change.

Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
parent 979abfdd
Loading
Loading
Loading
Loading
+11 −20
Original line number Original line Diff line number Diff line
@@ -713,16 +713,17 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
			struct dentry *dn = get_nonsnap_parent(parent);
			struct dentry *dn = get_nonsnap_parent(parent);
			inode = dn->d_inode;
			inode = dn->d_inode;
			dout("__choose_mds using nonsnap parent %p\n", inode);
			dout("__choose_mds using nonsnap parent %p\n", inode);
		} else if (req->r_dentry->d_inode) {
		} else {
			/* dentry target */
			/* dentry target */
			inode = req->r_dentry->d_inode;
			inode = req->r_dentry->d_inode;
		} else {
			if (!inode || mode == USE_AUTH_MDS) {
				/* dir + name */
				/* dir + name */
				inode = dir;
				inode = dir;
				hash = ceph_dentry_hash(dir, req->r_dentry);
				hash = ceph_dentry_hash(dir, req->r_dentry);
				is_hash = true;
				is_hash = true;
			}
			}
		}
		}
	}


	dout("__choose_mds %p is_hash=%d (%d) mode %d\n", inode, (int)is_hash,
	dout("__choose_mds %p is_hash=%d (%d) mode %d\n", inode, (int)is_hash,
	     (int)hash, mode);
	     (int)hash, mode);
@@ -2161,26 +2162,16 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
	 */
	 */
	if (result == -ESTALE) {
	if (result == -ESTALE) {
		dout("got ESTALE on request %llu", req->r_tid);
		dout("got ESTALE on request %llu", req->r_tid);
		if (!req->r_inode) {
		if (req->r_direct_mode != USE_AUTH_MDS) {
			/* do nothing; not an authority problem */
		} else if (req->r_direct_mode != USE_AUTH_MDS) {
			dout("not using auth, setting for that now");
			dout("not using auth, setting for that now");
			req->r_direct_mode = USE_AUTH_MDS;
			req->r_direct_mode = USE_AUTH_MDS;
			__do_request(mdsc, req);
			__do_request(mdsc, req);
			mutex_unlock(&mdsc->mutex);
			mutex_unlock(&mdsc->mutex);
			goto out;
			goto out;
		} else  {
		} else  {
			struct ceph_inode_info *ci = ceph_inode(req->r_inode);
			int mds = __choose_mds(mdsc, req);
			struct ceph_cap *cap = NULL;
			if (mds >= 0 && mds != req->r_session->s_mds) {

				dout("but auth changed, so resending");
			if (req->r_session)
				cap = ceph_get_cap_for_mds(ci,
						   req->r_session->s_mds);

			dout("already using auth");
			if ((!cap || cap != ci->i_auth_cap) ||
			    (cap->mseq != req->r_sent_on_mseq)) {
				dout("but cap changed, so resending");
				__do_request(mdsc, req);
				__do_request(mdsc, req);
				mutex_unlock(&mdsc->mutex);
				mutex_unlock(&mdsc->mutex);
				goto out;
				goto out;