All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: Yi Zhang <yi.zhang@redhat.com>,
	linux-nvme@lists.infradead.org,
	linux-block <linux-block@vger.kernel.org>,
	axboe@kernel.dk, Rachel Sibley <rasibley@redhat.com>,
	Chaitanya.Kulkarni@wdc.com, CKI Project <cki-project@redhat.com>
Subject: Re: kernel null pointer at nvme_tcp_init_iter+0x7d/0xd0 [nvme_tcp]
Date: Tue, 9 Feb 2021 18:33:00 +0800	[thread overview]
Message-ID: <20210209103300.GA101814@T590> (raw)
In-Reply-To: <d5e33680-5196-2873-332f-19191c60fd3b@grimberg.me>

On Tue, Feb 09, 2021 at 02:07:15AM -0800, Sagi Grimberg wrote:
> 
> > > > 
> > > > One obvious error is that nr_segments is computed wrong.
> > > > 
> > > > Yi, can you try the following patch?
> > > > 
> > > > diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> > > > index 881d28eb15e9..a393d99b74e1 100644
> > > > --- a/drivers/nvme/host/tcp.c
> > > > +++ b/drivers/nvme/host/tcp.c
> > > > @@ -239,9 +239,14 @@ static void nvme_tcp_init_iter(struct nvme_tcp_request *req,
> > > >    		offset = 0;
> > > >    	} else {
> > > >    		struct bio *bio = req->curr_bio;
> > > > +		struct bio_vec bv;
> > > > +		struct bvec_iter iter;
> > > > +
> > > > +		nsegs = 0;
> > > > +		bio_for_each_bvec(bv, bio, iter)
> > > > +			nsegs++;
> > > >    		vec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
> > > > -		nsegs = bio_segments(bio);
> > > 
> > > This was exactly the patch that caused the issue.
> > 
> > What was the issue you are talking about? Any link or commit hash?
> 
> The commit that caused the crash is:
> 0dc9edaf80ea nvme-tcp: pass multipage bvec to request iov_iter

Not found this commit in linus tree, :-(

> 
> > 
> > nvme-tcp builds iov_iter(BVEC) from __bvec_iter_bvec(), the segment
> > number has to be the actual bvec number. But bio_segment() just returns
> > number of the single-page segment, which is wrong for iov_iter.
> 
> That is what I thought, but its causing a crash, and was fine with
> bio_segments. So I'm trying to understand why is that.

I tested this patch, and it works just fine.

> 
> > Please see the same usage in lo_rw_aio().
> 
> nvme-tcp works on the bio basis to avoid bvec allocation
> in the data path. Hence the iterator is fed directly by
> the bio bvec and will re-initialize on every bio that
> is spanned by the request.

Yeah, I know that. What I meant is that rq_for_each_bvec() is used
to figure out bvec number in loop, which may feed the bio bvec
directly to fs via iov_iter too, just similar with nvme-tcp.

The difference is that loop will switch to allocate a new bvec
table and copy bios's bvec to the new table in case of bios merge.

-- 
Ming


WARNING: multiple messages have this Message-ID (diff)
From: Ming Lei <ming.lei@redhat.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: axboe@kernel.dk, Rachel Sibley <rasibley@redhat.com>,
	Yi Zhang <yi.zhang@redhat.com>,
	Chaitanya.Kulkarni@wdc.com, linux-nvme@lists.infradead.org,
	linux-block <linux-block@vger.kernel.org>,
	CKI Project <cki-project@redhat.com>
Subject: Re: kernel null pointer at nvme_tcp_init_iter+0x7d/0xd0 [nvme_tcp]
Date: Tue, 9 Feb 2021 18:33:00 +0800	[thread overview]
Message-ID: <20210209103300.GA101814@T590> (raw)
In-Reply-To: <d5e33680-5196-2873-332f-19191c60fd3b@grimberg.me>

On Tue, Feb 09, 2021 at 02:07:15AM -0800, Sagi Grimberg wrote:
> 
> > > > 
> > > > One obvious error is that nr_segments is computed wrong.
> > > > 
> > > > Yi, can you try the following patch?
> > > > 
> > > > diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> > > > index 881d28eb15e9..a393d99b74e1 100644
> > > > --- a/drivers/nvme/host/tcp.c
> > > > +++ b/drivers/nvme/host/tcp.c
> > > > @@ -239,9 +239,14 @@ static void nvme_tcp_init_iter(struct nvme_tcp_request *req,
> > > >    		offset = 0;
> > > >    	} else {
> > > >    		struct bio *bio = req->curr_bio;
> > > > +		struct bio_vec bv;
> > > > +		struct bvec_iter iter;
> > > > +
> > > > +		nsegs = 0;
> > > > +		bio_for_each_bvec(bv, bio, iter)
> > > > +			nsegs++;
> > > >    		vec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
> > > > -		nsegs = bio_segments(bio);
> > > 
> > > This was exactly the patch that caused the issue.
> > 
> > What was the issue you are talking about? Any link or commit hash?
> 
> The commit that caused the crash is:
> 0dc9edaf80ea nvme-tcp: pass multipage bvec to request iov_iter

Not found this commit in linus tree, :-(

> 
> > 
> > nvme-tcp builds iov_iter(BVEC) from __bvec_iter_bvec(), the segment
> > number has to be the actual bvec number. But bio_segment() just returns
> > number of the single-page segment, which is wrong for iov_iter.
> 
> That is what I thought, but its causing a crash, and was fine with
> bio_segments. So I'm trying to understand why is that.

I tested this patch, and it works just fine.

> 
> > Please see the same usage in lo_rw_aio().
> 
> nvme-tcp works on the bio basis to avoid bvec allocation
> in the data path. Hence the iterator is fed directly by
> the bio bvec and will re-initialize on every bio that
> is spanned by the request.

Yeah, I know that. What I meant is that rq_for_each_bvec() is used
to figure out bvec number in loop, which may feed the bio bvec
directly to fs via iov_iter too, just similar with nvme-tcp.

The difference is that loop will switch to allocate a new bvec
table and copy bios's bvec to the new table in case of bios merge.

-- 
Ming


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2021-02-09 10:38 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cki.F3E139361A.EN5MUSJKK9@redhat.com>
2021-02-06  3:08 ` kernel null pointer at nvme_tcp_init_iter+0x7d/0xd0 [nvme_tcp] Yi Zhang
2021-02-07  4:50   ` kernel null pointer at nvme_tcp_init_iter[nvme_tcp] with blktests nvme-tcp/012 Yi Zhang
2021-02-07  4:50     ` Yi Zhang
2021-02-07  5:25     ` Chaitanya Kulkarni
2021-02-07  5:25       ` Chaitanya Kulkarni
2021-02-08  6:48       ` Yi Zhang
2021-02-08  6:48         ` Yi Zhang
2021-02-07  5:48     ` Chaitanya Kulkarni
2021-02-07  5:48       ` Chaitanya Kulkarni
2021-02-07  5:58     ` Chaitanya Kulkarni
2021-02-07  5:58       ` Chaitanya Kulkarni
2021-02-07  7:14   ` kernel null pointer at nvme_tcp_init_iter+0x7d/0xd0 [nvme_tcp] Chaitanya Kulkarni
2021-02-07  7:14     ` Chaitanya Kulkarni
2021-02-08  9:53     ` Sagi Grimberg
2021-02-08  9:53       ` Sagi Grimberg
2021-02-08  9:46   ` Sagi Grimberg
2021-02-08  9:46     ` Sagi Grimberg
2021-02-08 13:28     ` Yi Zhang
2021-02-08 17:54       ` Sagi Grimberg
2021-02-08 17:54         ` Sagi Grimberg
2021-02-08 18:42         ` Sagi Grimberg
2021-02-08 18:42           ` Sagi Grimberg
2021-02-09  4:21           ` Ming Lei
2021-02-09  4:21             ` Ming Lei
2021-02-09  7:21             ` Sagi Grimberg
2021-02-09  7:21               ` Sagi Grimberg
2021-02-09  7:50               ` Ming Lei
2021-02-09  7:50                 ` Ming Lei
2021-02-09  8:34                 ` Chaitanya Kulkarni
2021-02-09  8:34                   ` Chaitanya Kulkarni
2021-02-09 10:09                   ` Sagi Grimberg
2021-02-09 10:09                     ` Sagi Grimberg
2021-02-09 10:07                 ` Sagi Grimberg
2021-02-09 10:07                   ` Sagi Grimberg
2021-02-09 10:33                   ` Ming Lei [this message]
2021-02-09 10:33                     ` Ming Lei
2021-02-09 10:36                     ` Sagi Grimberg
2021-02-09 10:36                       ` Sagi Grimberg
2021-02-09 10:25       ` Sagi Grimberg
2021-02-09 10:25         ` Sagi Grimberg
2021-02-09 12:57         ` Yi Zhang
2021-02-09 12:57           ` Yi Zhang
2021-02-09 18:01           ` Sagi Grimberg
2021-02-09 18:01             ` Sagi Grimberg
2021-02-10  2:51             ` Yi Zhang
2021-02-10  2:51               ` Yi Zhang
2021-02-10  3:38               ` Keith Busch
2021-02-10  3:38                 ` Keith Busch
2021-02-10  5:03               ` Chaitanya Kulkarni
2021-02-10  5:03                 ` Chaitanya Kulkarni
2021-02-10 22:06                 ` Sagi Grimberg
2021-02-10 22:06                   ` Sagi Grimberg
2021-02-10 22:15                   ` Chaitanya Kulkarni
2021-02-10 22:15                     ` Chaitanya Kulkarni

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=20210209103300.GA101814@T590 \
    --to=ming.lei@redhat.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=cki-project@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=rasibley@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=yi.zhang@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 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.