linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] lightnvm: pblk: collection of small fixes
@ 2018-08-29  9:01 Javier González
  2018-08-29  9:01 ` [PATCH 1/4] lightnvm: pblk: calculate line pad distance in helper Javier González
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Javier González @ 2018-08-29  9:01 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

Collection of small helper function fixes, removal of unused variables
and comment typos.

Javier González (4):
  lightnvm: pblk: calculate line pad distance in helper
  lightnvm: pblk: fix comment typo
  lightnvm: pblk: remove unused variable.
  lightnvm: pblk: guarantee emeta on line close

 drivers/lightnvm/pblk-core.c     | 13 +++++++++++--
 drivers/lightnvm/pblk-recovery.c |  2 --
 drivers/lightnvm/pblk-write.c    |  2 +-
 drivers/lightnvm/pblk.h          |  6 +++---
 4 files changed, 15 insertions(+), 8 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] lightnvm: pblk: calculate line pad distance in helper
  2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
@ 2018-08-29  9:01 ` Javier González
  2018-08-29  9:01 ` [PATCH 2/4] lightnvm: pblk: fix comment typo Javier González
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Javier González @ 2018-08-29  9:01 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

If a line is padded, calculate the pad distance directly on the helper
being used for this purpose.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/pblk-recovery.c | 2 --
 drivers/lightnvm/pblk.h          | 5 +++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index fdc770f2545f..188c89819a40 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -487,8 +487,6 @@ static int pblk_recov_scan_all_oob(struct pblk *pblk, struct pblk_line *line,
 		bitmap_clear(line->map_bitmap, line->cur_sec, nr_error_bits);
 
 		pad_secs = pblk_pad_distance(pblk);
-		if (pad_secs > line->left_msecs)
-			pad_secs = line->left_msecs;
 
 		ret = pblk_recov_pad_oob(pblk, line, pad_secs);
 		if (ret)
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 54f937c1fb62..994a081994fb 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -990,12 +990,13 @@ static inline int pblk_line_vsc(struct pblk_line *line)
 	return le32_to_cpu(*line->vsc);
 }
 
-static inline int pblk_pad_distance(struct pblk *pblk)
+static inline int pblk_pad_distance(struct pblk *pblk, struct pblk_line *line)
 {
 	struct nvm_tgt_dev *dev = pblk->dev;
 	struct nvm_geo *geo = &dev->geo;
+	int distance = geo->mw_cunits * geo->all_luns * geo->ws_opt;
 
-	return geo->mw_cunits * geo->all_luns * geo->ws_opt;
+	return (distance > line->left_msecs) ? line->left_msecs : distance;
 }
 
 static inline int pblk_ppa_to_line_id(struct ppa_addr p)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] lightnvm: pblk: fix comment typo
  2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
  2018-08-29  9:01 ` [PATCH 1/4] lightnvm: pblk: calculate line pad distance in helper Javier González
@ 2018-08-29  9:01 ` Javier González
  2018-08-29  9:01 ` [PATCH 3/4] lightnvm: pblk: remove unused variable Javier González
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Javier González @ 2018-08-29  9:01 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

Fix comment typo Decrese -> Decrease

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/pblk-write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index 767618eba4c2..617572717065 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -195,7 +195,7 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry,
 		/* Release flags on write context. Protect from writes */
 		smp_store_release(&w_ctx->flags, flags);
 
-		/* Decrese the reference count to the line as we will
+		/* Decrease the reference count to the line as we will
 		 * re-map these entries
 		 */
 		line = pblk_ppa_to_line(pblk, w_ctx->ppa);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] lightnvm: pblk: remove unused variable.
  2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
  2018-08-29  9:01 ` [PATCH 1/4] lightnvm: pblk: calculate line pad distance in helper Javier González
  2018-08-29  9:01 ` [PATCH 2/4] lightnvm: pblk: fix comment typo Javier González
@ 2018-08-29  9:01 ` Javier González
  2018-08-29  9:01 ` [PATCH 4/4] lightnvm: pblk: guarantee emeta on line close Javier González
  2018-08-29 13:14 ` [PATCH 0/4] lightnvm: pblk: collection of small fixes Matias Bjørling
  4 siblings, 0 replies; 9+ messages in thread
From: Javier González @ 2018-08-29  9:01 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

Removed unused struct ppa_addr variable.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/pblk.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 994a081994fb..22cc9bfbbb10 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -1398,7 +1398,6 @@ static inline int pblk_check_io(struct pblk *pblk, struct nvm_rq *rqd)
 
 	if (rqd->opcode == NVM_OP_PWRITE) {
 		struct pblk_line *line;
-		struct ppa_addr ppa;
 		int i;
 
 		for (i = 0; i < rqd->nr_ppas; i++) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] lightnvm: pblk: guarantee emeta on line close
  2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
                   ` (2 preceding siblings ...)
  2018-08-29  9:01 ` [PATCH 3/4] lightnvm: pblk: remove unused variable Javier González
@ 2018-08-29  9:01 ` Javier González
  2018-08-29 13:14 ` [PATCH 0/4] lightnvm: pblk: collection of small fixes Matias Bjørling
  4 siblings, 0 replies; 9+ messages in thread
From: Javier González @ 2018-08-29  9:01 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

If a line is recovered from open chunks, the memory structures for
emeta have not necessarily been properly set on line initialization.
When closing a line, make sure that emeta is consistent so that the line
can be recovered on the fast path on next reboot.

Also, remove a couple of empty lines at the end of the function.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/pblk-core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 1e4dc0c1ed88..fdcbeb920c9e 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1857,6 +1857,17 @@ void pblk_line_close_meta(struct pblk *pblk, struct pblk_line *line)
 	wa->pad = cpu_to_le64(atomic64_read(&pblk->pad_wa));
 	wa->gc = cpu_to_le64(atomic64_read(&pblk->gc_wa));
 
+	if (le32_to_cpu(emeta_buf->header.identifier) != PBLK_MAGIC) {
+		emeta_buf->header.identifier = cpu_to_le32(PBLK_MAGIC);
+		memcpy(emeta_buf->header.uuid, pblk->instance_uuid, 16);
+		emeta_buf->header.id = cpu_to_le32(line->id);
+		emeta_buf->header.type = cpu_to_le16(line->type);
+		emeta_buf->header.version_major = EMETA_VERSION_MAJOR;
+		emeta_buf->header.version_minor = EMETA_VERSION_MINOR;
+		emeta_buf->header.crc = cpu_to_le32(
+			pblk_calc_meta_header_crc(pblk, &emeta_buf->header));
+	}
+
 	emeta_buf->nr_valid_lbas = cpu_to_le64(line->nr_valid_lbas);
 	emeta_buf->crc = cpu_to_le32(pblk_calc_emeta_crc(pblk, emeta_buf));
 
@@ -1874,8 +1885,6 @@ void pblk_line_close_meta(struct pblk *pblk, struct pblk_line *line)
 	spin_unlock(&l_mg->close_lock);
 
 	pblk_line_should_sync_meta(pblk);
-
-
 }
 
 static void pblk_save_lba_list(struct pblk *pblk, struct pblk_line *line)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] lightnvm: pblk: collection of small fixes
  2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
                   ` (3 preceding siblings ...)
  2018-08-29  9:01 ` [PATCH 4/4] lightnvm: pblk: guarantee emeta on line close Javier González
@ 2018-08-29 13:14 ` Matias Bjørling
  2018-08-29 13:27   ` Javier Gonzalez
  4 siblings, 1 reply; 9+ messages in thread
From: Matias Bjørling @ 2018-08-29 13:14 UTC (permalink / raw)
  To: javier; +Cc: linux-block, linux-kernel, javier

On 08/29/2018 11:01 AM, Javier González wrote:
> Collection of small helper function fixes, removal of unused variables
> and comment typos.
> 
> Javier González (4):
>    lightnvm: pblk: calculate line pad distance in helper
>    lightnvm: pblk: fix comment typo
>    lightnvm: pblk: remove unused variable.
>    lightnvm: pblk: guarantee emeta on line close
> 
>   drivers/lightnvm/pblk-core.c     | 13 +++++++++++--
>   drivers/lightnvm/pblk-recovery.c |  2 --
>   drivers/lightnvm/pblk-write.c    |  2 +-
>   drivers/lightnvm/pblk.h          |  6 +++---
>   4 files changed, 15 insertions(+), 8 deletions(-)
> 

Thanks. Applied 2-4. The pad distance does not compile due to missing 
update to pblk_pad_distance call from pblk-recovery.c.

Also, it looks like pblk-recovery.c is the only user. Please consider 
moving it the function from pblk.h to pblk-recovery.c

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] lightnvm: pblk: collection of small fixes
  2018-08-29 13:14 ` [PATCH 0/4] lightnvm: pblk: collection of small fixes Matias Bjørling
@ 2018-08-29 13:27   ` Javier Gonzalez
  2018-08-29 18:11     ` Matias Bjørling
  0 siblings, 1 reply; 9+ messages in thread
From: Javier Gonzalez @ 2018-08-29 13:27 UTC (permalink / raw)
  To: Matias Bjørling; +Cc: linux-block, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]


> On 29 Aug 2018, at 15.14, Matias Bjørling <mb@lightnvm.io> wrote:
> 
> On 08/29/2018 11:01 AM, Javier González wrote:
>> Collection of small helper function fixes, removal of unused variables
>> and comment typos.
>> Javier González (4):
>>   lightnvm: pblk: calculate line pad distance in helper
>>   lightnvm: pblk: fix comment typo
>>   lightnvm: pblk: remove unused variable.
>>   lightnvm: pblk: guarantee emeta on line close
>>  drivers/lightnvm/pblk-core.c     | 13 +++++++++++--
>>  drivers/lightnvm/pblk-recovery.c |  2 --
>>  drivers/lightnvm/pblk-write.c    |  2 +-
>>  drivers/lightnvm/pblk.h          |  6 +++---
>>  4 files changed, 15 insertions(+), 8 deletions(-)
> 
> Thanks. Applied 2-4. The pad distance does not compile due to missing
> update to pblk_pad_distance call from pblk-recovery.c.
> 
> Also, it looks like pblk-recovery.c is the only user. Please consider
> moving it the function from pblk.h to pblk-recovery.c

I reordered to send the helpers, but you can see that all these are made
to support.

  lightnvm: pblk: recover open lines on 2.0 devices

Can you fix this directly and apply 1 too? I'm fine with moving it to
pblk-recovery.c. The patch above will use it.

Thanks,
Javier

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] lightnvm: pblk: collection of small fixes
  2018-08-29 13:27   ` Javier Gonzalez
@ 2018-08-29 18:11     ` Matias Bjørling
  2018-08-29 19:13       ` Javier Gonzalez
  0 siblings, 1 reply; 9+ messages in thread
From: Matias Bjørling @ 2018-08-29 18:11 UTC (permalink / raw)
  To: javier; +Cc: linux-block, linux-kernel

On 08/29/2018 03:27 PM, Javier Gonzalez wrote:
> 
>> On 29 Aug 2018, at 15.14, Matias Bjørling <mb@lightnvm.io> wrote:
>>
>> On 08/29/2018 11:01 AM, Javier González wrote:
>>> Collection of small helper function fixes, removal of unused variables
>>> and comment typos.
>>> Javier González (4):
>>>    lightnvm: pblk: calculate line pad distance in helper
>>>    lightnvm: pblk: fix comment typo
>>>    lightnvm: pblk: remove unused variable.
>>>    lightnvm: pblk: guarantee emeta on line close
>>>   drivers/lightnvm/pblk-core.c     | 13 +++++++++++--
>>>   drivers/lightnvm/pblk-recovery.c |  2 --
>>>   drivers/lightnvm/pblk-write.c    |  2 +-
>>>   drivers/lightnvm/pblk.h          |  6 +++---
>>>   4 files changed, 15 insertions(+), 8 deletions(-)
>>
>> Thanks. Applied 2-4. The pad distance does not compile due to missing
>> update to pblk_pad_distance call from pblk-recovery.c.
>>
>> Also, it looks like pblk-recovery.c is the only user. Please consider
>> moving it the function from pblk.h to pblk-recovery.c
> 
> I reordered to send the helpers, but you can see that all these are made
> to support.
> 
>    lightnvm: pblk: recover open lines on 2.0 devices
> 
> Can you fix this directly and apply 1 too? I'm fine with moving it to
> pblk-recovery.c. The patch above will use it.
> 

Yes. I've fixed it up in pblk-recovery.c, and also moved the function to 
pblk-recovery.c. Applied for 4.20.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] lightnvm: pblk: collection of small fixes
  2018-08-29 18:11     ` Matias Bjørling
@ 2018-08-29 19:13       ` Javier Gonzalez
  0 siblings, 0 replies; 9+ messages in thread
From: Javier Gonzalez @ 2018-08-29 19:13 UTC (permalink / raw)
  To: Matias Bjørling; +Cc: linux-block, linux-kernel


> On 29 Aug 2018, at 20.11, Matias Bjørling <mb@lightnvm.io> wrote:
> 
> On 08/29/2018 03:27 PM, Javier Gonzalez wrote:
>>> On 29 Aug 2018, at 15.14, Matias Bjørling <mb@lightnvm.io> wrote:
>>> 
>>>> On 08/29/2018 11:01 AM, Javier González wrote:
>>>> Collection of small helper function fixes, removal of unused variables
>>>> and comment typos.
>>>> Javier González (4):
>>>>   lightnvm: pblk: calculate line pad distance in helper
>>>>   lightnvm: pblk: fix comment typo
>>>>   lightnvm: pblk: remove unused variable.
>>>>   lightnvm: pblk: guarantee emeta on line close
>>>>  drivers/lightnvm/pblk-core.c     | 13 +++++++++++--
>>>>  drivers/lightnvm/pblk-recovery.c |  2 --
>>>>  drivers/lightnvm/pblk-write.c    |  2 +-
>>>>  drivers/lightnvm/pblk.h          |  6 +++---
>>>>  4 files changed, 15 insertions(+), 8 deletions(-)
>>> 
>>> Thanks. Applied 2-4. The pad distance does not compile due to missing
>>> update to pblk_pad_distance call from pblk-recovery.c.
>>> 
>>> Also, it looks like pblk-recovery.c is the only user. Please consider
>>> moving it the function from pblk.h to pblk-recovery.c
>> I reordered to send the helpers, but you can see that all these are made
>> to support.
>>   lightnvm: pblk: recover open lines on 2.0 devices
>> Can you fix this directly and apply 1 too? I'm fine with moving it to
>> pblk-recovery.c. The patch above will use it.
> 
> Yes. I've fixed it up in pblk-recovery.c, and also moved the function to pblk-recovery.c. Applied for 4.20.

Thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-08-29 19:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  9:01 [PATCH 0/4] lightnvm: pblk: collection of small fixes Javier González
2018-08-29  9:01 ` [PATCH 1/4] lightnvm: pblk: calculate line pad distance in helper Javier González
2018-08-29  9:01 ` [PATCH 2/4] lightnvm: pblk: fix comment typo Javier González
2018-08-29  9:01 ` [PATCH 3/4] lightnvm: pblk: remove unused variable Javier González
2018-08-29  9:01 ` [PATCH 4/4] lightnvm: pblk: guarantee emeta on line close Javier González
2018-08-29 13:14 ` [PATCH 0/4] lightnvm: pblk: collection of small fixes Matias Bjørling
2018-08-29 13:27   ` Javier Gonzalez
2018-08-29 18:11     ` Matias Bjørling
2018-08-29 19:13       ` 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).