From patchwork Thu Oct 11 03:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6K646Zuq5a+S?= X-Patchwork-Id: 10635691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F470112B for ; Thu, 11 Oct 2018 04:03:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B61E28AD2 for ; Thu, 11 Oct 2018 04:03:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6938028B4B; Thu, 11 Oct 2018 04:03:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FROM_EXCESS_BASE64, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC2328AD2 for ; Thu, 11 Oct 2018 04:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726222AbeJKL2f (ORCPT ); Thu, 11 Oct 2018 07:28:35 -0400 Received: from mtabjsc2.360.cn ([123.125.82.7]:43945 "EHLO mtabjsc2.360.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbeJKL2f (ORCPT ); Thu, 11 Oct 2018 07:28:35 -0400 X-Greylist: delayed 372 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 Oct 2018 07:28:31 EDT Received: from CAS1.corp.qihoo.net (unknown [220.181.158.129]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mtabjsc2.360.cn (QHMAIL) with ESMTP id 00177ABA67A; Thu, 11 Oct 2018 11:56:56 +0800 (CST) Received: from EX02.corp.qihoo.net ([fe80::7882:7b3d:59d6:3fc7]) by CAS1.corp.qihoo.net ([220.181.158.129]) with mapi id 14.03.0319.002; Thu, 11 Oct 2018 11:57:20 +0800 From: =?eucgb2312_cn?b?0O3Rqbqu?= To: "ukernel@gmail.com" CC: "ceph-devel@vger.kernel.org" Subject: [PATCH] ceph: set timeout conditionally in __cap_delay_requeue Thread-Topic: [PATCH] ceph: set timeout conditionally in __cap_delay_requeue Thread-Index: AdRhFnf3IhSZsfNeQ1+rfoH8+NeNmw== Date: Thu, 11 Oct 2018 03:57:21 +0000 Message-ID: <23B01353C2E80240BBE34865782DFE01359A8F9C@EX02.corp.qihoo.net> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.18.22.137] MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP __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 --- fs/ceph/caps.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 990258c..486cc77 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -533,9 +533,11 @@ 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) { - __cap_set_timeouts(mdsc, ci); + if (set_timeout) + __cap_set_timeouts(mdsc, ci); dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode, ci->i_ceph_flags, ci->i_hold_caps_max); if (!mdsc->stopping) { @@ -734,7 +736,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) { @@ -1661,7 +1663,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; } @@ -2079,7 +2081,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); @@ -2139,7 +2141,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 {