lightnvm: pblk: print incompatible line version correctly
authorRakesh Pandit <rakesh@tuxera.com>
Fri, 13 Oct 2017 12:45:59 +0000 (14:45 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Oct 2017 14:34:57 +0000 (08:34 -0600)
Correct it by converting 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>
Reviewed-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-core.c
drivers/lightnvm/pblk-recovery.c
drivers/lightnvm/pblk.h

index 027c42bb1ab99afa2b7708f89331c59f2882f1a0..8536d38ef97e3f8b71b52b676190ac64512a14d6 100644 (file)
@@ -978,7 +978,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);
index cb556e06673e7465bf856cab8e3329867e676382..caf1242795757b202a25b824aa824d25baa5a333 100644 (file)
@@ -900,9 +900,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);
                }
 
index 67e623bd5c2df1f69fecd084def0d793da7eab7c..9ece409993fecfd866b7070512edf1ca3aaba81e 100644 (file)
@@ -310,6 +310,7 @@ enum {
 };
 
 #define PBLK_MAGIC 0x70626c6b /*pblk*/
+#define SMETA_VERSION cpu_to_le16(1)
 
 struct line_header {
        __le32 crc;