From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6414331B113 for ; Mon, 17 Nov 2025 20:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763412695; cv=none; b=PZ6sgmZLuqmjUPmeAFuBEAeqgrRhcN+DAaLLKCA56c8ZtSDPqIHVV8sht/IdTrzHyjSL4jqANzCmbLcfQ20weNJo+6qI8VkX40DBad5Q47LbNq5W1WbfhEehGKX1PhKDJgppo0jxVIugUXMRK90oWe7KChbQaHZD4D13DtHD2tM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763412695; c=relaxed/simple; bh=MhRuGKREKjnDv5Rvs5Tcu3ha4BQBYTByx2vMFukybAI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Uk9xddWqTJuUAGdtpSVufVWmETDSP/VhYjbrGWLDA60mkQsiY0lH1TNsYpMuuvoJ1WToaszeMkgunxNTi2Z1jdXjOn7Gu8kxXlNlt+2cFafUa0/xYUitYjptEn2NC15PIEopmQdMJeYjvI/wofEWQfPN1al/00makfqlGHZkgC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=k5JggWYP; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="k5JggWYP" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7b9215e55e6so3058624b3a.2 for ; Mon, 17 Nov 2025 12:51:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1763412692; x=1764017492; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VzhSFtd1TJYR/cIblKSU+QrS3cy0V4ly+fmhKB6r+qY=; b=k5JggWYPoO+BSCmkWvSENgLSY7VpDkFZpUobtUkiLdyHcfvOVjG/7umvPtVzdDJ6Yt GqYhtxescCO4qPkHW7t/atI3oVslTbgyQArfVL/V7yi9eZGXTmbeKh75jxVkFp6jBKBR uM+mK9A3DAbsRNzaCcTKHa446Br/tBeN8ClPiof63iq6kknLAJeWihVvNt+Z5Oc39ug+ sNgufYbP+LieOvVfDnyStlUF9vXgTftwlGOFxEOdALx4yAAJ5wmDahs+nuZqgpRg5HyZ t/XpcIh2k0btXfL358zNgpsPEg9goAYsNZYIoVookT2hpP1/R+cR+G34z2lPDccrh8XN 1Hag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763412692; x=1764017492; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VzhSFtd1TJYR/cIblKSU+QrS3cy0V4ly+fmhKB6r+qY=; b=Lh+meVwEqYnZ6Aa8ak4UrJVe/TrYYhk+IK9jRpMCJQFdf5yqWDr07HPTc2jW51HD1B s+aNPG7k12aTTNUi+pVD4bag/ZqWvMvmhxjU+e9rC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lSkctA94mD5u3ieiUdMxFP9/1+M2F7w== X-Received: by 2002:a05:6a00:982:b0:7b2:2d85:ae59 with SMTP id d2e1a72fcca58-7ba39ecfa9dmr13503855b3a.11.1763412692398; Mon, 17 Nov 2025 12:51:32 -0800 (PST) Received: from dread.disaster.area (pa49-181-58-136.pa.nsw.optusnet.com.au. [49.181.58.136]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b92714df0esm14242994b3a.37.2025.11.17.12.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 12:51:31 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.98.2) (envelope-from ) id 1vL6C7-0000000CADH-2ixk; Tue, 18 Nov 2025 07:51:27 +1100 Date: Tue, 18 Nov 2025 07:51:27 +1100 From: Dave Chinner To: John Garry Cc: Ojaswin Mujoo , Ritesh Harjani , Christoph Hellwig , Christian Brauner , djwong@kernel.org, tytso@mit.edu, willy@infradead.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jack@suse.cz, nilay@linux.ibm.com, martin.petersen@oracle.com, rostedt@goodmis.org, axboe@kernel.dk, linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [RFC PATCH 0/8] xfs: single block atomic writes for buffered IO Message-ID: References: <20251113052337.GA28533@lst.de> <87frai8p46.ritesh.list@gmail.com> <8d645cb5-7589-4544-a547-19729610d44d@oracle.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@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: <8d645cb5-7589-4544-a547-19729610d44d@oracle.com> On Mon, Nov 17, 2025 at 10:59:55AM +0000, John Garry wrote: > On 16/11/2025 08:11, Dave Chinner wrote: > > > This patch set focuses on HW accelerated single block atomic writes with > > > buffered IO, to get some early reviews on the core design. > > What hardware acceleration? Hardware atomic writes are do not make > > IO faster; they only change IO failure semantics in certain corner > > cases. > > I think that he references using REQ_ATOMIC-based bio vs xfs software-based > atomic writes (which reuse the CoW infrastructure). And the former is > considerably faster from my testing (for DIO, obvs). But the latter has not > been optimized. For DIO, REQ_ATOMIC IO will generally be faster than the software fallback because no page cache interactions or data copy is required by the DIO REQ_ATOMIC fast path. But we are considering buffered writes, which *must* do a data copy, and so the behaviour and performance differential of doing a COW vs trying to force writeback to do REQ_ATOMIC IO is going to be much different. Consider that the way atomic buffered writes have been implemented in writeback - turning off all folio and IO merging. This means writeback efficiency of atomic writes is going to be horrendous compared to COW writes that don't use REQ_ATOMIC. Further, REQ_ATOMIC buffered writes need to turn off delayed allocation because if you can't allocate aligned extents then the atomic write can *never* be performed. Hence we have to allocate up front where we can return errors to userspace immediately, rather than just reserve space and punt allocation to writeback. i.e. we have to avoid the situation where we have dirty "atomic" data in the page cache that cannot be written because physical allocation fails. The likely outcome of turning off delalloc is that it further degrades buffered atomic write writeback efficiency because it removes the ability for the filesystem to optimise physical locality of writeback IO. e.g. adjacent allocation across multiple small files or packing of random writes in a single file to allow them to merge at the block layer into one big IO... REQ_ATOMIC is a natural fit for DIO because DIO is largely a "one write syscall, one physical IO" style interface. Buffered writes, OTOH, completely decouples application IO from physical IO, and so there is no real "atomic" connection between the data being written into the page caceh and the physical IO that is performed at some time later. This decoupling of physical IO is what brings all the problems and inefficiencies. The filesystem being able to mark the RWF_ATOMIC write range as a COW range at submission time creates a natural "atomic IO" behaviour without requiring the page cache or writeback to even care that the data needs to be written atomically. >From there, we optimise the COW IO path to record that the new COW extent was created for the purpose of an atomic write. Then when we go to write back data over that extent, the filesystem can chose to do a REQ_ATOMIC write to do an atomic overwrite instead of allocating a new extent and swapping the BMBT extent pointers at IO completion time. We really don't care if 4x16kB adjacent RWF_ATOMIC writes are submitted as 1x64kB REQ_ATOMIC IO or 4 individual 16kB REQ_ATOMIC IOs. The former is much more efficient from an IO perspective, and the COW path can actually optimise for this because it can track the atomic write ranges in cache exactly. If the range is larger (or unaligned) than what REQ_ATOMIC can handle, we use COW writeback to optimise for maximum writeback bandwidth, otherwise we use REQ_ATOMIC to optimise for minimum writeback submission and completion overhead... IOWs, I think that for XFS (and other COW-capable filesystems) we should be looking at optimising the COW IO path to use REQ_ATOMIC where appropriate to create a direct overwrite fast path for RWF_ATOMIC buffered writes. This seems a more natural and a lot less intrusive than trying to blast through the page caceh abstractions to directly couple userspace IO boundaries to physical writeback IO boundaries... -Dave. -- Dave Chinner david@fromorbit.com