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

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba

Reply via email to