[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Jul 18 16:51:03 UTC 2016


The branch, master has been updated
       via  5a58a14 notify_inotify: Map inotify mask back to filter
       via  f83432b notify_inotify: Move mapping table to top of file
       via  a5c51ae smbd: Allow passing notify filter from inotify and fam
       via  6bb41cf smbtorture: Correctly initialize notify request in smb2.notify.tree
      from  fddee66 lib: Fix a signed/unsigned mixup

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5a58a14be8143bea81b0cee4251445507e9766ba
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Jul 15 12:16:18 2016 -0700

    notify_inotify: Map inotify mask back to filter
    
    Instead of reporting that an inotify event triggered all possible filter
    masks, map the inotify event back to the filter mask. This is slightly
    more accurate, although there can still be mismatches due to the
    mapping.
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Jul 18 18:50:55 CEST 2016 on sn-devel-144

commit f83432bf3f0adab7c470124777216fbfbbda784b
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Jul 15 12:15:15 2016 -0700

    notify_inotify: Move mapping table to top of file
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a5c51ae7f6f3cc48bc16111101c3a981a1e4050e
Author: Christof Schmitt <cs at samba.org>
Date:   Thu Jul 14 15:44:46 2016 -0700

    smbd: Allow passing notify filter from inotify and fam
    
    This only adds a parameter to the callback without any functional
    change.
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 6bb41cf396efdbd9163564f6449fa627fcd2ed16
Author: Christof Schmitt <cs at samba.org>
Date:   Thu Jul 14 13:35:15 2016 -0700

    smbtorture: Correctly initialize notify request in smb2.notify.tree
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/notify_fam.c      |   8 ++--
 source3/smbd/notify_inotify.c  | 103 ++++++++++++++++++++++++++---------------
 source3/smbd/notifyd/notifyd.c |  11 +++--
 source3/smbd/notifyd/notifyd.h |   3 +-
 source3/smbd/proto.h           |   6 ++-
 source4/torture/smb2/notify.c  |   2 +
 6 files changed, 86 insertions(+), 47 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/notify_fam.c b/source3/smbd/notify_fam.c
index d8d6946..2cf1e35 100644
--- a/source3/smbd/notify_fam.c
+++ b/source3/smbd/notify_fam.c
@@ -52,7 +52,8 @@ struct fam_watch_context {
 	struct sys_notify_context *sys_ctx;
 	void (*callback)(struct sys_notify_context *ctx,
 			 void *private_data,
-			 struct notify_event *ev);
+			 struct notify_event *ev,
+			 uint32_t filter);
 	void *private_data;
 	uint32_t mask; /* the inotify mask */
 	uint32_t filter; /* the windows completion filter */
@@ -205,7 +206,7 @@ static void fam_handler(struct tevent_context *event_ctx,
 	}
 	ne.dir = ctx->path;
 
-	ctx->callback(ctx->sys_ctx, ctx->private_data, &ne);
+	ctx->callback(ctx->sys_ctx, ctx->private_data, &ne, UINT32_MAX);
 }
 
 static int fam_watch_context_destructor(struct fam_watch_context *ctx)
@@ -228,7 +229,8 @@ int fam_watch(TALLOC_CTX *mem_ctx,
 	      uint32_t *subdir_filter,
 	      void (*callback)(struct sys_notify_context *ctx,
 			       void *private_data,
-			       struct notify_event *ev),
+			       struct notify_event *ev,
+			       uint32_t filter),
 	      void *private_data,
 	      void *handle_p)
 {
diff --git a/source3/smbd/notify_inotify.c b/source3/smbd/notify_inotify.c
index 78fb654..3848dd6 100644
--- a/source3/smbd/notify_inotify.c
+++ b/source3/smbd/notify_inotify.c
@@ -48,7 +48,8 @@ struct inotify_watch_context {
 	int wd;
 	void (*callback)(struct sys_notify_context *ctx, 
 			 void *private_data,
-			 struct notify_event *ev);
+			 struct notify_event *ev,
+			 uint32_t filter);
 	void *private_data;
 	uint32_t mask; /* the inotify mask */
 	uint32_t filter; /* the windows completion filter */
@@ -57,6 +58,60 @@ struct inotify_watch_context {
 
 
 /*
+  map from a change notify mask to a inotify mask. Remove any bits
+  which we can handle
+*/
+static const struct {
+	uint32_t notify_mask;
+	uint32_t inotify_mask;
+} inotify_mapping[] = {
+	{FILE_NOTIFY_CHANGE_FILE_NAME,   IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
+	{FILE_NOTIFY_CHANGE_DIR_NAME,    IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
+	{FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB|IN_MOVED_TO|IN_MOVED_FROM|IN_MODIFY},
+	{FILE_NOTIFY_CHANGE_LAST_WRITE,  IN_ATTRIB},
+	{FILE_NOTIFY_CHANGE_LAST_ACCESS, IN_ATTRIB},
+	{FILE_NOTIFY_CHANGE_EA,          IN_ATTRIB},
+	{FILE_NOTIFY_CHANGE_SECURITY,    IN_ATTRIB}
+};
+
+static uint32_t inotify_map(uint32_t *filter)
+{
+	int i;
+	uint32_t out=0;
+	for (i=0;i<ARRAY_SIZE(inotify_mapping);i++) {
+		if (inotify_mapping[i].notify_mask & *filter) {
+			out |= inotify_mapping[i].inotify_mask;
+			*filter &= ~inotify_mapping[i].notify_mask;
+		}
+	}
+	return out;
+}
+
+/*
+ * Map inotify mask back to filter. This returns all filters that
+ * could have created the inotify watch.
+ */
+static uint32_t inotify_map_mask_to_filter(uint32_t mask)
+{
+	int i;
+	uint32_t filter = 0;
+
+	for (i = 0; i < ARRAY_SIZE(inotify_mapping); i++) {
+		if (inotify_mapping[0].inotify_mask & mask) {
+			filter |= inotify_mapping[i].notify_mask;
+		}
+	}
+
+	if (mask & IN_ISDIR) {
+		filter &= ~FILE_NOTIFY_CHANGE_FILE_NAME;
+	} else {
+		filter &= ~FILE_NOTIFY_CHANGE_DIR_NAME;
+	}
+
+	return filter;
+}
+
+/*
   destroy the inotify private context
 */
 static int inotify_destructor(struct inotify_private *in)
@@ -122,6 +177,7 @@ static void inotify_dispatch(struct inotify_private *in,
 {
 	struct inotify_watch_context *w, *next;
 	struct notify_event ne;
+	uint32_t filter;
 
 	DEBUG(10, ("inotify_dispatch called with mask=%x, name=[%s]\n",
 		   e->mask, e->len ? e->name : ""));
@@ -156,15 +212,17 @@ static void inotify_dispatch(struct inotify_private *in,
 	}
 	ne.path = e->name;
 
-	DEBUG(10, ("inotify_dispatch: ne.action = %d, ne.path = %s\n",
-		   ne.action, ne.path));
+	filter = inotify_map_mask_to_filter(e->mask);
+
+	DBG_DEBUG("ne.action = %d, ne.path = %s, filter = %d\n",
+		  ne.action, ne.path, filter);
 
 	/* find any watches that have this watch descriptor */
 	for (w=in->watches;w;w=next) {
 		next = w->next;
 		if (w->wd == e->wd && filter_match(w, e)) {
 			ne.dir = w->path;
-			w->callback(in->ctx, w->private_data, &ne);
+			w->callback(in->ctx, w->private_data, &ne, filter);
 		}
 	}
 
@@ -185,7 +243,8 @@ static void inotify_dispatch(struct inotify_private *in,
 			if (w->wd == e->wd && filter_match(w, e) &&
 			    !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
 				ne.dir = w->path;
-				w->callback(in->ctx, w->private_data, &ne);
+				w->callback(in->ctx, w->private_data, &ne,
+					    filter);
 			}
 		}
 	}
@@ -286,37 +345,6 @@ static int inotify_setup(struct sys_notify_context *ctx)
 	return 0;
 }
 
-
-/*
-  map from a change notify mask to a inotify mask. Remove any bits
-  which we can handle
-*/
-static const struct {
-	uint32_t notify_mask;
-	uint32_t inotify_mask;
-} inotify_mapping[] = {
-	{FILE_NOTIFY_CHANGE_FILE_NAME,   IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
-	{FILE_NOTIFY_CHANGE_DIR_NAME,    IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
-	{FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB|IN_MOVED_TO|IN_MOVED_FROM|IN_MODIFY},
-	{FILE_NOTIFY_CHANGE_LAST_WRITE,  IN_ATTRIB},
-	{FILE_NOTIFY_CHANGE_LAST_ACCESS, IN_ATTRIB},
-	{FILE_NOTIFY_CHANGE_EA,          IN_ATTRIB},
-	{FILE_NOTIFY_CHANGE_SECURITY,    IN_ATTRIB}
-};
-
-static uint32_t inotify_map(uint32_t *filter)
-{
-	int i;
-	uint32_t out=0;
-	for (i=0;i<ARRAY_SIZE(inotify_mapping);i++) {
-		if (inotify_mapping[i].notify_mask & *filter) {
-			out |= inotify_mapping[i].inotify_mask;
-			*filter &= ~inotify_mapping[i].notify_mask;
-		}
-	}
-	return out;
-}
-
 /*
   destroy a watch
 */
@@ -355,7 +383,8 @@ int inotify_watch(TALLOC_CTX *mem_ctx,
 		  uint32_t *subdir_filter,
 		  void (*callback)(struct sys_notify_context *ctx,
 				   void *private_data,
-				   struct notify_event *ev),
+				   struct notify_event *ev,
+				   uint32_t filter),
 		  void *private_data,
 		  void *handle_p)
 {
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index 45b029b..519109f 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -140,7 +140,8 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn,
 				     struct messaging_reclog *log);
 #endif
 static void notifyd_sys_callback(struct sys_notify_context *ctx,
-				 void *private_data, struct notify_event *ev);
+				 void *private_data, struct notify_event *ev,
+				 uint32_t filter);
 
 #ifdef CLUSTER_SUPPORT
 static struct tevent_req *notifyd_broadcast_reclog_send(
@@ -163,7 +164,8 @@ static int sys_notify_watch_dummy(
 	uint32_t *subdir_filter,
 	void (*callback)(struct sys_notify_context *ctx,
 			 void *private_data,
-			 struct notify_event *ev),
+			 struct notify_event *ev,
+			 uint32_t filter),
 	void *private_data,
 	void *handle_p)
 {
@@ -513,7 +515,8 @@ fail:
 }
 
 static void notifyd_sys_callback(struct sys_notify_context *ctx,
-				 void *private_data, struct notify_event *ev)
+				 void *private_data, struct notify_event *ev,
+				 uint32_t filter)
 {
 	struct messaging_context *msg_ctx = talloc_get_type_abort(
 		private_data, struct messaging_context);
@@ -524,7 +527,7 @@ static void notifyd_sys_callback(struct sys_notify_context *ctx,
 	msg = (struct notify_trigger_msg) {
 		.when = timespec_current(),
 		.action = ev->action,
-		.filter = UINT32_MAX
+		.filter = filter,
 	};
 
 	iov[0].iov_base = &msg;
diff --git a/source3/smbd/notifyd/notifyd.h b/source3/smbd/notifyd/notifyd.h
index 672ffba..82fdd6e 100644
--- a/source3/smbd/notifyd/notifyd.h
+++ b/source3/smbd/notifyd/notifyd.h
@@ -129,7 +129,8 @@ typedef int (*sys_notify_watch_fn)(TALLOC_CTX *mem_ctx,
 				   uint32_t *subdir_filter,
 				   void (*callback)(struct sys_notify_context *ctx,
 						    void *private_data,
-						    struct notify_event *ev),
+						    struct notify_event *ev,
+						    uint32_t filter),
 				   void *private_data,
 				   void *handle_p);
 
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 81bdc87..f330b4c 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -560,7 +560,8 @@ int inotify_watch(TALLOC_CTX *mem_ctx,
 		  uint32_t *subdir_filter,
 		  void (*callback)(struct sys_notify_context *ctx,
 				   void *private_data,
-				   struct notify_event *ev),
+				   struct notify_event *ev,
+				   uint32_t filter),
 		  void *private_data,
 		  void *handle_p);
 
@@ -571,7 +572,8 @@ int fam_watch(TALLOC_CTX *mem_ctx,
 	      uint32_t *subdir_filter,
 	      void (*callback)(struct sys_notify_context *ctx,
 			       void *private_data,
-			       struct notify_event *ev),
+			       struct notify_event *ev,
+			       uint32_t filter),
 	      void *private_data,
 	      void *handle_p);
 
diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c
index e045f25..de4ff58 100644
--- a/source4/torture/smb2/notify.c
+++ b/source4/torture/smb2/notify.c
@@ -1883,7 +1883,9 @@ static bool torture_smb2_notify_tree(struct torture_context *torture,
 	do {
 		/* count events that have happened in each dir */
 		for (i=0;i<ARRAY_SIZE(dirs);i++) {
+			notify.smb2.in.completion_filter = dirs[i].filter;
 			notify.smb2.in.file.handle = dirs[i].h1;
+			notify.smb2.in.recursive = dirs[i].recursive;
 			req = smb2_notify_send(tree, &(notify.smb2));
 			smb2_cancel(req);
 			notify.smb2.out.num_changes = 0;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list