diff options
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/onefs.h | 8 | ||||
-rw-r--r-- | source3/modules/onefs_cbrl.c | 93 | ||||
-rw-r--r-- | source3/modules/onefs_system.c | 14 | ||||
-rw-r--r-- | source3/modules/vfs_default.c | 24 | ||||
-rw-r--r-- | source3/modules/vfs_full_audit.c | 40 | ||||
-rw-r--r-- | source3/modules/vfs_onefs.c | 4 |
6 files changed, 168 insertions, 15 deletions
diff --git a/source3/modules/onefs.h b/source3/modules/onefs.h index ebeece40ad..bb7695800e 100644 --- a/source3/modules/onefs.h +++ b/source3/modules/onefs.h @@ -106,6 +106,14 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle, struct lock_struct *plock, struct blocking_lock_record *blr); +bool onefs_strict_lock(vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock); + +void onefs_strict_unlock(vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock); + NTSTATUS onefs_notify_watch(vfs_handle_struct *vfs_handle, struct sys_notify_context *ctx, struct notify_entry *e, diff --git a/source3/modules/onefs_cbrl.c b/source3/modules/onefs_cbrl.c index 7311e1961e..a6178a9751 100644 --- a/source3/modules/onefs_cbrl.c +++ b/source3/modules/onefs_cbrl.c @@ -248,7 +248,7 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle, { int fd = br_lck->fsp->fh->fd; uint64_t id = 0; - bool exclusive = false; + enum cbrl_lock_type type; bool async = false; bool pending = false; bool pending_async = false; @@ -268,20 +268,22 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle, switch (plock->lock_type) { case WRITE_LOCK: - exclusive = true; + type = CBRL_LK_EX; break; case READ_LOCK: + type = CBRL_LK_SH; break; case PENDING_WRITE_LOCK: /* Called when a blocking lock request is added - do an * async lock. */ + type = CBRL_LK_EX; pending = true; async = true; - exclusive = true; break; case PENDING_READ_LOCK: /* Called when a blocking lock request is added - do an * async lock. */ + type = CBRL_LK_SH; pending = true; async = true; break; @@ -323,7 +325,7 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle, } DEBUG(10, ("Calling ifs_cbrl(LOCK)...")); - error = ifs_cbrl(fd, CBRL_OP_LOCK, exclusive, plock->start, + error = ifs_cbrl(fd, CBRL_OP_LOCK, type, plock->start, plock->size, async, id, plock->context.smbpid, plock->context.tid, plock->fnum); if (!error) { @@ -373,8 +375,6 @@ success: return NT_STATUS_OK; } -#define CBRL_NOTYPE true - bool onefs_brl_unlock_windows(vfs_handle_struct *handle, struct messaging_context *msg_ctx, struct byte_range_lock *br_lck, @@ -389,8 +389,8 @@ bool onefs_brl_unlock_windows(vfs_handle_struct *handle, SMB_ASSERT(plock->lock_type == UNLOCK_LOCK); DEBUG(10, ("Calling ifs_cbrl(UNLOCK)...")); - error = ifs_cbrl(fd, CBRL_OP_UNLOCK, CBRL_NOTYPE, - plock->start, plock->size, CBRL_NOTYPE, 0, plock->context.smbpid, + error = ifs_cbrl(fd, CBRL_OP_UNLOCK, CBRL_LK_SH, + plock->start, plock->size, false, 0, plock->context.smbpid, plock->context.tid, plock->fnum); END_PROFILE(syscall_brl_unlock); @@ -444,8 +444,8 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle, /* A real cancel. */ DEBUG(10, ("Calling ifs_cbrl(CANCEL)...")); - error = ifs_cbrl(fd, CBRL_OP_CANCEL, CBRL_NOTYPE, plock->start, - plock->size, CBRL_NOTYPE, bs->id, plock->context.smbpid, + error = ifs_cbrl(fd, CBRL_OP_CANCEL, CBRL_LK_UNSPEC, plock->start, + plock->size, false, bs->id, plock->context.smbpid, plock->context.tid, plock->fnum); END_PROFILE(syscall_brl_cancel); @@ -462,6 +462,79 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle, return true; } +bool onefs_strict_lock(vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock) +{ + int error; + + START_PROFILE(syscall_strict_lock); + + SMB_ASSERT(plock->lock_type == READ_LOCK || + plock->lock_type == WRITE_LOCK); + + if (!lp_locking(handle->conn->params) || + !lp_strict_locking(handle->conn->params)) { + END_PROFILE(syscall_strict_lock); + return True; + } + + if (plock->lock_flav == POSIX_LOCK) { + END_PROFILE(syscall_strict_lock); + return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock); + } + + if (plock->size == 0) { + END_PROFILE(syscall_strict_lock); + return True; + } + + error = ifs_cbrl(fsp->fh->fd, CBRL_OP_LOCK, + plock->lock_type == READ_LOCK ? CBRL_LK_RD : CBRL_LK_WR, + plock->start, plock->size, 0, 0, plock->context.smbpid, + plock->context.tid, plock->fnum); + + END_PROFILE(syscall_strict_lock); + + return (error == 0); +} + +void onefs_strict_unlock(vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock) +{ + START_PROFILE(syscall_strict_unlock); + + SMB_ASSERT(plock->lock_type == READ_LOCK || + plock->lock_type == WRITE_LOCK); + + if (!lp_locking(handle->conn->params) || + !lp_strict_locking(handle->conn->params)) { + END_PROFILE(syscall_strict_unlock); + return; + } + + if (plock->lock_flav == POSIX_LOCK) { + SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock); + END_PROFILE(syscall_strict_unlock); + return; + } + + if (plock->size == 0) { + END_PROFILE(syscall_strict_unlock); + return; + } + + if (fsp->fh) { + ifs_cbrl(fsp->fh->fd, CBRL_OP_UNLOCK, + plock->lock_type == READ_LOCK ? CBRL_LK_RD : CBRL_LK_WR, + plock->start, plock->size, 0, 0, plock->context.smbpid, + plock->context.tid, plock->fnum); + } + + END_PROFILE(syscall_strict_unlock); +} + /* TODO Optimization: Abstract out brl_get_locks() in the Windows case. * We'll malloc some memory or whatever (can't return NULL), but not actually * touch the TDB. */ diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c index b8b059bce9..46f38265b1 100644 --- a/source3/modules/onefs_system.c +++ b/source3/modules/onefs_system.c @@ -591,8 +591,8 @@ ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset, */ while (total_rbytes < count) { - DEBUG(0, ("shallow recvfile, reading %llu\n", - count - total_rbytes)); + DEBUG(0, ("shallow recvfile (%s), reading %llu\n", + strerror(errno), count - total_rbytes)); /* * Read the remaining data into the spill buffer. recvfile @@ -603,9 +603,13 @@ ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset, spill_buffer + (total_rbytes - total_wbytes), count - total_rbytes); - if (ret == -1) { - DEBUG(0, ("shallow recvfile read failed: %s\n", - strerror(errno))); + if (ret <= 0) { + if (ret == 0) { + DEBUG(0, ("shallow recvfile read: EOF\n")); + } else { + DEBUG(0, ("shallow recvfile read failed: %s\n", + strerror(errno))); + } /* Socket is dead, so treat as if it were drained. */ socket_drained = true; goto out; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 7384268dae..bb01f98588 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1157,6 +1157,26 @@ static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct *handle, return brl_lock_cancel_default(br_lck, plock); } +static bool vfswrap_strict_lock(struct vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock) +{ + SMB_ASSERT(plock->lock_type == READ_LOCK || + plock->lock_type == WRITE_LOCK); + + return strict_lock_default(fsp, plock); +} + +static void vfswrap_strict_unlock(struct vfs_handle_struct *handle, + files_struct *fsp, + struct lock_struct *plock) +{ + SMB_ASSERT(plock->lock_type == READ_LOCK || + plock->lock_type == WRITE_LOCK); + + strict_unlock_default(fsp, plock); +} + /* NT ACL operations. */ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, @@ -1592,6 +1612,10 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_brl_cancel_windows),SMB_VFS_OP_BRL_CANCEL_WINDOWS, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_strict_lock), SMB_VFS_OP_STRICT_LOCK, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK, + SMB_VFS_LAYER_OPAQUE}, /* NT ACL operations. */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 3c159f10eb..ebe89ec5fd 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -234,6 +234,12 @@ static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle, struct byte_range_lock *br_lck, struct lock_struct *plock, struct blocking_lock_record *blr); +static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle, + struct files_struct *fsp, + struct lock_struct *plock); +static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle, + struct files_struct *fsp, + struct lock_struct *plock); static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc); @@ -483,6 +489,10 @@ static vfs_op_tuple audit_op_tuples[] = { SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS, SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK, + SMB_VFS_LAYER_LOGGER}, /* NT ACL operations. */ @@ -660,6 +670,8 @@ static struct { { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" }, { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" }, { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" }, + { SMB_VFS_OP_STRICT_LOCK, "strict_lock" }, + { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" }, { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" }, { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" }, { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" }, @@ -1766,6 +1778,34 @@ static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle, return result; } +static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle, + struct files_struct *fsp, + struct lock_struct *plock) +{ + bool result; + + result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock); + + do_log(SMB_VFS_OP_STRICT_LOCK, result, handle, + "%s:%llu-%llu:%d", fsp->fsp_name, plock->start, + plock->size); + + return result; +} + +static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle, + struct files_struct *fsp, + struct lock_struct *plock) +{ + SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock); + + do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle, + "%s:%llu-%llu:%d", fsp->fsp_name, plock->start, + plock->size); + + return; +} + static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) diff --git a/source3/modules/vfs_onefs.c b/source3/modules/vfs_onefs.c index 2ec6e069c3..ad59c2b32d 100644 --- a/source3/modules/vfs_onefs.c +++ b/source3/modules/vfs_onefs.c @@ -289,6 +289,10 @@ static vfs_op_tuple onefs_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(onefs_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(onefs_strict_lock), SMB_VFS_OP_STRICT_LOCK, + SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(onefs_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK, + SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(onefs_notify_watch), SMB_VFS_OP_NOTIFY_WATCH, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(onefs_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, |