]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Move implicit call to lp_posix_cifsu_locktype() out of init_strict_lock_str...
authorJeremy Allison <jra@samba.org>
Tue, 16 Nov 2021 23:00:03 +0000 (15:00 -0800)
committerNoel Power <npower@samba.org>
Thu, 6 Jan 2022 15:11:38 +0000 (15:11 +0000)
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>
source3/locking/locking.c
source3/locking/proto.h
source3/modules/vfs_btrfs.c
source3/modules/vfs_default.c
source3/smbd/aio.c
source3/smbd/reply.c
source3/smbd/smb2_ioctl_filesys.c
source3/smbd/smb2_read.c
source3/smbd/smb2_write.c

index 5fd117ac31e53e47790a98d0cf4980555e695130..b002e80fee4b5043c32c97cc50501d0055f958e8 100644 (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);
index 72d037040f2b1138610c84a2837e9acd02fdf854..d6e7a54a7665c27b429e435ba1175daa28ca9313 100644 (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);
index 53e6a3fd7c74e068156172f5cc9fd1e21058d8f1..309923a9320ddc059bb4ba3dfc1accf004f18934 100644 (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)) {
index db25527bfd6111d20534e44daf031b15ad0e618a..c52d29dc2fece30efcd48b11d8be3f288188119d 100644 (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,
index 038487ad4ba7eed7dc4356947641d550b4d7f1c1..95f1821786820e0e94f59c770d8cbdb51f143ec6 100644 (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)) {
index 0e0b22008300c1144a64d5872e8a449ef5f8935e..31181d6586a622c3ae0a9af1fbccae13c0cff775 100644 (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);
index 3324afbffc859dfe60ac62f235531b5f3af583e0..fe24fca518d55fad2ab3a68b5b98a0288e0c2ee9 100644 (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)) {
index a846215b0ecae8b597ef218aa85bb38ac62e3c98..1547c41fc3ec0377985e33cef6dd2f68b36e92f5 100644 (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)) {
index 612c89d59d1b79228542b92201a57e574cb1d317..e4067f83c2ed523115dcfaa40473f297c37a3e98 100644 (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)) {