linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: raw device library to provide block alignment
       [not found] <Pine.A41.4.31.0108091157240.59224-100000@orion.it.luc.edu.suse.lists.linux.kernel>
@ 2001-08-10 20:00 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2001-08-10 20:00 UTC (permalink / raw)
  To: B. Galliart; +Cc: linux-kernel

"B. Galliart" <bgallia@orion.it.luc.edu> writes:
> 
>   Is anyone working on such a library as I described above?  Or is there
> an easier method?

The standard non raw page cache does what you want.
Basically adding such things kills all the performance benefits raw may 
have. If you want raw you should fix your application to use aligned buffers.

-Andi

^ permalink raw reply	[flat|nested] 2+ messages in thread

* raw device library to provide block alignment
@ 2001-08-09 19:38 B. Galliart
  0 siblings, 0 replies; 2+ messages in thread
From: B. Galliart @ 2001-08-09 19:38 UTC (permalink / raw)
  To: linux-kernel

  I have been using the Linux v2.2 and the non-standard rawfs module[1]
with great success for a while for running INN[2].  I would like to be
able to upgrade to Linux v2.4 and raw devices.  However, I have run into
the following limitation as stated in the raw man page:

       All I/Os must be correctly aligned in memory and on  disk:
       they  must  start at a sector offset on disk, they must be
       an exact number of sectors long, and the  data  buffer  in
       virtual  memory  must also be aligned to a multiple of the
       sector size.  The  sector  size  is  512  bytes  for  most
       devices.

  Is anyone working on an user space library to making porting programs to
Linux raw devices easier?  RAWfs did not require data alignment and INN's
current CNFS implimentation does not attempt to do data alignment.  I
wondered if there is something that would allow for a quick and dirty
port.

  Take for example the following code:

  fd = open("/dev/raw/raw1", O_RDWR);
  lseek(fd, 700, SEEK_SET);
  read(fd, buf1, 1200);
  write(fd, buf2, 1500);
  close(fd);

  I would like to be able to replace open, seek, read, write and close
with calls to rawopen, rawseek, rawread, rawwrite and rawclose where the
arguments are left the same and the drop in replacements handle data align
such that the resulting system calls would become something along the
lines of:

  lseek(fd, 512, SEEK_SET);
    // additional 188 byte offset kept in a variable
  read(fd, alternatebuf, 1536);
    // discard first 188 bytes, discard last 148 bytes and copy into buf1
  lseek(fd, 1536, SEEK_SET);
  read(fd, rewritebuffer, 512);
    // copy 148 bytes of buf2 into the end of rewritebuffer
  lseek(fd, 1536, SEEK_SET);
  write(fd, rewritebuffer, 512);
    // skip 148 bytes and copy 1024 bytes of buf2 into alternatebuf
  write(fd, alternatebuf, 1024);
  read(fd, rewritebuffer, 512);
    // copy last 328 bytes of buf2 into beginning of rewritebuffer
  lseek(fd, 3072, SEEK_SET);
  write(fd, rewritebuffer, 512);

  Is anyone working on such a library as I described above?  Or is there
an easier method?

Thanks

In-Reply-To:
[1] ftp://ftp.cistron.nl/pub/people/miquels/kernel/
[2] http://www.isc.org/products/INN/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-10 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.A41.4.31.0108091157240.59224-100000@orion.it.luc.edu.suse.lists.linux.kernel>
2001-08-10 20:00 ` raw device library to provide block alignment Andi Kleen
2001-08-09 19:38 B. Galliart

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).