Permalink
Browse files

subtract one sector from the disk size before passing it back to the

scsi layer, which will add one sector back

fixes incorrect disk size reporting which was causing fdisk to
create a protective MBR of one too many sectors, which caused our
EFI bootloader to fail to recognize it as a GPT disk

ok dlg
  • Loading branch information...
jcs committed May 12, 2017
1 parent 4fefb21 commit dc8298f669ea2d7e18c8a8efea509eed200cb989
Showing with 5 additions and 3 deletions.
  1. +5 −3 sys/dev/ic/nvme.c
@@ -1,4 +1,4 @@
/* $OpenBSD: nvme.c,v 1.54 2017/04/08 02:57:25 deraadt Exp $ */
/* $OpenBSD: nvme.c,v 1.55 2017/05/12 22:16:54 jcs Exp $ */

/*
* Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -747,7 +747,8 @@ nvme_scsi_capacity16(struct scsi_xfer *xs)
return;
}

nsze = lemtoh64(&ns->nsze);
/* sd_read_cap_16() will add one */
nsze = lemtoh64(&ns->nsze) - 1;
f = &ns->lbaf[NVME_ID_NS_FLBAS(ns->flbas)];

memset(&rcd, 0, sizeof(rcd));
@@ -779,7 +780,8 @@ nvme_scsi_capacity(struct scsi_xfer *xs)
return;
}

nsze = lemtoh64(&ns->nsze);
/* sd_read_cap_10() will add one */
nsze = lemtoh64(&ns->nsze) - 1;
if (nsze > 0xffffffff)
nsze = 0xffffffff;

0 comments on commit dc8298f

Please sign in to comment.