Add alignment hints for e512 ATA drives.
This commit is contained in:
parent
aead11533e
commit
dd1b8df880
7 changed files with 32 additions and 9 deletions
|
@ -42,6 +42,8 @@ struct Disk {
|
|||
vlong size;
|
||||
vlong offset; /* within larger disk, perhaps */
|
||||
int width; /* of disk size in bytes as decimal string */
|
||||
int psecsize;
|
||||
int physalign;
|
||||
int c;
|
||||
int h;
|
||||
int s;
|
||||
|
|
|
@ -102,6 +102,7 @@ struct Sfis {
|
|||
uint sig;
|
||||
uint lsectsz;
|
||||
uint physshift; /* log2(log/phys) */
|
||||
uint physalign; /* location of lba0 within phys0 */
|
||||
uint c; /* disgusting, no? */
|
||||
uint h;
|
||||
uint s;
|
||||
|
|
|
@ -2226,6 +2226,8 @@ iarctl(SDunit *u, char *p, int l)
|
|||
p = seprint(p, e, "\n");
|
||||
p = seprint(p, e, "mode\t%s %s\n", modes[d->mode], modes[maxmode(c)]);
|
||||
p = seprint(p, e, "geometry %llud %lud\n", d->sectors, u->secsize);
|
||||
p = seprint(p, e, "alignment %d %d\n",
|
||||
d->secsize<<d->portm.physshift, d->portm.physalign);
|
||||
return p - op;
|
||||
}
|
||||
|
||||
|
|
|
@ -2349,6 +2349,8 @@ atarctl(SDunit* unit, char* p, int l)
|
|||
if(drive->pkt == 0 && (drive->feat & Dlba) == 0)
|
||||
p = seprint(p, e, " %d %d %d", drive->c, drive->h, drive->s);
|
||||
p = seprint(p, e, "\n");
|
||||
p = seprint(p, e, "alignment %d %d\n",
|
||||
drive->secsize<<drive->physshift, drive->physalign);
|
||||
}
|
||||
p = seprint(p, e, "missirq %ud\n", drive->missirq);
|
||||
p = seprint(p, e, "sloop %ud\n", drive->spurloop);
|
||||
|
|
|
@ -354,7 +354,8 @@ static void
|
|||
autoxpart(Edit *edit)
|
||||
{
|
||||
int i, totw, futz;
|
||||
vlong secs, secsize, s;
|
||||
vlong secs, secsize, psecsize, s, e, pa;
|
||||
long stride;
|
||||
char *err;
|
||||
|
||||
if(edit->npart > 0) {
|
||||
|
@ -362,9 +363,12 @@ autoxpart(Edit *edit)
|
|||
fprint(2, "partitions already exist; not repartitioning\n");
|
||||
return;
|
||||
}
|
||||
|
||||
secs = edit->disk->secs;
|
||||
secsize = edit->disk->secsize;
|
||||
psecsize = edit->disk->psecsize;
|
||||
stride = psecsize / secsize;
|
||||
pa = (edit->disk->offset - edit->disk->physalign + stride) % stride;
|
||||
secs -= (secs + pa) % stride;
|
||||
for(;;){
|
||||
/* compute total weights */
|
||||
totw = 0;
|
||||
|
@ -431,12 +435,16 @@ autoxpart(Edit *edit)
|
|||
print("%s %llud\n", autox[i].name, autox[i].size);
|
||||
|
||||
s = 0;
|
||||
secs = edit->disk->secs;
|
||||
for(i=0; i<nelem(autox); i++){
|
||||
if(autox[i].alloc == 0)
|
||||
continue;
|
||||
if(err = addpart(edit, mkpart(autox[i].name, s, s+autox[i].size, 1)))
|
||||
e = (s + autox[i].size);
|
||||
if((e + pa) % stride) e += stride - (e + pa) % stride;
|
||||
if(e>secs) e = secs - stride + (secs + pa) % stride;
|
||||
if(err = addpart(edit, mkpart(autox[i].name, s, e, 1)))
|
||||
fprint(2, "addpart %s: %s\n", autox[i].name, err);
|
||||
s += autox[i].size;
|
||||
s = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -247,13 +247,17 @@ opensd(Disk *disk)
|
|||
disk->s = strtol(f[5], 0, 0);
|
||||
}
|
||||
}
|
||||
if(nf >= 3 && strcmp(f[0], "alignment") == 0) {
|
||||
disk->psecsize = strtol(f[1], 0, 0);
|
||||
disk->physalign = strtol(f[2], 0, 0);
|
||||
}
|
||||
if(nf >= 4 && strcmp(f[0], "part") == 0 && strcmp(f[1], disk->part) == 0) {
|
||||
disk->offset = strtoll(f[2], 0, 0);
|
||||
disk->secs = strtoll(f[3], 0, 0) - disk->offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!disk->psecsize) disk->psecsize = disk->secsize;
|
||||
disk->size = disk->secs * disk->secsize;
|
||||
if(disk->size <= 0) {
|
||||
strcpy(disk->part, "");
|
||||
|
|
|
@ -307,20 +307,24 @@ idfeat(Sfis *f, ushort *id)
|
|||
int
|
||||
idss(Sfis *f, ushort *id)
|
||||
{
|
||||
uint sw, i;
|
||||
uint sw, i, pa;
|
||||
|
||||
if(f->sig>>16 == 0xeb14)
|
||||
return 0;
|
||||
f->lsectsz = 512;
|
||||
f->physshift = 0;
|
||||
f->physalign = 0;
|
||||
i = gbit16(id + 106);
|
||||
if(i >> 14 != 1)
|
||||
return f->lsectsz;
|
||||
if((sw = gbit32(id + 117)) >= 256)
|
||||
if((i & (1<<12)) && (sw = gbit32(id + 117)) >= 256)
|
||||
f->lsectsz = sw * 2;
|
||||
if(i & 1<<13)
|
||||
if(i & 1<<13){
|
||||
f->physshift = i & 7;
|
||||
return f->lsectsz * (1<<f->physshift);
|
||||
if((pa = gbit16(id + 209)) & 0x4000)
|
||||
f->physalign = pa & 0x3fff;
|
||||
}
|
||||
return f->lsectsz;
|
||||
}
|
||||
|
||||
uvlong
|
||||
|
|
Loading…
Reference in a new issue