[SCM] Samba Shared Repository - branch master updated -
83ff6979f504d50caf725ee62549604630b69be7
Jeremy Allison
jra at samba.org
Sat Nov 22 02:21:22 GMT 2008
The branch, master has been updated
via 83ff6979f504d50caf725ee62549604630b69be7 (commit)
via dcc4661d4ab55526444f742a2f9634ec14832054 (commit)
via ecd8c5d3078f4fd06586485665f956520b2314a3 (commit)
from 3d30d5945cf561c5baf2716d8f41870cecf947c0 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 83ff6979f504d50caf725ee62549604630b69be7
Author: Jeremy Allison <jra at samba.org>
Date: Fri Nov 21 18:20:38 2008 -0800
Fix the logic bug that caused us to run into kernel oplocks on an open for a stream inside a file with stream_xattr module. On opening the base_fsp we must break existing oplocks.
Jeremy.
commit dcc4661d4ab55526444f742a2f9634ec14832054
Merge: ecd8c5d3078f4fd06586485665f956520b2314a3 3d30d5945cf561c5baf2716d8f41870cecf947c0
Author: Jeremy Allison <jra at samba.org>
Date: Fri Nov 21 18:20:33 2008 -0800
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
commit ecd8c5d3078f4fd06586485665f956520b2314a3
Author: Jeremy Allison <jra at samba.org>
Date: Fri Nov 21 16:02:31 2008 -0800
Use fxattr calls whenever possible (trying to work around the strange Linux kernel oplock bug).
Jeremy.
-----------------------------------------------------------------------
Summary of changes:
source3/modules/vfs_streams_xattr.c | 116 ++++++++++++++++++++++-------------
source3/smbd/open.c | 8 ++-
2 files changed, 81 insertions(+), 43 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 9df88e5..3555654 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -64,14 +64,16 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
return result;
}
-static ssize_t get_xattr_size(connection_struct *conn, const char *fname,
- const char *xattr_name)
+static ssize_t get_xattr_size(connection_struct *conn,
+ files_struct *fsp,
+ const char *fname,
+ const char *xattr_name)
{
NTSTATUS status;
struct ea_struct ea;
ssize_t result;
- status = get_ea_value(talloc_tos(), conn, NULL, fname,
+ status = get_ea_value(talloc_tos(), conn, fsp, fname,
xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
@@ -100,7 +102,8 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
return -1;
}
- sbuf->st_size = get_xattr_size(handle->conn, io->base, io->xattr_name);
+ sbuf->st_size = get_xattr_size(handle->conn, fsp,
+ io->base, io->xattr_name);
if (sbuf->st_size == -1) {
return -1;
}
@@ -144,7 +147,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname,
goto fail;
}
- sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
+ sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
if (sbuf->st_size == -1) {
errno = ENOENT;
goto fail;
@@ -191,7 +194,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname,
goto fail;
}
- sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
+ sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
if (sbuf->st_size == -1) {
errno = ENOENT;
goto fail;
@@ -246,29 +249,29 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname,
/*
* We use baseflags to turn off nasty side-effects when opening the
* underlying file.
- */
- baseflags = flags;
- baseflags &= ~O_TRUNC;
- baseflags &= ~O_EXCL;
- baseflags &= ~O_CREAT;
-
- hostfd = SMB_VFS_OPEN(handle->conn, base, fsp, baseflags, mode);
-
- /* It is legit to open a stream on a directory, but the base
- * fd has to be read-only.
- */
- if ((hostfd == -1) && (errno == EISDIR)) {
- baseflags &= ~O_ACCMODE;
- baseflags |= O_RDONLY;
- hostfd = SMB_VFS_OPEN(handle->conn, fname, fsp, baseflags,
- mode);
- }
+ */
+ baseflags = flags;
+ baseflags &= ~O_TRUNC;
+ baseflags &= ~O_EXCL;
+ baseflags &= ~O_CREAT;
+
+ hostfd = SMB_VFS_OPEN(handle->conn, base, fsp, baseflags, mode);
- if (hostfd == -1) {
+ /* It is legit to open a stream on a directory, but the base
+ * fd has to be read-only.
+ */
+ if ((hostfd == -1) && (errno == EISDIR)) {
+ baseflags &= ~O_ACCMODE;
+ baseflags |= O_RDONLY;
+ hostfd = SMB_VFS_OPEN(handle->conn, fname, fsp, baseflags,
+ mode);
+ }
+
+ if (hostfd == -1) {
goto fail;
- }
+ }
- status = get_ea_value(talloc_tos(), handle->conn, NULL, base,
+ status = get_ea_value(talloc_tos(), handle->conn, fsp, base,
xattr_name, &ea);
DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status)));
@@ -300,22 +303,40 @@ static int streams_xattr_open(vfs_handle_struct *handle, const char *fname,
DEBUG(10, ("creating attribute %s on file %s\n",
xattr_name, base));
- if (SMB_VFS_SETXATTR(
- handle->conn, base, xattr_name,
- &null, sizeof(null),
- flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
- goto fail;
+ if (fsp->fh->fd != -1) {
+ if (SMB_VFS_FSETXATTR(
+ fsp, xattr_name,
+ &null, sizeof(null),
+ flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
+ goto fail;
+ }
+ } else {
+ if (SMB_VFS_SETXATTR(
+ handle->conn, base, xattr_name,
+ &null, sizeof(null),
+ flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
+ goto fail;
+ }
}
}
}
if (flags & O_TRUNC) {
char null = '\0';
- if (SMB_VFS_SETXATTR(
- handle->conn, base, xattr_name,
- &null, sizeof(null),
- flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
- goto fail;
+ if (fsp->fh->fd != -1) {
+ if (SMB_VFS_FSETXATTR(
+ fsp, xattr_name,
+ &null, sizeof(null),
+ flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
+ goto fail;
+ }
+ } else {
+ if (SMB_VFS_SETXATTR(
+ handle->conn, base, xattr_name,
+ &null, sizeof(null),
+ flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
+ goto fail;
+ }
}
}
@@ -579,7 +600,7 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
}
- status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
+ status = get_ea_value(talloc_tos(), handle->conn, fsp,
sio->base, sio->xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
return -1;
@@ -603,10 +624,15 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
memcpy(ea.value.data + offset, data, n);
- ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name,
+ if (fsp->fh->fd != -1) {
+ ret = SMB_VFS_FSETXATTR(fsp,
sio->xattr_name,
ea.value.data, ea.value.length, 0);
-
+ } else {
+ ret = SMB_VFS_SETXATTR(fsp->conn, sio->base,
+ sio->xattr_name,
+ ea.value.data, ea.value.length, 0);
+ }
TALLOC_FREE(ea.value.data);
if (ret == -1) {
@@ -630,7 +656,7 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
}
- status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
+ status = get_ea_value(talloc_tos(), handle->conn, fsp,
sio->base, sio->xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
return -1;
@@ -670,7 +696,7 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
}
- status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp,
+ status = get_ea_value(talloc_tos(), handle->conn, fsp,
sio->base, sio->xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
return -1;
@@ -695,9 +721,15 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
ea.value.length = offset + 1;
ea.value.data[offset] = 0;
- ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name,
+ if (fsp->fh->fd != -1) {
+ ret = SMB_VFS_FSETXATTR(fsp,
+ sio->xattr_name,
+ ea.value.data, ea.value.length, 0);
+ } else {
+ ret = SMB_VFS_SETXATTR(fsp->conn, sio->base,
sio->xattr_name,
ea.value.data, ea.value.length, 0);
+ }
TALLOC_FREE(ea.value.data);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index a6867e0..018d104 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2830,7 +2830,13 @@ NTSTATUS create_file_unixpath(connection_struct *conn,
break;
}
- status = create_file_unixpath(conn, NULL, base, 0,
+ DEBUG(10, ("Recursing into create_file_unixpath for "
+ "base %s\n", base));
+
+ /* This call will break any oplock on the base file,
+ * but will not actually open an underlying fd. */
+
+ status = create_file_unixpath(conn, req, base, 0,
FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE,
--
Samba Shared Repository
More information about the samba-cvs
mailing list