[PATCHES] for smbd durable open code
Michael Adam
obnox at samba.org
Mon May 27 01:52:40 MDT 2013
Hi,
attached find three patches around the s3 smbd durable handle
code. Two are only touching comments and one removes
code duplication in the smbd_smb2_create_send() call, removing
the code to the place where it actually belongs.
Review and possibly push appreciated.
Cheers - Michael
-------------- next part --------------
>From 620c89f4c54ec2c128745c26bf81bd409b2b9f6b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 22 May 2013 20:26:49 +0200
Subject: [PATCH 1/3] s3:smbd: remove old comment about scavenger timer from
vfs_default_durable_reconnect()
scavenger functionality belongs to the smb layer (and is meanwhile
implemented there).
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/smbd/durable.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c
index 69ba109..9b05d48 100644
--- a/source3/smbd/durable.c
+++ b/source3/smbd/durable.c
@@ -696,20 +696,6 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
}
/*
- * TODO:
- * add scavenger timer functionality
- *
- * For now we always allow the reconnect
- */
-#if 0
- expire_time = op->global->disconnect_time;
- expire_time += NTTIME_MAGIC(op->global->durable_timeout_msec);
- if (expire < now) {
- //TODO reopen and close before telling the client...
- }
-#endif
-
- /*
* 2. proceed with opening file
*/
--
1.7.9.5
>From 886d1e498f66d7857733ac699b3d1f2a06a0a442 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 22 May 2013 19:53:12 +0200
Subject: [PATCH 2/3] s3:smbd: remove code duplication in smb2_create_send()
Move the calls to smb2srv_open_recreate() from the parsing of
the create blobs (DHNC and DH2C) to a central place in the
open execution phase.
This is also where it should be called: in the durable reconnect
part, right before the call to SMB_VFS_DURABLE_RECONNECT()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/smbd/smb2_create.c | 76 +++++++++++++++-----------------------------
1 file changed, 25 insertions(+), 51 deletions(-)
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 60ba739..11b3b7f 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -552,6 +552,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
uint32_t durable_timeout_msec = 0;
bool do_durable_reconnect = false;
struct smb2_create_blob *dh2q = NULL;
+ uint64_t persistent_id = 0;
exta = smb2_create_blob_find(&in_context_blobs,
SMB2_CREATE_TAG_EXTA);
@@ -683,41 +684,13 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
}
if (dhnc) {
- NTTIME now = timeval_to_nttime(&smb2req->request_time);
- uint64_t persistent_id;
-
persistent_id = BVAL(dhnc->data.data, 0);
- status = smb2srv_open_recreate(smb2req->sconn->conn,
- smb1req->conn->session_info,
- persistent_id, create_guid,
- now, &op);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("smbd_smb2_create_send: "
- "smb2srv_open_recreate v1 failed: %s\n",
- nt_errstr(status)));
- tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
- }
-
- DEBUG(10, ("smb2_create_send: DHNC: %s recreate the "
- "smb2srv_open struct for a durable handle.\n",
- op->global->durable ? "did" : "could not"));
-
- if (!op->global->durable) {
- talloc_free(op);
- tevent_req_nterror(req,
- NT_STATUS_OBJECT_NAME_NOT_FOUND);
- return tevent_req_post(req, ev);
- }
-
do_durable_reconnect = true;
}
if (dh2c) {
const uint8_t *p = dh2c->data.data;
- NTTIME now = timeval_to_nttime(&smb2req->request_time);
- uint64_t persistent_id;
DATA_BLOB create_guid_blob;
persistent_id = BVAL(p, 0);
@@ -729,29 +702,6 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- status = smb2srv_open_recreate(smb2req->sconn->conn,
- smb1req->conn->session_info,
- persistent_id, create_guid,
- now, &op);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("smbd_smb2_create_send: "
- "smb2srv_open_recreate v2 failed: %s\n",
- nt_errstr(status)));
- tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
- }
-
- DEBUG(10, ("smb2_create_send: DH2C: %s recreate the "
- "smb2srv_open struct for a durable handle.\n",
- op->global->durable ? "did" : "could not"));
-
- if (!op->global->durable) {
- talloc_free(op);
- tevent_req_nterror(req,
- NT_STATUS_OBJECT_NAME_NOT_FOUND);
- return tevent_req_post(req, ev);
- }
-
do_durable_reconnect = true;
}
@@ -813,6 +763,30 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
*/
if (do_durable_reconnect) {
DATA_BLOB new_cookie = data_blob_null;
+ NTTIME now = timeval_to_nttime(&smb2req->request_time);
+
+ status = smb2srv_open_recreate(smb2req->sconn->conn,
+ smb1req->conn->session_info,
+ persistent_id, create_guid,
+ now, &op);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("smbd_smb2_create_send: "
+ "smb2srv_open_recreate failed: %s\n",
+ nt_errstr(status)));
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
+
+ DEBUG(10, ("smb2_create_send: %s to recreate the "
+ "smb2srv_open struct for a durable handle.\n",
+ op->global->durable ? "succeded" : "failed"));
+
+ if (!op->global->durable) {
+ talloc_free(op);
+ tevent_req_nterror(req,
+ NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ return tevent_req_post(req, ev);
+ }
status = SMB_VFS_DURABLE_RECONNECT(smb1req->conn,
smb1req,
--
1.7.9.5
>From 702f39ef72e9032e75cd962ac1494c21059fcf43 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 22 May 2013 20:16:50 +0200
Subject: [PATCH 3/3] s3:smbd: explain parameters in call to
SMB_VFS_DURABLE_RECONNECT()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/smbd/smb2_create.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 11b3b7f..6a43d27 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -790,9 +790,10 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
status = SMB_VFS_DURABLE_RECONNECT(smb1req->conn,
smb1req,
- op,
+ op, /* smbXsrv_open input */
op->global->backend_cookie,
- op, &result, &new_cookie);
+ op, /* TALLOC_CTX */
+ &result, &new_cookie);
if (!NT_STATUS_IS_OK(status)) {
NTSTATUS return_status;
--
1.7.9.5
More information about the samba-technical
mailing list