From nobody Sat Feb 7 13:45:51 2026 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 589F6EB64DC for ; Mon, 19 Jun 2023 13:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232022AbjFSNnI (ORCPT ); Mon, 19 Jun 2023 09:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232006AbjFSNnF (ORCPT ); Mon, 19 Jun 2023 09:43:05 -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 B89D4E78 for ; Mon, 19 Jun 2023 06:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687182136; 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=D31vA8JX9DN+/zyM3aRK1TEDXyUSGbv3rJjPwoSWc28=; b=SFmz8hgrAcfjQSm1FuOqHfFArCiF8CiefNdqRuzWGo9o0gYNzR4pLd+7IGOkUJeIWTXj+9 EvCBaj/lCCkmmr2bhPRYcFnKAYpsy5w89BW2a8v6yzHgk9Zs2gYXznZTjyOaIw7BXQNbBa p4y9oUtYO9NBHV1vBnrRMnN09oZXkNY= 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-Lf93kQWeN1uQcqW1Z8TCFA-1; Mon, 19 Jun 2023 09:42:10 -0400 X-MC-Unique: Lf93kQWeN1uQcqW1Z8TCFA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 080D785A59D; Mon, 19 Jun 2023 13:42:10 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272D040C6E8E; Mon, 19 Jun 2023 13:42:09 +0000 (UTC) From: David Howells To: Linus Torvalds Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH 1/2] afs: Fix dangling folio ref counts in writeback Date: Mon, 19 Jun 2023 14:42:03 +0100 Message-ID: <20230619134204.922713-2-dhowells@redhat.com> In-Reply-To: <20230619134204.922713-1-dhowells@redhat.com> References: <20230619134204.922713-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Vishal Moola (Oracle)" Commit acc8d8588cb7 converted afs_writepages_region() to write back a folio batch. If writeback needs rescheduling, the function exits without dropping the references to the folios in fbatch. This patch fixes that. [DH: Moved the added line before the _leave()] Fixes: acc8d8588cb7 ("afs: convert afs_writepages_region() to use filemap_g= et_folios_tag()") Signed-off-by: Vishal Moola (Oracle) Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20230607204120.89416-1-vishal.moola@gmail.c= om/ --- fs/afs/write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/afs/write.c b/fs/afs/write.c index c822d6006033..fd433024070e 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -763,6 +763,7 @@ static int afs_writepages_region(struct address_space *= mapping, if (wbc->sync_mode =3D=3D WB_SYNC_NONE) { if (skips >=3D 5 || need_resched()) { *_next =3D start; + folio_batch_release(&fbatch); _leave(" =3D 0 [%llx]", *_next); return 0; } From nobody Sat Feb 7 13:45:51 2026 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 5C414EB64D9 for ; Mon, 19 Jun 2023 13:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbjFSNnL (ORCPT ); Mon, 19 Jun 2023 09:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbjFSNnF (ORCPT ); Mon, 19 Jun 2023 09:43:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C3AE63 for ; Mon, 19 Jun 2023 06:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687182137; 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=tmhBzVk04OxjQU7+mvQb9QjdfMiM2IPBAE5pRAjvCBI=; b=Iy1fh8dXS/0t22BInAub8YC+oI8WenROAbdPlINjeDlFdJ3fCp8u4++aoAxHBgs4vKcpZ/ +7ao7h4eiITrlBQYJoQZCBqBmJ+l4jddGbdH+kJfeZOR7zhtVWG9yo03dNY0t+wMXZlm+T iII+J4w32SjEmnTO3hthdh926oqJZIs= 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-401-cY5mjncINvWwWGUMnL5--g-1; Mon, 19 Jun 2023 09:42:11 -0400 X-MC-Unique: cY5mjncINvWwWGUMnL5--g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D65685A58C; Mon, 19 Jun 2023 13:42:11 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906D8C1603B; Mon, 19 Jun 2023 13:42:10 +0000 (UTC) From: David Howells To: Linus Torvalds Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH 2/2] afs: Fix waiting for writeback then skipping folio Date: Mon, 19 Jun 2023 14:42:04 +0100 Message-ID: <20230619134204.922713-3-dhowells@redhat.com> In-Reply-To: <20230619134204.922713-1-dhowells@redhat.com> References: <20230619134204.922713-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Vishal Moola (Oracle)" Commit acc8d8588cb7 converted afs_writepages_region() to write back a folio batch. The function waits for writeback to a folio, but then proceeds to the rest of the batch without trying to write that folio again. This patch fixes has it attempt to write the folio again. [DH: Also remove an 'else' that adding a goto makes redundant] Fixes: acc8d8588cb7 ("afs: convert afs_writepages_region() to use filemap_g= et_folios_tag()") Signed-off-by: Vishal Moola (Oracle) Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20230607204120.89416-2-vishal.moola@gmail.c= om/ --- fs/afs/write.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index fd433024070e..8750b99c3f56 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -731,6 +731,7 @@ static int afs_writepages_region(struct address_space *= mapping, * (changing page->mapping to NULL), or even swizzled * back from swapper_space to tmpfs file mapping */ +try_again: if (wbc->sync_mode !=3D WB_SYNC_NONE) { ret =3D folio_lock_killable(folio); if (ret < 0) { @@ -757,9 +758,10 @@ static int afs_writepages_region(struct address_space = *mapping, #ifdef CONFIG_AFS_FSCACHE folio_wait_fscache(folio); #endif - } else { - start +=3D folio_size(folio); + goto try_again; } + + start +=3D folio_size(folio); if (wbc->sync_mode =3D=3D WB_SYNC_NONE) { if (skips >=3D 5 || need_resched()) { *_next =3D start;