From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 21 03:42:53 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 66EA21065675 for ; Wed, 21 Mar 2012 03:42:53 +0000 (UTC) (envelope-from kaduk@mit.edu) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by mx1.freebsd.org (Postfix) with ESMTP id 027288FC0C for ; Wed, 21 Mar 2012 03:42:52 +0000 (UTC) X-AuditID: 1209190f-b7f8a6d000000914-0c-4f694e36d09b Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 2A.0B.02324.63E496F4; Tue, 20 Mar 2012 23:42:46 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q2L3gkM2002081; Tue, 20 Mar 2012 23:42:46 -0400 Received: from multics.mit.edu (MULTICS.MIT.EDU [18.187.1.73]) (authenticated bits=56) (User authenticated as kaduk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q2L3giM7007756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 20 Mar 2012 23:42:45 -0400 (EDT) Received: (from kaduk@localhost) by multics.mit.edu (8.12.9.20060308) id q2L3giUY026308; Tue, 20 Mar 2012 23:42:44 -0400 (EDT) Date: Tue, 20 Mar 2012 23:42:44 -0400 (EDT) From: Benjamin Kaduk To: rank1seeker@gmail.com In-Reply-To: <20120320.200234.909.1@DOMY-PC> Message-ID: References: <20120318.130139.003.1@DOMY-PC> <20120318134156.61d6db61@gumby.homeunix.com> <20120320.200234.909.1@DOMY-PC> User-Agent: Alpine 1.10 (GSO 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsUixCmqrWvml+lv8HO2qMWGBYUWLT+usTsw ecz4NJ/FY+esu+wBTFFcNimpOZllqUX6dglcGW19C9kKLspV9JxaytjAeEi8i5GTQ0LAROLc /FPMELaYxIV769m6GLk4hAT2MUr8+f2DFcLZwCjxZt5VZgjnAJPE5EWbWCCcBkaJC5tPsIH0 swhoS8zpW8gEYrMJqEjMfLMRLC4iICkx5f5KsB3MAuISC+/1AjVzcAgLWEtMumwDEuYU0JE4 23yNHcTmFXCUeN93EKxcSKBC4sLzF2BxUaCa1funsEDUCEqcnPmEBWKkpcS/tb9YJzAKzkKS moUktYCRaRWjbEpulW5uYmZOcWqybnFyYl5eapGuiV5uZoleakrpJkZwoEry72D8dlDpEKMA B6MSD6/28gx/IdbEsuLK3EOMkhxMSqK85j6Z/kJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeLNW AZXzpiRWVqUW5cOkpDlYlMR51bTe+QkJpCeWpGanphakFsFkZTg4lCR41X2BhgoWpaanVqRl 5pQgpJk4OEGG8wANnwpSw1tckJhbnJkOkT/FqCglztsIkhAASWSU5sH1whLJK0ZxoFeEeSNB qniASQiu+xXQYCagwXE300AGlyQipKQaGOczxejteq806bzIY65/svueL31nvmv2Klf+LX/Z 0+WV/0zq+KswOZqB71f5jaNa5sff5Agwuk/6lu3Rvta96W1caOMR802FDYsF3xxY7W/c//0W T/mL6k+GHpGzpb5Ee+4y7tXVOdPw6kn1/0PPnPyaDhgwb77RHCTz//vpzt433XeDWFU505RY ijMSDbWYi4oTAUi6ZPP/AgAA Cc: hackers@freebsd.org Subject: Re: BUG: REL 9.0 - MD malloc of custom sector size X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Mar 2012 03:42:53 -0000 On Tue, 20 Mar 2012, rank1seeker@gmail.com wrote: > ----- Original Message ----- > From: RW > To: freebsd-hackers@freebsd.org > Date: Sun, 18 Mar 2012 13:41:56 +0000 > Subject: Re: BUG: REL 9.0 - MD malloc of custom sector size > >> On Sun, 18 Mar 2012 14:01:39 +0100 >> rank1seeker@gmail.com wrote: >> >>> man mdconfig >>> ---- >>> -S sectorsize to use for malloc backed device >>> ---- >>> >>> I want to create MD device, with sector size of 4 Kb. >>> >>> It is CRITICAL to NOT append ANY suffixes, when specifing size, via >>> '-s' flag in order to use sectors, to set it's size. # mdconfig -a -t >>> malloc -S 4096 -s 32768 >>> >>> This should created dev of 128 Mb in size. >>> 32768 sectors * 4 Kb each = 131072 Kb = 128 Mb >>> Not! It created dev of 16 Mb in size, because sector size remained at >>> 512 bytes. >> >> >> From mdconfig 8 >> >> "Size is the number of 512 byte sectors unless ..." >> >> Looks to me like it's doing what it said it would. >> >> BTW are you sure you want to use "-t malloc". This keeps the files >> (even the deleted ones) in memory unconditionally while ordinary >> process memory is paged-out. >> > > My MAIN reason to hassle with MD here, is to test a custom sector size. > This can be done with '-S' flag only, in order to set sectorsize of /dev/md* > But as it is malloc ONLY option/flag, I must combine it with '-t malloc' > > Then I've defined it's size by amount of sectors and as I've redefined > size of 1 sector, it simply isn't doing it's task. Because it enforces > hardcoded size of 512 bytes, so documentation should not misleadingly > refer to sector in any way, but a hardcode value of 0.5 Kb, no matter of > real/actual sector size is. It should not be technically challenging to cause mdconfig to have the -s size argument in terms of -S sectorsize sized sectors; the following would probably suffice (untested): %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Index: mdconfig.c =================================================================== --- mdconfig.c (revision 233159) +++ mdconfig.c (working copy) @@ -94,16 +94,19 @@ int main(int argc, char **argv) { - int ch, fd, i, vflag; + int ch, fd, i, vflag, sflag; char *p; char *fflag = NULL, *tflag = NULL, *uflag = NULL; + unsigned bsize; bzero(&mdio, sizeof(mdio)); mdio.md_file = malloc(PATH_MAX); if (mdio.md_file == NULL) err(1, "could not allocate memory"); vflag = 0; + sflag = 0; bzero(mdio.md_file, PATH_MAX); + bsize = DEV_BSIZE; if (argc == 1) usage(); @@ -186,11 +189,12 @@ break; case 'S': mdio.md_sectorsize = strtoul(optarg, &p, 0); + bsize = mdio.md_sectorsize; break; case 's': mdio.md_mediasize = (off_t)strtoumax(optarg, &p, 0); if (p == NULL || *p == '\0') - mdio.md_mediasize *= DEV_BSIZE; + sflag = 1; else if (*p == 'b' || *p == 'B') ; /* do nothing */ else if (*p == 'k' || *p == 'K') @@ -232,6 +236,9 @@ if (action == UNSET) action = ATTACH; + if (sflag == 1) + mdio.md_mediasize *= bsize; + if (action == ATTACH) { if (tflag == NULL) { /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Or would you prefer a man page change? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Index: mdconfig.8 =================================================================== --- mdconfig.8 (revision 233159) +++ mdconfig.8 (working copy) @@ -132,7 +132,7 @@ .It Fl s Ar size Size of the memory disk. .Ar Size -is the number of 512 byte sectors unless suffixed with a +is measured in increments of 512 byes unless suffixed with a .Cm b , k , m , g , or .Cm t %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BTW I do not see where -S is a malloc-only option; please show the command line and error message using a vnode- or swap-backed device. -Ben Kaduk