Skip to content

Commit

Permalink
ceph: set timeout conditionally in __cap_delay_requeue
Browse files Browse the repository at this point in the history
__cap_delay_requeue could be invoked through ceph_check_caps when there
exists caps that needs to be sent and are delayed by "i_hold_caps_min"
or "i_hold_caps_max". If __cap_delay_requeue sets timeout unconditionally,
there could be a chance that some "wanted" caps can not be release for a
long since their timeouts are reset every time they get delayed.

Fixes: http://tracker.ceph.com/issues/36369
Signed-off-by: Xuehan Xu <xuxuehan@360.cn>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Xuehan Xu authored and Ilya Dryomov committed Oct 22, 2018
1 parent 8948683 commit 6680288
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ static void __cap_set_timeouts(struct ceph_mds_client *mdsc,
* -> we take mdsc->cap_delay_lock
*/
static void __cap_delay_requeue(struct ceph_mds_client *mdsc,
struct ceph_inode_info *ci)
struct ceph_inode_info *ci,
bool set_timeout)
{
dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode,
ci->i_ceph_flags, ci->i_hold_caps_max);
Expand All @@ -530,7 +531,8 @@ static void __cap_delay_requeue(struct ceph_mds_client *mdsc,
goto no_change;
list_del_init(&ci->i_cap_delay_list);
}
__cap_set_timeouts(mdsc, ci);
if (set_timeout)
__cap_set_timeouts(mdsc, ci);
list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list);
no_change:
spin_unlock(&mdsc->cap_delay_lock);
Expand Down Expand Up @@ -720,7 +722,7 @@ void ceph_add_cap(struct inode *inode,
dout(" issued %s, mds wanted %s, actual %s, queueing\n",
ceph_cap_string(issued), ceph_cap_string(wanted),
ceph_cap_string(actual_wanted));
__cap_delay_requeue(mdsc, ci);
__cap_delay_requeue(mdsc, ci, true);
}

if (flags & CEPH_CAP_FLAG_AUTH) {
Expand Down Expand Up @@ -1647,7 +1649,7 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask,
if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
(mask & CEPH_CAP_FILE_BUFFER))
dirty |= I_DIRTY_DATASYNC;
__cap_delay_requeue(mdsc, ci);
__cap_delay_requeue(mdsc, ci, true);
return dirty;
}

Expand Down Expand Up @@ -2065,7 +2067,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,

/* Reschedule delayed caps release if we delayed anything */
if (delayed)
__cap_delay_requeue(mdsc, ci);
__cap_delay_requeue(mdsc, ci, false);

spin_unlock(&ci->i_ceph_lock);

Expand Down Expand Up @@ -2125,7 +2127,7 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)

if (delayed) {
spin_lock(&ci->i_ceph_lock);
__cap_delay_requeue(mdsc, ci);
__cap_delay_requeue(mdsc, ci, true);
spin_unlock(&ci->i_ceph_lock);
}
} else {
Expand Down

0 comments on commit 6680288

Please sign in to comment.