Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2012 20:14:20 +0100
From:      rank1seeker@gmail.com
To:        "Benjamin Kaduk" <kaduk@MIT.EDU>, hackers@freebsd.org
Subject:   Re: BUG: REL 9.0 - MD malloc of custom sector size
Message-ID:  <20120323.191420.168.1@DOMY-PC>
In-Reply-To: <alpine.GSO.1.10.1203202309410.27539@multics.mit.edu>
References:  <20120318.130139.003.1@DOMY-PC> <20120318134156.61d6db61@gumby.homeunix.com> <20120320.200234.909.1@DOMY-PC> <alpine.GSO.1.10.1203202309410.27539@multics.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----=0D=0AFrom: Benjamin Kaduk =
<kaduk@MIT.EDU>=0D=0ATo: rank1seeker@gmail.com=0D=0ACc: =
hackers@freebsd.org=0D=0ADate: Tue, 20 Mar 2012 23:42:44 -0400 =
(EDT)=0D=0ASubject: Re: BUG: REL 9.0 - MD malloc of custom sector =
size=0D=0A=0D=0A> On Tue, 20 Mar 2012, rank1seeker@gmail.com =
wrote:=0D=0A> =0D=0A> > ----- Original Message -----=0D=0A> > From: RW =
<rwmaillists@googlemail.com>=0D=0A> > To: =
freebsd-hackers@freebsd.org=0D=0A> > Date: Sun, 18 Mar 2012 13:41:56 =
+0000=0D=0A> > Subject: Re: BUG: REL 9.0 - MD malloc of custom sector =
size=0D=0A> >=0D=0A> >> On Sun, 18 Mar 2012 14:01:39 +0100=0D=0A> >> =
rank1seeker@gmail.com wrote:=0D=0A> >>=0D=0A> >>> man mdconfig=0D=0A> >>> =
----=0D=0A> >>> -S sectorsize to use for malloc backed device=0D=0A> >>> =
----=0D=0A> >>>=0D=0A> >>> I want to create MD device, with sector size =
of 4 Kb.=0D=0A> >>>=0D=0A> >>> It is CRITICAL to NOT append ANY suffixes, =
when specifing size, via=0D=0A> >>> '-s' flag in order to use sectors, to =
set it's size. # mdconfig -a -t=0D=0A> >>> malloc -S 4096 -s 32768=0D=0A> =
>>>=0D=0A> >>> This should created dev of 128 Mb in size.=0D=0A> >>> =
32768 sectors * 4 Kb each =3D 131072 Kb =3D 128 Mb=0D=0A> >>> Not! It =
created dev of 16 Mb in size, because sector size remained at=0D=0A> >>> =
512 bytes.=0D=0A> >>=0D=0A> >>=0D=0A> >> From mdconfig 8=0D=0A> >>=0D=0A> =
>> "Size is the number of 512 byte sectors unless ..."=0D=0A> >>=0D=0A> =
>> Looks to me like it's doing what it said it would.=0D=0A> >>=0D=0A> >> =
BTW are you sure you want to use  "-t malloc". This keeps the =
files=0D=0A> >> (even the deleted ones) in memory unconditionally  while =
ordinary=0D=0A> >> process memory is paged-out.=0D=0A> >>=0D=0A> >=0D=0A> =
> My MAIN reason to hassle with MD here, is to test a custom sector =
size.=0D=0A> > This can be done with '-S' flag only, in order to set =
sectorsize of /dev/md*=0D=0A> > But as it is malloc ONLY option/flag, I =
must combine it with '-t malloc'=0D=0A> >=0D=0A> > Then I've defined it's =
size by amount of sectors and as I've redefined =0D=0A> > size of 1 =
sector, it simply isn't doing it's task. Because it enforces =0D=0A> > =
hardcoded size of 512 bytes, so documentation should not misleadingly =
=0D=0A> > refer to sector in any way, but a hardcode value of 0.5 Kb, no =
matter of =0D=0A> > real/actual sector size is.=0D=0A> =0D=0A> It should =
not be technically challenging to cause mdconfig to have the -s =0D=0A> =
size argument in terms of -S sectorsize sized sectors; the following =
would =0D=0A> probably suffice (untested):=0D=0A> =
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=0D=0A> Index: mdconfig.c=0D=0A> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D=0A> =
--- mdconfig.c	(revision 233159)=0D=0A> +++ mdconfig.c	(working =
copy)=0D=0A> @@ -94,16 +94,19 @@=0D=0A>   int=0D=0A>   main(int argc, =
char **argv)=0D=0A>   {=0D=0A> -	int ch, fd, i, vflag;=0D=0A> +	int ch, =
fd, i, vflag, sflag;=0D=0A>   	char *p;=0D=0A>   	char *fflag =3D NULL, =
*tflag =3D NULL, *uflag =3D NULL;=0D=0A> +	unsigned bsize;=0D=0A> =0D=0A> =
  	bzero(&mdio, sizeof(mdio));=0D=0A>   	mdio.md_file =3D =
malloc(PATH_MAX);=0D=0A>   	if (mdio.md_file =3D=3D NULL)=0D=0A>   		=
err(1, "could not allocate memory");=0D=0A>   	vflag =3D 0;=0D=0A> +	=
sflag =3D 0;=0D=0A>   	bzero(mdio.md_file, PATH_MAX);=0D=0A> +	bsize =3D =
DEV_BSIZE;=0D=0A> =0D=0A>   	if (argc =3D=3D 1)=0D=0A>   		=
usage();=0D=0A> @@ -186,11 +189,12 @@=0D=0A>   			break;=0D=0A>   		case =
'S':=0D=0A>   			mdio.md_sectorsize =3D strtoul(optarg, &p, 0);=0D=0A> +		=
	bsize =3D mdio.md_sectorsize;=0D=0A>   			break;=0D=0A>   		case =
's':=0D=0A>   			mdio.md_mediasize =3D (off_t)strtoumax(optarg, &p, =
0);=0D=0A>   			if (p =3D=3D NULL || *p =3D=3D '\0')=0D=0A> -				=
mdio.md_mediasize *=3D DEV_BSIZE;=0D=0A> +				sflag =3D 1;=0D=0A>   			=
else if (*p =3D=3D 'b' || *p =3D=3D 'B')=0D=0A>   				; /* do nothing =
*/=0D=0A>   			else if (*p =3D=3D 'k' || *p =3D=3D 'K')=0D=0A> @@ -232,6 =
+236,9 @@=0D=0A>   	if (action =3D=3D UNSET)=0D=0A>   		action =3D =
ATTACH;=0D=0A> =0D=0A> +	if (sflag =3D=3D 1)=0D=0A> +		mdio.md_mediasize =
*=3D bsize;=0D=0A> +=0D=0A>   	if (action =3D=3D ATTACH) {=0D=0A>   		if =
(tflag =3D=3D NULL) {=0D=0A>   			/*=0D=0A> =
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=0D=0A> =0D=0A> Or would you prefer a =
man page change?=0D=0A=0D=0AI would prefer both.=0D=0AAbove patch to make =
it default to sector size of 512 bytes, IF not overridden with -S flag =
(then sector size is set to it)=0D=0AInstead to a hardcoded value of 512 =
bytes.=0D=0A=0D=0AAnd manpages to document that ... (just mention =
sectorsize - it's size may vary)=0D=0A=0D=0A> =0D=0A> =
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=0D=0A> Index: mdconfig.8=0D=0A> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D=0A> =
--- mdconfig.8  (revision 233159)=0D=0A> +++ mdconfig.8  (working =
copy)=0D=0A> @@ -132,7 +132,7 @@=0D=0A>   .It Fl s Ar size=0D=0A>   Size =
of the memory disk.=0D=0A>   .Ar Size=0D=0A> -is the number of 512 byte =
sectors unless suffixed with a=0D=0A> +is measured in increments of 512 =
byes unless suffixed with a=0D=0A>   .Cm b , k , m , g ,=0D=0A>   =
or=0D=0A>   .Cm t=0D=0A> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=0D=0A> =0D=0A> =
BTW I do not see where -S is a malloc-only option; please show the =
command =0D=0A> line and error message using a vnode- or swap-backed =
device.=0D=0A> =0D=0A> -Ben Kaduk=0D=0A> =0D=0A=0D=0AFrom man =
pages:=0D=0A----=0D=0A-S sectorsize   Sectorsize to use for MALLOC backed =
device.=0D=0A----=0D=0AWhen I tried:=0D=0A# mdconfig -S 4096 -nf =
/usr/IT=0D=0Ausage: mdconfig -a -t type [-n] [-o [no]option] ... [-f =
file]=0D=0A                [-s size] [-S sectorsize] [-u unit]=0D=0A      =
          [-x sectors/track] [-y =
heads/cylinder]=0D=0A...=0D=0A----=0D=0ASo it made me into thinking that =
manpages were correct.=0D=0A=0D=0AHowever, when I've tried this, it =
worked:=0D=0A------------=0D=0A# mdconfig -nf /usr/IT -S 4096=0D=0A# =
diskinfo -v md0=0D=0Amd0=0D=0A        4096            # sectorsize=0D=0A  =
      2147483648      # mediasize in bytes (2.0G)=0D=0A        524288     =
     # mediasize in sectors=0D=0A        0               # =
stripesize=0D=0A        0               # =
stripeoffset=0D=0A------------=0D=0A=0D=0A=0D=0AMan page for -S flag, =
should be updated, to note that only INT value (without SI suffixes) is =
accepted, which represents bytes.=0D=0AThis didn't work:=0D=0A-S =
4k=0D=0AActually it did! I've ended up with device of 4 byte sector size! =
:P=0D=0A=0D=0A=0D=0ADomagoj Smol=E8i=E6=0D=0A



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120323.191420.168.1>