Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5413207rwb; Wed, 7 Sep 2022 02:22:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/QkU1HUfUK0/JtFLJuAr99cE0847f6/aMgbogkF0sE95YLqR38M62NEtnvTZu7OuudVMb X-Received: by 2002:a63:a43:0:b0:430:9ec5:4775 with SMTP id z3-20020a630a43000000b004309ec54775mr2645668pgk.572.1662542557574; Wed, 07 Sep 2022 02:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662542557; cv=none; d=google.com; s=arc-20160816; b=V50Mq5GIqGQ5/WAxUqix+7HKP5Im44qO5q/g6UNbFEn6LkbymnAjU+VghC7JWkgCBU xlJe593QCZ56XMtA5l03pi/OmDc4mvbnEKfk1Rw9sqywpSbqHWWSU0qxzwSPvvpObT9J OSNlcHPUBfUDrxAeK4j3YT65G1ScnR7jNASrWfcp82W9GUF7Zet72ZdqBzWtF85t8aA/ UD2VUvegjrc4t5WIO4NQFgXQzk9xAQNM9Qdx5q2hHcYsayAx5Js7R5WddtwVVprIehBs 5rtghHkyBLvtKLk6DC9b6a0Sh93vUrrRMNROEPFpiHw9Y8KLSlm2cqGlcnMqpreppmOW DFbA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Xpj2U7r7NjexOSS9xVf5PrWGymrSCyPJQhceOLJbhrs=; b=p/uSxZRsF1XsIuAB2vOz/q/BhgZdGfle73sRo7lVWjLVRllX2Iwz8oBqmBcbiyRbZ+ 1t6WV7JOvLclMvIURWekCbF8IC1gv9un7XqqoOvzzQ8MN6kGg33TJuX1zfX9fNGcbPH4 Sr9GzuuJhnasMqqRIJEDNpEkKpGPrmY8oE44ySN6tQPXJ0Mly0QTHtRbF+h753Hm9PMv +Z+0XNtEn8vmMlwOf6qeHpOtV49to77Z5HZDu/Ka6j9XvkNvgLAfYbB1Bm6ztQ6mG4tV KXmexuXCJw9JEyk6MVfwOwLePPDoco6nD1IodEm/tfBA55bdIP+5Twz7pKaGSS4d5CNp npvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WbUGnYmn; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020a170903005400b00176be20c432si2177509pla.271.2022.09.07.02.22.24; Wed, 07 Sep 2022 02:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WbUGnYmn; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbiIGJKN (ORCPT + 99 others); Wed, 7 Sep 2022 05:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiIGJKL (ORCPT ); Wed, 7 Sep 2022 05:10:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B84D174B84; Wed, 7 Sep 2022 02:10:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3A50B617D8; Wed, 7 Sep 2022 09:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BFE0C433C1; Wed, 7 Sep 2022 09:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662541808; bh=a6rxNDyNfNYsftFOTgasxTViBPk+jSbvU4105tQOkhw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WbUGnYmnyFUJoHmUJJNdkTfTbKlPdXgHPr6kq8a5AS52w8H4F2fLqyyuPqnpfXV8k 37Zvs4OH5t6Hisr1Kr1ar+Srb4OFC2sceheTmucJeYWHEk0UabmunmqGt+Rmk/BZA+ MIBjoqwWGIc1EU3fa/Pn7cfW3nZvtyCJNLWYMQY+jxycJNzGnHvEuiUs0DKarv6FSg XcNIBcxLDyRBP1Qbu0guN/v1Kfnb3RRqgCT2UJ3oHI7Yc1I2V8NTb8eTLSB5xrknjZ ATDIZfsT+DqdOdZMjCbb2DP99VSiZ1Mj/Xnsu3jHmWSU81XAYsNmH/NaXvzC45Ug5c w/N7bwzH1xjJw== Date: Wed, 7 Sep 2022 11:10:02 +0200 From: Christian Brauner To: Eric Biggers Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-api@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Keith Busch , Christoph Hellwig , "Darrick J. Wong" , "Martin K. Petersen" Subject: Re: [PATCH v5 1/8] statx: add direct I/O alignment information Message-ID: <20220907091002.6ay72r4tgk5g6rma@wittgenstein> References: <20220827065851.135710-1-ebiggers@kernel.org> <20220827065851.135710-2-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220827065851.135710-2-ebiggers@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Aug 26, 2022 at 11:58:44PM -0700, Eric Biggers wrote: > From: Eric Biggers > > Traditionally, the conditions for when DIO (direct I/O) is supported > were fairly simple. For both block devices and regular files, DIO had > to be aligned to the logical block size of the block device. > > However, due to filesystem features that have been added over time (e.g. > multi-device support, data journalling, inline data, encryption, verity, > compression, checkpoint disabling, log-structured mode), the conditions > for when DIO is allowed on a regular file have gotten increasingly > complex. Whether a particular regular file supports DIO, and with what > alignment, can depend on various file attributes and filesystem mount > options, as well as which block device(s) the file's data is located on. > > Moreover, the general rule of DIO needing to be aligned to the block > device's logical block size was recently relaxed to allow user buffers > (but not file offsets) aligned to the DMA alignment instead. See > commit bf8d08532bc1 ("iomap: add support for dma aligned direct-io"). > > XFS has an ioctl XFS_IOC_DIOINFO that exposes DIO alignment information. > Uplifting this to the VFS is one possibility. However, as discussed > (https://lore.kernel.org/linux-fsdevel/20220120071215.123274-1-ebiggers@kernel.org/T/#u), > this ioctl is rarely used and not known to be used outside of > XFS-specific code. It was also never intended to indicate when a file > doesn't support DIO at all, nor was it intended for block devices. > > Therefore, let's expose this information via statx(). Add the > STATX_DIOALIGN flag and two new statx fields associated with it: > > * stx_dio_mem_align: the alignment (in bytes) required for user memory > buffers for DIO, or 0 if DIO is not supported on the file. > > * stx_dio_offset_align: the alignment (in bytes) required for file > offsets and I/O segment lengths for DIO, or 0 if DIO is not supported > on the file. This will only be nonzero if stx_dio_mem_align is > nonzero, and vice versa. > > Note that as with other statx() extensions, if STATX_DIOALIGN isn't set > in the returned statx struct, then these new fields won't be filled in. > This will happen if the file is neither a regular file nor a block > device, or if the file is a regular file and the filesystem doesn't > support STATX_DIOALIGN. It might also happen if the caller didn't > include STATX_DIOALIGN in the request mask, since statx() isn't required > to return unrequested information. > > This commit only adds the VFS-level plumbing for STATX_DIOALIGN. For > regular files, individual filesystems will still need to add code to > support it. For block devices, a separate commit will wire it up too. > > Reviewed-by: Christoph Hellwig > Reviewed-by: Darrick J. Wong > Reviewed-by: Martin K. Petersen > Signed-off-by: Eric Biggers > --- Looks good to me, Reviewed-by: Christian Brauner (Microsoft)