9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] copying fossil filesystem to a bigger disk
Date: Sat,  1 Oct 2011 12:14:27 -0400	[thread overview]
Message-ID: <27cbf24b3414cf47835e99ecbbd97e6d@brasstown.quanstro.net> (raw)
In-Reply-To: <CAEaiYYzXCfB2KbnDzBHTXytrfQqGUCepRg5Aj-c14ZoEz5hHaw@mail.gmail.c>

[-- Attachment #1: Type: text/plain, Size: 1498 bytes --]

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<<f->physshift);
+ 	return f->lsectsz /* * (1<<f->physshift) */;
  }

and then recompile your libfis and your kernel, and you
should be good-to-go.

- erik

[-- Attachment #2: ident.c --]
[-- Type: text/plain, Size: 1867 bytes --]

#include <u.h>
#include <libc.h>
#include <fis.h>

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<<f->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("");
}

  parent reply	other threads:[~2011-10-01 16:14 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-24  0:20 slash
2011-09-24  8:07 ` David du Colombier
2011-09-24  8:34   ` Steve Simon
2011-09-29 23:54   ` slash
2011-09-30  8:31     ` Richard Miller
2011-09-30  8:54       ` Richard Miller
2011-09-30  9:44         ` Charles Forsyth
2011-09-30 14:06           ` erik quanstrom
2011-09-30 14:16           ` Ethan Grammatikidis
2011-09-30 14:00         ` erik quanstrom
2011-10-01 10:36           ` slash
     [not found]           ` <CAEaiYYzXCfB2KbnDzBHTXytrfQqGUCepRg5Aj-c14ZoEz5hHaw@mail.gmail.c>
2011-10-01 13:51             ` erik quanstrom
2011-10-01 15:27               ` slash
2011-10-01 16:14             ` erik quanstrom [this message]
2011-10-01 16:23               ` erik quanstrom
2011-10-04 11:28                 ` Richard Miller
2011-10-04 11:52                   ` Charles Forsyth
2011-10-04 12:01                     ` Richard Miller
2011-10-04 12:05                       ` erik quanstrom
2011-10-04 12:09                       ` Charles Forsyth
2011-10-04 12:13                         ` Charles Forsyth
2011-10-04 12:19                           ` dexen deVries
2011-10-04 12:27                           ` Richard Miller
     [not found]                       ` <CAOw7k5i3i+w_=pUuFjUCnxH1Tp5U0vh3v7wFUoBddfML9xG+ag@mail.gmail.c>
2011-10-04 12:17                         ` erik quanstrom
2011-10-04 12:30                           ` Charles Forsyth
     [not found]                           ` <CAOw7k5hGWG16a5fTjtXBEBd2-gt=XnhjEJKFNjdPrB46_6=dBg@mail.gmail.c>
2011-10-04 12:34                             ` erik quanstrom
2011-10-04 12:05                   ` erik quanstrom
2011-10-04 12:15                     ` Richard Miller
2011-10-04 12:17                       ` erik quanstrom
2011-10-04 12:17                   ` erik quanstrom
2011-10-04 12:33                     ` Richard Miller
2011-10-04 12:52                       ` dexen deVries
2011-10-04 13:05                         ` dexen deVries
2011-10-04 14:13                       ` erik quanstrom
2011-10-04 15:56                         ` Richard Miller
2011-10-04 16:00                           ` erik quanstrom
2011-10-04 16:42                             ` Richard Miller
2011-10-04 16:45                               ` erik quanstrom
2011-10-04 17:52                                 ` Charles Forsyth
2011-10-04 18:05                                   ` dexen deVries
2011-10-04 18:24                                 ` Bakul Shah
2011-10-04 18:29                                   ` erik quanstrom
2011-10-03 23:07               ` slash
2011-10-06  7:35                 ` Peter A. Cejchan
2011-10-07 10:49                   ` slash
2011-10-07 11:15                     ` Peter A. Cejchan
2011-10-07 13:03                       ` Steve Simon
2011-10-10 10:32                         ` Peter A. Cejchan
     [not found]                   ` <CAEaiYYya5eq3CoVbbZGqPf91_kMEcbkCQ_8WEL4yakFdenek5g@mail.gmail.c>
2011-10-07 13:17                     ` erik quanstrom
2011-10-10  2:32                       ` slash
     [not found]                       ` <CAEaiYYy36ydHfw=Tg2YC9x9gEW7=MAHF2C6-UVbgr36G-qv=rA@mail.gmail.c>
2011-10-10  3:11                         ` erik quanstrom
2011-10-10 10:15                           ` slash
     [not found]                         ` <d0c02b8a1e36c9329902a1183192d732@chula.quanstro.>
     [not found]                           ` <CAEaiYYxoHLgMZddGZ4gCPvW-GuqwRYzytXgfezoi+vjUgxx9tg@mail.gmail.c>
2011-10-10 13:17                             ` erik quanstrom
2011-10-11  8:51                               ` slash
2011-10-11  8:55                                 ` slash
2011-10-11 15:01                                 ` slash
2011-10-11 15:36                                   ` David du Colombier
2011-10-12 19:24                                     ` slash
2011-10-13  7:07                   ` Peter A. Cejchan
     [not found]               ` <CAEaiYYxsUzf70Ffhd3hzsBZcMb5=2yhfSCv5-nJ+_27wYbJKig@mail.gmail.c>
2011-10-03 23:10                 ` erik quanstrom
2011-10-04  0:02                 ` erik quanstrom
2011-10-04  7:58                   ` dexen deVries
2011-10-04  9:52               ` Richard Miller
2011-10-04  9:34           ` Richard Miller
2011-10-07  7:47       ` [9fans] io patterns erik quanstrom
2011-09-24  8:30 ` [9fans] copying fossil filesystem to a bigger disk Steve Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27cbf24b3414cf47835e99ecbbd97e6d@brasstown.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).