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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02EE4C352A7 for ; Fri, 1 Apr 2022 15:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355445AbiDAPPA (ORCPT ); Fri, 1 Apr 2022 11:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350404AbiDAOr2 (ORCPT ); Fri, 1 Apr 2022 10:47:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F370B2A3394; Fri, 1 Apr 2022 07:37:42 -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 ACA3C60C00; Fri, 1 Apr 2022 14:37:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2550C2BBE4; Fri, 1 Apr 2022 14:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823861; bh=vANaOh00GfqQBTcK5sP1BvrXEFApLiocXg4m5Mdy1BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EDHIv996O9MTc8cdwjlbOy23oO0BS3M9aQsRCfI3zQ4kJoRQ4WOb9+z4rIZkcACYt kXjGXxQi5C9IYlgo1AiJLVRSwPp87ideQ6S8YtYkVzwXYYAtkGM12P/57KQ+4Blncn pUqbiVKys86PvKoFCIZAAyWOqdg9I9R5/VcefWSDNjvO6K+wJr1bFdYCMdhDeZj9Gz 1GRz/Fw1pB7hARLN7fJ+MTYVe6b0Y23KMYPokheBjlxJq+gIlbnWzpHHLtFL2E4j4j eMIL/Ik2I2PEpKn956LUdxisxKUkuN/ncF/6CyLt1pLzKVApDBSzsR/hQ36RLoXvc3 0J3E7MvGkbWOQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qinghua Jin , Colin Ian King , Jan Kara , Christian Brauner , Andrew Morton , Linus Torvalds , Sasha Levin , willy@infradead.org, damien.lemoal@opensource.wdc.com, roman.gushchin@linux.dev, songmuchun@bytedance.com Subject: [PATCH AUTOSEL 5.16 109/109] minix: fix bug when opening a file with O_DIRECT Date: Fri, 1 Apr 2022 10:32:56 -0400 Message-Id: <20220401143256.1950537-109-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401143256.1950537-1-sashal@kernel.org> References: <20220401143256.1950537-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qinghua Jin [ Upstream commit 9ce3c0d26c42d279b6c378a03cd6a61d828f19ca ] Testcase: 1. create a minix file system and mount it 2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT 3. open fails with -EINVAL but leaves an empty file behind. All other open() failures don't leave the failed open files behind. It is hard to check the direct_IO op before creating the inode. Just as ext4 and btrfs do, this patch will resolve the issue by allowing to create the file with O_DIRECT but returning error when writing the file. Link: https://lkml.kernel.org/r/20220107133626.413379-1-qhjin.dev@gmail.com Signed-off-by: Qinghua Jin Reported-by: Colin Ian King Reviewed-by: Jan Kara Acked-by: Christian Brauner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/minix/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/minix/inode.c b/fs/minix/inode.c index a71f1cf894b9..d4bd94234ef7 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = { .writepage = minix_writepage, .write_begin = minix_write_begin, .write_end = generic_write_end, - .bmap = minix_bmap + .bmap = minix_bmap, + .direct_IO = noop_direct_IO }; static const struct inode_operations minix_symlink_inode_operations = { -- 2.34.1