On Fri, Apr 27, 2012 at 3:42 PM, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote: > > The obvious way to set the flag would seem to me to also btake O_DIRECT > on the pipe as meaning this ? Ok, that really does seem to be pretty natural. The attached patch implements that, and makes autofs automatically set the O_DIRECT flag. And now that it is exposed to user-space, here's a test-program that uses it: [torvalds@i5 ~]$ cat packet.c #define _GNU_SOURCE #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #define REPORT(op,fd,size) do { \ int ret = op(fd, buffer, size); \ fprintf(stderr, #op "(%d)=%d\n", size, ret); \ } while (0) #define WRITE(x) REPORT(write,fd[1],x) #define READ(x) REPORT(read,fd[0],x) int main(void) { int fd[2]; static char buffer[1024]; if (pipe2(fd, O_DIRECT)) { perror("pipe2 O_DIRECT"); exit(1); } WRITE(8); WRITE(12); WRITE(300); WRITE(5); READ(64); READ(64); WRITE(7); READ(64); READ(64); READ(64); return 0; } which results in this output: [torvalds@i5 ~]$ ./a.out write(8)=8 write(12)=12 write(300)=300 write(5)=5 read(64)=8 read(64)=12 write(7)=7 read(64)=64 read(64)=5 read(64)=7 iow, notice how all the read() calls return individual packets (and the 300-byte packet was truncated to 64 bytes). HOWEVER. I haven't actually tested the autofs part. But I suspect it "should just work". Thomas, Michael, can you test whether this patch (again: note the "+8" in autofs_v5_packet_size() purely for debug purposes, so this would be interesting to test for other people too) makes your setups work? Linus
Attachment:
patch.diff
Description: Binary data