* [PATCH] lightnvm: limit get chunk meta request size
@ 2018-07-02 8:02 Matias Bjørling
2018-07-03 19:10 ` Javier Gonzalez
0 siblings, 1 reply; 4+ messages in thread
From: Matias Bjørling @ 2018-07-02 8:02 UTC (permalink / raw)
To: igor.j.konopko, marcin.dziegielewski, javier, hans.holmberg,
hlitz, youngtack.jin
Cc: linux-block, linux-kernel, Matias Bjørling
For devices that does not specify a limit on its transfer size, the
get_chk_meta command may send down a single I/O retrieving the full
chunk metadata table. Resulting in large 2-4MB I/O requests. Instead,
split up the I/Os to a maximum of 256KB and issue them separately to
reduce memory requirements.
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
---
drivers/nvme/host/lightnvm.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index b9989717418d..3b644b0e9713 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -583,7 +583,13 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
struct ppa_addr ppa;
size_t left = nchks * sizeof(struct nvme_nvm_chk_meta);
size_t log_pos, offset, len;
- int ret, i;
+ int ret, i, max_len;
+
+ /*
+ * limit requests to maximum 256K to avoid issuing arbitrary large
+ * requests when the device does not specific a maximum transfer size.
+ */
+ max_len = min_t(unsigned int, ctrl->max_hw_sectors << 9, 256 * 1024);
/* Normalize lba address space to obtain log offset */
ppa.ppa = slba;
@@ -596,7 +602,7 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
offset = log_pos * sizeof(struct nvme_nvm_chk_meta);
while (left) {
- len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9);
+ len = min_t(unsigned int, left, max_len);
ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK,
dev_meta, len, offset);
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lightnvm: limit get chunk meta request size
2018-07-02 8:02 [PATCH] lightnvm: limit get chunk meta request size Matias Bjørling
@ 2018-07-03 19:10 ` Javier Gonzalez
2018-07-03 19:14 ` Matias Bjørling
0 siblings, 1 reply; 4+ messages in thread
From: Javier Gonzalez @ 2018-07-03 19:10 UTC (permalink / raw)
To: Matias Bjørling
Cc: Konopko, Igor J, Marcin Dziegielewski, Hans Holmberg,
Heiner Litz, Young Tack Tack Jin, linux-block, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1913 bytes --]
> On 2 Jul 2018, at 10.02, Matias Bjørling <mb@lightnvm.io> wrote:
>
> For devices that does not specify a limit on its transfer size, the
> get_chk_meta command may send down a single I/O retrieving the full
> chunk metadata table. Resulting in large 2-4MB I/O requests. Instead,
> split up the I/Os to a maximum of 256KB and issue them separately to
> reduce memory requirements.
>
> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
> ---
> drivers/nvme/host/lightnvm.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
> index b9989717418d..3b644b0e9713 100644
> --- a/drivers/nvme/host/lightnvm.c
> +++ b/drivers/nvme/host/lightnvm.c
> @@ -583,7 +583,13 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
> struct ppa_addr ppa;
> size_t left = nchks * sizeof(struct nvme_nvm_chk_meta);
> size_t log_pos, offset, len;
> - int ret, i;
> + int ret, i, max_len;
> +
> + /*
> + * limit requests to maximum 256K to avoid issuing arbitrary large
> + * requests when the device does not specific a maximum transfer size.
> + */
> + max_len = min_t(unsigned int, ctrl->max_hw_sectors << 9, 256 * 1024);
>
> /* Normalize lba address space to obtain log offset */
> ppa.ppa = slba;
> @@ -596,7 +602,7 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
> offset = log_pos * sizeof(struct nvme_nvm_chk_meta);
>
> while (left) {
> - len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9);
> + len = min_t(unsigned int, left, max_len);
>
> ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK,
> dev_meta, len, offset);
> --
> 2.11.0
Is this a v2? I remember seeing this patch being posted before [1]. It
still looks good to me :)
[1] https://lkml.org/lkml/2018/6/12/466
Reviewed-by: Javier González <javier@cnexlabs.com>
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lightnvm: limit get chunk meta request size
2018-07-03 19:10 ` Javier Gonzalez
@ 2018-07-03 19:14 ` Matias Bjørling
2018-07-05 7:14 ` Javier Gonzalez
0 siblings, 1 reply; 4+ messages in thread
From: Matias Bjørling @ 2018-07-03 19:14 UTC (permalink / raw)
To: javier
Cc: igor.j.konopko, marcin.dziegielewski, hans.holmberg, hlitz,
youngtack.jin, linux-block, linux-kernel
On 07/03/2018 09:10 PM, Javier Gonzalez wrote:
>> On 2 Jul 2018, at 10.02, Matias Bjørling <mb@lightnvm.io> wrote:
>>
>> For devices that does not specify a limit on its transfer size, the
>> get_chk_meta command may send down a single I/O retrieving the full
>> chunk metadata table. Resulting in large 2-4MB I/O requests. Instead,
>> split up the I/Os to a maximum of 256KB and issue them separately to
>> reduce memory requirements.
>>
>> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
>> ---
>> drivers/nvme/host/lightnvm.c | 10 ++++++++--
>> 1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
>> index b9989717418d..3b644b0e9713 100644
>> --- a/drivers/nvme/host/lightnvm.c
>> +++ b/drivers/nvme/host/lightnvm.c
>> @@ -583,7 +583,13 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
>> struct ppa_addr ppa;
>> size_t left = nchks * sizeof(struct nvme_nvm_chk_meta);
>> size_t log_pos, offset, len;
>> - int ret, i;
>> + int ret, i, max_len;
>> +
>> + /*
>> + * limit requests to maximum 256K to avoid issuing arbitrary large
>> + * requests when the device does not specific a maximum transfer size.
>> + */
>> + max_len = min_t(unsigned int, ctrl->max_hw_sectors << 9, 256 * 1024);
>>
>> /* Normalize lba address space to obtain log offset */
>> ppa.ppa = slba;
>> @@ -596,7 +602,7 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
>> offset = log_pos * sizeof(struct nvme_nvm_chk_meta);
>>
>> while (left) {
>> - len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9);
>> + len = min_t(unsigned int, left, max_len);
>>
>> ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK,
>> dev_meta, len, offset);
>> --
>> 2.11.0
>
> Is this a v2? I remember seeing this patch being posted before [1]. It
> still looks good to me :)
>
>
> [1] https://lkml.org/lkml/2018/6/12/466
>
>
> Reviewed-by: Javier González <javier@cnexlabs.com>
>
I changed the title. Since it didn't touch pblk. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lightnvm: limit get chunk meta request size
2018-07-03 19:14 ` Matias Bjørling
@ 2018-07-05 7:14 ` Javier Gonzalez
0 siblings, 0 replies; 4+ messages in thread
From: Javier Gonzalez @ 2018-07-05 7:14 UTC (permalink / raw)
To: Matias Bjørling
Cc: Konopko, Igor J, Marcin Dziegielewski, Hans Holmberg,
Heiner Litz, Young Tack Tack Jin, linux-block, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2212 bytes --]
> On 3 Jul 2018, at 21.14, Matias Bjørling <mb@lightnvm.io> wrote:
>
> On 07/03/2018 09:10 PM, Javier Gonzalez wrote:
>>> On 2 Jul 2018, at 10.02, Matias Bjørling <mb@lightnvm.io> wrote:
>>>
>>> For devices that does not specify a limit on its transfer size, the
>>> get_chk_meta command may send down a single I/O retrieving the full
>>> chunk metadata table. Resulting in large 2-4MB I/O requests. Instead,
>>> split up the I/Os to a maximum of 256KB and issue them separately to
>>> reduce memory requirements.
>>>
>>> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
>>> ---
>>> drivers/nvme/host/lightnvm.c | 10 ++++++++--
>>> 1 file changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
>>> index b9989717418d..3b644b0e9713 100644
>>> --- a/drivers/nvme/host/lightnvm.c
>>> +++ b/drivers/nvme/host/lightnvm.c
>>> @@ -583,7 +583,13 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
>>> struct ppa_addr ppa;
>>> size_t left = nchks * sizeof(struct nvme_nvm_chk_meta);
>>> size_t log_pos, offset, len;
>>> - int ret, i;
>>> + int ret, i, max_len;
>>> +
>>> + /*
>>> + * limit requests to maximum 256K to avoid issuing arbitrary large
>>> + * requests when the device does not specific a maximum transfer size.
>>> + */
>>> + max_len = min_t(unsigned int, ctrl->max_hw_sectors << 9, 256 * 1024);
>>>
>>> /* Normalize lba address space to obtain log offset */
>>> ppa.ppa = slba;
>>> @@ -596,7 +602,7 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
>>> offset = log_pos * sizeof(struct nvme_nvm_chk_meta);
>>>
>>> while (left) {
>>> - len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9);
>>> + len = min_t(unsigned int, left, max_len);
>>>
>>> ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK,
>>> dev_meta, len, offset);
>>> --
>>> 2.11.0
>> Is this a v2? I remember seeing this patch being posted before [1]. It
>> still looks good to me :)
>> [1] https://lkml.org/lkml/2018/6/12/466
>> Reviewed-by: Javier González <javier@cnexlabs.com>
>
> I changed the title. Since it didn't touch pblk. Thanks.
Makes sense. Thanks!
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-05 7:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 8:02 [PATCH] lightnvm: limit get chunk meta request size Matias Bjørling
2018-07-03 19:10 ` Javier Gonzalez
2018-07-03 19:14 ` Matias Bjørling
2018-07-05 7:14 ` Javier Gonzalez
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).