Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6171546rwp; Mon, 17 Jul 2023 16:38:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8hGMRhRlqTjWebe3NqWilf/c1cp8aPwEEi3nF6XVkG64hq4IHNakOBBSv8YgKvGaDEary X-Received: by 2002:a17:902:c40f:b0:1b1:753a:49ce with SMTP id k15-20020a170902c40f00b001b1753a49cemr13548157plk.53.1689637081709; Mon, 17 Jul 2023 16:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637081; cv=none; d=google.com; s=arc-20160816; b=MVjnVOv0ceD/pgIk/c5baF2uN1bTEDixSNxq5inCeLchZ0qeWEb0SR8h9pLJ7NQzHc bCzPPR84l/1KisgTzhZZD+KL9se53lLEpjicWNPzMNUdhWCwiXNhAeEDbUTgQtKu00nh SiWBwVZVmnUMawraX2F+ZJcdTAt9FlTjEU3gS1cCu8XnrgmLg5PSTBC3lRUa2Le/luT9 pLMqlJtVqGBBd0DkoXuxZeE75Ztm629yWgy8wqwkFUdYiNvmSsT6QhZ25MN1uST1eqz0 r4spjPrUsCPamufjvdG4OaNYXVA/UYhYCewPXAJIj9UjNQrWIuH5tysN1KSp3wIXLhUp nupQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hD4JEP1fqNjsd6/Thhkhf4NODGfDet8t60Eb54LdlhQ=; fh=KHxXNc9FEP7UfJ/L3up+hgq8DLvfODZhD3izZyksFd8=; b=whW8kU10jEWdaYCnUfuFFgoqxHignYErROYNeWGCMSvVMsT30PiyBuTaPlYvAE8RtW xLufHlnVLhlcxs6kunZnIBkWelrLT0oSgCVafnZ5LzMVP7YCS4orRml92aQIcFiX9tQv F0tMNoBL7Y19jO0P/YZujbaT1mZ08d6m26JoLWpcynIW6I+oL+MKSAFaPfDRKNOM/G7i tc9ZSpzxpHqN3DNAEs9wy3z2puDz1DrqNNZZaW9rIgUm0Q4ebE4I1O5NYr1oX9fmPJno 3NjZUrCvHgMpkuKB416/ZAqClIrMxMP1323797UFBAnVpRxbM5sQ+9BOKROXS34utgBs uHXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20221208.gappssmtp.com header.s=20221208 header.b=XQ+HW7KB; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170902d88800b001ac6d4e1d72si604774plz.149.2023.07.17.16.37.49; Mon, 17 Jul 2023 16:38:01 -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; dkim=pass header.i=@fromorbit-com.20221208.gappssmtp.com header.s=20221208 header.b=XQ+HW7KB; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjGQXJL (ORCPT + 99 others); Mon, 17 Jul 2023 19:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbjGQXJJ (ORCPT ); Mon, 17 Jul 2023 19:09:09 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C21571B6 for ; Mon, 17 Jul 2023 16:08:31 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3a337ddff16so3709843b6e.0 for ; Mon, 17 Jul 2023 16:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20221208.gappssmtp.com; s=20221208; t=1689635308; x=1692227308; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=hD4JEP1fqNjsd6/Thhkhf4NODGfDet8t60Eb54LdlhQ=; b=XQ+HW7KBLR6UyEEa71S7PBEisxabnkDtV8i4UE1k0Bf/lAGlMypNtUKMMkujySlgt+ jSqgPMIxNi0lkjmbIRoznQ2gstweOycKyIjsItR97KYZpdIOhGmVbu1OClW89cfIEG9G ZpEgk9pZC/NoamEUmZjcXYdcFFMJMwRvyliAFXuWnIsIo2dwWhBZicWfKZAnCKtt7FsD KH2uLj01pTbDFddsxOUbj5IDOdsgkKAYR7nC8MVa2XqN+E2prq5d+zbbYjOQEMrfKWxN vdNvW4I3FN1Yi72np4Rwx8tsEpc0G7sTPWLtWBKq/FODMH9oIQ/6svnSK1GQ4p6gPZc4 86sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689635308; x=1692227308; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hD4JEP1fqNjsd6/Thhkhf4NODGfDet8t60Eb54LdlhQ=; b=dlaGuHU3SqfIDbYSa5bGQOEERVzxkD4S1CwZFu38n7jl1DUaHvCEBwr4Il06h1kZoM hMRpNxDi/TuKrU/QP8DsF42MXCMtFCR+xI6x7RbFXg9tX3BaIsB927cR8hBtBpNa9YSA PBFCH9SPae6TUrueqbmvyXHnzAnLd8k/xBsP6JCfpTEhx+qtVcqf2QrvSRKOlB1Cy/au K3wR5x5A2l7NIiupEt+fwfp0UDOdp4xI0r1U1mw0LZ1MnL6lR+/xNLVqk+KdhGZh99g1 noverudUxU05QDkRYtBNPmsx8U7Un5ZfvtLsuOyncGjjH1hj+chOVNa+3ODK9bWMAT6e PJRw== X-Gm-Message-State: ABy/qLYbTsHcQIV1neR5qRUCDkarQYYSthYXqHxMuKNf1cqwqNnr2G4N mTCGayfpOBBRbo74CcN47Be2hw== X-Received: by 2002:a05:6808:20aa:b0:3a1:eb0e:ddc6 with SMTP id s42-20020a05680820aa00b003a1eb0eddc6mr14001585oiw.29.1689635307772; Mon, 17 Jul 2023 16:08:27 -0700 (PDT) Received: from dread.disaster.area (pa49-186-119-116.pa.vic.optusnet.com.au. [49.186.119.116]) by smtp.gmail.com with ESMTPSA id x5-20020a63b205000000b005533c53f550sm317793pge.45.2023.07.17.16.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 16:08:26 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1qLXKJ-007LR9-0R; Tue, 18 Jul 2023 09:08:23 +1000 Date: Tue, 18 Jul 2023 09:08:23 +1000 From: Dave Chinner To: Leesoo Ahn Cc: Leesoo Ahn , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] fs: inode: return proper error code in bmap() Message-ID: References: <20230715082204.1598206-1-lsahn@wewakecorp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 On Tue, Jul 18, 2023 at 12:08:07AM +0900, Leesoo Ahn wrote: > 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. That wrapper returns -EINVAL unconditionally. If CONFIG_BLOCK=n, then by your reasoning it should return -EOPNOTSUPP, not -EINVAL, so you need to fix that as well. > > > > 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. That doesn't matter a whole lot - what matters is if the change of return value breaks existing userspace binaries. That's on you to audit all known userspace users (e.g. via debian codesearch) to determine that nothing in userspace using FIBMAP cares about the change of return value. > For me, the big problem is that user could get confused by these two cases > with the same error code. So you're talking about a theoretical problem, not an actual real world issue that is causing an application to do the wrong thing? -Dave. -- Dave Chinner david@fromorbit.com