All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	Christoph Hellwig <hch@lst.de>, Ming Lin <ming.l@ssi.samsung.com>,
	Jens Axboe <axboe@fb.com>,
	"Artem S. Tashkinov" <t.artem@mailcity.com>,
	Steven Whitehouse <swhiteho@redhat.com>,
	IDE-ML <linux-ide@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: IO errors after "block: remove bio_get_nr_vecs()"
Date: Sun, 20 Dec 2015 21:10:19 -0800	[thread overview]
Message-ID: <CA+55aFw+4yR01ZUPbFhCKg4fDVWqomQKMx6ZhjM0SfZc0fZncw@mail.gmail.com> (raw)
In-Reply-To: <20151221042613.GA27493@htj.duckdns.org>

On Sun, Dec 20, 2015 at 8:26 PM, Tejun Heo <tj@kernel.org> wrote:
>
> I wonder whether ahci is screwing up command / sg table setup in a way
> that e.g. if there are too many segments the sg table overflows into
> the neighboring one which is now being exposed by upper layer being
> fixed to send down larger commands.  Looking into it.

That would explain the

  Corrupted low memory at c0001000 ...

that Artem also saw.

Anyway, it would be lovely to have some verification in the ATA
routines that the passed-on IO actually h9onors the limits it set.
Could you add a WARN_ON_ONCE(check_io_limits())" or similar, and maybe
we could catch whatever causes the overflow red-handed?

On a totally separate issue:

Just looking at some of the merging code, and I have to say that it
strikes me as insane. This in particular:

  #define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
        (((addr1) | (mask)) == (((addr2) - 1) | (mask)))
  #define BIOVEC_SEG_BOUNDARY(q, b1, b2) \
        __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) +
(b2)->bv_len, queue_segment_boundary((q)))

seems just *stupid*.

Why does it do that "bvec_to_phys((b2)) + (b2)->bv_len -1" on the
second bvec? That's the :"physical address of the last byte of the
second bvec".

I understand the "round both addresses up by the mask, and we want to
make sure that they are in the same segment" part.

But since an individual bvec had better be fully inside one segment
(since we split at bvec boundaries anyway, so if ). why do all that
crap anyway? The end address doesn't matter, you could just use the
beginning.

So remove the "-1" and remove the "+bv_len".

At which it would become just

  #define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
        ((addr1) | (mask) == (addr2)|(mask))
  #define BIOVEC_SEG_BOUNDARY(q, b1, b2) \
        __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)),
queue_segment_boundary((q)))

which seems simpler and more understandable. "Are the beginning
addresses in within the same segment"

Or are there ever bv_len == 0 things at the boundary that we want to
merge. Because then the "-1+bv_len" case migth make sense.

Anyway, that shouldn't change the end result in any way, so that
doesn't all *matter*, but it worries me when things look more
complicated than I think they should be.

Is there something I'm missing?

               Linus

  reply	other threads:[~2015-12-21  5:10 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20 17:51 IO errors after "block: remove bio_get_nr_vecs()" Linus Torvalds
2015-12-20 18:18 ` Christoph Hellwig
2015-12-20 18:41   ` Linus Torvalds
2015-12-20 23:36     ` Artem S. Tashkinov
2015-12-21 11:21     ` Dan Aloni
2015-12-20 18:44   ` Kent Overstreet
2015-12-20 23:41     ` Artem S. Tashkinov
2015-12-20 23:25   ` Artem S. Tashkinov
2015-12-20 23:42     ` Kent Overstreet
2015-12-20 23:49       ` Artem S. Tashkinov
2015-12-20 23:23 ` Artem S. Tashkinov
2015-12-21  1:38 ` Ming Lei
2015-12-21  1:50   ` Artem S. Tashkinov
2015-12-21  2:18     ` Ming Lei
2015-12-21  2:25       ` Artem S. Tashkinov
2015-12-21  2:32     ` Kent Overstreet
2015-12-21  3:21       ` Ming Lei
2015-12-21  3:36         ` Artem S. Tashkinov
2015-12-21  4:32     ` Linus Torvalds
2015-12-21  4:43       ` Artem S. Tashkinov
2015-12-21  4:47         ` Linus Torvalds
2015-12-21  5:23           ` Linus Torvalds
2015-12-21  7:31             ` Artem S. Tashkinov
2015-12-22  4:06             ` Artem S. Tashkinov
2015-12-21  4:26 ` Tejun Heo
2015-12-21  5:10   ` Linus Torvalds [this message]
2015-12-21  6:55 ` Tejun Heo
2015-12-21  7:25   ` Artem S. Tashkinov
2015-12-21 19:35     ` Tejun Heo
2015-12-21 20:07       ` Tejun Heo
2015-12-21 21:08         ` Tejun Heo
2015-12-22  3:43           ` Kent Overstreet
2015-12-22  3:59           ` Kent Overstreet
2015-12-22  5:26             ` Junichi Nomura
2015-12-22  5:37               ` Kent Overstreet
2015-12-22  5:38               ` Kent Overstreet
2015-12-22  5:52                 ` Artem S. Tashkinov
2015-12-22  5:55                   ` Kent Overstreet
2015-12-22  5:59                     ` Artem S. Tashkinov
2015-12-22  6:02                       ` Kent Overstreet
2015-12-22 17:28               ` Jens Axboe
2015-12-22  4:45           ` Kent Overstreet
2015-12-22  5:10         ` Artem S. Tashkinov
2015-12-22  5:20         ` Artem S. Tashkinov
2015-12-21 22:51       ` Ming Lei

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=CA+55aFw+4yR01ZUPbFhCKg4fDVWqomQKMx6ZhjM0SfZc0fZncw@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.l@ssi.samsung.com \
    --cc=swhiteho@redhat.com \
    --cc=t.artem@mailcity.com \
    --cc=tj@kernel.org \
    /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.