From: Krzysztof Wilczynski <kw@linux.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Layton <jlayton@kernel.org>,
"J. Bruce Fields" <bfields@fieldses.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: Remove duplicated flag from VALID_OPEN_FLAGS
Date: Fri, 22 May 2020 19:22:51 +0200 [thread overview]
Message-ID: <20200522172251.GA40716@rocinante> (raw)
In-Reply-To: <20200522154719.GS23230@ZenIV.linux.org.uk>
On 20-05-22 16:47:19, Al Viro wrote:
Hello Al,
Thank you for review. This is going to be an invaluable learning for
experience me. Also, apologies for causing you to do more work.
[...]
> Now ask yourself what might be the reason for that "duplicated argument".
> Try to figure out what the values of those constants might depend upon.
> For extra points, try to guess what has caused the divergences.
>
> Please, post the result of your investigation in followup to this.
I had a look at O_NONBLOCK and O_NDELAY, and the values of these are
platform-specific, as per:
include/uapi/asm-generic/fcntl.h:
#define O_NONBLOCK 00004000
#define O_NDELAY O_NONBLOCK
arch/sparc/include/uapi/asm/fcntl.h:
#define O_NONBLOCK 0x4000
#if defined(__sparc__) && defined(__arch64__)
#define O_NDELAY 0x0004
#else
#define O_NDELAY (0x0004 | O_NONBLOCK)
#endif
arch/alpha/include/uapi/asm/fcntl.h:
#define O_NONBLOCK 00004
arch/mips/include/uapi/asm/fcntl.h:
#define O_NONBLOCK 0x0080
For Sparc, there we handle it as a special case, for example:
linux/fs/ioctl.c ->
ioctl_fionbio():
#ifdef __sparc__
/* SunOS compatibility item. */
if (O_NONBLOCK != O_NDELAY)
flag |= O_NDELAY;
#endif
There is also a comment in the fs/fcntl.c that adds clarification:
fs/fcntl.c ->
fcntl_init():
/*
* Please add new bits here to ensure allocation uniqueness.
* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
* is defined as O_NONBLOCK on some platforms and not on others.
*/
The behaviour of O_NONBLOCK and O_NDELAY also is platform-dependent,
where O_NDELAY might just return 0 instead of returning an error and
setting errno to either EAGAIN or EWOULDBLOCK.
I also took a look at commit 80f18379a7c3 ("fs: add a VALID_OPEN_FLAGS")
that introduced the new definition.
After looking at the warning coming from Coccinelle, I had a look and
assumed that flag O_NDELAY was added to the VALID_OPEN_FLAGS twice
accidentally.
I am still unsure why we would want to keep O_NDELAY twice? Setting the
same bits multiple would be a non-operation to the best of my knowledge.
But, I sincerely apologise for a not very clear commit message and not
mentioning the flag in the subject and explaining what has been done
better. I will send a v2, if that is OK with you?
Again, thank you for you time!
Krzysztof
prev parent reply other threads:[~2020-05-22 17:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 13:37 [PATCH] fs: Remove duplicated flag from VALID_OPEN_FLAGS Krzysztof Wilczynski
2020-05-22 15:47 ` Al Viro
2020-05-22 17:01 ` Matthew Wilcox
2020-05-22 17:18 ` Al Viro
2020-05-22 17:32 ` Krzysztof Wilczynski
2020-05-22 17:22 ` Krzysztof Wilczynski [this message]
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=20200522172251.GA40716@rocinante \
--to=kw@linux.com \
--cc=bfields@fieldses.org \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--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