Subject: Re: Writing to disk from the network stack (bottom half of the
To: Paul Sommerhein <pms-netbsd@sommerhein.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 02/04/2003 09:38:25
On Tue, 4 Feb 2003, Paul Sommerhein wrote:
> Ok, this might not be feasible, but what I want to do is to write
> a 64kB chunk of data to the end of a disk file from within the
> network stack in the bottom half of the kernel (incoming data
> path, no process context).
What do you want to do? i.e. what's the bigger-picture goal?
> Some assumptions
>
> o Not required to work with all filesystems, but need to work
> with UFS/FFS.
> o Only one writer (bottom half of kernel) and no readers (yet).
> o The file has been opened for writing by a process which
> we have a pointer to.
> o The buffer cache should not be used (for writing).
Note, with the addition of UBC, we no longer use the buffer cache for file
data.
> o The 64kB chunk will (always) extend the file (appending).
> o The file system has a 64kB block size.
> o The maximum disk request is 64kB (is it?).
>
> The idea is to allocate a buffer structure and point its data
> buffer pointer to my 64kB data chunk. Then I initialize
> b_iodone to point to a function that will take care of the
> buffer when the write has completed. The other members
> of the buffer structure is initalized to proper values.
> The buffer is then sent to the disk driver (VOP_STRATEGY?).
>
> If I have understood things correctly, my main problem will be
> that some of the file system code might block, which I can't
> tolerate since I am in the bottom half of the kernel. More
> specifically, I have a feeling that since I need to extend the
> file, the process of allocating a physical disk block might block.
> Is this feeling right?
>
> Are there any other issues involved which may make this impossible?
>
> Any pointers highly appreciated.
Why not just create a kernel thread that reads the socket and writes the
file?
Take care,
Bill