From: Goswin v. B. <gos...@we...> - 2011-11-26 04:02:28
|
Miklos Szeredi <mi...@sz...> writes: > On Sat, Nov 19, 2011 at 11:57 PM, Goswin von Brederlow > <gos...@we...> wrote: >> Miklos Szeredi <mi...@sz...> writes: >> >>>>>> On Thu, Oct 27, 2011 at 11:03 PM, VenkataRao >>>>>> <ven...@gm...> wrote: >>>>>> > Hi, >>>>>> > >>>>>> > I'm kind of new to this fuse development and our file-system >>>>>> > implementation requires the buffer address & file offsets to all read >>>>>> > & write requests from lib-fuse to be aligned with 512 bytes. >>> >>> Following patch should fix the read buffer alignment. Â Fixing the write >>> buffer alignment properly would be more involved. >> >> For write buffers the buffer needs to be aligned to 512/4K - the size of >> the header. Unfortunately there is no posix_memalign() equivalent to >> allocate memory at an offset to alignment. But it isn't that hard >> (although a bit wastefull) to allocate a bigger buffer and ignore the >> first X bytes. >> >> Alternatively wouldn't it be possible to have 2 buffers, one for the >> header, one for payload data, and user readv() to fill them both >> atomically? > > Yes, those are possibilities. The problem is, the parsing of the > message is done on a different layer as the reading of the message. > Which means it's pretty difficult to cleanly add those alignment > constraints to the message reading part. > > But yes, it's doable. > > Thanks, > Miklos I know the code. :) I already started on a patch for this a while back but then I got concerns about the atomicity of readv(). The manpage says readv/writev are atomic with the exception noted in pipe(7), which I means this part: O_NONBLOCK disabled, n > PIPE_BUF The write is nonatomic: the data given to write(2) may be inter- leaved with write(2)s by other process; the write(2) blocks until n bytes have been written. What isn't clear is wether that only applies if a pipe is involved or on any readv/writev operation? Well, the only concern would be the behaviour of /dev/fuse for this. But if you say they will be atomic then lets try that. I will see if I can dig out the patch, update and complete it this weekend. MfG Goswin |