All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: mszeredi@redhat.com, brauner@kernel.org, lkp@intel.com,
	oe-lkp@lists.linux.dev, kernel test robot <oliver.sang@intel.com>,
	viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	Reuben Hawkins <reubenhwk@gmail.com>,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] vfs: fix readahead(2) on block devices
Date: Sat, 23 Sep 2023 15:41:43 +0100	[thread overview]
Message-ID: <ZQ75JynY8Y2DqaHD@casper.infradead.org> (raw)
In-Reply-To: <CAOQ4uxjnCdAeWe3W4mp=DwgL49Vwp_FVx4S_V33A3-JLtzJb-g@mail.gmail.com>

On Sat, Sep 23, 2023 at 08:56:28AM +0300, Amir Goldstein wrote:
> We decided to deliberately try the change of behavior
> from EINVAL to ESPIPE, to align with fadvise behavior,
> so eventually the LTP test should be changed to allow both.
> 
> It was the test failure on the socket that alarmed me.
> However, if we will have to special case socket in
> readahead() after all, we may as well also special case
> pipe with it and retain the EINVAL behavior - let's see
> what your findings are and decide.

If I read it correctly, LTP is reporting that readhaead() on a socket
returned success instead of an error.  Sockets do have a_ops, right?
It's set to empty_aops in inode_init_always, I think.

It would be nice if we documented somewhere which pointers should be
checked for NULL for which cases ... it doesn't really make sense for
a socket inode to have an i_mapping since it doesn't have pagecache.
But maybe we rely on i_mapping always being set.

Irritatingly, POSIX specifies ESPIPE for pipes, but does not specify
what to do with sockets.  It's kind of a meaningless syscall for
any kind of non-seekable fd.  lseek() returns ESPIPE for sockets
as well as pipes, so I'd see this as an oversight.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html
https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html

Of course readahead() is a Linux-specific syscall, so we can do whatever
we want here, but I'm really tempted to just allow readahead() for
regular files and block devices.  Hmm.  Can we check FMODE_LSEEK
instead of (S_ISFILE || S_ISBLK)?

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

WARNING: multiple messages have this Message-ID (diff)
From: Matthew Wilcox <willy@infradead.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Reuben Hawkins <reubenhwk@gmail.com>,
	Cyril Hrubis <chrubis@suse.cz>,
	mszeredi@redhat.com, brauner@kernel.org, lkp@intel.com,
	linux-fsdevel@vger.kernel.org,
	kernel test robot <oliver.sang@intel.com>,
	viro@zeniv.linux.org.uk, oe-lkp@lists.linux.dev,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] vfs: fix readahead(2) on block devices
Date: Sat, 23 Sep 2023 15:41:43 +0100	[thread overview]
Message-ID: <ZQ75JynY8Y2DqaHD@casper.infradead.org> (raw)
In-Reply-To: <CAOQ4uxjnCdAeWe3W4mp=DwgL49Vwp_FVx4S_V33A3-JLtzJb-g@mail.gmail.com>

On Sat, Sep 23, 2023 at 08:56:28AM +0300, Amir Goldstein wrote:
> We decided to deliberately try the change of behavior
> from EINVAL to ESPIPE, to align with fadvise behavior,
> so eventually the LTP test should be changed to allow both.
> 
> It was the test failure on the socket that alarmed me.
> However, if we will have to special case socket in
> readahead() after all, we may as well also special case
> pipe with it and retain the EINVAL behavior - let's see
> what your findings are and decide.

If I read it correctly, LTP is reporting that readhaead() on a socket
returned success instead of an error.  Sockets do have a_ops, right?
It's set to empty_aops in inode_init_always, I think.

It would be nice if we documented somewhere which pointers should be
checked for NULL for which cases ... it doesn't really make sense for
a socket inode to have an i_mapping since it doesn't have pagecache.
But maybe we rely on i_mapping always being set.

Irritatingly, POSIX specifies ESPIPE for pipes, but does not specify
what to do with sockets.  It's kind of a meaningless syscall for
any kind of non-seekable fd.  lseek() returns ESPIPE for sockets
as well as pipes, so I'd see this as an oversight.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html
https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html

Of course readahead() is a Linux-specific syscall, so we can do whatever
we want here, but I'm really tempted to just allow readahead() for
regular files and block devices.  Hmm.  Can we check FMODE_LSEEK
instead of (S_ISFILE || S_ISBLK)?

  parent reply	other threads:[~2023-09-23 14:42 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-09  4:38 [PATCH] vfs: fix readahead(2) on block devices Reuben Hawkins
2023-09-09  6:36 ` Amir Goldstein
2023-09-10 10:02   ` Christian Brauner
2023-09-11  8:15     ` Amir Goldstein
2023-09-19  2:47 ` [LTP] " kernel test robot
2023-09-19  2:47   ` kernel test robot
2023-09-19  8:43   ` [LTP] " Amir Goldstein
2023-09-19  8:43     ` Amir Goldstein
2023-09-21 13:01     ` [LTP] " Reuben Hawkins
2023-09-21 14:44       ` Amir Goldstein
2023-09-21 14:44         ` Amir Goldstein
2023-09-22  9:10       ` [LTP] " Cyril Hrubis
2023-09-22  9:10         ` Cyril Hrubis
2023-09-22 20:29         ` Reuben Hawkins
2023-09-23  5:56           ` Amir Goldstein
2023-09-23  5:56             ` Amir Goldstein
2023-09-23 12:20             ` Reuben Hawkins
2023-09-23 12:28               ` Reuben Hawkins
2023-09-23 14:41             ` Matthew Wilcox [this message]
2023-09-23 14:41               ` Matthew Wilcox
2023-09-23 15:48               ` Amir Goldstein
2023-09-23 15:48                 ` Amir Goldstein
2023-09-24  3:48                 ` Reuben Hawkins
2023-09-24  6:46                   ` Amir Goldstein
2023-09-24  6:46                     ` Amir Goldstein
2023-09-24 11:47                     ` Amir Goldstein
2023-09-24 11:47                       ` Amir Goldstein
2023-09-24 14:27                       ` Matthew Wilcox
2023-09-24 14:27                         ` Matthew Wilcox
2023-09-24 15:32                         ` Amir Goldstein
2023-09-24 15:32                           ` Amir Goldstein
2023-09-24 21:56                           ` Matthew Wilcox
2023-09-24 21:56                             ` Matthew Wilcox
2023-09-25  4:35                             ` Reuben Hawkins
2023-09-25  6:42                               ` Matthew Wilcox
2023-09-25  6:42                                 ` Matthew Wilcox
2023-09-25  9:43                                 ` Amir Goldstein
2023-09-25  9:43                                   ` Amir Goldstein
2023-09-25 12:39                                   ` Christian Brauner
2023-09-25 12:39                                     ` Christian Brauner
2023-09-25 15:36                                   ` Reuben Hawkins
2023-09-25 16:51                                     ` Amir Goldstein
2023-09-25 16:51                                       ` Amir Goldstein
2023-09-26 10:08                                       ` Christian Brauner
2023-09-26 10:08                                         ` Christian Brauner
2023-09-26  1:56                           ` Oliver Sang
2023-09-26  1:56                             ` Oliver Sang
2023-09-26  5:34                             ` Amir Goldstein
2023-09-26  5:34                               ` Amir Goldstein

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=ZQ75JynY8Y2DqaHD@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=ltp@lists.linux.it \
    --cc=mszeredi@redhat.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    --cc=reubenhwk@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.