lightnvm: pblk: check data lines version on recovery

As a preparation for future bumps of data line persistent storage
versions, we need to start checking the emeta line version during
recovery. Also slit up the current emeta/smeta version into two
bytes (major,minor).

Recovering lines with the same major number as the current pblk data
line version must succeed. This means that any changes in the
persistent format must be:

 (1) Backward compatible: if we switch back to and older
     kernel, recovery of lines stored with major == current_major
     and minor > current_minor must succeed.

 (2) Forward compatible: switching to a newer kernel,
     recovery of lines stored with major=current_major and
     minor < minor must handle the data format differences
     gracefully(i.e. initialize new data structures to default values).

If we detect lines that have a different major number than
the current we must abort recovery. The user must manually
migrate the data in this case.

Previously the version stored in the emeta header was copied
from smeta, which has version 1, so we need to set the minor
version to 1.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Hans Holmberg
2018-03-30 00:04:51 +02:00
committed by Jens Axboe
szülő cfe1c9e2e2
commit d0ab0b1ab9
3 fájl változott, egészen pontosan 46 új sor hozzáadva és 5 régi sor törölve

Fájl megtekintése

@@ -320,14 +320,26 @@ enum {
};
#define PBLK_MAGIC 0x70626c6b /*pblk*/
#define SMETA_VERSION cpu_to_le16(1)
/* emeta/smeta persistent storage format versions:
* Changes in major version requires offline migration.
* Changes in minor version are handled automatically during
* recovery.
*/
#define SMETA_VERSION_MAJOR (0)
#define SMETA_VERSION_MINOR (1)
#define EMETA_VERSION_MAJOR (0)
#define EMETA_VERSION_MINOR (1)
struct line_header {
__le32 crc;
__le32 identifier; /* pblk identifier */
__u8 uuid[16]; /* instance uuid */
__le16 type; /* line type */
__le16 version; /* type version */
__u8 version_major; /* version major */
__u8 version_minor; /* version minor */
__le32 id; /* line id for current line */
};