Skip to content

Commit bf64318

Browse files
MatiasBjorlingaxboe
authored andcommitted
lightnvm: allow to force mm initialization
System block allows the device to initialize with its configured media manager. The system blocks is written to disk, and read again when media manager is determined. For this to work, the backend must store the data. Device drivers, such as null_blk, does not have any backend storage. This patch allows the media manager to be initialized without a storage backend. It also fix incorrect configuration of capabilities in null_blk, as it does not support get/set bad block interface. Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6dde1d6 commit bf64318

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

drivers/block/null_blk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
478478
id->ver_id = 0x1;
479479
id->vmnt = 0;
480480
id->cgrps = 1;
481-
id->cap = 0x3;
481+
id->cap = 0x2;
482482
id->dom = 0x1;
483483

484484
id->ppaf.blk_offset = 0;

drivers/lightnvm/core.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,13 @@ int nvm_register(struct request_queue *q, char *disk_name,
572572
}
573573
}
574574

575-
ret = nvm_get_sysblock(dev, &dev->sb);
576-
if (!ret)
577-
pr_err("nvm: device not initialized.\n");
578-
else if (ret < 0)
579-
pr_err("nvm: err (%d) on device initialization\n", ret);
575+
if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) {
576+
ret = nvm_get_sysblock(dev, &dev->sb);
577+
if (!ret)
578+
pr_err("nvm: device not initialized.\n");
579+
else if (ret < 0)
580+
pr_err("nvm: err (%d) on device initialization\n", ret);
581+
}
580582

581583
/* register device with a supported media manager */
582584
down_write(&nvm_lock);
@@ -1055,9 +1057,11 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)
10551057
strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN);
10561058
info.fs_ppa.ppa = -1;
10571059

1058-
ret = nvm_init_sysblock(dev, &info);
1059-
if (ret)
1060-
return ret;
1060+
if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) {
1061+
ret = nvm_init_sysblock(dev, &info);
1062+
if (ret)
1063+
return ret;
1064+
}
10611065

10621066
memcpy(&dev->sb, &info, sizeof(struct nvm_sb_info));
10631067

@@ -1117,7 +1121,10 @@ static long nvm_ioctl_dev_factory(struct file *file, void __user *arg)
11171121
dev->mt = NULL;
11181122
}
11191123

1120-
return nvm_dev_factory(dev, fact.flags);
1124+
if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT)
1125+
return nvm_dev_factory(dev, fact.flags);
1126+
1127+
return 0;
11211128
}
11221129

11231130
static long nvm_ctl_ioctl(struct file *file, uint cmd, unsigned long arg)

include/linux/lightnvm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ enum {
135135
/* Memory types */
136136
NVM_ID_FMTYPE_SLC = 0,
137137
NVM_ID_FMTYPE_MLC = 1,
138+
139+
/* Device capabilities */
140+
NVM_ID_DCAP_BBLKMGMT = 0x1,
141+
NVM_UD_DCAP_ECC = 0x2,
138142
};
139143

140144
struct nvm_id_lp_mlc {

0 commit comments

Comments
 (0)