From: miod Date: Mon, 12 Jan 2015 21:31:06 +0000 (+0000) Subject: Fix two 19 years old (since day one) bug in bad144 sector reassignment logic: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ce972886967a424c0baa84d3a6b1abfb23b552f;p=openbsd Fix two 19 years old (since day one) bug in bad144 sector reassignment logic: - when entering bad144 mode, correctly compute the actual C/H/S values for the logical block number. - when leaving bad144 mode and resuming normal I/O operation, when computing back the C/H/S values for the next logical block number, compute the sector number correctly. --- diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c index b62fe3afe4d..4f52ccdc865 100644 --- a/sys/arch/sparc/dev/xd.c +++ b/sys/arch/sparc/dev/xd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xd.c,v 1.62 2014/07/11 16:35:40 jsg Exp $ */ +/* $OpenBSD: xd.c,v 1.63 2015/01/12 21:31:06 miod Exp $ */ /* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */ /* @@ -1879,7 +1879,7 @@ xdc_remove_iorq(xdcsc) iopb->headno = (iorq->blockno / iorq->xd->nhead) % iorq->xd->nhead; - iopb->sectno = iorq->blockno % XDFM_BPS; + iopb->sectno = iorq->blockno % iorq->xd->nsect; iopb->daddr = (u_long) iorq->dbuf - DVMA_BASE; XDC_HWAIT(xdcsc, rqno); xdc_start(xdcsc, 1); /* resubmit */ @@ -2003,8 +2003,8 @@ xdc_error(xdcsc, iorq, iopb, rqno, comm) /* second to last acyl */ i = iorq->xd->sectpercyl - 1 - i; /* follow bad144 * standard */ - iopb->headno = i / iorq->xd->nhead; - iopb->sectno = i % iorq->xd->nhead; + iopb->headno = i % iorq->xd->nhead; + iopb->sectno = i / iorq->xd->nhead; XDC_HWAIT(xdcsc, rqno); xdc_start(xdcsc, 1); /* resubmit */ return (XD_ERR_AOK); /* recovered! */ diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c index 30e78981975..23a91269da3 100644 --- a/sys/arch/sparc/dev/xy.c +++ b/sys/arch/sparc/dev/xy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xy.c,v 1.59 2014/07/11 16:35:40 jsg Exp $ */ +/* $OpenBSD: xy.c,v 1.60 2015/01/12 21:31:06 miod Exp $ */ /* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */ /* @@ -1750,11 +1750,11 @@ xyc_remove_iorq(xycsc) iopb->head = (iorq->blockno / iorq->xy->nhead) % iorq->xy->nhead; - iopb->sect = iorq->blockno % XYFM_BPS; + iopb->sect = iorq->blockno % iorq->xy->nsect; addr = (u_long) iorq->dbuf - DVMA_BASE; iopb->dataa = (addr & 0xffff); iopb->datar = ((addr & 0xff0000) >> 16); - /* will resubit at end */ + /* will resubmit at end */ continue; } } @@ -1871,8 +1871,8 @@ xyc_error(xycsc, iorq, iopb, comm) /* second to last acyl */ i = iorq->xy->sectpercyl - 1 - i; /* follow bad144 * standard */ - iopb->head = i / iorq->xy->nhead; - iopb->sect = i % iorq->xy->nhead; + iopb->head = i % iorq->xy->nhead; + iopb->sect = i / iorq->xy->nhead; /* will resubmit when we come out of remove_iorq */ return (XY_ERR_AOK); /* recovered! */ }