Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4415718rdb; Mon, 11 Dec 2023 20:37:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMR/Q7RyMkbiMKbZkNa7wGa46yJRYTyC/1bzyzaSSazcF7q6jxbc2+KpARp6KjP/EGbTAG X-Received: by 2002:a05:622a:14c6:b0:425:a8a7:54dd with SMTP id u6-20020a05622a14c600b00425a8a754ddmr6856019qtx.103.1702355831669; Mon, 11 Dec 2023 20:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702355831; cv=none; d=google.com; s=arc-20160816; b=ozytBoFaghVOYH5ujd0SjG8ZPPCIbythso/mmcwEclN+KT6z5oVWs+JUwB1rBPP0Kg ONFZTye2J3wrGXcqW3nNw1BJ7NNvQpeCDlmRKxW4z7UQQ7QMn6lUuR++8NXsRNBzLHmb +d+Mmj6jiipT0OrBBkFFdy/Xd1HU/yPpJ4fzWlJdlI+CyhiBXsrDu9/yYc3HkXZvbP8B bhs19NVnnkNhOaIFI21EqPECHFMPxUMI7i0LSJ8JglFaoxvLkdvNJl+30kc30MYhE++J TybnKodToVAOipH3M+NE4bM6Y85BER9YLuC/G9B8KVtN/LHXdBYwRDie1ynvBw6UZC/i Pnbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UterbU1lY68chbDZ2KRFpiUZP8yEoxB+cO4YjpDyhgk=; fh=XokN96238wUlGY7e41Uy10q4PxCfYPMRAHiKi5xO9j0=; b=lGgv8XWarITQanf2SyQW2lMAyimqLMAO19MBjf4j4XWr1P898sbuvW6MJ9qCmHKvmJ DTmeqNt6WPr+oXkFWgy2I3xfjQXW8kp9taCkl68ImpNyBS3Uboy2MoHdueJw1TXRIu17 LWhf5V7BQKlZaAUiB/9AX7bQ7dAUJVIhJ1l87R1hJZ6ZzIf0h5EllF6utEFqGzgco3MT 3jQN8yjiuqKRFcG0PeFLUKGjdn7xeQixJkTbWk0JwgXnkSgEVnFaiE7G2AaFwIwzC2Hr FHOhfRRN4hzrLCMe31pLYV3v5QmdVU+CAntPJ1KFzBNg6gxYY1dPbVRrYDiAQirauso1 lXEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YZTKS8kt; spf=pass (google.com: domain of linux-ext4+bounces-387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-387-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ci27-20020a05622a261b00b00425814dc80fsi10729972qtb.333.2023.12.11.20.37.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 20:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YZTKS8kt; spf=pass (google.com: domain of linux-ext4+bounces-387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-387-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B9CF1C21AB1 for ; Tue, 12 Dec 2023 04:37:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3864AD2E1; Tue, 12 Dec 2023 04:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YZTKS8kt" X-Original-To: linux-ext4@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1842A6; Mon, 11 Dec 2023 20:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=UterbU1lY68chbDZ2KRFpiUZP8yEoxB+cO4YjpDyhgk=; b=YZTKS8ktQn3PVpr4ijYJlRv8d8 Wcxi6WSeFcE8qV1rz/zSjQoCASaX94/5/JjH22enU+grOyzAE9nzAbLPkksSyIBMH3Z6b9ITOsgjl 75H3pcfXBxFRObCMZVievtZQsN2oCPAVYZJVNUZWM8RlNiyQM2EEvJ/EqwVj4w4D4hqpME+/qtinO TKzfYz+Sqf9ZieUatcd/hX3xNiKk8/6Pvdvm8A6kwALWaPkpi7vg+fDpZUymcLeBlb8dZLjco6+Gr ZGevd+JOdMdDH9JsXAiJG4hvdkKZS/BftgjpDMEy5Z9uWeofuDkRlXi4B6IS+N/mLYpPxZ3fR1CmN 8L1aUoGw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCuVi-009cuU-0H; Tue, 12 Dec 2023 04:36:46 +0000 Date: Tue, 12 Dec 2023 04:36:45 +0000 From: Matthew Wilcox To: Jan Kara Cc: Baokun Li , linux-mm@kvack.org, linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, akpm@linux-foundation.org, ritesh.list@gmail.com, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH -RFC 0/2] mm/ext4: avoid data corruption when extending DIO write race with buffered read Message-ID: References: <20231202091432.8349-1-libaokun1@huawei.com> <20231204121120.mpxntey47rluhcfi@quack3> <20231204144106.fk4yxc422gppifsz@quack3> <70b274c2-c19a-103b-4cf4-b106c698ddcc@huawei.com> <20231206193757.k5cppxqew6zjmbx3@quack3> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231206193757.k5cppxqew6zjmbx3@quack3> On Wed, Dec 06, 2023 at 08:37:57PM +0100, Jan Kara wrote: > Within the same page buffered reads and writes should be consistent because > they are synchronized by the page lock. However once reads and writes > involve multiple pages, there is no serialization so you can get contents > of some pages before write and some pages after being written. However this > doesn't seem to be your particular case here. I just wanted to point out > that in general even buffered reads vs writes are not fully consistent. Buffered reads don't take the page/folio lock. We only use the folio lock to avoid reading stale data from the page cache while we're fetching the data from storage. Once the uptodate flag is set on the folio, we never take the folio lock for reads.