Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1736579 > unrolled thread

[PATCH 5/6] lightnvm: pblk: print incompatible line version correctly

Started byRakesh Pandit <rakesh@tuxera.com>
First post2017-09-21 13:30 +0200
Last post2017-09-25 12:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly Rakesh Pandit <rakesh@tuxera.com> - 2017-09-21 13:30 +0200
    Re: [PATCH 5/6] lightnvm: pblk: print incompatible line version  correctly Javier González <jg@lightnvm.io> - 2017-09-22 11:10 +0200
      Re: [PATCH 5/6] lightnvm: pblk: print incompatible line version  correctly Matias Bjørling <mb@lightnvm.io> - 2017-09-25 12:20 +0200

#1736579 — [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly

FromRakesh Pandit <rakesh@tuxera.com>
Date2017-09-21 13:30 +0200
Subject[PATCH 5/6] lightnvm: pblk: print incompatible line version correctly
Message-ID<us7Q8-kv-55@gated-at.bofh.it>
Correct it by coverting little endian to cpu endian and also define a
macro for line version so that maintenance is easy.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
 drivers/lightnvm/pblk-core.c     | 2 +-
 drivers/lightnvm/pblk-recovery.c | 4 ++--
 drivers/lightnvm/pblk.h          | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 74ddb30..57583a1 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -991,7 +991,7 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line,
 	memcpy(smeta_buf->header.uuid, pblk->instance_uuid, 16);
 	smeta_buf->header.id = cpu_to_le32(line->id);
 	smeta_buf->header.type = cpu_to_le16(line->type);
-	smeta_buf->header.version = cpu_to_le16(1);
+	smeta_buf->header.version = SMETA_VERSION;
 
 	/* Start metadata */
 	smeta_buf->seq_nr = cpu_to_le64(line->seq_nr);
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index 1869eef..686bc17 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -876,9 +876,9 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
 		if (le32_to_cpu(smeta_buf->header.identifier) != PBLK_MAGIC)
 			continue;
 
-		if (le16_to_cpu(smeta_buf->header.version) != 1) {
+		if (smeta_buf->header.version != SMETA_VERSION) {
 			pr_err("pblk: found incompatible line version %u\n",
-					smeta_buf->header.version);
+					le16_to_cpu(smeta_buf->header.version));
 			return ERR_PTR(-EINVAL);
 		}
 
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index eaf5397..87b1d7f 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -318,6 +318,7 @@ enum {
 };
 
 #define PBLK_MAGIC 0x70626c6b /*pblk*/
+#define SMETA_VERSION cpu_to_le16(1)
 
 struct line_header {
 	__le32 crc;
-- 
2.5.0

[toc] | [next] | [standalone]


#1737305 — Re: [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly

FromJavier González <jg@lightnvm.io>
Date2017-09-22 11:10 +0200
SubjectRe: [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly
Message-ID<uss8a-4hz-33@gated-at.bofh.it>
In reply to#1736579

[Multipart message — attachments visible in raw view] — view raw

> On 21 Sep 2017, at 13.28, Rakesh Pandit <rakesh@tuxera.com> wrote:
> 
> Correct it by coverting little endian to cpu endian and also define a
> macro for line version so that maintenance is easy.
> 
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> drivers/lightnvm/pblk-core.c     | 2 +-
> drivers/lightnvm/pblk-recovery.c | 4 ++--
> drivers/lightnvm/pblk.h          | 1 +
> 3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index 74ddb30..57583a1 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -991,7 +991,7 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line,
> 	memcpy(smeta_buf->header.uuid, pblk->instance_uuid, 16);
> 	smeta_buf->header.id = cpu_to_le32(line->id);
> 	smeta_buf->header.type = cpu_to_le16(line->type);
> -	smeta_buf->header.version = cpu_to_le16(1);
> +	smeta_buf->header.version = SMETA_VERSION;
> 
> 	/* Start metadata */
> 	smeta_buf->seq_nr = cpu_to_le64(line->seq_nr);
> diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
> index 1869eef..686bc17 100644
> --- a/drivers/lightnvm/pblk-recovery.c
> +++ b/drivers/lightnvm/pblk-recovery.c
> @@ -876,9 +876,9 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
> 		if (le32_to_cpu(smeta_buf->header.identifier) != PBLK_MAGIC)
> 			continue;
> 
> -		if (le16_to_cpu(smeta_buf->header.version) != 1) {
> +		if (smeta_buf->header.version != SMETA_VERSION) {
> 			pr_err("pblk: found incompatible line version %u\n",
> -					smeta_buf->header.version);
> +					le16_to_cpu(smeta_buf->header.version));
> 			return ERR_PTR(-EINVAL);
> 		}
> 
> diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
> index eaf5397..87b1d7f 100644
> --- a/drivers/lightnvm/pblk.h
> +++ b/drivers/lightnvm/pblk.h
> @@ -318,6 +318,7 @@ enum {
> };
> 
> #define PBLK_MAGIC 0x70626c6b /*pblk*/
> +#define SMETA_VERSION cpu_to_le16(1)
> 
> struct line_header {
> 	__le32 crc;
> --
> 2.5.0

It's a different way of doing it, and it's fine to have a macro.

Reviewed-by: Javier González <javier@cnexlabs.com>

[toc] | [prev] | [next] | [standalone]


#1738889 — Re: [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly

FromMatias Bjørling <mb@lightnvm.io>
Date2017-09-25 12:20 +0200
SubjectRe: [PATCH 5/6] lightnvm: pblk: print incompatible line version correctly
Message-ID<utyEy-4YG-21@gated-at.bofh.it>
In reply to#1737305
On 09/22/2017 11:01 AM, Javier González wrote:
>> On 21 Sep 2017, at 13.28, Rakesh Pandit <rakesh@tuxera.com> wrote:
>>
>> Correct it by coverting little endian to cpu endian and also define a
>> macro for line version so that maintenance is easy.
>>
>> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
>> ---
>> drivers/lightnvm/pblk-core.c     | 2 +-
>> drivers/lightnvm/pblk-recovery.c | 4 ++--
>> drivers/lightnvm/pblk.h          | 1 +
>> 3 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
>> index 74ddb30..57583a1 100644
>> --- a/drivers/lightnvm/pblk-core.c
>> +++ b/drivers/lightnvm/pblk-core.c
>> @@ -991,7 +991,7 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line,
>> 	memcpy(smeta_buf->header.uuid, pblk->instance_uuid, 16);
>> 	smeta_buf->header.id = cpu_to_le32(line->id);
>> 	smeta_buf->header.type = cpu_to_le16(line->type);
>> -	smeta_buf->header.version = cpu_to_le16(1);
>> +	smeta_buf->header.version = SMETA_VERSION;
>>
>> 	/* Start metadata */
>> 	smeta_buf->seq_nr = cpu_to_le64(line->seq_nr);
>> diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
>> index 1869eef..686bc17 100644
>> --- a/drivers/lightnvm/pblk-recovery.c
>> +++ b/drivers/lightnvm/pblk-recovery.c
>> @@ -876,9 +876,9 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
>> 		if (le32_to_cpu(smeta_buf->header.identifier) != PBLK_MAGIC)
>> 			continue;
>>
>> -		if (le16_to_cpu(smeta_buf->header.version) != 1) {
>> +		if (smeta_buf->header.version != SMETA_VERSION) {
>> 			pr_err("pblk: found incompatible line version %u\n",
>> -					smeta_buf->header.version);
>> +					le16_to_cpu(smeta_buf->header.version));
>> 			return ERR_PTR(-EINVAL);
>> 		}
>>
>> diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
>> index eaf5397..87b1d7f 100644
>> --- a/drivers/lightnvm/pblk.h
>> +++ b/drivers/lightnvm/pblk.h
>> @@ -318,6 +318,7 @@ enum {
>> };
>>
>> #define PBLK_MAGIC 0x70626c6b /*pblk*/
>> +#define SMETA_VERSION cpu_to_le16(1)
>>
>> struct line_header {
>> 	__le32 crc;
>> --
>> 2.5.0
> 
> It's a different way of doing it, and it's fine to have a macro.
> 
> Reviewed-by: Javier González <javier@cnexlabs.com>
> 

Thanks, I picked it up.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web