From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D626C04A94 for ; Thu, 10 Aug 2023 23:41:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2132F6B0071; Thu, 10 Aug 2023 19:41:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C31C6B0074; Thu, 10 Aug 2023 19:41:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B2B76B0078; Thu, 10 Aug 2023 19:41:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EEFD96B0071 for ; Thu, 10 Aug 2023 19:41:29 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BDAFFA0118 for ; Thu, 10 Aug 2023 23:41:29 +0000 (UTC) X-FDA: 81109819098.12.B62C1CB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 09A0A2001B for ; Thu, 10 Aug 2023 23:41:26 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="s/a4uUP6"; spf=pass (imf13.hostedemail.com: domain of djwong@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691710887; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KHPwgt0pzyGlgeucT7Xie/2oqjalZq38Q5mTh+rZDg8=; b=zSkYIFHuPU9hhwNqXRWLEj3RoQWJLfLWQawKmjFSZ3mHTXRivDq2FH/jKPYl0cg2PohZdX srCADH51+m4FIKmmj22SaIV9vX/asxFwJxiMvWq2rENr76n2hvrkAaeHEQDAw9PYY8AJG6 kIaY6Bw7UizAcZwfMJ8gYC6y4FXc808= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691710887; a=rsa-sha256; cv=none; b=J8sDppiVTlGMNZkXKg+Qz6xriu2rYiKBcENrif4d1s9Myo8qgifdygNzqZjyOyqg08L9Kt e/77LdHOMrr/EoIacIV2822CJRKMM6c/2xY0kNxL+/2ga7O/x5PYzJ0RKPF4HLivd9keCY +my66kfZY74GG6u6WFU3HTu1H/tqfFM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="s/a4uUP6"; spf=pass (imf13.hostedemail.com: domain of djwong@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D3E160E84; Thu, 10 Aug 2023 23:41:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57B3EC433C7; Thu, 10 Aug 2023 23:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691710885; bh=Y1kWoKWlcA+XrKaXzoE45uKmAhUYXgJ2vtEmvg5+vJA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s/a4uUP6VEEQElT1YCD2UCVhl8a393t9jHRlhMPMWT4CopjEJdgzv7vUPtgPUrKJh coJ/+seP/PnMDWfcE2Zt9DyAedpexKdAsHJ5/fy4s0QYLQA3mqHRWzjFi/js13xvo+ 5SPNq44+wKD1ii/W2FsRmR1mEKBr7OyLgHws6ij4+dOPgwwEFzY87RbBH0UAHbsLZ5 7Ia1dZFXjcdX3vTblH+N//+mE/d49NWJN5Kik0t1oDKJtupkyjBi3+YLzqR2BJiu/L bxQM1mgXx0bjALXg8xa44Ik8B54gOehYFi9Kx20E9rar35AnHwHWMie5XBNrQRZ4uO 0/1a9bH8+wfIA== Date: Thu, 10 Aug 2023 16:41:24 -0700 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Hugh Dickins , Christian Brauner , Andrew Morton , Oleksandr Tymoshenko , Carlos Maiolino , Jeff Layton , Chuck Lever , Jan Kara , Miklos Szeredi , Daniel Xu , Chris Down , Tejun Heo , Greg Kroah-Hartman , Matthew Wilcox , Pete Zaitcev , Helge Deller , Topi Miettinen , Yu Kuai , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH vfs.tmpfs 4/5] tmpfs: trivial support for direct IO Message-ID: <20230810234124.GH11336@frogsfrogsfrogs> References: <7c12819-9b94-d56-ff88-35623aa34180@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 09A0A2001B X-Rspam-User: X-Stat-Signature: ccus7k5yudkncuao8jidbykjzpobjjyu X-Rspamd-Server: rspam03 X-HE-Tag: 1691710886-136734 X-HE-Meta: U2FsdGVkX18JUrMlqBhjDrlXqV1MnR0oCAT99qkHos1H+0vmuQzm+FXbhzExJqExMT0cKFLULDOuPci2O8cx4pB8gREy7jucYWvs1Awx2dGR0hq6RUtmyPchIxcxPZwR6iphFWJui9tEQWG+wbZk2rp6By6IeXaMQn8W3Mm7SHwxhHeX9lbXZmK+CGdbIm7m491720uV+0Eyy22n+9f9I0KePtCx1SgK8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Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Aug 09, 2023 at 06:41:17AM -0700, Christoph Hellwig wrote: > Please do not add a new ->direct_IO method. I'm currently working hard > on removing it, just set FMODE_CAN_ODIRECT and handle the fallback in > your read_iter/write_iter methods. > > But if we just start claiming direct I/O support for file systems that > don't actually support it, I'm starting to seriously wonder why we > bother with the flag at all and don't just allow O_DIRECT opens > to always succeed.. I see it differently -- you can do byte-aligned directio to S_DAX files on persistent memory, so I don't see why you can't do that for tmpfs files too. (I'm not advocating for letting *disk* based filesystems allow O_DIRECT even if read and writes are always going to go through the page cache and get flushed to disk. If programs wanted that, they'd use O_SYNC.) /mnt is a pmem filesystem, /mnt/on/file has S_DAX set, and /mnt/off/file does not: # xfs_io -c statx /mnt/{on,off}/file fd.path = "/mnt/on/file" fd.flags = non-sync,non-direct,read-write stat.ino = 132 stat.type = regular file stat.size = 1048576 stat.blocks = 2048 fsxattr.xflags = 0x8002 [-p------------x--] fsxattr.projid = 0 fsxattr.extsize = 0 fsxattr.cowextsize = 0 fsxattr.nextents = 1 fsxattr.naextents = 0 dioattr.mem = 0x200 dioattr.miniosz = 512 dioattr.maxiosz = 2147483136 fd.path = "/mnt/off/file" fd.flags = non-sync,non-direct,read-write stat.ino = 8388737 stat.type = regular file stat.size = 1048576 stat.blocks = 2048 fsxattr.xflags = 0x2 [-p---------------] fsxattr.projid = 0 fsxattr.extsize = 0 fsxattr.cowextsize = 0 fsxattr.nextents = 1 fsxattr.naextents = 0 dioattr.mem = 0x200 dioattr.miniosz = 512 dioattr.maxiosz = 2147483136 And now we try a byte-aligned direct write: # xfs_io -d -c 'pwrite -S 0x58 47 1' /mnt/off/file pwrite: Invalid argument # xfs_io -d -c 'pwrite -S 0x58 47 1' /mnt/on/file wrote 1/1 bytes at offset 47 1.000000 bytes, 1 ops; 0.0001 sec (5.194 KiB/sec and 5319.1489 ops/sec) --D