From patchwork Wed Mar 23 23:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12790222 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 1A2A6C433F5 for ; Wed, 23 Mar 2022 23:06:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1FD56B0073; Wed, 23 Mar 2022 19:06:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D0888D000D; Wed, 23 Mar 2022 19:06:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BE106B0083; Wed, 23 Mar 2022 19:06:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 7D9EA6B0073 for ; Wed, 23 Mar 2022 19:06:27 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 53D2981DAC for ; Wed, 23 Mar 2022 23:06:27 +0000 (UTC) X-FDA: 79277186814.14.E1B9D89 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id CE8F91A002F for ; Wed, 23 Mar 2022 23:06:26 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id A1EC5B82181; Wed, 23 Mar 2022 23:06:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6016BC340E9; Wed, 23 Mar 2022 23:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648076784; bh=tN4p0J3FdsIJcTqpYHQYhslGR1cMY0pflMq2Wwx8foY=; h=Date:To:From:In-Reply-To:Subject:From; b=qNt92sH3G/TRnit530UcJmVcVLAZiV8GcmV3zwdbByGBWRBsWw4EOXhhXhcefYJV6 /6E+bIrrlLI8Nc2m7nWviubtJiJoB4R1v/tz6xo78g5HnumO9gUHM3KgxdkZifxbJE O4AIh/DENp3TRmzc92+KqKRpYWq4SVS+X5LEf0AU= Date: Wed, 23 Mar 2022 16:06:23 -0700 To: jack@suse.cz,colin.king@intel.com,christian.brauner@ubuntu.com,qhjin.dev@gmail.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220323160453.65922ced539cbf445b191555@linux-foundation.org> Subject: [patch 22/41] minix: fix bug when opening a file with O_DIRECT Message-Id: <20220323230624.6016BC340E9@smtp.kernel.org> X-Stat-Signature: m9fgzs5sbu57r6wbqpp7ak6yzuhtk9pu Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=qNt92sH3; dmarc=none; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: CE8F91A002F X-HE-Tag: 1648076786-203226 X-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: From: Qinghua Jin Subject: minix: fix bug when opening a file with O_DIRECT 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 --- fs/minix/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/minix/inode.c~minix-fix-bug-when-opening-a-file-with-o_direct +++ a/fs/minix/inode.c @@ -447,7 +447,8 @@ static const struct address_space_operat .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 = {