[ltt-dev] [PATCH take2 08/13] get&put chan&chan_buf's reference

Lai Jiangshan laijs at cn.fujitsu.com
Wed Feb 4 22:31:42 EST 2009


these 4 APIs is for get and put struct rchan or struct chan_buf's
reference.

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
diff --git a/include/linux/ltt-relay.h b/include/linux/ltt-relay.h
index 1225a6a..173b557 100644
--- a/include/linux/ltt-relay.h
+++ b/include/linux/ltt-relay.h
@@ -170,6 +173,18 @@ struct rchan *ltt_relay_open(const char *base_filename,
 			 void *private_data);
 extern void ltt_relay_close(struct rchan *chan);
 
+static inline void ltt_relay_get_chan(struct rchan *chan)
+{
+	kref_get(&chan->kref);
+}
+void ltt_relay_put_chan(struct rchan *chan);
+
+static inline void ltt_relay_get_chan_buf(struct rchan_buf *buf)
+{
+	kref_get(&buf->kref);
+}
+void ltt_relay_put_chan_buf(struct rchan_buf *buf);
+
 /*
  * exported ltt_relay file operations, ltt/ltt-relay-alloc.c
  */
diff --git a/ltt/ltt-relay-alloc.c b/ltt/ltt-relay-alloc.c
index 80e856c..4d9489d 100644
--- a/ltt/ltt-relay-alloc.c
+++ b/ltt/ltt-relay-alloc.c
@@ -116,6 +116,12 @@ static void relay_destroy_channel(struct kref *kref)
 	kfree(chan);
 }
 
+void ltt_relay_put_chan(struct rchan *chan)
+{
+	kref_put(&chan->kref, relay_destroy_channel);
+}
+EXPORT_SYMBOL_GPL(ltt_relay_put_chan);
+
 /**
  *	relay_destroy_buf - destroy an rchan_buf struct and associated buffer
  *	@buf: the buffer struct
@@ -150,6 +156,12 @@ static void relay_remove_buf(struct kref *kref)
 	relay_destroy_buf(buf);
 }
 
+void ltt_relay_put_chan_buf(struct rchan_buf *buf)
+{
+	kref_put(&buf->kref, relay_remove_buf);
+}
+EXPORT_SYMBOL_GPL(ltt_relay_put_chan_buf);
+
 /*
  * High-level relay kernel API and associated functions.
  */







More information about the lttng-dev mailing list