Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2894741rdb; Mon, 4 Dec 2023 10:17:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEd2j697HGH4qIKCSgV9Xxo/PLmABhRbtl7m5UcWBPKm1IJEhkx3o3PJAW0gf9AlWKpAMK X-Received: by 2002:a17:902:aa85:b0:1d0:a0f2:afac with SMTP id d5-20020a170902aa8500b001d0a0f2afacmr1407967plr.131.1701713856171; Mon, 04 Dec 2023 10:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713856; cv=none; d=google.com; s=arc-20160816; b=SfFvrf9EzHLb78RhM4jD90ywcbFUjF+YKtCon7KYJ4aj/Xc8L1DQe8FuwqUpX/AIYf xVWWjrrQsLGyWXPqsta8yaKGuFhdlxAa2HdfEe2JWmMxB5l3WqyYbghkUJ1B3LCzSRCR ya5J/SC2GkKkRh1onSzAF4ck+bSiYe/d353dez44f1b+dtgDA/DPPoNXkI3ij2klCro8 OHtWU2fv38YHPj4ejzcKAbsQLF8uldsjbcGbylgr+zHTzR698y2MIonNXy5pZg6rFapY jISPPgb3F4he+fXvmy+OqD9MDMnmeVil6vFFxlDXmStuClOENIKbXeMl8h0vvJo8stvP IFWA== 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=UyN0HvWCitjIQSsmGnWIjZjSCCnw4k4+Do56oiQYRHk=; fh=9+yawRdfwWYUklguQ2p+2cRCq62qAB17xEn49ckYe18=; b=hPrVncb1nAoGBRG6ZkuHIciNuk3vZBMwiGDMgjGo4VXz1ifJDNdqWQdRRqTW+115+U Oz4en/y39NfIua+d/PXarASt7xEibM97F5jy6UDxDXOipURCujyNA/I9yyKmQu8Y6IZC NxAuLVwkgEHGvq9wLVWOal8hTqDZe+QvQJNyEMSiL6lQfL6KzprC8k3rppanPT8PdJKG +Vd5DPqrKdVjUnsmLyhrn7nILJ15DslSc1gUFS/mAaeadxfg20gUTqAE6QsoZd+pXZI9 MtWugDl52qsfwtVoLcjGd5Ird3fLRujRBwOL4LiRoCkbxj67xawEgC+JKwAP3HHn+JEn Gbtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NBX05rBX; spf=pass (google.com: domain of linux-ext4+bounces-284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h10-20020a170902f7ca00b001cfb65f4c9asi5555190plw.570.2023.12.04.10.17.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:17:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NBX05rBX; spf=pass (google.com: domain of linux-ext4+bounces-284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B7708281168 for ; Mon, 4 Dec 2023 18:17:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B90D2F844; Mon, 4 Dec 2023 18:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NBX05rBX" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D28932EAE0; Mon, 4 Dec 2023 18:17:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50E2DC433C7; Mon, 4 Dec 2023 18:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701713844; bh=Fi3pCbX8xBLieIUl9i0+l3BnMEoZrFImzIzLlsbdmlc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NBX05rBXcx3ydA9sc8mTA1ymvmz4Tbzz4ipYsOMzJwDp1ClUWoLQipwGJy1B2ADNR YkmKuZ/Lqx86w+MELHqE7hN5P9AVRcAPrpwA7neD/d19X4kRo7PdpNTUupwLmn1Qwe 6lUjhNpN/xXHzmSxNbvhGgyGB5/RcsEuLlTFfM9AhlTDYdcgkRXdABeUgl4DZhzENz xL4IUZsGH0M10mKsRlQj1A1tLf3ODzjze5ZGrjJgqE0Swe1YxLiscoZJ1wBVU93r+L LIO9sv41gm4RohmK+Qfx20R7yOGMPoKjm6cgaLxOnYOQKe28gj5s3EaFRVNHZYBOfg wsvkI/ci8fS+Q== Date: Mon, 4 Dec 2023 10:17:23 -0800 From: "Darrick J. Wong" To: John Garry Cc: Dave Chinner , Ojaswin Mujoo , linux-ext4@vger.kernel.org, Theodore Ts'o , Ritesh Harjani , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, dchinner@redhat.com Subject: Re: [RFC 1/7] iomap: Don't fall back to buffered write if the write is atomic Message-ID: <20231204181723.GW361584@frogsfrogsfrogs> References: <09ec4c88b565c85dee91eccf6e894a0c047d9e69.1701339358.git.ojaswin@linux.ibm.com> <85d1b27c-f4ef-43dd-8eed-f497817ab86d@oracle.com> <2aced048-4d4b-4a48-9a45-049f73763697@oracle.com> 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: <2aced048-4d4b-4a48-9a45-049f73763697@oracle.com> On Mon, Dec 04, 2023 at 09:02:56AM +0000, John Garry wrote: > On 01/12/2023 22:07, Dave Chinner wrote: > > > Sure, and I think that we need a better story for supporting buffered IO for > > > atomic writes. > > > > > > Currently we have: > > > - man pages tell us RWF_ATOMIC is only supported for direct IO > > > - statx gives atomic write unit min/max, not explicitly telling us it's for > > > direct IO > > > - RWF_ATOMIC is ignored for !O_DIRECT > > > > > > So I am thinking of expanding statx support to enable querying of atomic > > > write capabilities for buffered IO and direct IO separately. > > You're over complicating this way too much by trying to restrict the > > functionality down to just what you want to implement right now. > > > > RWF_ATOMIC is no different to RWF_NOWAIT. The API doesn't decide > > what can be supported - the filesystems themselves decide what part > > of the API they can support and implement those pieces. > > Sure, but for RWF_ATOMIC we still have the associated statx call to tell us > whether atomic writes are supported for a file and the specific range > capability. > > > > > TO go back to RWF_NOWAIT, for a long time we (XFS) only supported > > RWF_NOWAIT on DIO, and buffered reads and writes were given > > -EOPNOTSUPP by the filesystem. Then other filesystems started > > supporting DIO with RWF_NOWAIT. Then buffered read support was added > > to the page cache and XFS, and as other filesystems were converted > > they removed the RWF_NOWAIT exclusion check from their read IO > > paths. > > > > We are now in the same place with buffered write support for > > RWF_NOWAIT. XFS, the page cache and iomap allow buffered writes w/ > > RWF_NOWAIT, but ext4, btrfs and f2fs still all return -EOPNOTSUPP > > because they don't support non-blocking buffered writes yet. > > > > This is the same model we should be applying with RWF_ATOMIC - we > > know that over time we'll be able to expand support for atomic > > writes across both direct and buffered IO, so we should not be > > restricting the API or infrastructure to only allow RWF_ATOMIC w/ > > DIO. > > Agreed. > > > Just have the filesystems reject RWF_ATOMIC w/ -EOPNOTSUPP if > > they don't support it, > > Yes, I was going to add this regardless. > > > and for those that do it is conditional on > > whther the filesystem supports it for the given type of IO being > > done. > > > > Seriously - an application can easily probe for RWF_ATOMIC support > > without needing information to be directly exposed in statx() - just > > open a O_TMPFILE, issue the type of RWF_ATOMIC IO you require to be > > supported, and if it returns -EOPNOTSUPP then it you can't use > > RWF_ATOMIC optimisations in the application.... > > ok, if that is the done thing. > > So I can't imagine that atomic write unit range will be different for direct > IO and buffered IO (ignoring for a moment Christoph's idea for CoW always > for no HW offload) when supported. But it seems that we may have a scenario > where statx tells is that atomic writes are supported for a file, and a DIO > write succeeds and a buffered IO write may return -EOPNOTSUPP. If that's > acceptable then I'll work towards that. > > If we could just run statx on a file descriptor here then that would be > simpler... statx(fd, "", AT_EMPTY_PATH, ...); ? --D > Thanks, > John > > >