1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

s3: smbd: Move implicit call to lp_posix_cifsu_locktype() out of init_strict_lock_struct().

Make it explicit. When we add POSIX handles to SMB2 we will only
look at the handle type. lp_posix_cifsu_locktype() already does this,
but hidden inside init_strict_lock_struct() makes it hard to see.

No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
Jeremy Allison 2021-11-16 15:00:03 -08:00 committed by Noel Power
parent 9a0212800c
commit 85e131b54b
9 changed files with 96 additions and 36 deletions

View File

@ -90,6 +90,7 @@ void init_strict_lock_struct(files_struct *fsp,
br_off start,
br_off size,
enum brl_type lock_type,
enum brl_flavour lock_flav,
struct lock_struct *plock)
{
SMB_ASSERT(lock_type == READ_LOCK || lock_type == WRITE_LOCK);

View File

@ -98,6 +98,7 @@ void init_strict_lock_struct(files_struct *fsp,
br_off start,
br_off size,
enum brl_type lock_type,
enum brl_flavour lock_flav,
struct lock_struct *plock);
bool strict_lock_check_default(files_struct *fsp,
struct lock_struct *plock);

View File

@ -343,6 +343,7 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
src_off,
num,
READ_LOCK,
lp_posix_cifsu_locktype(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);
@ -360,6 +361,7 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
dest_off,
num,
WRITE_LOCK,
lp_posix_cifsu_locktype(dest_fsp),
&dest_lck);
if (!SMB_VFS_STRICT_LOCK_CHECK(dest_fsp->conn, dest_fsp, &dest_lck)) {

View File

@ -2245,6 +2245,7 @@ static NTSTATUS vfswrap_offload_copy_file_range(struct tevent_req *req)
state->src_off,
state->remaining,
READ_LOCK,
lp_posix_cifsu_locktype(state->src_fsp),
&lck);
ok = SMB_VFS_STRICT_LOCK_CHECK(state->src_fsp->conn,
@ -2264,6 +2265,7 @@ static NTSTATUS vfswrap_offload_copy_file_range(struct tevent_req *req)
state->dst_off,
state->remaining,
WRITE_LOCK,
lp_posix_cifsu_locktype(state->dst_fsp),
&lck);
ok = SMB_VFS_STRICT_LOCK_CHECK(state->dst_fsp->conn,
@ -2358,6 +2360,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req)
state->src_off,
state->next_io_size,
READ_LOCK,
lp_posix_cifsu_locktype(state->src_fsp),
&read_lck);
ok = SMB_VFS_STRICT_LOCK_CHECK(state->src_fsp->conn,
@ -2421,6 +2424,7 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq)
state->dst_off,
state->next_io_size,
WRITE_LOCK,
lp_posix_cifsu_locktype(state->dst_fsp),
&write_lck);
ok = SMB_VFS_STRICT_LOCK_CHECK(state->dst_fsp->conn,

View File

@ -207,9 +207,13 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
SCVAL(aio_ex->outbuf.data,smb_vwv0,0xFF); /* Never a chained reply. */
SCVAL(smb_buf(aio_ex->outbuf.data), 0, 0); /* padding byte */
init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
(uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
&aio_ex->lock);
init_strict_lock_struct(fsp,
(uint64_t)smbreq->smbpid,
(uint64_t)startpos,
(uint64_t)smb_maxcnt,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
@ -472,9 +476,13 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
srv_set_message((char *)aio_ex->outbuf.data, 6, 0, True);
SCVAL(aio_ex->outbuf.data,smb_vwv0,0xFF); /* Never a chained reply. */
init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&aio_ex->lock);
init_strict_lock_struct(fsp,
(uint64_t)smbreq->smbpid,
(uint64_t)startpos,
(uint64_t)numtowrite,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
@ -720,9 +728,13 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
return NT_STATUS_NO_MEMORY;
}
init_strict_lock_struct(fsp, fsp->op->global->open_persistent_id,
(uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
&aio_ex->lock);
init_strict_lock_struct(fsp,
fsp->op->global->open_persistent_id,
(uint64_t)startpos,
(uint64_t)smb_maxcnt,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
@ -857,9 +869,13 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
aio_ex->write_through = write_through;
init_strict_lock_struct(fsp, fsp->op->global->open_persistent_id,
in_offset, (uint64_t)in_data.length, WRITE_LOCK,
&aio_ex->lock);
init_strict_lock_struct(fsp,
fsp->op->global->open_persistent_id,
in_offset,
(uint64_t)in_data.length,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&aio_ex->lock);
/* Take the lock until the AIO completes. */
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {

View File

@ -3697,9 +3697,13 @@ void reply_readbraw(struct smb_request *req)
/* ensure we don't overrun the packet size */
maxcount = MIN(65535,maxcount);
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)maxcount, READ_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)maxcount,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_readbraw_error(xconn);
@ -3965,9 +3969,13 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
data = smb_buf(req->outbuf) + 3;
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)numtoread, READ_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)numtoread,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -4042,9 +4050,13 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
int saved_errno = 0;
NTSTATUS status;
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)smb_maxcnt,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -4565,9 +4577,13 @@ void reply_writebraw(struct smb_request *req)
}
if (!fsp->print_file) {
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)tcount, WRITE_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)tcount,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -4780,9 +4796,13 @@ void reply_writeunlock(struct smb_request *req)
}
if (!fsp->print_file && numtowrite > 0) {
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)numtowrite,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -4911,9 +4931,13 @@ void reply_write(struct smb_request *req)
}
if (!fsp->print_file) {
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)numtowrite,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -5207,9 +5231,13 @@ void reply_write_and_X(struct smb_request *req)
/* NT_STATUS_RETRY - fall through to sync write. */
}
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)numtowrite,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
@ -5909,9 +5937,13 @@ void reply_writeclose(struct smb_request *req)
}
if (fsp->print_file == NULL) {
init_strict_lock_struct(fsp, (uint64_t)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
init_strict_lock_struct(fsp,
(uint64_t)req->smbpid,
(uint64_t)startpos,
(uint64_t)numtowrite,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);

View File

@ -463,6 +463,7 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
zdata_info.file_off,
len,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lck);
if (!SMB_VFS_STRICT_LOCK_CHECK(fsp->conn, fsp, &lck)) {

View File

@ -335,6 +335,7 @@ normal_read:
in_offset,
in_length,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
*pstatus = NT_STATUS_OK;
@ -553,6 +554,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
in_offset,
in_length,
READ_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {

View File

@ -361,6 +361,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
in_offset,
in_data.length,
WRITE_LOCK,
lp_posix_cifsu_locktype(fsp),
&lock);
if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {