From c9172c5a4505eb18cb4645e2436eabcc93ec67e1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 9 Jul 2017 14:21:21 +0200 Subject: [PATCH] s3/vfs: remove SMB_VFS_STRICT_UNLOCK It's just a noop, so let's remove it. SMB_VFS_STRICT_LOCK doesn't set logs, it just checks for the presence of incompatible locks. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- examples/VFS/skel_opaque.c | 8 ---- examples/VFS/skel_transparent.c | 8 ---- source3/include/vfs.h | 8 +--- source3/include/vfs_macros.h | 5 --- source3/locking/locking.c | 4 -- source3/locking/proto.h | 2 - source3/modules/vfs_btrfs.c | 5 --- source3/modules/vfs_catia.c | 18 -------- source3/modules/vfs_default.c | 33 +++----------- source3/modules/vfs_full_audit.c | 14 ------ source3/modules/vfs_glusterfs.c | 1 - source3/modules/vfs_time_audit.c | 18 -------- source3/smbd/aio.c | 20 --------- source3/smbd/reply.c | 75 ++++++++++--------------------- source3/smbd/smb2_ioctl_filesys.c | 3 -- source3/smbd/smb2_read.c | 6 --- source3/smbd/smb2_write.c | 2 - source3/smbd/vfs.c | 8 ---- 18 files changed, 30 insertions(+), 208 deletions(-) diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index fed9d2f3ddb..072ec8036b1 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -695,13 +695,6 @@ static bool skel_strict_lock(struct vfs_handle_struct *handle, return false; } -static void skel_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock) -{ - ; -} - static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle, const char *mapped_name, enum vfs_translate_direction direction, @@ -1023,7 +1016,6 @@ struct vfs_fn_pointers skel_opaque_fns = { .brl_unlock_windows_fn = skel_brl_unlock_windows, .brl_cancel_windows_fn = skel_brl_cancel_windows, .strict_lock_fn = skel_strict_lock, - .strict_unlock_fn = skel_strict_unlock, .translate_name_fn = skel_translate_name, .fsctl_fn = skel_fsctl, .readdir_attr_fn = skel_readdir_attr, diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index d9123e091c1..9592c17414a 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -863,13 +863,6 @@ static bool skel_strict_lock(struct vfs_handle_struct *handle, return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock); } -static void skel_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock) -{ - SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock); -} - static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle, const char *mapped_name, enum vfs_translate_direction direction, @@ -1196,7 +1189,6 @@ struct vfs_fn_pointers skel_transparent_fns = { .brl_unlock_windows_fn = skel_brl_unlock_windows, .brl_cancel_windows_fn = skel_brl_cancel_windows, .strict_lock_fn = skel_strict_lock, - .strict_unlock_fn = skel_strict_unlock, .translate_name_fn = skel_translate_name, .fsctl_fn = skel_fsctl, .readdir_attr_fn = skel_readdir_attr, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 7b9a6f8f085..bd00e8f0318 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -241,6 +241,7 @@ /* Version 37 - Add SMB_VFS_OFFLOAD_READ_SEND/RECV */ /* Version 37 - Rename SMB_VFS_COPY_CHUNK_SEND/RECV to SMB_VFS_OFFLOAD_READ_SEND/RECV */ +/* Version 37 - Remove SMB_VFS_STRICT_UNLOCK */ #define SMB_VFS_INTERFACE_VERSION 37 @@ -852,10 +853,6 @@ struct vfs_fn_pointers { struct files_struct *fsp, struct lock_struct *plock); - void (*strict_unlock_fn)(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock); - NTSTATUS (*translate_name_fn)(struct vfs_handle_struct *handle, const char *name, enum vfs_translate_direction direction, @@ -1318,9 +1315,6 @@ bool smb_vfs_call_brl_cancel_windows(struct vfs_handle_struct *handle, bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle, struct files_struct *fsp, struct lock_struct *plock); -void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock); NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle, const char *name, enum vfs_translate_direction direction, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 69fa85b297b..843d62617d3 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -381,11 +381,6 @@ #define SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock) \ smb_vfs_call_strict_lock((handle)->next, (fsp), (plock)) -#define SMB_VFS_STRICT_UNLOCK(conn, fsp, plock) \ - smb_vfs_call_strict_unlock((conn)->vfs_handles, (fsp), (plock)) -#define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) \ - smb_vfs_call_strict_unlock((handle)->next, (fsp), (plock)) - #define SMB_VFS_TRANSLATE_NAME(conn, name, direction, mem_ctx, mapped_name) \ smb_vfs_call_translate_name((conn)->vfs_handles, (name), (direction), (mem_ctx), (mapped_name)) #define SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx, mapped_name) \ diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 037a9876668..d344731a726 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -164,10 +164,6 @@ bool strict_lock_default(files_struct *fsp, struct lock_struct *plock) return ret; } -void strict_unlock_default(files_struct *fsp, struct lock_struct *plock) -{ -} - /**************************************************************************** Find out if a lock could be granted - return who is blocking us if we can't. ****************************************************************************/ diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 6fb2bf2fafe..ebd80f29631 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -107,8 +107,6 @@ void init_strict_lock_struct(files_struct *fsp, struct lock_struct *plock); bool strict_lock_default(files_struct *fsp, struct lock_struct *plock); -void strict_unlock_default(files_struct *fsp, - struct lock_struct *plock); NTSTATUS query_lock(files_struct *fsp, uint64_t *psmblctx, uint64_t *pcount, diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c index 0fd4c6cb0d8..a90f583d064 100644 --- a/source3/modules/vfs_btrfs.c +++ b/source3/modules/vfs_btrfs.c @@ -322,7 +322,6 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han return tevent_req_post(req, ev); } if (!SMB_VFS_STRICT_LOCK(dest_fsp->conn, dest_fsp, &dest_lck)) { - SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &src_lck); tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT); return tevent_req_post(req, ev); } @@ -335,10 +334,6 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han cr_args.src_length = (uint64_t)num; ret = ioctl(dest_fsp->fh->fd, BTRFS_IOC_CLONE_RANGE, &cr_args); - if (do_locking) { - SMB_VFS_STRICT_UNLOCK(dest_fsp->conn, dest_fsp, &dest_lck); - SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &src_lck); - } if (ret < 0) { /* * BTRFS_IOC_CLONE_RANGE only supports 'sectorsize' aligned diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 6adf4414af6..6e623bce8aa 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -2390,23 +2390,6 @@ static bool catia_strict_lock(struct vfs_handle_struct *handle, return ok; } -static void catia_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock) -{ - struct catia_cache *cc = NULL; - int ret; - - ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc); - if (ret != 0) { - smb_panic("CATIA_FETCH_FSP_PRE_NEXT failed\n"); - } - - SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock); - - CATIA_FETCH_FSP_POST_NEXT(&cc, fsp); -} - static NTSTATUS catia_fsctl(struct vfs_handle_struct *handle, struct files_struct *fsp, TALLOC_CTX *ctx, @@ -2624,7 +2607,6 @@ static struct vfs_fn_pointers vfs_catia_fns = { .chflags_fn = catia_chflags, .streaminfo_fn = catia_streaminfo, .strict_lock_fn = catia_strict_lock, - .strict_unlock_fn = catia_strict_unlock, .translate_name_fn = catia_translate_name, .fsctl_fn = catia_fsctl, .get_dos_attributes_fn = catia_get_dos_attributes, diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 111a0c3aa71..a03fd8da7b6 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1686,9 +1686,7 @@ struct vfswrap_offload_write_state { struct tevent_context *ev; uint8_t *buf; bool read_lck_locked; - struct lock_struct read_lck; bool write_lck_locked; - struct lock_struct write_lck; DATA_BLOB *token; struct files_struct *src_fsp; off_t src_off; @@ -1827,6 +1825,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req) struct vfswrap_offload_write_state *state = tevent_req_data( req, struct vfswrap_offload_write_state); struct tevent_req *subreq = NULL; + struct lock_struct read_lck; bool ok; state->next_io_size = MIN(state->remaining, talloc_array_length(state->buf)); @@ -1836,11 +1835,11 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req) state->src_off, state->next_io_size, READ_LOCK, - &state->read_lck); + &read_lck); ok = SMB_VFS_STRICT_LOCK(state->src_fsp->conn, state->src_fsp, - &state->read_lck); + &read_lck); if (!ok) { return NT_STATUS_FILE_LOCK_CONFLICT; } @@ -1868,14 +1867,10 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq) struct vfswrap_offload_write_state *state = tevent_req_data( req, struct vfswrap_offload_write_state); struct vfs_aio_state aio_state; + struct lock_struct write_lck; ssize_t nread; bool ok; - SMB_VFS_STRICT_UNLOCK(state->src_fsp->conn, - state->src_fsp, - &state->read_lck); - ZERO_STRUCT(state->read_lck); - nread = SMB_VFS_PREAD_RECV(subreq, &aio_state); TALLOC_FREE(subreq); if (nread == -1) { @@ -1897,11 +1892,11 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq) state->dst_off, state->next_io_size, WRITE_LOCK, - &state->write_lck); + &write_lck); ok = SMB_VFS_STRICT_LOCK(state->dst_fsp->conn, state->dst_fsp, - &state->write_lck); + &write_lck); if (!ok) { tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT); return; @@ -1930,11 +1925,6 @@ static void vfswrap_offload_write_write_done(struct tevent_req *subreq) ssize_t nwritten; NTSTATUS status; - SMB_VFS_STRICT_UNLOCK(state->dst_fsp->conn, - state->dst_fsp, - &state->write_lck); - ZERO_STRUCT(state->write_lck); - nwritten = SMB_VFS_PWRITE_RECV(subreq, &aio_state); TALLOC_FREE(subreq); if (nwritten == -1) { @@ -2760,16 +2750,6 @@ static bool vfswrap_strict_lock(struct vfs_handle_struct *handle, 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, @@ -3099,7 +3079,6 @@ static struct vfs_fn_pointers vfs_default_fns = { .brl_unlock_windows_fn = vfswrap_brl_unlock_windows, .brl_cancel_windows_fn = vfswrap_brl_cancel_windows, .strict_lock_fn = vfswrap_strict_lock, - .strict_unlock_fn = vfswrap_strict_unlock, .translate_name_fn = vfswrap_translate_name, .fsctl_fn = vfswrap_fsctl, .set_dos_attributes_fn = vfswrap_set_dos_attributes, diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index bd31fadec78..af5c2c6591f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -165,7 +165,6 @@ typedef enum _vfs_op_type { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, SMB_VFS_OP_BRL_CANCEL_WINDOWS, SMB_VFS_OP_STRICT_LOCK, - SMB_VFS_OP_STRICT_UNLOCK, SMB_VFS_OP_TRANSLATE_NAME, SMB_VFS_OP_FSCTL, SMB_VFS_OP_OFFLOAD_READ_SEND, @@ -309,7 +308,6 @@ static struct { { 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_TRANSLATE_NAME, "translate_name" }, { SMB_VFS_OP_FSCTL, "fsctl" }, { SMB_VFS_OP_OFFLOAD_READ_SEND, "offload_read_send" }, @@ -1849,17 +1847,6 @@ static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle, 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_str_do_log(fsp), plock->start, - plock->size, plock->lock_type); -} - static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle, const char *name, enum vfs_translate_direction direction, @@ -2590,7 +2577,6 @@ static struct vfs_fn_pointers vfs_full_audit_fns = { .brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows, .brl_cancel_windows_fn = smb_full_audit_brl_cancel_windows, .strict_lock_fn = smb_full_audit_strict_lock, - .strict_unlock_fn = smb_full_audit_strict_unlock, .translate_name_fn = smb_full_audit_translate_name, .fsctl_fn = smb_full_audit_fsctl, .get_dos_attributes_fn = smb_full_audit_get_dos_attributes, diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 1dafe8d4089..662892bce8e 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1481,7 +1481,6 @@ static struct vfs_fn_pointers glusterfs_fns = { .brl_unlock_windows_fn = NULL, .brl_cancel_windows_fn = NULL, .strict_lock_fn = NULL, - .strict_unlock_fn = NULL, .translate_name_fn = NULL, .fsctl_fn = NULL, diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 164f56da7ac..5985394dd2c 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1730,23 +1730,6 @@ static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle, return result; } -static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock) -{ - struct timespec ts1,ts2; - double timediff; - - clock_gettime_mono(&ts1); - SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock); - clock_gettime_mono(&ts2); - timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; - - if (timediff > audit_timeout) { - smb_time_audit_log_fsp("strict_unlock", timediff, fsp); - } -} - static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle, const char *name, enum vfs_translate_direction direction, @@ -2786,7 +2769,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = { .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows, .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows, .strict_lock_fn = smb_time_audit_strict_lock, - .strict_unlock_fn = smb_time_audit_strict_unlock, .translate_name_fn = smb_time_audit_translate_name, .fsctl_fn = smb_time_audit_fsctl, .get_dos_attributes_fn = smb_time_get_dos_attributes, diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index ff1be138246..a9d6c0a5948 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -242,7 +242,6 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn, if (req == NULL) { DEBUG(0,("schedule_aio_read_and_X: aio_read failed. " "Error %s\n", strerror(errno) )); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -250,7 +249,6 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn, if (!aio_add_req_to_fsp(fsp, req)) { DEBUG(1, ("Could not add req to fsp\n")); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -289,9 +287,6 @@ static void aio_pread_smb1_done(struct tevent_req *req) return; } - /* Unlock now we're done. */ - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock); - if (nread < 0) { DEBUG( 3, ("handle_aio_read_complete: file %s nread == %d. " "Error = %s\n", fsp_str_dbg(fsp), (int)nread, @@ -491,7 +486,6 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn, if (req == NULL) { DEBUG(3,("schedule_aio_wrote_and_X: aio_write failed. " "Error %s\n", strerror(errno) )); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -499,7 +493,6 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn, if (!aio_add_req_to_fsp(fsp, req)) { DEBUG(1, ("Could not add req to fsp\n")); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -563,9 +556,6 @@ static void aio_pwrite_smb1_done(struct tevent_req *req) return; } - /* Unlock now we're done. */ - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock); - mark_file_modified(fsp); if (fsp->aio_write_behind) { @@ -735,7 +725,6 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn, if (req == NULL) { DEBUG(0, ("smb2: SMB_VFS_PREAD_SEND failed. " "Error %s\n", strerror(errno))); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -743,7 +732,6 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn, if (!aio_add_req_to_fsp(fsp, req)) { DEBUG(1, ("Could not add req to fsp\n")); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -785,9 +773,6 @@ static void aio_pread_smb2_done(struct tevent_req *req) return; } - /* Unlock now we're done. */ - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock); - /* Common error or success code processing for async or sync read returns. */ @@ -886,7 +871,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn, if (req == NULL) { DEBUG(3, ("smb2: SMB_VFS_PWRITE_SEND failed. " "Error %s\n", strerror(errno))); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -894,7 +878,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn, if (!aio_add_req_to_fsp(fsp, req)) { DEBUG(1, ("Could not add req to fsp\n")); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock); TALLOC_FREE(aio_ex); return NT_STATUS_RETRY; } @@ -951,9 +934,6 @@ static void aio_pwrite_smb2_done(struct tevent_req *req) return; } - /* Unlock now we're done. */ - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock); - mark_file_modified(fsp); status = smb2_write_complete_nosync(subreq, nwritten, err); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d102b7a876c..30015f6a8a8 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3711,8 +3711,6 @@ void reply_readbraw(struct smb_request *req) DEBUG(5,("reply_readbraw finished\n")); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - END_PROFILE(SMBreadbraw); return; } @@ -3903,7 +3901,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", if (nread < 0) { reply_nterror(req, map_nt_error_from_unix(errno)); - goto strict_unlock; + goto out; } srv_set_message((char *)req->outbuf, 5, nread+3, False); @@ -3916,9 +3914,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", DEBUG(3, ("read %s num=%d nread=%d\n", fsp_fnum_dbg(fsp), (int)numtoread, (int)nread)); -strict_unlock: - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - +out: END_PROFILE(SMBread); return; } @@ -3991,7 +3987,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, if(fsp_stat(fsp) == -1) { reply_nterror(req, map_nt_error_from_unix(errno)); - goto strict_unlock; + goto out; } if (!S_ISREG(fsp->fsp_name->st.st_ex_mode) || @@ -4053,7 +4049,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, DEBUG(3, ("send_file_readX: fake_sendfile %s max=%d nread=%d\n", fsp_fnum_dbg(fsp), (int)smb_maxcnt, (int)nread)); /* No outbuf here means successful sendfile. */ - goto strict_unlock; + goto out; } DEBUG(0,("send_file_readX: sendfile failed for file " @@ -4094,7 +4090,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, /* No outbuf here means successful sendfile. */ SMB_PERFCOUNT_SET_MSGLEN_OUT(&req->pcd, nread); SMB_PERFCOUNT_END(&req->pcd); - goto strict_unlock; + goto out; } normal_read: @@ -4144,7 +4140,7 @@ normal_read: errno = saved_errno; exit_server_cleanly("send_file_readX: fake_sendfile failed"); } - goto strict_unlock; + goto out; } nosendfile_read: @@ -4157,8 +4153,6 @@ nosendfile_read: startpos, smb_maxcnt); saved_errno = errno; - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - if (nread < 0) { reply_nterror(req, map_nt_error_from_unix(saved_errno)); return; @@ -4170,8 +4164,7 @@ nosendfile_read: fsp_fnum_dbg(fsp), (int)smb_maxcnt, (int)nread)); return; - strict_unlock: - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); +out: TALLOC_FREE(req->outbuf); return; } @@ -4513,7 +4506,7 @@ void reply_writebraw(struct smb_request *req) if (nwritten < (ssize_t)numtowrite) { reply_nterror(req, NT_STATUS_DISK_FULL); error_to_writebrawerr(req); - goto strict_unlock; + goto out; } total_written = nwritten; @@ -4523,7 +4516,7 @@ void reply_writebraw(struct smb_request *req) if (!buf) { reply_nterror(req, NT_STATUS_NO_MEMORY); error_to_writebrawerr(req); - goto strict_unlock; + goto out; } /* Return a SMBwritebraw message to the redirector to tell @@ -4586,7 +4579,7 @@ void reply_writebraw(struct smb_request *req) TALLOC_FREE(buf); reply_nterror(req, map_nt_error_from_unix(errno)); error_to_writebrawerr(req); - goto strict_unlock; + goto out; } if (nwritten < (ssize_t)numtowrite) { @@ -4608,7 +4601,7 @@ void reply_writebraw(struct smb_request *req) fsp_str_dbg(fsp), nt_errstr(status))); reply_nterror(req, status); error_to_writebrawerr(req); - goto strict_unlock; + goto out; } DEBUG(3,("reply_writebraw: secondart write %s start=%.0f num=%d " @@ -4616,10 +4609,6 @@ void reply_writebraw(struct smb_request *req) fsp_fnum_dbg(fsp), (double)startpos, (int)numtowrite, (int)total_written)); - if (!fsp->print_file) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - } - /* We won't return a status if write through is not selected - this * follows what WfWg does */ END_PROFILE(SMBwritebraw); @@ -4641,11 +4630,7 @@ void reply_writebraw(struct smb_request *req) } return; -strict_unlock: - if (!fsp->print_file) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - } - +out: END_PROFILE(SMBwritebraw); return; } @@ -4721,17 +4706,17 @@ void reply_writeunlock(struct smb_request *req) DEBUG(5,("reply_writeunlock: sync_file for %s returned %s\n", fsp_str_dbg(fsp), nt_errstr(status))); reply_nterror(req, status); - goto strict_unlock; + goto out; } if(nwritten < 0) { reply_nterror(req, map_nt_error_from_unix(saved_errno)); - goto strict_unlock; + goto out; } if((nwritten < numtowrite) && (numtowrite != 0)) { reply_nterror(req, NT_STATUS_DISK_FULL); - goto strict_unlock; + goto out; } if (numtowrite && !fsp->print_file) { @@ -4744,7 +4729,7 @@ void reply_writeunlock(struct smb_request *req) if (NT_STATUS_V(status)) { reply_nterror(req, status); - goto strict_unlock; + goto out; } } @@ -4755,11 +4740,7 @@ void reply_writeunlock(struct smb_request *req) DEBUG(3, ("writeunlock %s num=%d wrote=%d\n", fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten)); -strict_unlock: - if (numtowrite && !fsp->print_file) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - } - +out: END_PROFILE(SMBwriteunlock); return; } @@ -4840,12 +4821,12 @@ void reply_write(struct smb_request *req) nwritten = vfs_allocate_file_space(fsp, (off_t)startpos); if (nwritten < 0) { reply_nterror(req, NT_STATUS_DISK_FULL); - goto strict_unlock; + goto out; } nwritten = vfs_set_filelen(fsp, (off_t)startpos); if (nwritten < 0) { reply_nterror(req, NT_STATUS_DISK_FULL); - goto strict_unlock; + goto out; } trigger_write_time_update_immediate(fsp); } else { @@ -4857,17 +4838,17 @@ void reply_write(struct smb_request *req) DEBUG(5,("reply_write: sync_file for %s returned %s\n", fsp_str_dbg(fsp), nt_errstr(status))); reply_nterror(req, status); - goto strict_unlock; + goto out; } if(nwritten < 0) { reply_nterror(req, map_nt_error_from_unix(saved_errno)); - goto strict_unlock; + goto out; } if((nwritten == 0) && (numtowrite != 0)) { reply_nterror(req, NT_STATUS_DISK_FULL); - goto strict_unlock; + goto out; } reply_outbuf(req, 1, 0); @@ -4881,11 +4862,7 @@ void reply_write(struct smb_request *req) DEBUG(3, ("write %s num=%d wrote=%d\n", fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten)); -strict_unlock: - if (!fsp->print_file) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - } - +out: END_PROFILE(SMBwrite); return; } @@ -5120,8 +5097,6 @@ void reply_write_and_X(struct smb_request *req) nwritten = write_file(req,fsp,data,startpos,numtowrite); saved_errno = errno; - - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); } if(nwritten < 0) { @@ -5516,10 +5491,6 @@ void reply_writeclose(struct smb_request *req) nwritten = write_file(req,fsp,data,startpos,numtowrite); - if (fsp->print_file == NULL) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - } - set_close_write_time(fsp, mtime); /* diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c index 732e3ab96fc..054fd936fcc 100644 --- a/source3/smbd/smb2_ioctl_filesys.c +++ b/source3/smbd/smb2_ioctl_filesys.c @@ -503,7 +503,6 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx, status = map_nt_error_from_unix_common(errno); DEBUG(2, ("zero-data fallocate(0x%x) failed: %s\n", mode, strerror(errno))); - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck); return status; } @@ -522,12 +521,10 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx, if (ret == -1) { status = map_nt_error_from_unix_common(errno); DEBUG(0, ("fallocate failed: %s\n", strerror(errno))); - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck); return status; } } - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck); return NT_STATUS_OK; } diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index d639bbf9285..6aa62cd8204 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -324,8 +324,6 @@ normal_read: READ_LOCK, &lock); - SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lock); - *pstatus = NT_STATUS_OK; return 0; } @@ -557,7 +555,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } else { if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); tevent_req_nterror(req, status); return tevent_req_post(req, ev); } @@ -566,7 +563,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, /* Ok, read into memory. Allocate the out buffer. */ state->out_data = data_blob_talloc(state, NULL, in_length); if (in_length > 0 && tevent_req_nomem(state->out_data.data, req)) { - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); return tevent_req_post(req, ev); } @@ -577,8 +573,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, saved_errno = errno; - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - DEBUG(10,("smbd_smb2_read: file %s, %s, offset=%llu " "len=%llu returned %lld\n", fsp_str_dbg(fsp), diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c index da583c9de8e..a8ebac87370 100644 --- a/source3/smbd/smb2_write.c +++ b/source3/smbd/smb2_write.c @@ -369,8 +369,6 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx, status = smb2_write_complete(req, nwritten, errno); - SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); - DEBUG(10,("smb2: write on " "file %s, offset %.0f, requested %u, written = %u\n", fsp_str_dbg(fsp), diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 67b79ef621b..f2861e24dfa 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -2282,14 +2282,6 @@ bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle, return handle->fns->strict_lock_fn(handle, fsp, plock); } -void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle, - struct files_struct *fsp, - struct lock_struct *plock) -{ - VFS_FIND(strict_unlock); - handle->fns->strict_unlock_fn(handle, fsp, plock); -} - NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle, const char *name, enum vfs_translate_direction direction, -- 2.34.1