From owner-rawio@oss.sgi.com Tue Apr 18 22:12:04 2000 Received: by oss.sgi.com id ; Tue, 18 Apr 2000 22:11:54 -0700 Received: from cheetah.cs.wisc.edu ([128.105.114.14]:44189 "EHLO cheetah.cs.wisc.edu") by oss.sgi.com with ESMTP id ; Tue, 18 Apr 2000 22:11:40 -0700 Received: from localhost (ledlie@localhost) by cheetah.cs.wisc.edu (8.9.2/8.9.2) with SMTP id AAA23084; Wed, 19 Apr 2000 00:11:35 -0500 (CDT) Date: Wed, 19 Apr 2000 00:11:35 -0500 (CDT) From: "Jonathan T. Ledlie" To: rawio@oss.sgi.com cc: kohai Subject: setup question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-rawio@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;rawio-outgoing Hi! Another Wisconsin student and I are trying to use the SGI RawIO patch to do some experiments relating to HTTP web caching, and we are not quite sure how to set it up. Here's what we've done: - applied the patch to a 2.2.13 kernel (set the CONFIG_RAW, using make xconfig) and booted with it. - added a raw device with the command: mknod raw c 8 9 where sda9 was a spare partition on my scsi disk. [root@calamata raw-prelim]# ls -la /dev/sda* brw-rw---- 1 root disk 8, 0 May 5 1998 /dev/sda brw-rw---- 1 root disk 8, 1 May 5 1998 /dev/sda1 brw-rw---- 1 root disk 8, 10 May 5 1998 /dev/sda10 brw-rw---- 1 root disk 8, 11 May 5 1998 /dev/sda11 brw-rw---- 1 root disk 8, 12 May 5 1998 /dev/sda12 brw-rw---- 1 root disk 8, 13 May 5 1998 /dev/sda13 brw-rw---- 1 root disk 8, 14 May 5 1998 /dev/sda14 brw-rw---- 1 root disk 8, 15 May 5 1998 /dev/sda15 brw-rw---- 1 root disk 8, 2 May 5 1998 /dev/sda2 brw-rw---- 1 root disk 8, 3 May 5 1998 /dev/sda3 brw-rw---- 1 root disk 8, 4 May 5 1998 /dev/sda4 brw-rw---- 1 root disk 8, 5 May 5 1998 /dev/sda5 brw-rw---- 1 root disk 8, 6 May 5 1998 /dev/sda6 brw-rw---- 1 root disk 8, 7 May 5 1998 /dev/sda7 brw-rw---- 1 root disk 8, 8 May 5 1998 /dev/sda8 brw-rw---- 1 root disk 8, 9 May 5 1998 /dev/sda9 And then I've tried to run the two follow C programs but, by the looks of the output, things aren't quite working: #include #include #include #include #include int main () { printf ("hi!"); int fd = open ("/dev/raw", O_WRONLY); if (fd < 2) { printf ("bad fd = %d\n", fd); exit (-1); } char *bufOut; bufOut = new char [512]; sprintf (bufOut, "i'm hungry."); int writeLen = write (fd, bufOut, 512); printf ("fd=%d %d %s\n", fd, writeLen, bufOut); close (fd); } *************************************** output: [root@calamata raw-prelim]# ./write hi!fd=3 -1 i'm hungry. ************************************** #include #include #include #include #include int main () { printf ("hi!"); int fd = open ("/dev/raw", O_RDONLY); if (fd < 2) { printf ("bad fd = %d\n", fd); exit (-1); } char *bufIn; bufIn = new char [512]; int readLen = read (fd, bufIn, 512); printf ("fd = %d readLen=%d %s\n", fd, readLen, bufIn); close (fd); } ****************************************** output: [root@calamata raw-prelim]# ./read hi!fd = 3 readLen=-1 ****************************************** Thanks for _any_ suggestions! -jonathan From owner-rawio@oss.sgi.com Wed Apr 19 10:38:43 2000 Received: by oss.sgi.com id ; Wed, 19 Apr 2000 10:38:33 -0700 Received: from tourguide.nanobiz.com ([208.176.9.173]:53239 "EHLO pendragon.eng.nanobiz.com") by oss.sgi.com with ESMTP id ; Wed, 19 Apr 2000 10:38:26 -0700 Received: (from slurn@localhost) by pendragon.eng.nanobiz.com (8.9.3/8.9.3) id KAA03096; Wed, 19 Apr 2000 10:36:03 -0700 From: Scott Lurndal Message-Id: <200004191736.KAA03096@pendragon.eng.nanobiz.com> Subject: Re: setup question To: ledlie@cs.wisc.edu (Jonathan T. Ledlie) Date: Wed, 19 Apr 2000 10:36:03 -0700 (PDT) Cc: rawio@oss.sgi.com, mattmcc@cs.wisc.edu (kohai) In-Reply-To: from "Jonathan T. Ledlie" at Apr 19, 2000 12:11:35 AM X-Mailer: ELM [version 2.5 PL1] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-rawio@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;rawio-outgoing > > > Hi! Another Wisconsin student and I are trying to use the SGI RawIO patch to > do some experiments relating to HTTP web caching, and we are not quite sure > how to set it up. Here's what we've done: > - applied the patch to a 2.2.13 kernel (set the CONFIG_RAW, using make > xconfig) and booted with it. > - added a raw device with the command: > mknod raw c 8 9 You really should use more descriptive names, # mknod /dev/rdsa9 c 8 9 Your problem is with buffer address alignment. Note that because you are bypassing the buffer cache in the kernel, your application _must_ issue I/O's to buffers which are aligned on sector-size boundaries in the user address space using offset (lseek) values that are congruent to zero modulo the sector size. (I typically use page size alignment on the buffers which are submitted to read and write to accommodate all types of disk devices, including those with 2k or 4k sector sizes). The I/O size should be an integral multiple of the sector size. I suggest you use mmap() to map an anonymous page (/dev/zero) to use as an I/O buffer. This buffer will be correctly aligned. scott > where sda9 was a spare partition on my scsi disk. > [root@calamata raw-prelim]# ls -la /dev/sda* > brw-rw---- 1 root disk 8, 0 May 5 1998 /dev/sda > brw-rw---- 1 root disk 8, 1 May 5 1998 /dev/sda1 > brw-rw---- 1 root disk 8, 10 May 5 1998 /dev/sda10 > brw-rw---- 1 root disk 8, 11 May 5 1998 /dev/sda11 > brw-rw---- 1 root disk 8, 12 May 5 1998 /dev/sda12 > brw-rw---- 1 root disk 8, 13 May 5 1998 /dev/sda13 > brw-rw---- 1 root disk 8, 14 May 5 1998 /dev/sda14 > brw-rw---- 1 root disk 8, 15 May 5 1998 /dev/sda15 > brw-rw---- 1 root disk 8, 2 May 5 1998 /dev/sda2 > brw-rw---- 1 root disk 8, 3 May 5 1998 /dev/sda3 > brw-rw---- 1 root disk 8, 4 May 5 1998 /dev/sda4 > brw-rw---- 1 root disk 8, 5 May 5 1998 /dev/sda5 > brw-rw---- 1 root disk 8, 6 May 5 1998 /dev/sda6 > brw-rw---- 1 root disk 8, 7 May 5 1998 /dev/sda7 > brw-rw---- 1 root disk 8, 8 May 5 1998 /dev/sda8 > brw-rw---- 1 root disk 8, 9 May 5 1998 /dev/sda9 > > And then I've tried to run the two follow C programs but, by the looks of the > output, things aren't quite working: > > #include > #include > #include > #include > #include > > int main () { > printf ("hi!"); > int fd = open ("/dev/raw", O_WRONLY); > if (fd < 2) { > printf ("bad fd = %d\n", fd); > exit (-1); > } > char *bufOut; > bufOut = new char [512]; > sprintf (bufOut, "i'm hungry."); > int writeLen = write (fd, bufOut, 512); > printf ("fd=%d %d %s\n", fd, writeLen, bufOut); > close (fd); > } > > *************************************** > output: > [root@calamata raw-prelim]# ./write > hi!fd=3 -1 i'm hungry. > > ************************************** > > > #include > #include > #include > #include > #include > > int main () { > printf ("hi!"); > int fd = open ("/dev/raw", O_RDONLY); > if (fd < 2) { > printf ("bad fd = %d\n", fd); > exit (-1); > } > char *bufIn; > bufIn = new char [512]; > int readLen = read (fd, bufIn, 512); > printf ("fd = %d readLen=%d %s\n", fd, readLen, bufIn); > close (fd); > } > > ****************************************** > output: > [root@calamata raw-prelim]# ./read > hi!fd = 3 readLen=-1 > > ****************************************** > > Thanks for _any_ suggestions! > > -jonathan > >