Message ID | 20240109112029.1572463-5-dhowells@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp41142dyi; Tue, 9 Jan 2024 03:23:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOifXVtpnWamT8dRSNSTZYPEp+NCm+rx15TV+Mk0ljS1RdScZ2If/VxXMg9XetzJtB8FuS X-Received: by 2002:a50:d492:0:b0:557:e919:3940 with SMTP id s18-20020a50d492000000b00557e9193940mr499729edi.2.1704799412589; Tue, 09 Jan 2024 03:23:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704799412; cv=none; d=google.com; s=arc-20160816; b=O9x+bAXGAx5HeqRone5Z8hKeIkhGq+r6mTbia2HnHQPkpspYLftGZMpzFytH1QXULC l62NEf+jsxpIXFSUYq1HJidY+iYyIXtgVyMWcxHCmvnXnDLn94YBBBlJHImCkI1z/aVX 9HDt03dj1SQD4ECAMKoSUQfRWzzSaSk4aEWs8eaCCa5MyhNXQHSxUY0r6/7DyclaeTfx i2S5RsvgUM/mDzV6ngWVktSUu2nSQQfC+qDm19QoCEgYQ0hTycCLa7n00fr6it11BqM9 SGayP9AM3bZm8pOEzHuLjEt1gcZPjbp81VfLkWZusxiOnAXSXU8/CFnTK/yomcakK4PC DO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v9Zmt8qPNtA4BbCqgJuw0LKGT28DtGNcpxFrcZYWG/0=; fh=wHeWnRAPvg2xJ56RgmOMhm93PiD0Bj1H5ZiEjecP7fw=; b=QMmpEhZJo7eZt4Z1XEkJeZd3zIXNjV2gNkghndViitxzdUIgSSnfqGmwbiSQVv+JgH ll50s8Qi9bQPuX32ranrsRdT/bQ0v/NvcyHUoIAIVRLGI0DeleAsPO1rBNojZ2Z9VbSs 8GiZlOA5DbDkTlmE/PZOAW62g2Q6u4Rslx+loYgukjXrKTXfZ0tLlxsiZDPWHZGcIeqX F4J+RImgZWy+BLMhvL5bX6gPMbyiZuaaCujNwc3NGu68UrGqExLhE8KOpuRYxbpxNSW5 jpJXgoY08OMOYZdUVl9eqJquNxV7n+v0XQUYx0Wa7UDWiBs3Gz+otkhr8Ak/oM0gvQb/ p7uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=elitUFS1; spf=pass (google.com: domain of linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q8-20020a50c348000000b0055829a8c716si6219edb.169.2024.01.09.03.23.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 03:23:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=elitUFS1; spf=pass (google.com: domain of linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20760-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3877D1F23584 for <ouuuleilei@gmail.com>; Tue, 9 Jan 2024 11:23:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD0AE39AD8; Tue, 9 Jan 2024 11:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="elitUFS1" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D2039870 for <linux-kernel@vger.kernel.org>; Tue, 9 Jan 2024 11:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704799258; 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=v9Zmt8qPNtA4BbCqgJuw0LKGT28DtGNcpxFrcZYWG/0=; b=elitUFS17RNYLyh4NrsXXo12fnyDkbYf77V6a9cH4wTJCJzRHAK9Y8m9R4LZtLzv1llWY9 YMpeKjKk+8DLsHvjL2/XuICFUmubB4ut/GZpbO8G1MvRAhNW9ZB6x76u9R8prQ9Zz/gsqH 8bnSAqyDbAjfykeaZNjShBmm6dr+0AM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-aZtDJMnWPAi-V2MIXSUMUQ-1; Tue, 09 Jan 2024 06:20:54 -0500 X-MC-Unique: aZtDJMnWPAi-V2MIXSUMUQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28F8329AA3AF; Tue, 9 Jan 2024 11:20:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CD382166B32; Tue, 9 Jan 2024 11:20:50 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Christian Brauner <christian@brauner.io>, Jeff Layton <jlayton@kernel.org>, Gao Xiang <hsiangkao@linux.alibaba.com>, Dominique Martinet <asmadeus@codewreck.org> Cc: David Howells <dhowells@redhat.com>, Steve French <smfrench@gmail.com>, Matthew Wilcox <willy@infradead.org>, Marc Dionne <marc.dionne@auristor.com>, Paulo Alcantara <pc@manguebit.com>, Shyam Prasad N <sprasad@microsoft.com>, Tom Talpey <tom@talpey.com>, Eric Van Hensbergen <ericvh@kernel.org>, Ilya Dryomov <idryomov@gmail.com>, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] netfs: Fix the loop that unmarks folios after writing to the cache Date: Tue, 9 Jan 2024 11:20:21 +0000 Message-ID: <20240109112029.1572463-5-dhowells@redhat.com> In-Reply-To: <20240109112029.1572463-1-dhowells@redhat.com> References: <20240109112029.1572463-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787611748566265477 X-GMAIL-MSGID: 1787611748566265477 |
Series |
netfs, cachefiles: More additional patches
|
|
Commit Message
David Howells
Jan. 9, 2024, 11:20 a.m. UTC
In the loop in netfs_rreq_unmark_after_write() that removes the PG_fscache
from folios after they've been written to the cache, as soon as we remove
the mark from a multipage folio, it can get split - and then we might see a
fragment of folio again.
Guard against this by advancing the 'unlocked' tracker to the index of the
last page in the folio to avoid a double removal of the PG_fscache mark.
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: linux-afs@lists.infradead.org
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
---
fs/netfs/buffered_write.c | 1 +
fs/netfs/io.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 6cd8f7422e9a..0b2b7a60dabc 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -698,6 +698,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq) end_wb: if (folio_test_fscache(folio)) folio_end_fscache(folio); + xas_advance(&xas, folio_next_index(folio) - 1); folio_end_writeback(folio); } diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 5b5af96cd4b9..4309edf33862 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -126,7 +126,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq, */ if (have_unlocked && folio_index(folio) <= unlocked) continue; - unlocked = folio_index(folio); + unlocked = folio_next_index(folio) - 1; trace_netfs_folio(folio, netfs_folio_trace_end_copy); folio_end_fscache(folio); have_unlocked = true;