From patchwork Mon Sep 25 05:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 726082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 108C3CE7A81 for ; Mon, 25 Sep 2023 05:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbjIYFbh (ORCPT ); Mon, 25 Sep 2023 01:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbjIYFbe (ORCPT ); Mon, 25 Sep 2023 01:31:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D48C6DA for ; Sun, 24 Sep 2023 22:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695619845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R5LIkF2/0hCwA84weq+iv5yAtFIJRmfwxJdVZ0dOy68=; b=bAYgQ6muHorWa5Y4OOX1l0vPzPvOFwq1ReObHrSt0mKPfl9+mSslUOGpgy2RbGVzqKxZPD YYfthL12t64RGmOkPS36HaVuJ9HNvkaXU78XFJE+Z90Q+WftSmL+Pznjwfy6P9/qoLnztK 1Zv8ylFNJ21FvTxRiQqCoH6mSaOEqqo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-lymyRr6XPIyGjs76dUMSHw-1; Mon, 25 Sep 2023 01:30:43 -0400 X-MC-Unique: lymyRr6XPIyGjs76dUMSHw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BDFB811E7D; Mon, 25 Sep 2023 05:30:43 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C08051E3; Mon, 25 Sep 2023 05:30:39 +0000 (UTC) From: xiubli@redhat.com To: ceph-devel@vger.kernel.org Cc: idryomov@gmail.com, jlayton@kernel.org, vshankar@redhat.com, mchangir@redhat.com, Xiubo Li Subject: [PATCH 1/3] ceph: do not break the loop if CEPH_I_FLUSH is set Date: Mon, 25 Sep 2023 13:28:08 +0800 Message-ID: <20230925052810.21914-2-xiubli@redhat.com> In-Reply-To: <20230925052810.21914-1-xiubli@redhat.com> References: <20230925052810.21914-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li For the unlink case we do not want it to be delayed. Else it will be trigger 5 seconds later. Because the MDS maybe stuck waiting for cap revocation. URL: https://tracker.ceph.com/issues/50223 Signed-off-by: Xiubo Li --- fs/ceph/caps.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index dc0402258384..efa036e7619f 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -4624,7 +4624,7 @@ unsigned long ceph_check_delayed_caps(struct ceph_mds_client *mdsc) struct ceph_inode_info *ci; struct ceph_mount_options *opt = mdsc->fsc->mount_options; unsigned long delay_max = opt->caps_wanted_delay_max * HZ; - unsigned long loop_start = jiffies; + unsigned long loop_start = jiffies, end; unsigned long delay = 0; doutc(cl, "begin\n"); @@ -4633,14 +4633,17 @@ unsigned long ceph_check_delayed_caps(struct ceph_mds_client *mdsc) ci = list_first_entry(&mdsc->cap_delay_list, struct ceph_inode_info, i_cap_delay_list); - if (time_before(loop_start, ci->i_hold_caps_max - delay_max)) { - doutc(cl, "caps added recently. Exiting loop"); - delay = ci->i_hold_caps_max; - break; + /* Do not break the loop if CEPH_I_FLUSH is set. */ + if (!(ci->i_ceph_flags & CEPH_I_FLUSH)) { + end = ci->i_hold_caps_max - delay_max; + if (time_before(loop_start, end)) { + doutc(cl, "caps added recently. Exiting loop"); + delay = ci->i_hold_caps_max; + break; + } + if (time_before(jiffies, ci->i_hold_caps_max)) + break; } - if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && - time_before(jiffies, ci->i_hold_caps_max)) - break; list_del_init(&ci->i_cap_delay_list); inode = igrab(&ci->netfs.inode); From patchwork Mon Sep 25 05:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 726081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1272CE7A8C for ; Mon, 25 Sep 2023 05:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjIYFbn (ORCPT ); Mon, 25 Sep 2023 01:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbjIYFbm (ORCPT ); Mon, 25 Sep 2023 01:31:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563EBE8 for ; Sun, 24 Sep 2023 22:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695619848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/+uGUxfHp02RCcRe6BcbF819hU3YIlzLr1cT6smnWaA=; b=g6VE8ldAGbEMyVYXZtgyNbOREoOMt2bUlfh+X9pn3v55Z33IyPR/LBqf1P3zNgbuJiTGTc Q2fD2+R44ZVZeJT2U2ncYFAdYFvjxNDvr6uybC2mW4eyJ+cENYehxUiO3ZQ098JXU4RsSs GR1WHqMcAMankU91Cc7XNRDLHOXDmME= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-bGoeUqeQPSmND2aeMV_qLA-1; Mon, 25 Sep 2023 01:30:46 -0400 X-MC-Unique: bGoeUqeQPSmND2aeMV_qLA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BB611C060C4; Mon, 25 Sep 2023 05:30:46 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD54F51E3; Mon, 25 Sep 2023 05:30:43 +0000 (UTC) From: xiubli@redhat.com To: ceph-devel@vger.kernel.org Cc: idryomov@gmail.com, jlayton@kernel.org, vshankar@redhat.com, mchangir@redhat.com, Xiubo Li Subject: [PATCH 2/3] ceph: always queue a writeback when revoking the Fb caps Date: Mon, 25 Sep 2023 13:28:09 +0800 Message-ID: <20230925052810.21914-3-xiubli@redhat.com> In-Reply-To: <20230925052810.21914-1-xiubli@redhat.com> References: <20230925052810.21914-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li In case there is 'Fw' dirty caps and 'CHECK_CAPS_FLUSH' is set we will always ignore queue a writeback. Queue a writeback is very important because it will block kclient flushing the snapcaps to MDS and which will block MDS waiting for revoking the 'Fb' caps. URL: https://tracker.ceph.com/issues/50223 Signed-off-by: Xiubo Li --- fs/ceph/caps.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index efa036e7619f..7ce275838007 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2156,6 +2156,30 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags) ceph_cap_string(cap->implemented), ceph_cap_string(revoking)); + /* completed revocation? going down and there are no caps? */ + if (revoking) { + if ((revoking & cap_used) == 0) { + doutc(cl, "completed revocation of %s\n", + ceph_cap_string(cap->implemented & ~cap->issued)); + goto ack; + } + + /* + * If the "i_wrbuffer_ref" was increased by mmap or generic + * cache write just before the ceph_check_caps() is called, + * the Fb capability revoking will fail this time. Then we + * must wait for the BDI's delayed work to flush the dirty + * pages and to release the "i_wrbuffer_ref", which will cost + * at most 5 seconds. That means the MDS needs to wait at + * most 5 seconds to finished the Fb capability's revocation. + * + * Let's queue a writeback for it. + */ + if (S_ISREG(inode->i_mode) && ci->i_wrbuffer_ref && + (revoking & CEPH_CAP_FILE_BUFFER)) + queue_writeback = true; + } + if (cap == ci->i_auth_cap && (cap->issued & CEPH_CAP_FILE_WR)) { /* request larger max_size from MDS? */ @@ -2183,30 +2207,6 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags) } } - /* completed revocation? going down and there are no caps? */ - if (revoking) { - if ((revoking & cap_used) == 0) { - doutc(cl, "completed revocation of %s\n", - ceph_cap_string(cap->implemented & ~cap->issued)); - goto ack; - } - - /* - * If the "i_wrbuffer_ref" was increased by mmap or generic - * cache write just before the ceph_check_caps() is called, - * the Fb capability revoking will fail this time. Then we - * must wait for the BDI's delayed work to flush the dirty - * pages and to release the "i_wrbuffer_ref", which will cost - * at most 5 seconds. That means the MDS needs to wait at - * most 5 seconds to finished the Fb capability's revocation. - * - * Let's queue a writeback for it. - */ - if (S_ISREG(inode->i_mode) && ci->i_wrbuffer_ref && - (revoking & CEPH_CAP_FILE_BUFFER)) - queue_writeback = true; - } - /* want more caps from mds? */ if (want & ~cap->mds_wanted) { if (want & ~(cap->mds_wanted | cap->issued))