rawio
[Top] [All Lists]

Re: setup question

To: ledlie@xxxxxxxxxxx (Jonathan T. Ledlie)
Subject: Re: setup question
From: Scott Lurndal <slurn@xxxxxxxxxxx>
Date: Wed, 19 Apr 2000 10:36:03 -0700 (PDT)
Cc: rawio@xxxxxxxxxxx, mattmcc@xxxxxxxxxxx (kohai)
In-reply-to: <Pine.GSO.3.96L.1000419000110.23078A-100000@xxxxxxxxxxxxxxxxxxx> from "Jonathan T. Ledlie" at Apr 19, 2000 12:11:35 AM
Sender: owner-rawio@xxxxxxxxxxx
> 
> 
> 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 <stdio.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h> 
> #include <unistd.h> 
> 
> 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 <stdio.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h> 
> #include <unistd.h> 
> 
> 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
> 
> 


<Prev in Thread] Current Thread [Next in Thread>
  • setup question, Jonathan T. Ledlie
    • Re: setup question, Scott Lurndal <=