Does samba 3.0.23c not support the use of O_DIRECT? When I try to open an smbmount'd file using O_DIRECT, I get EINVAL. I am able to use O_DIRECT with no problems on a block device and nfs mounts, so I know the kernel supports it. samba: 3.0.23c kernel: 2.6.9-42.0.3.EL (32-bit) I am using the below code for my test. smb fails on open(2). #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <stdint.h> #define SECTORSIZE 512 #define ALIGN_NUM(val, mult) (((val) + ((mult) - 1)) & ~(((mult) - 1))) #define ALIGN_PTR(ptr, mult) (void *)ALIGN_NUM((uintptr_t)(ptr), mult) #define DECL_ALIGNED_BUFFER(name, size) \ char __##name[(size) + SECTORSIZE]; \ char *name = (char *)ALIGN_PTR(__##name, SECTORSIZE) #define TEST_FILE "test.txt" int main(void) { int fd; int len = SECTORSIZE; DECL_ALIGNED_BUFFER(buf, len); unlink(TEST_FILE); errno = 0; // smb fails here fd = open(TEST_FILE, O_WRONLY|O_CREAT|O_EXCL|O_DIRECT, 0777); if(fd == -1) { perror("open"); return 1; } memset(buf, ' ', len); memcpy(buf, "hello\n", 6); if(write(fd, buf, len) == -1) { perror("write"); close(fd); return 1; } close(fd); printf("success\n"); return 0; } thanks
On Sat, Oct 14, 2006 at 09:32:05PM -0400, tupple wrote:> Does samba 3.0.23c not support the use of O_DIRECT? When I try to open an > smbmount'd file using O_DIRECT, I get EINVAL. I am able to use O_DIRECT > with no problems on a block device and nfs mounts, so I know the kernel > supports it.Are you using smbfs or cifsfs ? It isn't the Samba server side that doesn't support the O_DIRECT, this is a client side option. I would imagine cifsfs supports this. Jeremy.
>>not in the server.I am aware that we are talking about a client mount and not a samba server. Did I post to the wrong list? Is this for samba server questions? That is the second time you mentioned the server although I never mentioned it? Actually in my setup, there is no samba server. There is a win2k box and a linux box. I am trying to do directio from the linux box to the win2k box through a smb or cifs mount. My goal is to have the metadata and data flushed out of the linux machine after each write/fs_transaction. Whether the target machine on the network, in this case a win2k box, actually flushes that to disk, is not a requirement. My only requirement is that the smb or cifs mount on the linux box does not buffer anything: reads, writes, find_files, mkdirs, etc... Everything is flushed out to the target. With that in mind, does the mount.cifs "directio" option meet this requirement. Does the "directio" option behave/accomplish the same things as open(2)'s O_DIRECT or O_SYNC? Is buffer alignment required when using mount.cifs's directio? thanks, andrew Jeremy Allison wrote:> On Sat, Oct 14, 2006 at 11:20:57PM -0400, Andrew Chernow wrote: >> I tried this but got the same results, EINVAL? >> >> mount.cifs //machine/share /cifstest \ >> -o username=xxx,password=xxx,directio,rw,noperm,soft >> >> Is the samba client utils, like smbmount and mount.cifs, supposed to >> support O_DIRECT? There is mention of it in release notes, mostly samba4. >> Wondering if I need a patch or something. > > It's something that needs to be supported in the client > redirector code I think, not in the server. > > Jeremy. > >
On Sun, Oct 15, 2006 at 07:59:40AM -0400, Andrew Chernow wrote:> >>not in the server. > I am aware that we are talking about a client mount and not a samba server. > Did I post to the wrong list? Is this for samba server questions? That is > the second time you mentioned the server although I never mentioned it?Yes, this list is for Samba server questions. There is a cifs client list for client questions. Jeremy.