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

Commit e8a7b8b1 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov
Browse files

ceph: exclude setfilelock requests when calculating oldest tid



setfilelock requests can block for a long time, which can prevent
client from advancing its oldest tid.

Signed-off-by: default avatarYan, Zheng <zyan@redhat.com>
parent 745a8e3b
Loading
Loading
Loading
Loading
+23 −7
Original line number Original line Diff line number Diff line
@@ -628,6 +628,9 @@ static void __register_request(struct ceph_mds_client *mdsc,
	req->r_uid = current_fsuid();
	req->r_uid = current_fsuid();
	req->r_gid = current_fsgid();
	req->r_gid = current_fsgid();


	if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK)
		mdsc->oldest_tid = req->r_tid;

	if (dir) {
	if (dir) {
		struct ceph_inode_info *ci = ceph_inode(dir);
		struct ceph_inode_info *ci = ceph_inode(dir);


@@ -643,6 +646,21 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
				 struct ceph_mds_request *req)
				 struct ceph_mds_request *req)
{
{
	dout("__unregister_request %p tid %lld\n", req, req->r_tid);
	dout("__unregister_request %p tid %lld\n", req, req->r_tid);

	if (req->r_tid == mdsc->oldest_tid) {
		struct rb_node *p = rb_next(&req->r_node);
		mdsc->oldest_tid = 0;
		while (p) {
			struct ceph_mds_request *next_req =
				rb_entry(p, struct ceph_mds_request, r_node);
			if (next_req->r_op != CEPH_MDS_OP_SETFILELOCK) {
				mdsc->oldest_tid = next_req->r_tid;
				break;
			}
			p = rb_next(p);
		}
	}

	rb_erase(&req->r_node, &mdsc->request_tree);
	rb_erase(&req->r_node, &mdsc->request_tree);
	RB_CLEAR_NODE(&req->r_node);
	RB_CLEAR_NODE(&req->r_node);


@@ -1682,13 +1700,9 @@ static struct ceph_mds_request *__get_oldest_req(struct ceph_mds_client *mdsc)
			struct ceph_mds_request, r_node);
			struct ceph_mds_request, r_node);
}
}


static u64 __get_oldest_tid(struct ceph_mds_client *mdsc)
static inline  u64 __get_oldest_tid(struct ceph_mds_client *mdsc)
{
{
	struct ceph_mds_request *req = __get_oldest_req(mdsc);
	return mdsc->oldest_tid;

	if (req)
		return req->r_tid;
	return 0;
}
}


/*
/*
@@ -3378,6 +3392,7 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
	INIT_LIST_HEAD(&mdsc->snap_empty);
	INIT_LIST_HEAD(&mdsc->snap_empty);
	spin_lock_init(&mdsc->snap_empty_lock);
	spin_lock_init(&mdsc->snap_empty_lock);
	mdsc->last_tid = 0;
	mdsc->last_tid = 0;
	mdsc->oldest_tid = 0;
	mdsc->request_tree = RB_ROOT;
	mdsc->request_tree = RB_ROOT;
	INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work);
	INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work);
	mdsc->last_renew_caps = jiffies;
	mdsc->last_renew_caps = jiffies;
@@ -3471,7 +3486,8 @@ static void wait_unsafe_requests(struct ceph_mds_client *mdsc, u64 want_tid)
			nextreq = rb_entry(n, struct ceph_mds_request, r_node);
			nextreq = rb_entry(n, struct ceph_mds_request, r_node);
		else
		else
			nextreq = NULL;
			nextreq = NULL;
		if ((req->r_op & CEPH_MDS_OP_WRITE)) {
		if (req->r_op != CEPH_MDS_OP_SETFILELOCK &&
		    (req->r_op & CEPH_MDS_OP_WRITE)) {
			/* write op */
			/* write op */
			ceph_mdsc_get_request(req);
			ceph_mdsc_get_request(req);
			if (nextreq)
			if (nextreq)
+2 −0
Original line number Original line Diff line number Diff line
@@ -296,6 +296,8 @@ struct ceph_mds_client {
	spinlock_t              snap_empty_lock;  /* protect snap_empty */
	spinlock_t              snap_empty_lock;  /* protect snap_empty */


	u64                    last_tid;      /* most recent mds request */
	u64                    last_tid;      /* most recent mds request */
	u64                    oldest_tid;    /* oldest incomplete mds request,
						 excluding setfilelock requests */
	struct rb_root         request_tree;  /* pending mds requests */
	struct rb_root         request_tree;  /* pending mds requests */
	struct delayed_work    delayed_work;  /* delayed work */
	struct delayed_work    delayed_work;  /* delayed work */
	unsigned long    last_renew_caps;  /* last time we renewed our caps */
	unsigned long    last_renew_caps;  /* last time we renewed our caps */