[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Fri May 25 03:02:05 MDT 2012
The branch, master has been updated
via e17fa58 s3:smbd: move global smbd_msg_state to smbXsrv_connection
via 167cccb s3:smbd: move global koplocks to smbd_server_connection
via 3a66ee1 s3:smbd: pass smbd_server_connection to should_notify_deferred_opens()
via 469a2c8 s3:smbd: move global oplocks vars to smbd_server_connection
via 2f435bb s3:smbd: remove unused get_number_of_exclusive_open_oplocks()
from eec4f80 move VERSION to alpha22
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit e17fa58d6ee8bf190adba25462d9d97b26ca2c8f
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu May 24 23:41:43 2012 +0200
s3:smbd: move global smbd_msg_state to smbXsrv_connection
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Fri May 25 11:01:27 CEST 2012 on sn-devel-104
commit 167cccbc1990dbfb2b47f6aeb1168673a8817bd8
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu May 24 23:33:32 2012 +0200
s3:smbd: move global koplocks to smbd_server_connection
metze
commit 3a66ee1ae583520a1dea50883038de3ec82169ba
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu May 24 23:32:04 2012 +0200
s3:smbd: pass smbd_server_connection to should_notify_deferred_opens()
metze
commit 469a2c8e7cbcb0c9089f50b9323255840dc6ed04
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu May 24 23:15:08 2012 +0200
s3:smbd: move global oplocks vars to smbd_server_connection
metze
commit 2f435bb61aeaee142f8a826db6aed88d3dc3ab91
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu May 24 23:06:26 2012 +0200
s3:smbd: remove unused get_number_of_exclusive_open_oplocks()
metze
-----------------------------------------------------------------------
Summary of changes:
source3/smbd/close.c | 2 +-
source3/smbd/globals.c | 7 ------
source3/smbd/globals.h | 15 +++++++-----
source3/smbd/message.c | 34 ++++++++++++++++-------------
source3/smbd/oplock.c | 55 ++++++++++++++++++++++++++++++-----------------
source3/smbd/proto.h | 3 +-
6 files changed, 65 insertions(+), 51 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index ede7925..22d756c 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -173,7 +173,7 @@ static void notify_deferred_opens(struct smbd_server_connection *sconn,
uint32_t i, num_deferred;
struct share_mode_entry *deferred;
- if (!should_notify_deferred_opens()) {
+ if (!should_notify_deferred_opens(sconn)) {
return;
}
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 196b643..f107c0e 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -54,8 +54,6 @@ TDB_CONTEXT *tdb_mangled_cache = NULL;
*/
unsigned mangle_prefix = 0;
-struct msg_state *smbd_msg_state = NULL;
-
bool logged_ioctl_message = false;
time_t last_smb_conf_reload_time = 0;
@@ -93,11 +91,6 @@ struct vfs_init_function_entry *backends = NULL;
char *sparse_buf = NULL;
char *LastDir = NULL;
-/* Current number of oplocks we have outstanding. */
-int32_t exclusive_oplocks_open = 0;
-int32_t level_II_oplocks_open = 0;
-struct kernel_oplocks *koplocks = NULL;
-
struct smbd_parent_context *am_parent = NULL;
struct memcache *smbd_memcache_ctx = NULL;
bool exit_firsttime = true;
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 24c21ff..ccf79fe 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -58,7 +58,6 @@ extern struct tdb_context *tdb_mangled_cache;
extern unsigned mangle_prefix;
struct msg_state;
-extern struct msg_state *smbd_msg_state;
extern bool logged_ioctl_message;
@@ -108,11 +107,6 @@ extern struct vfs_init_function_entry *backends;
extern char *sparse_buf;
extern char *LastDir;
-/* Current number of oplocks we have outstanding. */
-extern int32_t exclusive_oplocks_open;
-extern int32_t level_II_oplocks_open;
-extern struct kernel_oplocks *koplocks;
-
struct smbd_parent_context;
extern struct smbd_parent_context *am_parent;
extern struct memcache *smbd_memcache_ctx;
@@ -356,6 +350,8 @@ struct smbXsrv_connection {
uint32_t max_write;
} server;
} smb2;
+
+ struct msg_state *msg_state;
};
NTSTATUS smbXsrv_connection_init_tables(struct smbXsrv_connection *conn,
@@ -519,6 +515,13 @@ struct smbd_server_connection {
uint64_t num_requests;
+ /* Current number of oplocks we have outstanding. */
+ struct {
+ int32_t exclusive_open;
+ int32_t level_II_open;
+ struct kernel_oplocks *kernel_ops;
+ } oplocks;
+
struct {
struct fd_event *fde;
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index 63b08e1..8ae588b 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -200,11 +200,11 @@ void reply_sendstrt(struct smb_request *req)
return;
}
- TALLOC_FREE(smbd_msg_state);
+ TALLOC_FREE(req->sconn->conn->msg_state);
- smbd_msg_state = talloc_zero(NULL, struct msg_state);
+ req->sconn->conn->msg_state = talloc_zero(NULL, struct msg_state);
- if (smbd_msg_state == NULL) {
+ if (req->sconn->conn->msg_state == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
END_PROFILE(SMBsendstrt);
return;
@@ -212,14 +212,17 @@ void reply_sendstrt(struct smb_request *req)
p = (const char *)req->buf+1;
p += srvstr_pull_req_talloc(
- smbd_msg_state, req, &smbd_msg_state->from, p,
+ req->sconn->conn->msg_state, req,
+ &req->sconn->conn->msg_state->from, p,
STR_ASCII|STR_TERMINATE) + 1;
p += srvstr_pull_req_talloc(
- smbd_msg_state, req, &smbd_msg_state->to, p,
+ req->sconn->conn->msg_state, req,
+ &req->sconn->conn->msg_state->to, p,
STR_ASCII|STR_TERMINATE) + 1;
- DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", smbd_msg_state->from,
- smbd_msg_state->to ) );
+ DEBUG(3, ("SMBsendstrt (from %s to %s)\n",
+ req->sconn->conn->msg_state->from,
+ req->sconn->conn->msg_state->to));
reply_outbuf(req, 0, 0);
@@ -247,7 +250,7 @@ void reply_sendtxt(struct smb_request *req)
return;
}
- if ((smbd_msg_state == NULL) || (req->buflen < 3)) {
+ if ((req->sconn->conn->msg_state == NULL) || (req->buflen < 3)) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
END_PROFILE(SMBsendtxt);
return;
@@ -255,12 +258,13 @@ void reply_sendtxt(struct smb_request *req)
msg = (const char *)req->buf + 1;
- old_len = talloc_get_size(smbd_msg_state->msg);
+ old_len = talloc_get_size(req->sconn->conn->msg_state->msg);
len = MIN(SVAL(msg, 0), smbreq_bufrem(req, msg+2));
- tmp = talloc_realloc(smbd_msg_state, smbd_msg_state->msg,
- char, old_len + len);
+ tmp = talloc_realloc(req->sconn->conn->msg_state,
+ req->sconn->conn->msg_state->msg,
+ char, old_len + len);
if (tmp == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
@@ -268,9 +272,9 @@ void reply_sendtxt(struct smb_request *req)
return;
}
- smbd_msg_state->msg = tmp;
+ req->sconn->conn->msg_state->msg = tmp;
- memcpy(&smbd_msg_state->msg[old_len], msg+2, len);
+ memcpy(&req->sconn->conn->msg_state->msg[old_len], msg+2, len);
DEBUG( 3, ( "SMBsendtxt\n" ) );
@@ -297,9 +301,9 @@ void reply_sendend(struct smb_request *req)
DEBUG(3,("SMBsendend\n"));
- msg_deliver(smbd_msg_state);
+ msg_deliver(req->sconn->conn->msg_state);
- TALLOC_FREE(smbd_msg_state);
+ TALLOC_FREE(req->sconn->conn->msg_state);
reply_outbuf(req, 0, 0);
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index e3f00a7..190a9d3 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -26,15 +26,6 @@
#include "messages.h"
#include "../librpc/gen_ndr/open_files.h"
-/****************************************************************************
- Get the number of current exclusive oplocks.
-****************************************************************************/
-
-int32 get_number_of_exclusive_open_oplocks(void)
-{
- return exclusive_oplocks_open;
-}
-
/*
* helper function used by the kernel oplock backends to post the break message
*/
@@ -62,7 +53,8 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
bool set_file_oplock(files_struct *fsp, int oplock_type)
{
-
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
bool use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) && koplocks;
if (fsp->oplock_type == LEVEL_II_OPLOCK) {
@@ -84,9 +76,9 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
fsp->oplock_type = oplock_type;
fsp->sent_oplock_break = NO_BREAK_SENT;
if (oplock_type == LEVEL_II_OPLOCK) {
- level_II_oplocks_open++;
+ sconn->oplocks.level_II_open++;
} else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
- exclusive_oplocks_open++;
+ sconn->oplocks.exclusive_open++;
}
DEBUG(5,("set_file_oplock: granted oplock on file %s, %s/%lu, "
@@ -104,6 +96,9 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
void release_file_oplock(files_struct *fsp)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
if ((fsp->oplock_type != NO_OPLOCK) &&
(fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) &&
koplocks) {
@@ -111,13 +106,13 @@ void release_file_oplock(files_struct *fsp)
}
if (fsp->oplock_type == LEVEL_II_OPLOCK) {
- level_II_oplocks_open--;
+ sconn->oplocks.level_II_open--;
} else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
- exclusive_oplocks_open--;
+ sconn->oplocks.exclusive_open--;
}
- SMB_ASSERT(exclusive_oplocks_open>=0);
- SMB_ASSERT(level_II_oplocks_open>=0);
+ SMB_ASSERT(sconn->oplocks.exclusive_open>=0);
+ SMB_ASSERT(sconn->oplocks.level_II_open>=0);
if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
/* This doesn't matter for close. */
@@ -139,6 +134,9 @@ void release_file_oplock(files_struct *fsp)
static void downgrade_file_oplock(files_struct *fsp)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
if (!EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
DEBUG(0, ("trying to downgrade an already-downgraded oplock!\n"));
return;
@@ -148,8 +146,8 @@ static void downgrade_file_oplock(files_struct *fsp)
koplocks->ops->release_oplock(koplocks, fsp, LEVEL_II_OPLOCK);
}
fsp->oplock_type = LEVEL_II_OPLOCK;
- exclusive_oplocks_open--;
- level_II_oplocks_open++;
+ sconn->oplocks.exclusive_open--;
+ sconn->oplocks.level_II_open++;
fsp->sent_oplock_break = NO_BREAK_SENT;
}
@@ -213,8 +211,9 @@ bool downgrade_oplock(files_struct *fsp)
/*
* Some kernel oplock implementations handle the notification themselves.
*/
-bool should_notify_deferred_opens()
+bool should_notify_deferred_opens(struct smbd_server_connection *sconn)
{
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
return !(koplocks &&
(koplocks->flags & KOPLOCKS_DEFERRED_OPEN_NOTIFICATION));
}
@@ -274,7 +273,8 @@ static files_struct *initial_break_processing(
dbgtext( "initial_break_processing: called for %s/%u\n",
file_id_string_tos(&id), (int)file_id);
dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n",
- exclusive_oplocks_open, level_II_oplocks_open );
+ sconn->oplocks.exclusive_open,
+ sconn->oplocks.level_II_open);
}
/*
@@ -340,6 +340,9 @@ static void oplock_timeout_handler(struct event_context *ctx,
static void add_oplock_timeout_handler(files_struct *fsp)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
/*
* If kernel oplocks already notifies smbds when an oplock break times
* out, just return.
@@ -491,6 +494,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
struct smbd_server_connection *sconn =
talloc_get_type_abort(private_data,
struct smbd_server_connection);
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
@@ -643,6 +647,8 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
void reply_to_oplock_break_requests(files_struct *fsp)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
int i;
/*
@@ -900,6 +906,9 @@ done:
void smbd_contend_level2_oplocks_begin(files_struct *fsp,
enum level2_contention_type type)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
if (koplocks && koplocks->ops->contend_level2_oplocks_begin) {
koplocks->ops->contend_level2_oplocks_begin(fsp, type);
return;
@@ -911,6 +920,9 @@ void smbd_contend_level2_oplocks_begin(files_struct *fsp,
void smbd_contend_level2_oplocks_end(files_struct *fsp,
enum level2_contention_type type)
{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
/* Only kernel oplocks implement this so far */
if (koplocks && koplocks->ops->contend_level2_oplocks_end) {
koplocks->ops->contend_level2_oplocks_end(fsp, type);
@@ -985,6 +997,8 @@ bool init_oplocks(struct smbd_server_connection *sconn)
void init_kernel_oplocks(struct smbd_server_connection *sconn)
{
+ struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
+
/* only initialize once */
if (koplocks == NULL) {
#if HAVE_KERNEL_OPLOCKS_IRIX
@@ -992,5 +1006,6 @@ void init_kernel_oplocks(struct smbd_server_connection *sconn)
#elif HAVE_KERNEL_OPLOCKS_LINUX
koplocks = linux_init_kernel_oplocks(sconn);
#endif
+ sconn->oplocks.kernel_ops = koplocks;
}
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 311072a..7fdbbea 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -662,13 +662,12 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
/* The following definitions come from smbd/oplock.c */
-int32 get_number_of_exclusive_open_oplocks(void);
void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
bool set_file_oplock(files_struct *fsp, int oplock_type);
void release_file_oplock(files_struct *fsp);
bool remove_oplock(files_struct *fsp);
bool downgrade_oplock(files_struct *fsp);
-bool should_notify_deferred_opens(void);
+bool should_notify_deferred_opens(struct smbd_server_connection *sconn);
void break_level2_to_none_async(files_struct *fsp);
void reply_to_oplock_break_requests(files_struct *fsp);
void contend_level2_oplocks_begin(files_struct *fsp,
--
Samba Shared Repository
More information about the samba-cvs
mailing list