(Finally) fix bug #7158 - SMB2 connection resets during IOZone tests from 64-bit...
authorJeremy Allison <jra@samba.org>
Thu, 20 May 2010 02:28:26 +0000 (19:28 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 20 May 2010 02:28:26 +0000 (19:28 -0700)
It turns out that the persistent handles are used by the Microsoft
redirector to index files on oplock break requests. So even if we
don't do durable handles (yet) we must set the persistent handle
on create. For now just use the same handle value as we use for
volatile.

Jeremy.

14 files changed:
source3/smbd/globals.h
source3/smbd/smb2_break.c
source3/smbd/smb2_close.c
source3/smbd/smb2_create.c
source3/smbd/smb2_find.c
source3/smbd/smb2_flush.c
source3/smbd/smb2_getinfo.c
source3/smbd/smb2_ioctl.c
source3/smbd/smb2_lock.c
source3/smbd/smb2_notify.c
source3/smbd/smb2_read.c
source3/smbd/smb2_server.c
source3/smbd/smb2_setinfo.c
source3/smbd/smb2_write.c

index f6dd36ea7233cfd29fdc457d62f9bc791bbeb61c..bb4f69501084f9a5db54ce5eb2193d8ccc429707 100644 (file)
@@ -269,6 +269,7 @@ NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req,
        smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn, __location__)
 
 NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
+                                    uint64_t file_id_persistent,
                                     uint64_t file_id_volatile,
                                     uint8_t oplock_level);
 
index a214da0f265337f470a24d5f65f7066304074efe..79b06b18764a40601b5dba002aae814fe877d203 100644 (file)
@@ -70,7 +70,7 @@ NTSTATUS smbd_smb2_request_process_break(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
@@ -270,6 +270,7 @@ void send_break_message_smb2(files_struct *fsp, int level)
                (unsigned int)smb2_oplock_level ));
 
        status = smbd_smb2_send_oplock_break(fsp->conn->sconn,
+                                       (uint64_t)fsp->fnum,
                                        (uint64_t)fsp->fnum,
                                        smb2_oplock_level);
        if (!NT_STATUS_IS_OK(status)) {
index b28fb7297937eb1d3f4d52770f722d87412914c7..56e3167e24bc9559bff6fc4485cdf530333aa9a4 100644 (file)
@@ -58,7 +58,7 @@ NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 02f83cbbe0862c02b40c23fa01153727efa8a7c1..65022d5c840cc3a6ff4d4a1e4fd7cd4b1ca09e67 100644 (file)
@@ -87,6 +87,7 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
                        uint64_t *out_allocation_size,
                        uint64_t *out_end_of_file,
                        uint32_t *out_file_attributes,
+                       uint64_t *out_file_id_persistent,
                        uint64_t *out_file_id_volatile,
                        struct smb2_create_blobs *out_context_blobs);
 
@@ -264,6 +265,7 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
        uint64_t out_allocation_size = 0;
        uint64_t out_end_of_file = 0;
        uint32_t out_file_attributes = 0;
+       uint64_t out_file_id_persistent = 0;
        uint64_t out_file_id_volatile = 0;
        struct smb2_create_blobs out_context_blobs;
        DATA_BLOB out_context_buffer;
@@ -295,6 +297,7 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
                                       &out_allocation_size,
                                       &out_end_of_file,
                                       &out_file_attributes,
+                                      &out_file_id_persistent,
                                       &out_file_id_volatile,
                                       &out_context_blobs);
        if (!NT_STATUS_IS_OK(status)) {
@@ -356,7 +359,8 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
        SIVAL(outbody.data, 0x38,
              out_file_attributes);             /* file attributes */
        SIVAL(outbody.data, 0x3C, 0);           /* reserved */
-       SBVAL(outbody.data, 0x40, 0);           /* file id (persistent) */
+       SBVAL(outbody.data, 0x40,
+             out_file_id_persistent);          /* file id (persistent) */
        SBVAL(outbody.data, 0x48,
              out_file_id_volatile);            /* file id (volatile) */
        SIVAL(outbody.data, 0x50,
@@ -391,6 +395,7 @@ struct smbd_smb2_create_state {
        uint64_t out_allocation_size;
        uint64_t out_end_of_file;
        uint32_t out_file_attributes;
+       uint64_t out_file_id_persistent;
        uint64_t out_file_id_volatile;
        struct smb2_create_blobs out_context_blobs;
 };
@@ -791,6 +796,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        if (state->out_file_attributes == 0) {
                state->out_file_attributes = FILE_ATTRIBUTE_NORMAL;
        }
+       state->out_file_id_persistent = result->fnum;
        state->out_file_id_volatile = result->fnum;
        state->out_context_blobs = out_context_blobs;
 
@@ -809,6 +815,7 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
                        uint64_t *out_allocation_size,
                        uint64_t *out_end_of_file,
                        uint32_t *out_file_attributes,
+                       uint64_t *out_file_id_persistent,
                        uint64_t *out_file_id_volatile,
                        struct smb2_create_blobs *out_context_blobs)
 {
@@ -830,6 +837,7 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
        *out_allocation_size    = state->out_allocation_size;
        *out_end_of_file        = state->out_end_of_file;
        *out_file_attributes    = state->out_file_attributes;
+       *out_file_id_persistent = state->out_file_id_persistent;
        *out_file_id_volatile   = state->out_file_id_volatile;
        *out_context_blobs      = state->out_context_blobs;
 
index 6690adcb93eaaa80438950a4f1eff817fe6c6ea2..9a7738ab7629a6c0253e4d9f5920d9ef7bd0a3f3 100644 (file)
@@ -114,7 +114,7 @@ NTSTATUS smbd_smb2_request_process_find(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 561e69058225def82b078abbc7c3fa6411bc89ca..108f3bd488f16131b303831beba4fee051441639 100644 (file)
@@ -57,7 +57,7 @@ NTSTATUS smbd_smb2_request_process_flush(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index d8963f4e9f74431b32cfe4e7f4882a3e686ef0cd..547d9dba16c8c68dcc8864e034a52bbee7a2bad1 100644 (file)
@@ -97,7 +97,7 @@ NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index c7775b4e4dadd6890289f3846655224ffebdc9b9..672965f4704ca5e885d4399d4dd30aab5ea996e2 100644 (file)
@@ -88,7 +88,7 @@ NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req)
        } else if (in_file_id_persistent == UINT64_MAX &&
                   in_file_id_volatile == UINT64_MAX) {
                /* without a handle */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 8e6624879055c2fb9c93eb63c42da5fb99933682..df5971566de01bffae64eff266beaf765b25f58b 100644 (file)
@@ -96,7 +96,7 @@ NTSTATUS smbd_smb2_request_process_lock(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index f3d8077eeee32bbec8f0c00279da6517ee418a1f..bffa651b1e49c74c7506c3fe44c3cd7b239f0f16 100644 (file)
@@ -85,7 +85,7 @@ NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 7a92cdf920d041803c2a52f31163cd60ee975f20..d4c38d65df4aaf31a6ab1cc3143699a74fff7ef9 100644 (file)
@@ -83,7 +83,7 @@ NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 75c818bcda52904412ec59b1affa76261b43ba04..b081b6a25769e3d99baafa182224258ded4c014c 100644 (file)
@@ -1448,6 +1448,7 @@ struct smbd_smb2_send_oplock_break_state {
 static void smbd_smb2_oplock_break_writev_done(struct tevent_req *subreq);
 
 NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
+                                    uint64_t file_id_persistent,
                                     uint64_t file_id_volatile,
                                     uint8_t oplock_level)
 {
@@ -1488,7 +1489,7 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
        SCVAL(body, 0x02, oplock_level);
        SCVAL(body, 0x03, 0);           /* reserved */
        SIVAL(body, 0x04, 0);           /* reserved */
-       SBVAL(body, 0x08, 0);           /* file_id_persistent */
+       SBVAL(body, 0x08, file_id_persistent);
        SBVAL(body, 0x10, file_id_volatile);
 
        subreq = tstream_writev_queue_send(state,
index 6a40714b1d9179584353f7e866ba5a11a3f8b4af..3e1bdd2771278c05ae700d6161bbbde03496bbff 100644 (file)
@@ -88,7 +88,7 @@ NTSTATUS smbd_smb2_request_process_setinfo(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
index 7813836e6564c4bb03fc5c29235b8b42de57a03a..ae98c812e9f565a38b4a1e24fa5b853fd094d37d 100644 (file)
@@ -96,7 +96,7 @@ NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req)
 
        if (req->compat_chain_fsp) {
                /* skip check */
-       } else if (in_file_id_persistent != 0) {
+       } else if (in_file_id_persistent != in_file_id_volatile) {
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }