public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [LTP] [linus:master] [iomap]  219580eea1: ltp.writev07.fail
       [not found] <202307132107.2ce4ea2f-oliver.sang@intel.com>
@ 2023-07-13 15:12 ` Cyril Hrubis
       [not found] ` <20230713150923.GA28246@lst.de>
  1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2023-07-13 15:12 UTC (permalink / raw)
  To: kernel test robot
  Cc: Christoph Hellwig, Darrick J. Wong, Andreas Gruenbacher,
	Miklos Szeredi, Matthew Wilcox, cluster-devel, Ilya Dryomov,
	Miklos Szeredi, Chao Yu, linux-fsdevel, Al Viro, Jaegeuk Kim,
	Xiubo Li, Trond Myklebust, ltp, lkp, Jens Axboe,
	Christian Brauner, Theodore Ts'o, Johannes Thumshirn,
	linux-kernel, linux-xfs, Anna Schumaker, oe-lkp, Andrew Morton,
	Hannes Reinecke

Hi!
The test description:

 Verify writev() behaviour with partially valid iovec list.
 Kernel <4.8 used to shorten write up to first bad invalid
 iovec. Starting with 4.8, a writev with short data (under
 page size) is likely to get shorten to 0 bytes and return
 EFAULT.

 This test doesn't make assumptions how much will write get
 shortened. It only tests that file content/offset after
 syscall corresponds to return value of writev().

 See: [RFC] writev() semantics with invalid iovec in the middle
      https://marc.info/?l=linux-kernel&m=147388891614289&w=2

-- 
Cyril Hrubis
chrubis@suse.cz

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

* Re: [LTP] [linus:master] [iomap]  219580eea1: ltp.writev07.fail
       [not found] ` <20230713150923.GA28246@lst.de>
@ 2023-07-13 15:34   ` Cyril Hrubis
  2023-07-13 15:56     ` Christoph Hellwig
  2023-07-14 11:50     ` Jan Stancek
  0 siblings, 2 replies; 5+ messages in thread
From: Cyril Hrubis @ 2023-07-13 15:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kernel test robot, Darrick J. Wong, Andreas Gruenbacher,
	Miklos Szeredi, Matthew Wilcox, cluster-devel, Ilya Dryomov,
	Miklos Szeredi, Chao Yu, linux-fsdevel, Al Viro, Jaegeuk Kim,
	Xiubo Li, Trond Myklebust, ltp, lkp, Jens Axboe,
	Christian Brauner, Theodore Ts'o, Johannes Thumshirn,
	linux-kernel, linux-xfs, Anna Schumaker, oe-lkp, Andrew Morton,
	Hannes Reinecke

Hi!
> I can't reproduce this on current mainline.  Is this a robust failure
> or flapping test?  Especiall as the FAIL conditions look rather
> unrelated.

Actually the test is spot on, the difference is that previously the
error was returned form the iomap_file_buffered_write() only if we
failed with the first buffer from the iov, now we always return the
error and we do not advance the offset.

The change that broke it:

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 063133ec77f4..550525a525c4 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -864,16 +864,19 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
                .len            = iov_iter_count(i),
                .flags          = IOMAP_WRITE,
        };
-       int ret;
+       ssize_t ret;

        if (iocb->ki_flags & IOCB_NOWAIT)
                iter.flags |= IOMAP_NOWAIT;

        while ((ret = iomap_iter(&iter, ops)) > 0)
                iter.processed = iomap_write_iter(&iter, i);
-       if (iter.pos == iocb->ki_pos)
+
+       if (unlikely(ret < 0))
                return ret;
-       return iter.pos - iocb->ki_pos;
+       ret = iter.pos - iocb->ki_pos;
+       iocb->ki_pos += ret;
+       return ret;
 }

I suppose that we shoudl fix is with something as:

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index adb92cdb24b0..bfb39f7bc303 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -872,11 +872,12 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
        while ((ret = iomap_iter(&iter, ops)) > 0)
                iter.processed = iomap_write_iter(&iter, i);

+       iocb->ki_pos += iter.pos - iocb->ki_pos;
+
        if (unlikely(ret < 0))
                return ret;
-       ret = iter.pos - iocb->ki_pos;
-       iocb->ki_pos += ret;
-       return ret;
+
+       return iter.pos - iocb->ki_pos;
 }
 EXPORT_SYMBOL_GPL(iomap_file_buffered_write);


-- 
Cyril Hrubis
chrubis@suse.cz

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

* Re: [LTP] [linus:master] [iomap]  219580eea1: ltp.writev07.fail
  2023-07-13 15:34   ` Cyril Hrubis
@ 2023-07-13 15:56     ` Christoph Hellwig
  2023-07-14 11:50     ` Jan Stancek
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2023-07-13 15:56 UTC (permalink / raw)
  To: Cyril Hrubis
  Cc: Christoph Hellwig, kernel test robot, Darrick J. Wong,
	Andreas Gruenbacher, Miklos Szeredi, Matthew Wilcox,
	cluster-devel, Ilya Dryomov, Miklos Szeredi, Chao Yu,
	linux-fsdevel, Al Viro, Jaegeuk Kim, Xiubo Li, Trond Myklebust,
	ltp, lkp, Jens Axboe, Christian Brauner, Theodore Ts'o,
	Johannes Thumshirn, linux-kernel, linux-xfs, Anna Schumaker,
	oe-lkp, Andrew Morton, Hannes Reinecke

On Thu, Jul 13, 2023 at 05:34:55PM +0200, Cyril Hrubis wrote:
>                 iter.processed = iomap_write_iter(&iter, i);
> 
> +       iocb->ki_pos += iter.pos - iocb->ki_pos;
> +
>         if (unlikely(ret < 0))
>                 return ret;
> -       ret = iter.pos - iocb->ki_pos;
> -       iocb->ki_pos += ret;
> -       return ret;
> +
> +       return iter.pos - iocb->ki_pos;

I don't think this works, as iocb->ki_pos has been updated above.
What you want is probably the version below.  But so far I can't
reproduce anything yet..

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index adb92cdb24b009..02aea0174ddbcf 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -872,7 +872,7 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
 	while ((ret = iomap_iter(&iter, ops)) > 0)
 		iter.processed = iomap_write_iter(&iter, i);
 
-	if (unlikely(ret < 0))
+	if (iter.pos == iocb->ki_pos)
 		return ret;
 	ret = iter.pos - iocb->ki_pos;
 	iocb->ki_pos += ret;

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

* Re: [LTP] [linus:master] [iomap] 219580eea1: ltp.writev07.fail
  2023-07-13 15:34   ` Cyril Hrubis
  2023-07-13 15:56     ` Christoph Hellwig
@ 2023-07-14 11:50     ` Jan Stancek
  2023-07-14 11:53       ` Cyril Hrubis
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2023-07-14 11:50 UTC (permalink / raw)
  To: Cyril Hrubis
  Cc: Christoph Hellwig, Darrick J. Wong, Andreas Gruenbacher,
	Miklos Szeredi, Matthew Wilcox, cluster-devel, Ilya Dryomov,
	Miklos Szeredi, Chao Yu, oe-lkp, Al Viro, Jaegeuk Kim, Xiubo Li,
	Trond Myklebust, ltp, lkp, Jens Axboe, Christian Brauner,
	Theodore Ts'o, Johannes Thumshirn, linux-kernel, linux-xfs,
	kernel test robot, Anna Schumaker, linux-fsdevel, Andrew Morton,
	Hannes Reinecke

On Thu, Jul 13, 2023 at 5:38 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > I can't reproduce this on current mainline.  Is this a robust failure
> > or flapping test?  Especiall as the FAIL conditions look rather
> > unrelated.

It's consistently reproducible for me on xfs with HEAD at:
eb26cbb1a754 ("Merge tag 'platform-drivers-x86-v6.5-2' of
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86")

>
> Actually the test is spot on, the difference is that previously the
> error was returned form the iomap_file_buffered_write() only if we
> failed with the first buffer from the iov, now we always return the
> error and we do not advance the offset.
>
> The change that broke it:
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 063133ec77f4..550525a525c4 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -864,16 +864,19 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
>                 .len            = iov_iter_count(i),
>                 .flags          = IOMAP_WRITE,
>         };
> -       int ret;
> +       ssize_t ret;
>
>         if (iocb->ki_flags & IOCB_NOWAIT)
>                 iter.flags |= IOMAP_NOWAIT;
>
>         while ((ret = iomap_iter(&iter, ops)) > 0)
>                 iter.processed = iomap_write_iter(&iter, i);
> -       if (iter.pos == iocb->ki_pos)
> +
> +       if (unlikely(ret < 0))
>                 return ret;
> -       return iter.pos - iocb->ki_pos;
> +       ret = iter.pos - iocb->ki_pos;
> +       iocb->ki_pos += ret;
> +       return ret;
>  }
>
> I suppose that we shoudl fix is with something as:
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index adb92cdb24b0..bfb39f7bc303 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -872,11 +872,12 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
>         while ((ret = iomap_iter(&iter, ops)) > 0)
>                 iter.processed = iomap_write_iter(&iter, i);
>
> +       iocb->ki_pos += iter.pos - iocb->ki_pos;
> +
>         if (unlikely(ret < 0))
>                 return ret;
> -       ret = iter.pos - iocb->ki_pos;
> -       iocb->ki_pos += ret;
> -       return ret;
> +
> +       return iter.pos - iocb->ki_pos;

Replacing "ret" with "iter.pos - iocb->ki_pos" here doesn't look
equivalent to original,
because you already updated "iocb->ki_pos" few lines above.

Wouldn't it be enough to bring the old condition back?

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index adb92cdb24b0..7cc9f7274883 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -872,7 +872,7 @@ iomap_file_buffered_write(struct kiocb *iocb,
struct iov_iter *i,
        while ((ret = iomap_iter(&iter, ops)) > 0)
                iter.processed = iomap_write_iter(&iter, i);

-       if (unlikely(ret < 0))
+       if (unlikely(iter.pos == iocb->ki_pos))
                return ret;
        ret = iter.pos - iocb->ki_pos;
        iocb->ki_pos += ret;

(with hunk above applied)
# ./writev07
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s
writev07.c:50: TINFO: starting test with initial file offset: 0
writev07.c:94: TINFO: writev() has written 64 bytes
writev07.c:105: TPASS: file has expected content
writev07.c:116: TPASS: offset at 64 as expected
writev07.c:50: TINFO: starting test with initial file offset: 65
writev07.c:94: TINFO: writev() has written 64 bytes
writev07.c:105: TPASS: file has expected content
writev07.c:116: TPASS: offset at 129 as expected
writev07.c:50: TINFO: starting test with initial file offset: 4096
writev07.c:94: TINFO: writev() has written 64 bytes
writev07.c:105: TPASS: file has expected content
writev07.c:116: TPASS: offset at 4160 as expected
writev07.c:50: TINFO: starting test with initial file offset: 4097
writev07.c:94: TINFO: writev() has written 64 bytes
writev07.c:105: TPASS: file has expected content
writev07.c:116: TPASS: offset at 4161 as expected




>  }
>  EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
>
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>


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

* Re: [LTP] [linus:master] [iomap] 219580eea1: ltp.writev07.fail
  2023-07-14 11:50     ` Jan Stancek
@ 2023-07-14 11:53       ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2023-07-14 11:53 UTC (permalink / raw)
  To: Jan Stancek
  Cc: Christoph Hellwig, Darrick J. Wong, Andreas Gruenbacher,
	Miklos Szeredi, Matthew Wilcox, cluster-devel, Ilya Dryomov,
	Miklos Szeredi, Chao Yu, oe-lkp, Al Viro, Jaegeuk Kim, Xiubo Li,
	Trond Myklebust, ltp, lkp, Jens Axboe, Christian Brauner,
	Theodore Ts'o, Johannes Thumshirn, linux-kernel, linux-xfs,
	kernel test robot, Anna Schumaker, linux-fsdevel, Andrew Morton,
	Hannes Reinecke

Hi!
> > > I can't reproduce this on current mainline.  Is this a robust failure
> > > or flapping test?  Especiall as the FAIL conditions look rather
> > > unrelated.
> 
> It's consistently reproducible for me on xfs with HEAD at:
> eb26cbb1a754 ("Merge tag 'platform-drivers-x86-v6.5-2' of
> git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86")

Should be fixed by https://lore.kernel.org/linux-fsdevel/20230714085124.548920-1-hch@lst.de/T/#t

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2023-07-14 11:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202307132107.2ce4ea2f-oliver.sang@intel.com>
2023-07-13 15:12 ` [LTP] [linus:master] [iomap] 219580eea1: ltp.writev07.fail Cyril Hrubis
     [not found] ` <20230713150923.GA28246@lst.de>
2023-07-13 15:34   ` Cyril Hrubis
2023-07-13 15:56     ` Christoph Hellwig
2023-07-14 11:50     ` Jan Stancek
2023-07-14 11:53       ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox