From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sat, 1 Oct 2011 12:14:27 -0400 To: 9fans@9fans.net Message-ID: <27cbf24b3414cf47835e99ecbbd97e6d@brasstown.quanstro.net> In-Reply-To: References: <1dc3dbdc0c9e0ecbc86047c58e0a2d33@hamnavoe.com> <6c0a6fdef3589e5cb13618f19d9ac9fc@chula.quanstro.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-wnzixsmwvkqftxirxrcsfpwsvp" Subject: Re: [9fans] copying fossil filesystem to a bigger disk Topicbox-Message-UUID: 2e2c6268-ead7-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-wnzixsmwvkqftxirxrcsfpwsvp Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit since i don't have one of these drives, i wrote a little program to dig into the ident block. a small aside. ata disks have two sector sizes. (groan.) there's the logical sector size and the physical sector size. by default they are both 512. the ears drive sets the set logical sector size to 512 and the physical sector size to 4096 by reporting that there are 8 logicals/physical. here's the output of this program 3,907,029,168 4096-byte sectors serial: WD-WCAD-WCAZA995782551.0AB51WDC WD20EARS-00MVWB0 firmware: 51.0AB51WDC WD20EARS-00MVWB0 model: WDC WD20EARS-00MVWB0 pflag: llba smart nop atapi16 sct note that there are not 3e9 4k sectors there are 3e9/8 4k sectors; fis has got that wrong. i've never had an 4k sector drive to test with. the way to interpret this information is you may use 512 byte sectors if you really want to suffer terrible performance (usually 1/3 the normal performance for reasonablly random workloads.) let me think a bit about the correct solutions to this. it's clear to me that we just can't assume 512-byte sectors any more. in the mean time, you can change this ; diff -c /sys/src/libfis/fis.c /tmp/fis.c /sys/src/libfis/fis.c:320,326 - /tmp/fis.c:320,326 f->lsectsz = sw * 2; if(i & 1<<13) f->physshift = i & 7; - return f->lsectsz * (1<physshift); + return f->lsectsz /* * (1<physshift) */; } and then recompile your libfis and your kernel, and you should be good-to-go. - erik --upas-wnzixsmwvkqftxirxrcsfpwsvp Content-Disposition: attachment; filename=ident.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include #include typedef struct Sfisx Sfisx; struct Sfisx { uvlong sectors; uint secsize; char serial[20]; char firmware[8]; char model[8]; uvlong wwn; Sfis; }; int idss0(Sfis *f, ushort *id) { uint sw, i; if(f->sig>>16 == 0xeb14) return 0; f->lsectsz = 512; f->physshift = 0; i = id16(id, 106); print("word 106 %.4ux [valid=%d]\n", i, i>>14 == 1); print(" multiple log/phys? %d\n", (i& 1<<13) != 0); if((i& 1<<13) != 0) print(" log/phys %d\n", 1<<(i&7)); sw = id32(id, 117); print(" logical sector size %d [valid=%d]\n", sw*2, (i & 1<<12) != 0); return 0; /* if(i >> 14 != 1) return f->lsectsz; if((sw = id32(id, 117)) >= 256) f->lsectsz = sw * 2; if(i & 1<<13) f->physshift = i & 7; return f->lsectsz * (1<physshift); */ } void main(void) { char buf[1024], buf2[128], *s2; ushort *id; int n, i, l; Sfisx *f; s2 = "az> "; l = strlen(s2); n = read(0, buf, sizeof buf); if(n < 512) sysfatal("bad ident: %r"); /* fix my mistake in asking for buffer */ for(i = 0; i <= n-l; i++) if(memcmp(buf+i, s2, l) == 0){ memcpy(buf+i, buf+i+l, n-(i+l)); n -= l; } if(n != 512) sysfatal("bad ident: %d bytes\n", n); // write(1, buf, 512); f = malloc(sizeof *f); if(f == nil) sysfatal("malloc"); memset(f, 0, sizeof *f); id = (ushort*)buf; f->sectors = idfeat(f, id); f->secsize = idss(f, id); f->wwn = idwwn(f, id); idmove(f->serial, id+10, 20); idmove(f->firmware, id+23, 8); idmove(f->model, id+27, 40); print("%,lld %d-byte sectors\n", f->sectors, f->secsize); print("serial: %s\n", f->serial); print("firmware: %s\n", f->firmware); print("model: %s\n", f->model); pflag(buf2, buf2+sizeof buf2, f); print("pflag: %s\n", buf2); idss0(f, id); exits(""); } --upas-wnzixsmwvkqftxirxrcsfpwsvp--