Add alignment hints for e512 ATA drives.

This commit is contained in:
google 2012-09-09 17:22:12 +12:00
parent aead11533e
commit dd1b8df880
7 changed files with 32 additions and 9 deletions

View file

@ -42,6 +42,8 @@ struct Disk {
vlong size; vlong size;
vlong offset; /* within larger disk, perhaps */ vlong offset; /* within larger disk, perhaps */
int width; /* of disk size in bytes as decimal string */ int width; /* of disk size in bytes as decimal string */
int psecsize;
int physalign;
int c; int c;
int h; int h;
int s; int s;

View file

@ -102,6 +102,7 @@ struct Sfis {
uint sig; uint sig;
uint lsectsz; uint lsectsz;
uint physshift; /* log2(log/phys) */ uint physshift; /* log2(log/phys) */
uint physalign; /* location of lba0 within phys0 */
uint c; /* disgusting, no? */ uint c; /* disgusting, no? */
uint h; uint h;
uint s; uint s;

View file

@ -2226,6 +2226,8 @@ iarctl(SDunit *u, char *p, int l)
p = seprint(p, e, "\n"); p = seprint(p, e, "\n");
p = seprint(p, e, "mode\t%s %s\n", modes[d->mode], modes[maxmode(c)]); 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, "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; return p - op;
} }

View file

@ -2349,6 +2349,8 @@ atarctl(SDunit* unit, char* p, int l)
if(drive->pkt == 0 && (drive->feat & Dlba) == 0) 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, " %d %d %d", drive->c, drive->h, drive->s);
p = seprint(p, e, "\n"); 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, "missirq %ud\n", drive->missirq);
p = seprint(p, e, "sloop %ud\n", drive->spurloop); p = seprint(p, e, "sloop %ud\n", drive->spurloop);

View file

@ -354,7 +354,8 @@ static void
autoxpart(Edit *edit) autoxpart(Edit *edit)
{ {
int i, totw, futz; int i, totw, futz;
vlong secs, secsize, s; vlong secs, secsize, psecsize, s, e, pa;
long stride;
char *err; char *err;
if(edit->npart > 0) { if(edit->npart > 0) {
@ -362,9 +363,12 @@ autoxpart(Edit *edit)
fprint(2, "partitions already exist; not repartitioning\n"); fprint(2, "partitions already exist; not repartitioning\n");
return; return;
} }
secs = edit->disk->secs; secs = edit->disk->secs;
secsize = edit->disk->secsize; 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(;;){ for(;;){
/* compute total weights */ /* compute total weights */
totw = 0; totw = 0;
@ -431,12 +435,16 @@ autoxpart(Edit *edit)
print("%s %llud\n", autox[i].name, autox[i].size); print("%s %llud\n", autox[i].name, autox[i].size);
s = 0; s = 0;
secs = edit->disk->secs;
for(i=0; i<nelem(autox); i++){ for(i=0; i<nelem(autox); i++){
if(autox[i].alloc == 0) if(autox[i].alloc == 0)
continue; 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); fprint(2, "addpart %s: %s\n", autox[i].name, err);
s += autox[i].size; s = e;
} }
} }

View file

@ -247,13 +247,17 @@ opensd(Disk *disk)
disk->s = strtol(f[5], 0, 0); 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) { if(nf >= 4 && strcmp(f[0], "part") == 0 && strcmp(f[1], disk->part) == 0) {
disk->offset = strtoll(f[2], 0, 0); disk->offset = strtoll(f[2], 0, 0);
disk->secs = strtoll(f[3], 0, 0) - disk->offset; disk->secs = strtoll(f[3], 0, 0) - disk->offset;
} }
} }
if (!disk->psecsize) disk->psecsize = disk->secsize;
disk->size = disk->secs * disk->secsize; disk->size = disk->secs * disk->secsize;
if(disk->size <= 0) { if(disk->size <= 0) {
strcpy(disk->part, ""); strcpy(disk->part, "");

View file

@ -307,20 +307,24 @@ idfeat(Sfis *f, ushort *id)
int int
idss(Sfis *f, ushort *id) idss(Sfis *f, ushort *id)
{ {
uint sw, i; uint sw, i, pa;
if(f->sig>>16 == 0xeb14) if(f->sig>>16 == 0xeb14)
return 0; return 0;
f->lsectsz = 512; f->lsectsz = 512;
f->physshift = 0; f->physshift = 0;
f->physalign = 0;
i = gbit16(id + 106); i = gbit16(id + 106);
if(i >> 14 != 1) if(i >> 14 != 1)
return f->lsectsz; return f->lsectsz;
if((sw = gbit32(id + 117)) >= 256) if((i & (1<<12)) && (sw = gbit32(id + 117)) >= 256)
f->lsectsz = sw * 2; f->lsectsz = sw * 2;
if(i & 1<<13) if(i & 1<<13){
f->physshift = i & 7; f->physshift = i & 7;
return f->lsectsz * (1<<f->physshift); if((pa = gbit16(id + 209)) & 0x4000)
f->physalign = pa & 0x3fff;
}
return f->lsectsz;
} }
uvlong uvlong