mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leesoo Ahn <lsahn@wewakecorp.com>
To: Dave Chinner <david@fromorbit.com>, Leesoo Ahn <lsahn@ooseel.net>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fs: inode: return proper error code in bmap()
Date: Tue, 18 Jul 2023 00:08:07 +0900	[thread overview]
Message-ID: <c32d3a3d-c2a7-fd18-9e14-ea5d9e0abb88@wewakecorp.com> (raw)
In-Reply-To: <ZLMtifV5ta5VTQ2e@dread.disaster.area>

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 <lsahn@wewakecorp.com>
>  > ---
>  > 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

  reply	other threads:[~2023-07-17 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15  8:22 Leesoo Ahn
     [not found] ` <cca223c5-b512-3913-a796-fa15341927ff@web.de>
2023-07-15 13:20   ` Leesoo Ahn
2023-07-15 14:56 ` Matthew Wilcox
2023-07-17 15:11   ` Leesoo Ahn
2023-07-15 23:36 ` Dave Chinner
2023-07-17 15:08   ` Leesoo Ahn [this message]
2023-07-17 23:08     ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c32d3a3d-c2a7-fd18-9e14-ea5d9e0abb88@wewakecorp.com \
    --to=lsahn@wewakecorp.com \
    --cc=brauner@kernel.org \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahn@ooseel.net \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®