Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2049934rdb; Tue, 3 Oct 2023 08:47:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRz24oAMpacD2NBUeiUv58FePtk1JCpxIldDBeYlupIn1ggeSuQnpxU9qA12mG5zVtylqA X-Received: by 2002:a17:902:a404:b0:1c7:495c:87e0 with SMTP id p4-20020a170902a40400b001c7495c87e0mr10682842plq.37.1696348031360; Tue, 03 Oct 2023 08:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696348031; cv=none; d=google.com; s=arc-20160816; b=xdqS+ivPDddrf8BE330wQ/UEROE/WI6yTJzd/nRnJVVvLTInW9L1LeGynAd4fOXeFR oEXw345J+OW4kyUYyESX/kV00LiQPWLV/BD9LwQwMh6maipJ0K3JXCCjWRmXhdXYOvMa pBEh1QcHiCCqITuDwEydfXyp5eG0JIbTp2DXRcyl3atcMoMoA+lff81hK+Obaq39IydE eJbEtV0EoeZRqCV84l5TPc9cU8eQgvGJZnstgQvwR7Qkj9Uho2bKflPSGMsRYMy/J4g9 LsuHDEgfdicnh9+u6L/Ep0sKOgDpBdr0xeXm+ZXgEoAlLElzc8lI9kwZT1fzaNq4B9FD S6hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hSv6YEzEqXqU6ZyJPo7ZIAbhwh66qV0sq2j32gYsx4M=; fh=0V5oThak+53Vk5tDLiR5pyKL4qRrpdU+F9jI4jAAApk=; b=a863rOSWiuR2xXdcWA+fKgyw8XP7gnk8mMu4nZo8JvnGxVzgziyX8caBSTxwdHZsOZ 7RyCI6lUc4ceQtIkAlpu6BjNQUpNANxhpK5TFuS6ugKxlMZjYbyTj+1AzCLt07P3u46J 2EPT6LbGxEBA21hF5htk3rIQOm+Hrg/j6IkLClF9zBRyJ1ZvcjzS5SErYd82PuTMEme2 shH/mAsYc0pugt+y2pEXmgQX/7wXe26RByt/KZef0jTW84p5ZlcFFK6qXDFHO1AZeOuz giFR/s9SM8I7493Ea3USGKTDa5ZQSNRB4H1YvR7MB81J2LGr1whjRiyPqSr8Aponxy4D DnbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nvLUqefq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q13-20020a170902c9cd00b001c62cfff79dsi1601914pld.194.2023.10.03.08.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nvLUqefq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 03C48807C5C7; Tue, 3 Oct 2023 08:47:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231694AbjJCPqt (ORCPT + 99 others); Tue, 3 Oct 2023 11:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbjJCPqs (ORCPT ); Tue, 3 Oct 2023 11:46:48 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D214495; Tue, 3 Oct 2023 08:46:44 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 396FEC433C7; Tue, 3 Oct 2023 15:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696348004; bh=9Om6q6hLGFKck5uVF88QEHxSQb3JRjlgYRDBBS8Ko7Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nvLUqefqqq+UfAdun974USJG2lGVA+E9uzE1UmyR4zGMlCLE4mRvEFMdzdc7hoAnG rEY0Eycqxt/vs6xdrLqoRzb6PRqlFf4sdE7hVvkIt80+IyRidbf2YfPE2ttuUMvSvA wGyqJj6zJZgrRJ7+K9HmtHjLbkIe996KM31TOS1HCWkIwN1ibxDwJsFZ+XKbdjq7Gf x+siscIZha/yq4GLNOjX8Ys3f92sZXEZ1awqfIEj8SSvvCe025wnVtJ6OdCOQGG/ug wn+jbc5oS203t6qqRwD7fBPtH44umNhO6qZnMQEbRDSrKJ8QsW4ocrDBFJBHX4kRAa zbmiuqRPqVV4w== Date: Tue, 3 Oct 2023 08:46:43 -0700 From: "Darrick J. Wong" To: John Garry Cc: Dave Chinner , Bart Van Assche , Eric Biggers , axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, viro@zeniv.linux.org.uk, brauner@kernel.org, chandan.babu@oracle.com, dchinner@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, linux-api@vger.kernel.org, Prasad Singamsetty Subject: Re: [PATCH 03/21] fs/bdev: Add atomic write support info to statx Message-ID: <20231003154643.GF21298@frogsfrogsfrogs> References: <20230929102726.2985188-1-john.g.garry@oracle.com> <20230929102726.2985188-4-john.g.garry@oracle.com> <20230929224922.GB11839@google.com> <20231003025703.GD21298@frogsfrogsfrogs> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:47:06 -0700 (PDT) On Tue, Oct 03, 2023 at 08:23:26AM +0100, John Garry wrote: > On 03/10/2023 03:57, Darrick J. Wong wrote: > > > > > > +#define STATX_ATTR_WRITE_ATOMIC??????? 0x00400000 /* File > > > > > > supports atomic write operations */ > > > > > How would this differ from stx_atomic_write_unit_min != 0? > > > Yeah, I suppose that we can just not set this for the case of > > > stx_atomic_write_unit_min == 0. > > Please use the STATX_ATTR_WRITE_ATOMIC flag to indicate that the > > filesystem, file and underlying device support atomic writes when > > the values are non-zero. The whole point of the attribute mask is > > that the caller can check the mask for supported functionality > > without having to read every field in the statx structure to > > determine if the functionality it wants is present. > > Sure, but again that would be just checking atomic_write_unit_min_bytes or > another atomic write block setting as that is the only way to tell from the > block layer (if atomic writes are supported), so it will be something like: > > if (request_mask & STATX_WRITE_ATOMIC && > queue_atomic_write_unit_min_bytes(bdev->bd_queue)) { > stat->atomic_write_unit_min = > queue_atomic_write_unit_min_bytes(bdev->bd_queue); > stat->atomic_write_unit_max = > queue_atomic_write_unit_max_bytes(bdev->bd_queue); > stat->attributes |= STATX_ATTR_WRITE_ATOMIC; > stat->attributes_mask |= STATX_ATTR_WRITE_ATOMIC; > stat->result_mask |= STATX_WRITE_ATOMIC; The result_mask (which becomes the statx stx_mask) needs to have STATX_WRITE_ATOMIC set any time a filesystem responds to STATX_WRITE_ATOMIC being set in the request_mask, even if the response is "not supported". The attributes_mask also needs to have STATX_ATTR_WRITE_ATOMIC set if the filesystem+file can support the flag, even if it's not currently set for that file. This should get turned into a generic vfs helper for the next fs that wants to support atomic write units: static void generic_fill_statx_atomic_writes(struct kstat *stat, struct block_device *bdev) { u64 min_bytes; /* Confirm that the fs driver knows about this statx request */ stat->result_mask |= STATX_WRITE_ATOMIC; /* Confirm that the file attribute is known to the fs. */ stat->attributes_mask |= STATX_ATTR_WRITE_ATOMIC; /* Fill out the rest of the atomic write fields if supported */ min_bytes = queue_atomic_write_unit_min_bytes(bdev->bd_queue); if (min_bytes == 0) return; stat->atomic_write_unit_min = min_bytes; stat->atomic_write_unit_max = queue_atomic_write_unit_max_bytes(bdev->bd_queue); /* Atomic writes actually supported on this file. */ stat->attributes |= STATX_ATTR_WRITE_ATOMIC; } and then: if (request_mask & STATX_WRITE_ATOMIC) generic_fill_statx_atomic_writes(stat, bdev); > } > > Thanks, > John