mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: Keith Busch <kbusch@kernel.org>,
	"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH] nvmet-tcp: Don't kmap() pages which can't come from HIGHMEM
Date: Wed, 17 Aug 2022 21:24:44 +0300	[thread overview]
Message-ID: <581ecec9-8f2b-32a2-6ce1-63551496e332@grimberg.me> (raw)
In-Reply-To: <Yv0o9MlqCjXUcDKc@kbusch-mbp.dhcp.thefacebook.com>


>> @@ -329,7 +312,6 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd)
>>   	u32 length, offset, sg_offset;
>>   
>>   	length = cmd->pdu_len;
>> -	cmd->nr_mapped = DIV_ROUND_UP(length, PAGE_SIZE);
>>   	offset = cmd->rbytes_done;
>>   	cmd->sg_idx = offset / PAGE_SIZE;
>>   	sg_offset = offset % PAGE_SIZE;
>> @@ -338,7 +320,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd)
>>   	while (length) {
>>   		u32 iov_len = min_t(u32, length, sg->length - sg_offset);
>>   
>> -		iov->iov_base = kmap(sg_page(sg)) + sg->offset + sg_offset;
>> +		iov->iov_base = page_address(sg_page(sg)) + sg->offset + sg_offset;
>>   		iov->iov_len = iov_len;
>>   
>>   		length -= iov_len;
>> @@ -347,8 +329,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd)
>>   		sg_offset = 0;
>>   	}
>>   
>> -	iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov,
>> -		cmd->nr_mapped, cmd->pdu_len);
>> +	iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov, 0, cmd->pdu_len);
>>   }
> 
> I earlier meant just use a local variable for 'nr_mapped' rather than replace
> it with '0'. I don't think that 0 segments would result in usable kvec.

yes, that is wrong. Need a local int nr_mapped variable.

> 
> I'm not even sure the existing code is correct, though. The sg->length can be
> higher order than a PAGE_SIZE, so it may be over-reporting nr_segs. It's just
> supposed to be the number of initialized iov's.

The sg is allocated with sgl_alloc so it is for sure 0-order.

      reply	other threads:[~2022-08-17 18:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 17:04 Fabio M. De Francesco
2022-08-17 17:44 ` Keith Busch
2022-08-17 18:24   ` Sagi Grimberg [this message]

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=581ecec9-8f2b-32a2-6ce1-63551496e332@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=chaitanyak@nvidia.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=hch@lst.de \
    --cc=ira.weiny@intel.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®