summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-05-24 23:33:32 +0200
committerStefan Metzmacher <metze@samba.org>2012-05-25 09:05:35 +0200
commit167cccbc1990dbfb2b47f6aeb1168673a8817bd8 (patch)
tree3a30653fda0de8cc09744e71cb772a9538b9d355 /source3
parent3a66ee1ae583520a1dea50883038de3ec82169ba (diff)
downloadsamba-167cccbc1990dbfb2b47f6aeb1168673a8817bd8.tar.gz
samba-167cccbc1990dbfb2b47f6aeb1168673a8817bd8.tar.bz2
samba-167cccbc1990dbfb2b47f6aeb1168673a8817bd8.zip
s3:smbd: move global koplocks to smbd_server_connection
metze
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/globals.c2
-rw-r--r--source3/smbd/globals.h3
-rw-r--r--source3/smbd/oplock.c19
3 files changed, 20 insertions, 4 deletions
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 515a1e810d..807271b320 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -93,8 +93,6 @@ struct vfs_init_function_entry *backends = NULL;
char *sparse_buf = NULL;
char *LastDir = NULL;
-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 f49cdbb473..b334e2593a 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -108,8 +108,6 @@ extern struct vfs_init_function_entry *backends;
extern char *sparse_buf;
extern char *LastDir;
-extern struct kernel_oplocks *koplocks;
-
struct smbd_parent_context;
extern struct smbd_parent_context *am_parent;
extern struct memcache *smbd_memcache_ctx;
@@ -520,6 +518,7 @@ struct smbd_server_connection {
struct {
int32_t exclusive_open;
int32_t level_II_open;
+ struct kernel_oplocks *kernel_ops;
} oplocks;
struct {
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 3705943474..190a9d39f8 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -54,6 +54,7 @@ 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) {
@@ -96,6 +97,7 @@ 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) &&
@@ -133,6 +135,7 @@ 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"));
@@ -210,6 +213,7 @@ bool downgrade_oplock(files_struct *fsp)
*/
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));
}
@@ -336,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.
@@ -487,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"));
@@ -639,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;
/*
@@ -896,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;
@@ -907,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);
@@ -981,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
@@ -988,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;
}
}