Skip to content

Commit

Permalink
lightnvm: invalid offset calculation for lba_shift
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
MatiasBjorling authored and axboe committed Nov 12, 2016
1 parent 86e4ee7 commit 409ae5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/nvme/host/lightnvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node,

ret = nvm_register(dev);

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

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

0 comments on commit 409ae5a

Please sign in to comment.