Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5720189rwp; Mon, 17 Jul 2023 08:29:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGwDqTPocA6GnvzhLcB739gShX7uF7lo6JrzcpsnJW1EzI0zpz/vMr2ZcPGPERmEw7UY7n X-Received: by 2002:a05:6402:12d5:b0:51e:2974:f471 with SMTP id k21-20020a05640212d500b0051e2974f471mr9646637edx.42.1689607746658; Mon, 17 Jul 2023 08:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689607746; cv=none; d=google.com; s=arc-20160816; b=s2Iagx1BtEHwxKLn0LyZv8Sp5Ad2+/UDUP3hPdLTcqaOXsnd73BP3sRTFceQ7OO8aw rpPgt6fnHAZ7nUyubh9yFJPivo/EEHovXRv3VBqyASrihuuiCSzX60hb+/5Pgz1zIjJ9 PNSY/P41HXVQmhnQFoxL6zZWzIZMmMQq4yS5bl6zSyFZdFvP4W6pxM/mcJv0/tFcFRg/ FaygmCkYWC7g9nnSxvru/TwdiIcdBew3RH2rYzevisU6qiigob4nZWPKA54v4vLEJwmH Zyzi6bxeI6rCKuwxHbHAzXar0w1hqVsLyn0S98xeLI8GNAH9RX5ewJ1G2MSdOKlIL3cM rS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=/ORk0OaOhhWmhawyDQO14J/5Gb4THjkGKptH5Wwq6k4=; fh=f8z6b/h1ESEsp9Zr4/HqKoJ3V2UiD7yD+LHlGlLkqn8=; b=g9OcX9rU6C8bCvTXVYV4kzoFqMoW1BdvtGGrME5fcLaXSqCAxwl7zJV9xqJxZo17AS WT1KeUv8ZHBGTdMZLVcQ9+kNP4W2aCjrnOprrZf8OxrhBRmqNTfSfnat5mhD7e47ERv+ FUnQwR42ltwU6jJWONTtC/Ns1l1109+ePLCgLe2UamlIwa921VAJ35Jej/MiOP38C8hD giOIoyG7o7ZwzAmoqtEuXunFV03TCJ5+SMuUZD9OCM5welP4K4lqIOQMP6KdUO/xmwdU NeAS3l/auIIG1hU/NLwUUS93K/4hm1XOeHReV1UEzi2ewKz1O8Pr01knKU+LyjqZ1MP7 UJSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a50fe91000000b0052171305283si4467845edt.335.2023.07.17.08.28.42; Mon, 17 Jul 2023 08:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbjGQPPP (ORCPT + 99 others); Mon, 17 Jul 2023 11:15:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbjGQPPN (ORCPT ); Mon, 17 Jul 2023 11:15:13 -0400 X-Greylist: delayed 398 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 17 Jul 2023 08:15:10 PDT Received: from mfwd09.mailplug.co.kr (mfwd09.mailplug.co.kr [14.63.195.166]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C85FDE6 for ; Mon, 17 Jul 2023 08:15:10 -0700 (PDT) Received: (qmail 1164 invoked from network); 18 Jul 2023 00:08:28 +0900 Received: from m41.mailplug.com (121.156.118.41) by 0 (qmail 1.03 + mailplug 2.0) with SMTP; 18 Jul 2023 00:08:15 +0900 Received: (qmail 510126 invoked from network); 18 Jul 2023 00:08:15 +0900 Received: from unknown (HELO sslauth10) (lsahn@wewakecorp.com@211.253.39.66) by 0 (qmail 1.03 + mailplug 2.0) with SMTP; 18 Jul 2023 00:08:15 +0900 Message-ID: Date: Tue, 18 Jul 2023 00:08:07 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] fs: inode: return proper error code in bmap() To: Dave Chinner , Leesoo Ahn Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230715082204.1598206-1-lsahn@wewakecorp.com> Content-Language: en-US From: Leesoo Ahn In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org 23. 7. 16. 08:36에 Dave Chinner 이(가) 쓴 글: > On Sat, Jul 15, 2023 at 05:22:04PM +0900, Leesoo Ahn wrote: > > Return -EOPNOTSUPP instead of -EINVAL which has the meaning of > > the argument is an inappropriate value. The current error code doesn't > > make sense to represent that a file system doesn't support bmap > operation. > > > > Signed-off-by: Leesoo Ahn > > --- > > Changes since v1: > > - Modify the comments of bmap() > > - Modify subject and description requested by Markus Elfring > > > https://lore.kernel.org/lkml/20230715060217.1469690-1-lsahn@wewakecorp.com/ > > > > fs/inode.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/fs/inode.c b/fs/inode.c > > index 8fefb69e1f84..697c51ed226a 100644 > > --- a/fs/inode.c > > +++ b/fs/inode.c > > @@ -1831,13 +1831,13 @@ EXPORT_SYMBOL(iput); > > * 4 in ``*block``, with disk block relative to the disk start that > holds that > > * block of the file. > > * > > - * Returns -EINVAL in case of error, 0 otherwise. If mapping falls > into a > > + * Returns -EOPNOTSUPP in case of error, 0 otherwise. If mapping > falls into a > > * hole, returns 0 and ``*block`` is also set to 0. > > */ > > int bmap(struct inode *inode, sector_t *block) > > { > > if (!inode->i_mapping->a_ops->bmap) > > - return -EINVAL; > > + return -EOPNOTSUPP; > > > > *block = inode->i_mapping->a_ops->bmap(inode->i_mapping, *block); > > return 0; > > What about the CONFIG_BLOCK=n wrapper? How does it work? Could you explain that in details, pls? However, as far as I understand, bmap operation could be NULL even though CONFIG_BLOCK is enabled. It totally depends on the implementation of file systems. > > Also, all the in kernel consumers squash this error back to 0, -EIO > or -EINVAL, so this change only ever propagates out to userspace via > the return from ioctl(FIBMAP). Do we really need to change this and > risk breaking userspace that handles -EINVAL correctly but not > -EOPNOTSUPP? That's a consideration and we must carefully modify the APIs which communicate to users. But -EINVAL could be interpreted by two cases at this point that the first, for sure an argument from user to kernel is inappropriate, on the other hand, the second case would be that a file system doesn't support bmap operation. However, I don't think there is a proper way to know which one is right from user. For me, the big problem is that user could get confused by these two cases with the same error code. Best regards, Leesoo