From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C07FA3783C1; Mon, 13 Jul 2026 02:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783910394; cv=none; b=PFsIsrLv4v2Yv2/8utt1wngZAukOLLavqdzoKHQeZCDZ3J9570nLsE3VRmwuZS+7S8vioUIynSXLi6JUyfFbRlglTYPV1EsObmF6ejfwQUClfINsUhLg9hCyLtTPBhl1JbzFXyetQC28oll+dX6Q8IDU1wuF4MJdVt2Mu002bbw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783910394; c=relaxed/simple; bh=NIvjBw0Tf/16SOBfIgvew1OBC5Er8zl7NXhVBr+CIMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=awralkn8z/ZiOn/OGRLmS2MWyxAEE2HZMLF8GPI6vtwZjOGIZQFMBTGeMes4J9wk+YNtMpasU290xotpSFnTOu2THHIgrQ08wGDVb7AA0biOe5QjzjRx/T5Sl5pgnfHjpROEJyHEtwqNpKOLZwkz6TGY05HT/xD4aCaYMcy1Pek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gUXac9pB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gUXac9pB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78B661F000E9; Mon, 13 Jul 2026 02:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783910391; bh=RpeHAoXwbljfB1aW+j0UuZMJgwf+yxoIhVBiwkRssAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gUXac9pBQIedxAwL31cbu3Z7nZ/Ij8tzZaeDijERELeT1IoMVAYimCF3BMm7Mx5Au eROt15+6ObKBDVLgWbhZvzFwwLrkKPryUmkZP0e+/DyXhB2OrP7XMWtrJi7xf91S7D l+oqZBA0KKy0t9siySv86ziVlMZDnwMSkUr0lueU7f8igaplVQV74LoqpDQV8ef5iJ OTk0Nv1eI6FduDv1qAAtbrNk6VEvM5cZIGjQdlgN6K/dVQSlryes/cLH8zHGQuMhgq Tfut0LWAdj+GYWR/vCgU15tnaoFhPNHCAhNPlTIMzt8sPqJrsx+9pEpQ2AuOoqNA5z wvERhrfRCAfww== From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, Christoph Hellwig , Theodore Ts'o , Andreas Dilger , Baokun Li , Jan Kara , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Jaegeuk Kim , Chao Yu , Eric Biggers Subject: [PATCH v3 13/17] fscrypt: Remove fscrypt_dio_supported() Date: Sun, 12 Jul 2026 22:37:04 -0400 Message-ID: <20260713023708.9245-14-ebiggers@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260713023708.9245-1-ebiggers@kernel.org> References: <20260713023708.9245-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On block-based filesystems, fscrypt file contents encryption is now always implemented using blk-crypto. This implementation supports direct I/O. Therefore, fscrypt_dio_supported() now always returns true, except in the edge case where statx(STATX_DIOALIGN) is called on an encrypted regular file that hasn't had its key set up. But that was really a workaround rather than the desired behavior, so we can disregard it. Thus, fscrypt_dio_supported() is no longer needed. Remove it. Reviewed-by: Christoph Hellwig Signed-off-by: Eric Biggers --- fs/crypto/inline_crypt.c | 43 ---------------------------------------- fs/ext4/inode.c | 11 ++-------- fs/f2fs/file.c | 6 +----- include/linux/fscrypt.h | 7 ------- 4 files changed, 3 insertions(+), 64 deletions(-) diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index 685815fa71a6..14c8af322c2f 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -298,49 +298,6 @@ bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, } EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio); -/** - * fscrypt_dio_supported() - check whether DIO (direct I/O) is supported on an - * inode, as far as encryption is concerned - * @inode: the inode in question - * - * Return: %true if there are no encryption constraints that prevent DIO from - * being supported; %false if DIO is unsupported. (Note that in the - * %true case, the filesystem might have other, non-encryption-related - * constraints that prevent DIO from actually being supported. Also, on - * encrypted files the filesystem is still responsible for only allowing - * DIO when requests are filesystem-block-aligned.) - */ -bool fscrypt_dio_supported(struct inode *inode) -{ - int err; - - /* If the file is unencrypted, no veto from us. */ - if (!fscrypt_needs_contents_encryption(inode)) - return true; - - /* - * We only support DIO with inline crypto, not fs-layer crypto. - * - * To determine whether the inode is using inline crypto, we have to set - * up the key if it wasn't already done. This is because in the current - * design of fscrypt, the decision of whether to use inline crypto or - * not isn't made until the inode's encryption key is being set up. In - * the DIO read/write case, the key will always be set up already, since - * the file will be open. But in the case of statx(), the key might not - * be set up yet, as the file might not have been opened yet. - */ - err = fscrypt_require_key(inode); - if (err) { - /* - * Key unavailable or couldn't be set up. This edge case isn't - * worth worrying about; just report that DIO is unsupported. - */ - return false; - } - return true; -} -EXPORT_SYMBOL_GPL(fscrypt_dio_supported); - /** * fscrypt_limit_io_blocks() - limit I/O blocks to avoid discontiguous DUNs * @inode: the file on which I/O is being done diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 567d62032bc5..0e21a2a0faa7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6147,11 +6147,8 @@ u32 ext4_dio_alignment(struct inode *inode) return 0; if (ext4_has_inline_data(inode)) return 0; - if (IS_ENCRYPTED(inode)) { - if (!fscrypt_dio_supported(inode)) - return 0; + if (IS_ENCRYPTED(inode)) return i_blocksize(inode); - } return 1; /* use the iomap defaults */ } @@ -6170,11 +6167,7 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path, stat->btime.tv_nsec = ei->i_crtime.tv_nsec; } - /* - * Return the DIO alignment restrictions if requested. We only return - * this information when requested, since on encrypted files it might - * take a fair bit of work to get if the file wasn't opened recently. - */ + /* Return the DIO alignment restrictions if requested. */ if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) { u32 dio_align = ext4_dio_alignment(inode); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 4b52c56d71f0..089759366cdc 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -950,8 +950,6 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - if (!fscrypt_dio_supported(inode)) - return true; if (fsverity_active(inode)) return true; if (f2fs_compressed_file(inode)) @@ -996,9 +994,7 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path, } /* - * Return the DIO alignment restrictions if requested. We only return - * this information when requested, since on encrypted files it might - * take a fair bit of work to get if the file wasn't opened recently. + * Return the DIO alignment restrictions if requested. * * f2fs sometimes supports DIO reads but not DIO writes. STATX_DIOALIGN * cannot represent that, so in that case we report no DIO support. diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 8d19b95150f1..43bafdd67dd7 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -870,8 +870,6 @@ void fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, loff_t pos); -bool fscrypt_dio_supported(struct inode *inode); - u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk, u64 nr_blocks); #else /* CONFIG_FS_ENCRYPTION_INLINE_CRYPT */ @@ -887,11 +885,6 @@ static inline bool fscrypt_mergeable_bio(struct bio *bio, return true; } -static inline bool fscrypt_dio_supported(struct inode *inode) -{ - return !fscrypt_needs_contents_encryption(inode); -} - static inline u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk, u64 nr_blocks) { -- 2.55.0