Skip to content

Commit 409ae5a

Browse files
MatiasBjorlingaxboe
authored andcommitted
lightnvm: invalid offset calculation for lba_shift
The ns->lba_shift assumes its value to be the logarithmic of the LA size. A previous patch duplicated the lba_shift calculation into lightnvm. It prematurely also subtracted a 512byte shift, which commonly is applied per-command. The 512byte shift being subtracted twice led to data loss when restoring the logical to physical mapping table from device and when issuing I/O commands using rrpc. Fix offset by removing the 512byte shift subtraction when calculating lba_shift. Fixes: b0b4e09 "lightnvm: control life of nvm_dev in driver" Reported-by: Javier González <[email protected]> Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 86e4ee7 commit 409ae5a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/host/lightnvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node,
612612

613613
ret = nvm_register(dev);
614614

615-
ns->lba_shift = ilog2(dev->sec_size) - 9;
615+
ns->lba_shift = ilog2(dev->sec_size);
616616

617617
if (sysfs_create_group(&dev->dev.kobj, attrs))
618618
pr_warn("%s: failed to create sysfs group for identification\n",

0 commit comments

Comments
 (0)