From patchwork Fri Jul 1 02:29:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 586345 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 EEE03C43334 for ; Fri, 1 Jul 2022 02:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233444AbiGACaJ (ORCPT ); Thu, 30 Jun 2022 22:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbiGACaG (ORCPT ); Thu, 30 Jun 2022 22:30:06 -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 ESMTP id 67B0860526 for ; Thu, 30 Jun 2022 19:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656642603; 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=n01m7VtXtdcuVzabA727+AaQVBJTldyYELej6RdPk8I=; b=ZZfCooLjJzheVh/mnb/03Xm3Xcqdg7AjodbFERPFgxSAzCOd3LcU8Q9f7Yel2e+ghleMEb ubXETBFgxF0j+4ECfO/rc/3098vvXJPqeVlc/GuYJVjLc40JG+VkTtuWK7+BTeO8uN59dN 0lKSFUgHwEdZg6WOjAigkXCTtY9oX8c= Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-364-VcjoUJ4FN7i-WkIkYCoPTg-1; Thu, 30 Jun 2022 22:30:00 -0400 X-MC-Unique: VcjoUJ4FN7i-WkIkYCoPTg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4C823C025CD; Fri, 1 Jul 2022 02:29:59 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1DE82026D64; Fri, 1 Jul 2022 02:29:55 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org, idryomov@gmail.com, dhowells@redhat.com Cc: vshankar@redhat.com, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, willy@infradead.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, Xiubo Li Subject: [PATCH 1/2] netfs: release the folio lock and put the folio before retrying Date: Fri, 1 Jul 2022 10:29:46 +0800 Message-Id: <20220701022947.10716-2-xiubli@redhat.com> In-Reply-To: <20220701022947.10716-1-xiubli@redhat.com> References: <20220701022947.10716-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li The lower layer filesystem should always make sure the folio is locked and do the unlock and put the folio in netfs layer. URL: https://tracker.ceph.com/issues/56423 Signed-off-by: Xiubo Li --- fs/netfs/buffered_read.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 42f892c5712e..257fd37c2461 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -351,8 +351,11 @@ int netfs_write_begin(struct netfs_inode *ctx, ret = ctx->ops->check_write_begin(file, pos, len, folio, _fsdata); if (ret < 0) { trace_netfs_failure(NULL, NULL, ret, netfs_fail_check_write_begin); - if (ret == -EAGAIN) + if (ret == -EAGAIN) { + folio_unlock(folio); + folio_put(folio); goto retry; + } goto error; } } From patchwork Fri Jul 1 02:29:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 586531 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 3EC2DC43334 for ; Fri, 1 Jul 2022 02:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233342AbiGACaP (ORCPT ); Thu, 30 Jun 2022 22:30:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233336AbiGACaK (ORCPT ); Thu, 30 Jun 2022 22:30:10 -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 ESMTP id 9D8006052F for ; Thu, 30 Jun 2022 19:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656642608; 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=FQz5T2SvnREyVd422FUfN9wuhrBc8hz6OFIwBIgy+C4=; b=OqLk9mfhx8LzU79yL8IsrCf9siFKlHg01La3/EkXZfUTd5hmzjYvCPEQ+pAouuGzUC6qie qGgnab58vnSY7TfsGo/Ca76F0s09GzrU5/BFvE9PFWmQ5tJiDXG84btKJEiUGBOJelFrzC +DqHvnlPs6GvcnbOu6lsIMKsJSI5VOY= 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-292-NEJFAeYDO4uDDcgj9LEyvw-1; Thu, 30 Jun 2022 22:30:04 -0400 X-MC-Unique: NEJFAeYDO4uDDcgj9LEyvw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 702CF101A588; Fri, 1 Jul 2022 02:30:04 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CBBC2026D64; Fri, 1 Jul 2022 02:30:00 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org, idryomov@gmail.com, dhowells@redhat.com Cc: vshankar@redhat.com, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, willy@infradead.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, Xiubo Li Subject: [PATCH 2/2] ceph: do not release the folio lock in kceph Date: Fri, 1 Jul 2022 10:29:47 +0800 Message-Id: <20220701022947.10716-3-xiubli@redhat.com> In-Reply-To: <20220701022947.10716-1-xiubli@redhat.com> References: <20220701022947.10716-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li The netfs layer should be responsible to unlock and put the folio, and we will always return 0 when succeeds. URL: https://tracker.ceph.com/issues/56423 Signed-off-by: Xiubo Li --- fs/ceph/addr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index fe6147f20dee..3ef5200e2005 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1310,16 +1310,16 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned if (snapc) { int r; - folio_unlock(folio); - folio_put(folio); if (IS_ERR(snapc)) return PTR_ERR(snapc); + folio_unlock(folio); ceph_queue_writeback(inode); r = wait_event_killable(ci->i_cap_wq, context_is_writeable_or_written(inode, snapc)); ceph_put_snap_context(snapc); - return r == 0 ? -EAGAIN : r; + folio_lock(folio); + return r == 0 ? -EAGAIN : 0; } return 0; }