From: "Ewan D. Milne" <emilne@redhat.com>
To: Eyal Ben David <bdeyal@gmail.com>
Cc: Laurence Oberman <loberman@redhat.com>,
dgilbert@interlog.com, linux-scsi@vger.kernel.org
Subject: Re: SG does not ignore dxferp (direct io + mmap)
Date: Mon, 21 Nov 2016 09:24:35 -0500 [thread overview]
Message-ID: <1479738275.19792.24.camel@localhost.localdomain> (raw)
In-Reply-To: <CAPrnrPBOrkzz5f5rVE4jBkEEvEQRoeo73y50V6cVNgP3c5yzNg@mail.gmail.com>
On Mon, 2016-11-21 at 11:23 +0200, Eyal Ben David wrote:
> Hi,
>
> The utility I mentioned is just a small program that I wrote to learn
> more about the problem.
>
> It is a very simple read16 with options for mmap and dxferp as null or other.
>
> Here is the source code:
>
> == cut here ==
>
<snip>
> 2016-11-21 2:04 GMT+02:00 Laurence Oberman <loberman@redhat.com>:
> >
> >
> > ----- Original Message -----
> >> From: "Eyal Ben David" <bdeyal@gmail.com>
> >> To: linux-scsi@vger.kernel.org
> >> Sent: Sunday, November 20, 2016 11:02:49 AM
> >> Subject: SG does not ignore dxferp (direct io + mmap)
> >>
> >> Hi all,
> >>
> >> We have some IO utility that perform the IOs using sg and direct io with
> >> mmap.
> >> Our current systems are Ubuntu 14.04, RHEL 6,7
> >> The IO utility always set dxferp to either the address or mmap of
> >> other allocation (valloc)
> >> Setting dxferp was harmless since SG is supposed to ignore the address
> >> if mmap IO is selected.
> >> When porting to Ubuntu 16.04, we had a corruption problem - first byte
> >> of a read task is always 0.
> >> When setting dxferp as NULL the corruption does not occur any more.
> >> This is a regression and not according to SCSI generic documentation.
> >>
> >> I wrote a small program that shows the change:
> >>
> >> Read indirect (no mmap), lba=0:
> >> =======================
> >> $ ./sg_mmap_read -d /dev/sg0 -l 0
> >> 0000000 eb 63 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
> >>
> >> Read with mmap, lba=0, dxferp=NULL:
> >> ============================
> >> $ ./sg_mmap_read -d /dev/sg0 -l 0 -m
> >> 0000000 eb 63 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
> >>
> >> Read with mmap, lba=0, dxferp=address from mmap
> >> ======================================
> >> $ ./sg_mmap_read -d /dev/sg0 -l 0 -m -b
> >> 0000000 00 63 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
> >>
> >> On the older systems all results are the same.
> >>
> >> Thanks for any answer!
> >> --
For what it's worth, I ran this on a 4.8 kernel and did not see your
problem. I couldn't reproduce it on a RHEL kernel either.
# ./sg_mmap_read -d /dev/sg0 -l 0 | od -x
0000000 63eb 1090 d08e 00bc b8b0 0000 d88e c08e
0000020 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000040 be00 07be 0438 0b75 c683 8110 fefe 7507
0000060 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000100
# ./sg_mmap_read -d /dev/sg0 -l 0 -m | od -x
0000000 63eb 1090 d08e 00bc b8b0 0000 d88e c08e
0000020 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000040 be00 07be 0438 0b75 c683 8110 fefe 7507
0000060 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000100
# ./sg_mmap_read -d /dev/sg0 -l 0 -m -b | od -x
0000000 63eb 1090 d08e 00bc b8b0 0000 d88e c08e
0000020 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000040 be00 07be 0438 0b75 c683 8110 fefe 7507
0000060 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000100
The only recent relevant change I see is:
commit 5ecee0a3ee8d74b6950cb41e8989b0c2174568d4
Author: Douglas Gilbert <dgilbert@interlog.com>
Date: Thu Mar 3 00:31:29 2016 -0500
sg: fix dxferp in from_to case
However the kernel I used has that change, and the
change purposely does not clear hp->dxferp if
SG_DXFER_TO_FROM_DEV is specified, which your program
does not, and the behavior is correct regardless.
Can you modify your program to output the userspace
address of your buffer?
-Ewan
next prev parent reply other threads:[~2016-11-21 14:24 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-20 16:02 SG does not ignore dxferp (direct io + mmap) Eyal Ben David
2016-11-21 0:04 ` Laurence Oberman
2016-11-21 9:23 ` Eyal Ben David
2016-11-21 14:24 ` Ewan D. Milne [this message]
2016-11-21 14:54 ` Laurence Oberman
2016-11-21 14:55 ` Eyal Ben David
2016-11-21 15:12 ` Laurence Oberman
2016-11-21 15:15 ` Johannes Thumshirn
2016-11-21 15:44 ` Johannes Thumshirn
2016-11-21 16:04 ` Eyal Ben David
2016-11-21 16:25 ` Ewan D. Milne
2016-11-21 17:34 ` Douglas Gilbert
2016-11-21 18:24 ` Ewan D. Milne
2016-11-22 8:37 ` Johannes Thumshirn
2016-11-22 13:48 ` Eyal Ben David
2016-11-22 15:31 ` Laurence Oberman
2016-11-22 16:00 ` Johannes Thumshirn
2016-11-22 16:28 ` Eyal Ben David
2016-11-22 18:30 ` Ewan D. Milne
2016-11-22 18:46 ` Laurence Oberman
2016-11-22 20:55 ` Eyal Ben David
2016-11-23 18:55 ` Laurence Oberman
2016-11-23 20:22 ` Ewan D. Milne
2016-11-25 8:07 ` Johannes Thumshirn
2016-11-25 11:20 ` Eyal Ben David
2016-11-25 11:53 ` Johannes Thumshirn
2016-11-25 12:28 ` Johannes Thumshirn
2016-11-25 12:36 ` Eyal Ben David
2016-11-25 14:46 ` Laurence Oberman
2016-11-28 10:30 ` Johannes Thumshirn
2016-11-25 17:56 ` Ewan Milne
2016-11-25 18:01 ` Laurence Oberman
2016-11-30 16:26 ` Ewan D. Milne
2016-12-01 13:40 ` Martin K. Petersen
2016-12-02 12:21 ` Christoph Hellwig
2016-12-02 13:29 ` Ewan D. Milne
2016-12-02 14:10 ` Hannes Reinecke
2016-12-02 14:17 ` Laurence Oberman
2016-12-02 19:29 ` Ewan D. Milne
2016-12-02 20:37 ` Ewan D. Milne
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=1479738275.19792.24.camel@localhost.localdomain \
--to=emilne@redhat.com \
--cc=bdeyal@gmail.com \
--cc=dgilbert@interlog.com \
--cc=linux-scsi@vger.kernel.org \
--cc=loberman@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).