linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Remove repeated test in ext4_file_read_iter.
@ 2017-12-27  8:19 Sean Fu
  2018-01-03  2:08 ` Al Viro
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Fu @ 2017-12-27  8:19 UTC (permalink / raw)
  To: tytso; +Cc: adilger.kernel, linux-ext4, linux-kernel, Sean Fu

generic_file_read_iter has done the count test.
So ext4_file_read_iter don't need to test the count repeatedly.

Signed-off-by: Sean Fu <fxinrong@gmail.com>
---
 fs/ext4/file.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index a0ae27b..87ca13e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -67,9 +67,6 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	if (unlikely(ext4_forced_shutdown(EXT4_SB(file_inode(iocb->ki_filp)->i_sb))))
 		return -EIO;
 
-	if (!iov_iter_count(to))
-		return 0; /* skip atime */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Remove repeated test in ext4_file_read_iter.
  2017-12-27  8:19 [PATCH] ext4: Remove repeated test in ext4_file_read_iter Sean Fu
@ 2018-01-03  2:08 ` Al Viro
  2018-01-10 14:01   ` Sean Fu
  0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2018-01-03  2:08 UTC (permalink / raw)
  To: Sean Fu; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

On Wed, Dec 27, 2017 at 04:19:58PM +0800, Sean Fu wrote:
> generic_file_read_iter has done the count test.
> So ext4_file_read_iter don't need to test the count repeatedly.

Huh?  You do realize that generic_file_read_iter() is not the
only variant possible there, right?

static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
        struct inode *inode = file_inode(iocb->ki_filp);
        ssize_t ret;

        if (!inode_trylock_shared(inode)) {
                if (iocb->ki_flags & IOCB_NOWAIT)
                        return -EAGAIN;
                inode_lock_shared(inode);
        }

... and now IOCB_NOWAIT read with zero count can fail with -EAGAIN.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Remove repeated test in ext4_file_read_iter.
  2018-01-03  2:08 ` Al Viro
@ 2018-01-10 14:01   ` Sean Fu
  2018-01-10 20:02     ` Theodore Ts'o
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Fu @ 2018-01-10 14:01 UTC (permalink / raw)
  To: Al Viro; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

On Wed, Jan 03, 2018 at 02:08:05AM +0000, Al Viro wrote:
> On Wed, Dec 27, 2017 at 04:19:58PM +0800, Sean Fu wrote:
> > generic_file_read_iter has done the count test.
> > So ext4_file_read_iter don't need to test the count repeatedly.
> 
> Huh?  You do realize that generic_file_read_iter() is not the
> only variant possible there, right?
>
Yes, I know that generic_file_read_iter() is not the only variant possible.
The other possible dax_iomap_rw() with zero count would return zero.
> static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
> {
>         struct inode *inode = file_inode(iocb->ki_filp);
>         ssize_t ret;
> 
>         if (!inode_trylock_shared(inode)) {
>                 if (iocb->ki_flags & IOCB_NOWAIT)
>                         return -EAGAIN;
>                 inode_lock_shared(inode);
>         }
> 
> ... and now IOCB_NOWAIT read with zero count can fail with -EAGAIN.
>
Correct, IOCB_NOWAIT read with zero count can return -EAGAIN, But I
think that it is reasonable. while it got lock, zero would be returned
in this case.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Remove repeated test in ext4_file_read_iter.
  2018-01-10 14:01   ` Sean Fu
@ 2018-01-10 20:02     ` Theodore Ts'o
  2018-01-16  8:10       ` Sean Fu
  0 siblings, 1 reply; 5+ messages in thread
From: Theodore Ts'o @ 2018-01-10 20:02 UTC (permalink / raw)
  To: Sean Fu; +Cc: Al Viro, adilger.kernel, linux-ext4, linux-kernel

On Wed, Jan 10, 2018 at 10:01:49PM +0800, Sean Fu wrote:
>
> Correct, IOCB_NOWAIT read with zero count can return -EAGAIN, But I
> think that it is reasonable. while it got lock, zero would be returned
> in this case.

Returning -EAGAIN and 0 are not the same thing.  Specifically
returning 0 means "end of file".  Hence, it is NOT reasonable.

See the man page for read(2) or the relevant Single Unix Specification
standard:

RETURN VALUE
     On success, the number of bytes read is returned (zero indicates
     end of file)....

Changing the behavior of the system in which will break userspace is
never acceptable, and even more so given that this is just a "cleanup
patch".

						- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: Remove repeated test in ext4_file_read_iter.
  2018-01-10 20:02     ` Theodore Ts'o
@ 2018-01-16  8:10       ` Sean Fu
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Fu @ 2018-01-16  8:10 UTC (permalink / raw)
  To: Theodore Ts'o, Al Viro, adilger.kernel, linux-ext4,
	linux-kernel

On Wed, Jan 10, 2018 at 03:02:55PM -0500, Theodore Ts'o wrote:
> On Wed, Jan 10, 2018 at 10:01:49PM +0800, Sean Fu wrote:
> >
> > Correct, IOCB_NOWAIT read with zero count can return -EAGAIN, But I
> > think that it is reasonable. while it got lock, zero would be returned
> > in this case.
> 
> Returning -EAGAIN and 0 are not the same thing.  Specifically
> returning 0 means "end of file".  Hence, it is NOT reasonable.
> 
I know that two returnning value mean different things.
once the inode is not under lock contention, read again with zero count
would return zero.
> See the man page for read(2) or the relevant Single Unix Specification
> standard:
> 
> RETURN VALUE
>      On success, the number of bytes read is returned (zero indicates
>      end of file)....
> 
> Changing the behavior of the system in which will break userspace is
> never acceptable, and even more so given that this is just a "cleanup
> patch".
>
I agree with you at this point.
Thanks for your reply.

> 						- Ted
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-16  8:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27  8:19 [PATCH] ext4: Remove repeated test in ext4_file_read_iter Sean Fu
2018-01-03  2:08 ` Al Viro
2018-01-10 14:01   ` Sean Fu
2018-01-10 20:02     ` Theodore Ts'o
2018-01-16  8:10       ` Sean Fu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).