1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3/vfs: rename SMB_VFS_STRICT_LOCK to SMB_VFS_STRICT_LOCK_CHECK

As per MS-SMB2 and MS-FSA and our SMB_VFS_STRICT_LOCK implementation,
we're merely testing for locks, not setting any.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul 11 03:37:44 CEST 2017 on sn-devel-144
This commit is contained in:
Ralph Boehme 2017-07-09 14:34:10 +02:00 committed by Jeremy Allison
parent c9172c5a45
commit 67466271c2
18 changed files with 73 additions and 71 deletions

View File

@ -687,9 +687,9 @@ static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
return false;
}
static bool skel_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
errno = ENOSYS;
return false;
@ -1015,7 +1015,7 @@ struct vfs_fn_pointers skel_opaque_fns = {
.brl_lock_windows_fn = skel_brl_lock_windows,
.brl_unlock_windows_fn = skel_brl_unlock_windows,
.brl_cancel_windows_fn = skel_brl_cancel_windows,
.strict_lock_fn = skel_strict_lock,
.strict_lock_check_fn = skel_strict_lock_check,
.translate_name_fn = skel_translate_name,
.fsctl_fn = skel_fsctl,
.readdir_attr_fn = skel_readdir_attr,

View File

@ -856,11 +856,11 @@ static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
}
static bool skel_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
}
static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
@ -1188,7 +1188,7 @@ struct vfs_fn_pointers skel_transparent_fns = {
.brl_lock_windows_fn = skel_brl_lock_windows,
.brl_unlock_windows_fn = skel_brl_unlock_windows,
.brl_cancel_windows_fn = skel_brl_cancel_windows,
.strict_lock_fn = skel_strict_lock,
.strict_lock_check_fn = skel_strict_lock_check,
.translate_name_fn = skel_translate_name,
.fsctl_fn = skel_fsctl,
.readdir_attr_fn = skel_readdir_attr,

View File

@ -242,6 +242,8 @@
/* Version 37 - Rename SMB_VFS_COPY_CHUNK_SEND/RECV to
SMB_VFS_OFFLOAD_READ_SEND/RECV */
/* Version 37 - Remove SMB_VFS_STRICT_UNLOCK */
/* Version 37 - Rename SMB_VFS_STRICT_LOCK to
SMB_VFS_STRICT_LOCK_CHECK */
#define SMB_VFS_INTERFACE_VERSION 37
@ -849,9 +851,9 @@ struct vfs_fn_pointers {
struct byte_range_lock *br_lck,
struct lock_struct *plock);
bool (*strict_lock_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock);
bool (*strict_lock_check_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,
@ -1312,9 +1314,9 @@ bool smb_vfs_call_brl_unlock_windows(struct vfs_handle_struct *handle,
bool smb_vfs_call_brl_cancel_windows(struct vfs_handle_struct *handle,
struct byte_range_lock *br_lck,
struct lock_struct *plock);
bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock);
bool smb_vfs_call_strict_lock_check(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,

View File

@ -376,10 +376,10 @@
#define SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock) \
smb_vfs_call_brl_cancel_windows((handle)->next, (br_lck), (plock))
#define SMB_VFS_STRICT_LOCK(conn, fsp, plock) \
smb_vfs_call_strict_lock((conn)->vfs_handles, (fsp), (plock))
#define SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock) \
smb_vfs_call_strict_lock((handle)->next, (fsp), (plock))
#define SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, plock) \
smb_vfs_call_strict_lock_check((conn)->vfs_handles, (fsp), (plock))
#define SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock) \
smb_vfs_call_strict_lock_check((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))

View File

@ -104,7 +104,7 @@ void init_strict_lock_struct(files_struct *fsp,
plock->lock_flav = lp_posix_cifsu_locktype(fsp);
}
bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)
{
struct byte_range_lock *br_lck;
int strict_locking = lp_strict_locking(fsp->conn->params);

View File

@ -105,8 +105,8 @@ void init_strict_lock_struct(files_struct *fsp,
br_off size,
enum brl_type lock_type,
struct lock_struct *plock);
bool strict_lock_default(files_struct *fsp,
struct lock_struct *plock);
bool strict_lock_check_default(files_struct *fsp,
struct lock_struct *plock);
NTSTATUS query_lock(files_struct *fsp,
uint64_t *psmblctx,
uint64_t *pcount,

View File

@ -317,11 +317,11 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
WRITE_LOCK,
&dest_lck);
if (!SMB_VFS_STRICT_LOCK(src_fsp->conn, src_fsp, &src_lck)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(src_fsp->conn, src_fsp, &src_lck)) {
tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
return tevent_req_post(req, ev);
}
if (!SMB_VFS_STRICT_LOCK(dest_fsp->conn, dest_fsp, &dest_lck)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(dest_fsp->conn, dest_fsp, &dest_lck)) {
tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
return tevent_req_post(req, ev);
}

View File

@ -2370,9 +2370,9 @@ static bool catia_getlock(vfs_handle_struct *handle,
return ok;
}
static bool catia_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
static bool catia_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
struct catia_cache *cc = NULL;
int ret;
@ -2383,7 +2383,7 @@ static bool catia_strict_lock(struct vfs_handle_struct *handle,
return -1;
}
ok = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
ok = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
@ -2606,7 +2606,7 @@ static struct vfs_fn_pointers vfs_catia_fns = {
.realpath_fn = catia_realpath,
.chflags_fn = catia_chflags,
.streaminfo_fn = catia_streaminfo,
.strict_lock_fn = catia_strict_lock,
.strict_lock_check_fn = catia_strict_lock_check,
.translate_name_fn = catia_translate_name,
.fsctl_fn = catia_fsctl,
.get_dos_attributes_fn = catia_get_dos_attributes,

View File

@ -1837,7 +1837,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req)
READ_LOCK,
&read_lck);
ok = SMB_VFS_STRICT_LOCK(state->src_fsp->conn,
ok = SMB_VFS_STRICT_LOCK_CHECK(state->src_fsp->conn,
state->src_fsp,
&read_lck);
if (!ok) {
@ -1894,7 +1894,7 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq)
WRITE_LOCK,
&write_lck);
ok = SMB_VFS_STRICT_LOCK(state->dst_fsp->conn,
ok = SMB_VFS_STRICT_LOCK_CHECK(state->dst_fsp->conn,
state->dst_fsp,
&write_lck);
if (!ok) {
@ -2740,14 +2740,14 @@ 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)
static bool vfswrap_strict_lock_check(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);
return strict_lock_check_default(fsp, plock);
}
/* NT ACL operations. */
@ -3078,7 +3078,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
.brl_lock_windows_fn = vfswrap_brl_lock_windows,
.brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
.brl_cancel_windows_fn = vfswrap_brl_cancel_windows,
.strict_lock_fn = vfswrap_strict_lock,
.strict_lock_check_fn = vfswrap_strict_lock_check,
.translate_name_fn = vfswrap_translate_name,
.fsctl_fn = vfswrap_fsctl,
.set_dos_attributes_fn = vfswrap_set_dos_attributes,

View File

@ -164,7 +164,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_BRL_LOCK_WINDOWS,
SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
SMB_VFS_OP_BRL_CANCEL_WINDOWS,
SMB_VFS_OP_STRICT_LOCK,
SMB_VFS_OP_STRICT_LOCK_CHECK,
SMB_VFS_OP_TRANSLATE_NAME,
SMB_VFS_OP_FSCTL,
SMB_VFS_OP_OFFLOAD_READ_SEND,
@ -307,7 +307,7 @@ 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_LOCK_CHECK, "strict_lock_check" },
{ SMB_VFS_OP_TRANSLATE_NAME, "translate_name" },
{ SMB_VFS_OP_FSCTL, "fsctl" },
{ SMB_VFS_OP_OFFLOAD_READ_SEND, "offload_read_send" },
@ -1832,15 +1832,15 @@ 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)
static bool smb_full_audit_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
bool result;
result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
do_log(SMB_VFS_OP_STRICT_LOCK_CHECK, result, handle,
"%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
plock->size, plock->lock_type);
@ -2576,7 +2576,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
.brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
.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_lock_check_fn = smb_full_audit_strict_lock_check,
.translate_name_fn = smb_full_audit_translate_name,
.fsctl_fn = smb_full_audit_fsctl,
.get_dos_attributes_fn = smb_full_audit_get_dos_attributes,

View File

@ -1480,7 +1480,7 @@ static struct vfs_fn_pointers glusterfs_fns = {
.brl_lock_windows_fn = NULL,
.brl_unlock_windows_fn = NULL,
.brl_cancel_windows_fn = NULL,
.strict_lock_fn = NULL,
.strict_lock_check_fn = NULL,
.translate_name_fn = NULL,
.fsctl_fn = NULL,

View File

@ -1710,21 +1710,21 @@ static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
return result;
}
static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
static bool smb_time_audit_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
bool result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(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_lock", timediff, fsp);
smb_time_audit_log_fsp("strict_lock_check", timediff, fsp);
}
return result;
@ -2768,7 +2768,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
.brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
.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_lock_check_fn = smb_time_audit_strict_lock_check,
.translate_name_fn = smb_time_audit_translate_name,
.fsctl_fn = smb_time_audit_fsctl,
.get_dos_attributes_fn = smb_time_get_dos_attributes,

View File

@ -227,7 +227,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
TALLOC_FREE(aio_ex);
return NT_STATUS_FILE_LOCK_CONFLICT;
}
@ -472,7 +472,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
TALLOC_FREE(aio_ex);
return NT_STATUS_FILE_LOCK_CONFLICT;
}
@ -712,7 +712,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
TALLOC_FREE(aio_ex);
return NT_STATUS_FILE_LOCK_CONFLICT;
}
@ -857,7 +857,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
TALLOC_FREE(aio_ex);
return NT_STATUS_FILE_LOCK_CONFLICT;
}

View File

@ -3679,7 +3679,7 @@ void reply_readbraw(struct smb_request *req)
(uint64_t)startpos, (uint64_t)maxcount, READ_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_readbraw_error(xconn);
END_PROFILE(SMBreadbraw);
return;
@ -3890,7 +3890,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
(uint64_t)startpos, (uint64_t)numtoread, READ_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
END_PROFILE(SMBread);
return;
@ -3966,7 +3966,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
(uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
return;
}
@ -4486,7 +4486,7 @@ void reply_writebraw(struct smb_request *req)
(uint64_t)startpos, (uint64_t)tcount, WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
error_to_writebrawerr(req);
END_PROFILE(SMBwritebraw);
@ -4684,7 +4684,7 @@ void reply_writeunlock(struct smb_request *req)
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
END_PROFILE(SMBwriteunlock);
return;
@ -4801,7 +4801,7 @@ void reply_write(struct smb_request *req)
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
END_PROFILE(SMBwrite);
return;
@ -5090,7 +5090,7 @@ void reply_write_and_X(struct smb_request *req)
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
goto out;
}
@ -5482,7 +5482,7 @@ void reply_writeclose(struct smb_request *req)
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
END_PROFILE(SMBwriteclose);
return;

View File

@ -483,7 +483,7 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
WRITE_LOCK,
&lck);
if (!SMB_VFS_STRICT_LOCK(fsp->conn, fsp, &lck)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(fsp->conn, fsp, &lck)) {
DEBUG(2, ("failed to lock range for zero-data\n"));
return NT_STATUS_FILE_LOCK_CONFLICT;
}

View File

@ -543,7 +543,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
READ_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
return tevent_req_post(req, ev);
}

View File

@ -354,7 +354,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
WRITE_LOCK,
&lock);
if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
return tevent_req_post(req, ev);
}

View File

@ -2274,12 +2274,12 @@ const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
return handle->fns->connectpath_fn(handle, smb_fname);
}
bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
struct files_struct *fsp,
struct lock_struct *plock)
{
VFS_FIND(strict_lock);
return handle->fns->strict_lock_fn(handle, fsp, plock);
VFS_FIND(strict_lock_check);
return handle->fns->strict_lock_check_fn(handle, fsp, plock);
}
NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,