Return POLLERR if channel is disabled (error state)
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Jun 2011 20:29:22 +0000 (16:29 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Jun 2011 20:29:22 +0000 (16:29 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/frontend.h
lib/ringbuffer/ring_buffer_vfs.c
ltt-debugfs-abi.c
ltt-events.h
ltt-ring-buffer-client.h
ltt-ring-buffer-metadata-client.h

index 85858d936ca0c3f43ad1c8b84f5f569b1e5e2e54..01af77a281b046a9dfc8d3de2d0eb69daa98c15e 100644 (file)
@@ -163,6 +163,12 @@ int lib_ring_buffer_channel_is_finalized(const struct channel *chan)
        return chan->finalized;
 }
 
+static inline
+int lib_ring_buffer_channel_is_disabled(const struct channel *chan)
+{
+       return atomic_read(&chan->record_disabled);
+}
+
 static inline
 unsigned long lib_ring_buffer_get_read_data_size(
                                const struct lib_ring_buffer_config *config,
index 2558ab667666be50b29eb9df484d4ea3773d140d..fecef217c8bfdd9a51587f930a5dc7c2dcecac64 100644 (file)
@@ -86,19 +86,24 @@ unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait)
        struct lib_ring_buffer *buf = filp->private_data;
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = chan->backend.config;
-       int finalized;
+       int finalized, disabled;
 
        if (filp->f_mode & FMODE_READ) {
                init_poll_funcptr(wait, wrapper_pollwait_exclusive);
                poll_wait(filp, &buf->read_wait, wait);
 
                finalized = lib_ring_buffer_is_finalized(config, buf);
+               disabled = lib_ring_buffer_channel_is_disabled(chan);
+
                /*
                 * lib_ring_buffer_is_finalized() contains a smp_rmb() ordering
                 * finalized load before offsets loads.
                 */
                WARN_ON(atomic_long_read(&buf->active_readers) != 1);
 retry:
+               if (disabled)
+                       return POLLERR;
+
                if (subbuf_trunc(lib_ring_buffer_get_offset(config, buf), chan)
                  - subbuf_trunc(lib_ring_buffer_get_consumed(config, buf), chan)
                  == 0) {
@@ -159,6 +164,9 @@ long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long ar
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = chan->backend.config;
 
+       if (lib_ring_buffer_channel_is_disabled(chan))
+               return -EIO;
+
        switch (cmd) {
        case RING_BUFFER_SNAPSHOT:
                return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
@@ -250,6 +258,9 @@ long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = chan->backend.config;
 
+       if (lib_ring_buffer_channel_is_disabled(chan))
+               return -EIO;
+
        switch (cmd) {
        case RING_BUFFER_SNAPSHOT:
                return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
index fb6c789f1e0da0f4aa32bba7775fb86d439b90f0..f8bee492c3daae003dc7702aaf638ad3af99d0d3 100644 (file)
@@ -568,6 +568,8 @@ unsigned int lttng_channel_poll(struct file *file, poll_table *wait)
                poll_wait(file, channel->ops->get_hp_wait_queue(channel->chan),
                          wait);
 
+               if (channel->ops->is_disabled(channel->chan))
+                       return POLLERR;
                if (channel->ops->is_finalized(channel->chan))
                        return POLLHUP;
                else
index 9c6fcac31a7a9207ad718be60a733c365755111c..05eff540726defe0b8e14d3a8c28785e65aef8bc 100644 (file)
@@ -205,6 +205,7 @@ struct ltt_channel_ops {
        wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
        wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
        int (*is_finalized)(struct channel *chan);
+       int (*is_disabled)(struct channel *chan);
 };
 
 struct ltt_channel {
index d14297857925b274fcf89222d37895adb97bcd8c..0d8051ece35bd5ec2e42e3641524b1c5c6a993fb 100644 (file)
@@ -472,6 +472,12 @@ int ltt_is_finalized(struct channel *chan)
        return lib_ring_buffer_channel_is_finalized(chan);
 }
 
+static
+int ltt_is_disabled(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_disabled(chan);
+}
+
 static struct ltt_transport ltt_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
        .owner = THIS_MODULE,
@@ -487,6 +493,7 @@ static struct ltt_transport ltt_relay_transport = {
                .get_reader_wait_queue = ltt_get_reader_wait_queue,
                .get_hp_wait_queue = ltt_get_hp_wait_queue,
                .is_finalized = ltt_is_finalized,
+               .is_disabled = ltt_is_disabled,
        },
 };
 
index a687b7050adfa94a3049b0f56e301a8c81611355..8b1079d98c7c930dced941601533b9a407a272d1 100644 (file)
@@ -237,6 +237,12 @@ int ltt_is_finalized(struct channel *chan)
        return lib_ring_buffer_channel_is_finalized(chan);
 }
 
+static
+int ltt_is_disabled(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_disabled(chan);
+}
+
 static struct ltt_transport ltt_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
        .owner = THIS_MODULE,
@@ -252,6 +258,7 @@ static struct ltt_transport ltt_relay_transport = {
                .get_reader_wait_queue = ltt_get_reader_wait_queue,
                .get_hp_wait_queue = ltt_get_hp_wait_queue,
                .is_finalized = ltt_is_finalized,
+               .is_disabled = ltt_is_disabled,
        },
 };
 
This page took 0.029247 seconds and 4 git commands to generate.