Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp232363rbb; Fri, 23 Feb 2024 20:18:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXRPQq9i3q86OssPxoJGOUdhEfkxJz3xcWy/4TAUmc2fdmlFzJ0Q+xnAzk3n75gAVziiev1uZsPRCKFq8Eir/GzhD0569q5uQPq43XW4g== X-Google-Smtp-Source: AGHT+IEWC8DgRn68AX/QFg+HifXzYy9ESSbM3j5n+QsPUmn3GbCKWaliszbtWqnk+xAyEmydFlOU X-Received: by 2002:a0c:9c88:0:b0:68f:cd2c:ee9f with SMTP id i8-20020a0c9c88000000b0068fcd2cee9fmr1523114qvf.29.1708748322295; Fri, 23 Feb 2024 20:18:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708748322; cv=pass; d=google.com; s=arc-20160816; b=BMbKy78LiG1lZZ2OZFCI9oJjO+/D1AMrQyZ6Prh0IANSktQNZccKlmNUnDBfFkSyQD TqE3Gvb9tAGeiW2AbcCGiwMSEKHJskY3PdiI9g74twYdXSVYKLz2jqLaBkuoepQNFeJw HB7NewVZj/sdbcAEh7tS7cJi9sAtlOo215lg8ScSMGO3aMdsxgqUmalhrBPSVBxotI+n tQRVp7tc/ESRkBZjR+5opxTs5+BmkW4qmfmvoXXUStf8voE1f4rwN7cpiKCNvIsm2EMB wcUjm7CF0yUj5h09OfttB4QSzCx3VW+09PylWSMX6Tj93w9o+7bT7e7b8bfoTcv0S2ke Oz1g== ARC-Message-Signature: i=2; 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=zsbpibCDZ1OkcnS2BF6B89msoz++CRJ57NAPj55FEh8=; fh=ZES2Ln2z5XVE4VFaIszdK+z+q92e5ayIKWQzYidgbmg=; b=OpoBcz14WGraQBZzgIva5NWQiBJLgzy/bx/YZ1+coj2KfqhUEh9wOYSbudu7i76LkO h1oN48ygDeLxpga+0TsYgeiQBEXfpAl2qESmX8L0NqVRmOjAk0lyHrG1++t1aFD/XYKb sfi82aP6AiBn+sVFrskULCce4lS2LcGPpdB80VC4SCezB6VqmxVZUdASFnJmDOQf/pDu CrEtX9QElW2dA+ObYUxxvVxXHC8W+ncenOuCnzi4co4OijScdXM4w/MYp6gU7/x0eQrk nQcGPY89vGbIhJmQd0G31Hyzpf8c/miYzdbOy0OHfaUxg4WQ3bwHsw5rAnh+ljigHrtY lrRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dI5zVrCS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 8-20020a05621420a800b0068ec08c8732si380204qvd.195.2024.02.23.20.18.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 20:18:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79464-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=@kernel.org header.s=k20201202 header.b=dI5zVrCS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79464-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 091A21C2206D for ; Sat, 24 Feb 2024 04:18:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 720C8171A7; Sat, 24 Feb 2024 04:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dI5zVrCS" 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 8123314013; Sat, 24 Feb 2024 04:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708748311; cv=none; b=oFOGYvyXTfEIDSB0HXaQyvXbPh1kvLjPWyT4mN2fE+vPNtf1Ec0W0Ffeoh4Cci7Oas99Sxg7Vg+1bqukxXgs1UQKerxcsh/HiMpWAcVgPDdRtZO8kShMioqBoEV5bSK4fsWTSH59fKzEYMnYRtkHSFGLIcmD0GBC6fATrWaOkHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708748311; c=relaxed/simple; bh=PlOmuFhugEwwRV6cuY7RCU8BXAR4nueeMtbiA2O68Hk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JBwtpvPmPC5fFshKsz3bnF5DhKnXt/Z3GbxLPskdUMI4FRYDnSJC0wqrV6L3Gru5RsIEjJuuDBawqApy2rPxnrdKJZ/owEFHqJ+8cdaxueGzMu3sP3QOsKNBzk2UCihZY9IRLnElMwBGmUACB1+aFiM7ihaiL2xSDuBVh3DeUiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dI5zVrCS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE431C433C7; Sat, 24 Feb 2024 04:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708748310; bh=PlOmuFhugEwwRV6cuY7RCU8BXAR4nueeMtbiA2O68Hk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dI5zVrCSJkhKhvZL66iKGt5qW9XRFwbM3LAXpnKm91wdxJ7id/P3Ay+NHaF39zKW1 xr02bKBnmI2u71g5MldyqRHEEVjlmluG7xkUDpYjwGYw0P/yd/1RBVb3NkQ9Ki/K5Y 6H7sCJe8p6kFWmqX4nQKJVaErmdqsXm1okBy/DHID3qU4FEBUKt7mxfrNXJwSeA5EZ IInQkbvL9FIyLoXGy3DYV6RpCzgxUn7a6NgQGw/xm5/naL90M89uQjwikNL7/RVDOt gySUvsirys0x9s7+FQ+KcHTPPUlLwsm2w20jtjwzAsXgupy1ZS1G6em78HWZyIzJpK /VMA3a+VILYaA== Date: Fri, 23 Feb 2024 20:18:30 -0800 From: "Darrick J. Wong" To: John Garry Cc: hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, chandan.babu@oracle.com, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com Subject: Re: [PATCH 6/6] fs: xfs: Set FMODE_CAN_ATOMIC_WRITE for FS_XFLAG_ATOMICWRITES set Message-ID: <20240224041830.GK6184@frogsfrogsfrogs> References: <20240124142645.9334-1-john.g.garry@oracle.com> <20240124142645.9334-7-john.g.garry@oracle.com> <20240202180619.GK6184@frogsfrogsfrogs> <7e3b9556-f083-4c14-a48f-46242d1c744b@oracle.com> <20240213175954.GV616564@frogsfrogsfrogs> <20240221170031.GI6184@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-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: On Wed, Feb 21, 2024 at 05:38:39PM +0000, John Garry wrote: > On 21/02/2024 17:00, Darrick J. Wong wrote: > > > > Hmm. Well, if we move towards pushing all the hardware checks out of > > > > xfs/iomap and into whatever goes on underneath submit_bio then I guess > > > > we don't need to check device support here at all. > > > Yeah, I have been thinking about this. But I was still planning on putting a > > > "bdev on atomic write" check here, as you mentioned. > > > > > > But is this a proper method to access the bdev for an xfs inode: > > > > > > STATIC bool > > > xfs_file_can_atomic_write( > > > struct xfs_inode *inode) > > > { > > > struct xfs_buftarg *target = xfs_inode_buftarg(inode); > > > struct block_device *bdev = target->bt_bdev; > > > > > > if (!xfs_inode_atomicwrites(inode)) > > > return false; > > > > > > return bdev_can_atomic_write(bdev); > > > } > > There's still a TOCTOU race problem if the bdev gets reconfigured > > between xfs_file_can_atomic_write and submit_bio. > > If that is the case then a check in the bio submit path is required to catch > any such reconfigure problems - and we effectively have that in this series. > > I am looking at change some of these XFS bdev_can_atomic_write() checks, but > would still have a check in the bio submit path. "check in the bio submit path" sounds good to me. Adding in redundant checks which are eventually gated on whatever submit_bio does sounds like excessive overhead and layering violations. > > > > However, if you're only using this to advertise the capability via statx > > then I suppose that's fine -- userspace has to have some means of > > discovering the ability at all. Userspace is also inherently racy. > > > > > I do notice the dax check in xfs_bmbt_to_iomap() when assigning iomap->bdev, > > > which is creating some doubt? > > Do you mean this? > > > > if (mapping_flags & IOMAP_DAX) > > iomap->dax_dev = target->bt_daxdev; > > else > > iomap->bdev = target->bt_bdev; > > > > The dax path wants dax_dev set so that it can do the glorified memcpy > > operation, and it doesn't need (or want) a block device. > > Yes, so proper to use target->bt_bdev for checks for bdev atomic write > capability, right? Right. fsdax doesn't support atomic memcpy to pmem. --D > > Thanks, > John > >