Linux-Next Archive on lore.kernel.org
 help / color / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>,
	LTP List <ltp@lists.linux.it>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org, chrubis <chrubis@suse.cz>,
	open list <linux-kernel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Mark Brown <broonie@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	lkft-triage@lists.linaro.org,
	Christoph Hellwig <hch@infradead.org>,
	linux-ext4 <linux-ext4@vger.kernel.org>,
	Theodore Ts'o <tytso@mit.edu>
Subject: Re: LTP: diotest4.c:476: read to read-only space. returns 0: Success
Date: Mon, 11 Nov 2019 03:19:40 -0500 (EST)
Message-ID: <1751469294.11431533.1573460380206.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20191111012614.GC6235@magnolia>


----- Original Message -----
> I can't do a whole lot with a code snippet that lacks a proper SOB
> header.

I'll resend as a patch, maybe split it to 2 returns instead.

> > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> > index 2f88d64c2a4d..8615b1f78389 100644
> > --- a/fs/iomap/direct-io.c
> > +++ b/fs/iomap/direct-io.c
> > @@ -318,7 +318,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos,
> > loff_t length,
> >                 if (pad)
> >                         iomap_dio_zero(dio, iomap, pos, fs_block_size -
> >                         pad);
> >         }
> > -       return copied ? copied : ret;
> > +       return copied ? (loff_t) copied : ret;
> 
> I'm a little confused on this proposed fix -- why does casting size_t
> (aka unsigned long) to loff_t (long long) on a 32-bit system change the
> test outcome?

Ternary operator has a return type and an attempt is made to convert
each of operands to the type of the other. So, in this case "ret"
appears to be converted to type of "copied" first. Both have size of
4 bytes on 32-bit x86:

size_t copied = 0;
int ret = -14;
long long actor_ret = copied ? copied : ret;

On x86_64: actor_ret == -14;
On x86   : actor_ret == 4294967282

> Does this same diotest4 failure happen with XFS?  I ask
> because XFS has been using iomap for directio for ages.

Yes, it fails on XFS too.


  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 13:59 Naresh Kamboju
2019-11-08  0:20 ` Jan Stancek
2019-11-11  1:26   ` Darrick J. Wong
2019-11-11  8:19     ` Jan Stancek [this message]
2019-11-11  8:38       ` Christoph Hellwig
2019-11-11 10:28         ` [PATCH] iomap: fix return value of iomap_dio_bio_actor on 32bit systems Jan Stancek
2019-11-11 10:36           ` Christoph Hellwig
2019-11-12  1:24           ` Darrick J. Wong
2019-11-11 10:38         ` LTP: diotest4.c:476: read to read-only space. returns 0: Success Jan Stancek
2019-11-11 18:26           ` Naresh Kamboju

Reply instructions:

You may reply publically 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=1751469294.11431533.1573460380206.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=chrubis@suse.cz \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=ltp@lists.linux.it \
    --cc=naresh.kamboju@linaro.org \
    --cc=tytso@mit.edu \
    --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

Linux-Next Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-next/0 linux-next/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-next linux-next/ https://lore.kernel.org/linux-next \
		linux-next@vger.kernel.org
	public-inbox-index linux-next

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-next


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git