* [-mm patch] relayfs: add read() support
@ 2005-08-05 2:32 Tom Zanussi
2005-08-05 7:57 ` Andrew Morton
2005-08-05 14:49 ` Jens Axboe
0 siblings, 2 replies; 7+ messages in thread
From: Tom Zanussi @ 2005-08-05 2:32 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, karim, prasadav
At the kernel summit, there was some discussion of relayfs and the
consensus was that it didn't make sense for relayfs to not implement
read(). So here's a read implementation...
Andrew, please apply.
Tom
Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
diff -urpN -X dontdiff linux-2.6.13-rc4-mm1/fs/relayfs/inode.c linux-2.6.13-rc4-mm1-cur/fs/relayfs/inode.c
--- linux-2.6.13-rc4-mm1/fs/relayfs/inode.c 2005-08-05 10:14:34.000000000 -0500
+++ linux-2.6.13-rc4-mm1-cur/fs/relayfs/inode.c 2005-08-05 10:17:47.000000000 -0500
@@ -232,7 +232,7 @@ int relayfs_remove_dir(struct dentry *de
*
* Increments the channel buffer refcount.
*/
-int relayfs_open(struct inode *inode, struct file *filp)
+static int relayfs_open(struct inode *inode, struct file *filp)
{
struct rchan_buf *buf = RELAYFS_I(inode)->buf;
kref_get(&buf->kref);
@@ -247,7 +247,7 @@ int relayfs_open(struct inode *inode, st
*
* Calls upon relay_mmap_buf to map the file into user space.
*/
-int relayfs_mmap(struct file *filp, struct vm_area_struct *vma)
+static int relayfs_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct inode *inode = filp->f_dentry->d_inode;
return relay_mmap_buf(RELAYFS_I(inode)->buf, vma);
@@ -260,7 +260,7 @@ int relayfs_mmap(struct file *filp, stru
*
* Poll implemention.
*/
-unsigned int relayfs_poll(struct file *filp, poll_table *wait)
+static unsigned int relayfs_poll(struct file *filp, poll_table *wait)
{
unsigned int mask = 0;
struct inode *inode = filp->f_dentry->d_inode;
@@ -286,7 +286,7 @@ unsigned int relayfs_poll(struct file *f
* Decrements the channel refcount, as the filesystem is
* no longer using it.
*/
-int relayfs_release(struct inode *inode, struct file *filp)
+static int relayfs_release(struct inode *inode, struct file *filp)
{
struct rchan_buf *buf = RELAYFS_I(inode)->buf;
kref_put(&buf->kref, relay_remove_buf);
@@ -295,6 +295,157 @@ int relayfs_release(struct inode *inode,
}
/**
+ * relayfs_read_start - find the first available byte to read
+ *
+ * If the read_pos is in the middle of padding, return the
+ * position of the first actually available byte, otherwise
+ * return the original value.
+ */
+static inline unsigned int relayfs_read_start(unsigned int read_pos,
+ unsigned int avail,
+ unsigned int start_subbuf,
+ struct rchan_buf *buf)
+{
+ unsigned int read_subbuf, adj_read_subbuf;
+ unsigned int padding, padding_start, padding_end;
+ unsigned int subbuf_size = buf->chan->subbuf_size;
+ unsigned int n_subbufs = buf->chan->n_subbufs;
+
+ read_subbuf = read_pos / subbuf_size;
+ adj_read_subbuf = (read_subbuf + start_subbuf) % n_subbufs;
+
+ if ((read_subbuf + 1) * subbuf_size <= avail) {
+ padding = buf->padding[adj_read_subbuf];
+ padding_start = (read_subbuf + 1) * subbuf_size - padding;
+ padding_end = (read_subbuf + 1) * subbuf_size;
+ if (read_pos >= padding_start && read_pos < padding_end) {
+ read_subbuf = (read_subbuf + 1) % n_subbufs;
+ read_pos = read_subbuf * subbuf_size;
+ }
+ }
+
+ return read_pos;
+}
+
+/**
+ * relayfs_read_end - return the end of available bytes to read
+ *
+ * If the read_pos is in the middle of a full sub-buffer, return
+ * the padding-adjusted end of that sub-buffer, otherwise return
+ * the position after the last byte written to the buffer. At
+ * most, 1 sub-buffer can be read at a time.
+ *
+ */
+static inline unsigned int relayfs_read_end(unsigned int read_pos,
+ unsigned int avail,
+ unsigned int start_subbuf,
+ struct rchan_buf *buf)
+{
+ unsigned int padding, read_endpos, buf_offset;
+ unsigned int read_subbuf, adj_read_subbuf;
+ unsigned int subbuf_size = buf->chan->subbuf_size;
+ unsigned int n_subbufs = buf->chan->n_subbufs;
+
+ buf_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset;
+ read_subbuf = read_pos / subbuf_size;
+ adj_read_subbuf = (read_subbuf + start_subbuf) % n_subbufs;
+
+ if ((read_subbuf + 1) * subbuf_size <= avail) {
+ padding = buf->padding[adj_read_subbuf];
+ read_endpos = (read_subbuf + 1) * subbuf_size - padding;
+ } else
+ read_endpos = read_subbuf * subbuf_size + buf_offset;
+
+ return read_endpos;
+}
+
+/**
+ * relayfs_read_avail - return total available along with buffer start
+ *
+ * Because buffers are circular, the 'beginning' of the buffer
+ * depends on where the buffer was last written. If the writer
+ * has cycled around the buffer, the beginning is defined to be
+ * the beginning of the sub-buffer following the last sub-buffer
+ * written to, otherwise it's the beginning of sub-buffer 0.
+ *
+ */
+static inline unsigned int relayfs_read_avail(struct rchan_buf *buf,
+ unsigned int *start_subbuf)
+{
+ unsigned int avail, complete_subbufs, cur_subbuf, buf_offset;
+ unsigned int subbuf_size = buf->chan->subbuf_size;
+ unsigned int n_subbufs = buf->chan->n_subbufs;
+
+ buf_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset;
+
+ if (buf->subbufs_produced >= n_subbufs) {
+ complete_subbufs = n_subbufs - 1;
+ cur_subbuf = (buf->data - buf->start) / subbuf_size;
+ *start_subbuf = (cur_subbuf + 1) % n_subbufs;
+ } else {
+ complete_subbufs = buf->subbufs_produced;
+ *start_subbuf = 0;
+ }
+
+ avail = complete_subbufs * subbuf_size + buf_offset;
+
+ return avail;
+}
+
+/**
+ * relayfs_read - read file op for relayfs files
+ * @filp: the file
+ * @buffer: the userspace buffer
+ * @count: number of bytes to read
+ * @ppos: position to read from
+ *
+ * Reads count bytes or the number of bytes available in the
+ * current sub-buffer being read, whichever is smaller.
+ *
+ * NOTE: The results of reading a relayfs file which is currently
+ * being written to are undefined. This is because the buffer is
+ * circular and an active writer in the kernel could be
+ * overwriting the data currently being read. Therefore read()
+ * is mainly useful for reading the contents of a buffer after
+ * logging has completed.
+ */
+static ssize_t relayfs_read(struct file *filp,
+ char __user *buffer,
+ size_t count,
+ loff_t *ppos)
+{
+ struct inode *inode = filp->f_dentry->d_inode;
+ struct rchan_buf *buf = RELAYFS_I(inode)->buf;
+ unsigned int read_start, read_end, avail, start_subbuf;
+ unsigned int buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs;
+ void *from;
+
+ avail = relayfs_read_avail(buf, &start_subbuf);
+ if (*ppos >= avail)
+ return 0;
+
+ read_start = relayfs_read_start(*ppos, avail, start_subbuf, buf);
+ if (read_start == 0 && *ppos)
+ return 0;
+
+ read_end = relayfs_read_end(read_start, avail, start_subbuf, buf);
+ if (read_end == read_start)
+ return 0;
+
+ from = buf->start + start_subbuf * buf->chan->subbuf_size + read_start;
+ if (from >= buf->start + buf_size)
+ from -= buf_size;
+
+ count = min(count, read_end - read_start);
+ if (copy_to_user(buffer, from, count))
+ return -EFAULT;
+
+ *ppos = read_start + count;
+
+ return count;
+}
+
+/**
* relayfs alloc_inode() implementation
*/
static struct inode *relayfs_alloc_inode(struct super_block *sb)
@@ -329,6 +480,7 @@ struct file_operations relayfs_file_oper
.open = relayfs_open,
.poll = relayfs_poll,
.mmap = relayfs_mmap,
+ .read = relayfs_read,
.release = relayfs_release,
};
@@ -404,10 +556,6 @@ static void __exit exit_relayfs_fs(void)
module_init(init_relayfs_fs)
module_exit(exit_relayfs_fs)
-EXPORT_SYMBOL_GPL(relayfs_open);
-EXPORT_SYMBOL_GPL(relayfs_poll);
-EXPORT_SYMBOL_GPL(relayfs_mmap);
-EXPORT_SYMBOL_GPL(relayfs_release);
EXPORT_SYMBOL_GPL(relayfs_file_operations);
EXPORT_SYMBOL_GPL(relayfs_create_dir);
EXPORT_SYMBOL_GPL(relayfs_remove_dir);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [-mm patch] relayfs: add read() support 2005-08-05 2:32 [-mm patch] relayfs: add read() support Tom Zanussi @ 2005-08-05 7:57 ` Andrew Morton 2005-08-05 17:06 ` Tom Zanussi 2005-08-05 14:49 ` Jens Axboe 1 sibling, 1 reply; 7+ messages in thread From: Andrew Morton @ 2005-08-05 7:57 UTC (permalink / raw) To: Tom Zanussi; +Cc: linux-kernel, karim, prasadav Tom Zanussi <zanussi@us.ibm.com> wrote: > > +static ssize_t relayfs_read(struct file *filp, > + char __user *buffer, > + size_t count, > + loff_t *ppos) > +{ > + struct inode *inode = filp->f_dentry->d_inode; > + struct rchan_buf *buf = RELAYFS_I(inode)->buf; > + unsigned int read_start, read_end, avail, start_subbuf; > + unsigned int buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs; > + void *from; > + > + avail = relayfs_read_avail(buf, &start_subbuf); > + if (*ppos >= avail) > + return 0; > + > + read_start = relayfs_read_start(*ppos, avail, start_subbuf, buf); > + if (read_start == 0 && *ppos) > + return 0; > + > + read_end = relayfs_read_end(read_start, avail, start_subbuf, buf); > + if (read_end == read_start) > + return 0; > + > + from = buf->start + start_subbuf * buf->chan->subbuf_size + read_start; > + if (from >= buf->start + buf_size) > + from -= buf_size; > + > + count = min(count, read_end - read_start); > + if (copy_to_user(buffer, from, count)) > + return -EFAULT; > + > + *ppos = read_start + count; > + > + return count; > +} The use of `unsigned int' in here will cause >4G reads to fail on 64-bit platforms. I think you want size_t throughout. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [-mm patch] relayfs: add read() support 2005-08-05 7:57 ` Andrew Morton @ 2005-08-05 17:06 ` Tom Zanussi 0 siblings, 0 replies; 7+ messages in thread From: Tom Zanussi @ 2005-08-05 17:06 UTC (permalink / raw) To: Andrew Morton; +Cc: Tom Zanussi, linux-kernel, karim, prasadav Andrew Morton writes: > > The use of `unsigned int' in here will cause >4G reads to fail on 64-bit > platforms. I think you want size_t throughout. OK, here's a patch that does that. It also switches to size_t for the buffer-related sizes elsewhere in relayfs. This applies on top of the previous patches. Tom Signed-off-by: Tom Zanussi <zanussi@us.ibm.com> diff -urpN -X dontdiff linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/buffers.c linux-2.6.13-rc4-mm1-cur/fs/relayfs/buffers.c --- linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/buffers.c 2005-08-05 10:17:30.000000000 -0500 +++ linux-2.6.13-rc4-mm1-cur/fs/relayfs/buffers.c 2005-08-06 11:33:56.000000000 -0500 @@ -137,7 +137,7 @@ struct rchan_buf *relay_create_buf(struc if (!buf) return NULL; - buf->padding = kmalloc(chan->n_subbufs * sizeof(unsigned *), GFP_KERNEL); + buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); if (!buf->padding) goto free_buf; diff -urpN -X dontdiff linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/inode.c linux-2.6.13-rc4-mm1-cur/fs/relayfs/inode.c --- linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/inode.c 2005-08-05 10:17:47.000000000 -0500 +++ linux-2.6.13-rc4-mm1-cur/fs/relayfs/inode.c 2005-08-06 11:36:02.000000000 -0500 @@ -301,15 +301,15 @@ static int relayfs_release(struct inode * position of the first actually available byte, otherwise * return the original value. */ -static inline unsigned int relayfs_read_start(unsigned int read_pos, - unsigned int avail, - unsigned int start_subbuf, - struct rchan_buf *buf) -{ - unsigned int read_subbuf, adj_read_subbuf; - unsigned int padding, padding_start, padding_end; - unsigned int subbuf_size = buf->chan->subbuf_size; - unsigned int n_subbufs = buf->chan->n_subbufs; +static inline size_t relayfs_read_start(size_t read_pos, + size_t avail, + size_t start_subbuf, + struct rchan_buf *buf) +{ + size_t read_subbuf, adj_read_subbuf; + size_t padding, padding_start, padding_end; + size_t subbuf_size = buf->chan->subbuf_size; + size_t n_subbufs = buf->chan->n_subbufs; read_subbuf = read_pos / subbuf_size; adj_read_subbuf = (read_subbuf + start_subbuf) % n_subbufs; @@ -336,15 +336,15 @@ static inline unsigned int relayfs_read_ * most, 1 sub-buffer can be read at a time. * */ -static inline unsigned int relayfs_read_end(unsigned int read_pos, - unsigned int avail, - unsigned int start_subbuf, - struct rchan_buf *buf) -{ - unsigned int padding, read_endpos, buf_offset; - unsigned int read_subbuf, adj_read_subbuf; - unsigned int subbuf_size = buf->chan->subbuf_size; - unsigned int n_subbufs = buf->chan->n_subbufs; +static inline size_t relayfs_read_end(size_t read_pos, + size_t avail, + size_t start_subbuf, + struct rchan_buf *buf) +{ + size_t padding, read_endpos, buf_offset; + size_t read_subbuf, adj_read_subbuf; + size_t subbuf_size = buf->chan->subbuf_size; + size_t n_subbufs = buf->chan->n_subbufs; buf_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset; read_subbuf = read_pos / subbuf_size; @@ -369,12 +369,12 @@ static inline unsigned int relayfs_read_ * written to, otherwise it's the beginning of sub-buffer 0. * */ -static inline unsigned int relayfs_read_avail(struct rchan_buf *buf, - unsigned int *start_subbuf) +static inline size_t relayfs_read_avail(struct rchan_buf *buf, + size_t *start_subbuf) { - unsigned int avail, complete_subbufs, cur_subbuf, buf_offset; - unsigned int subbuf_size = buf->chan->subbuf_size; - unsigned int n_subbufs = buf->chan->n_subbufs; + size_t avail, complete_subbufs, cur_subbuf, buf_offset; + size_t subbuf_size = buf->chan->subbuf_size; + size_t n_subbufs = buf->chan->n_subbufs; buf_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset; @@ -416,8 +416,8 @@ static ssize_t relayfs_read(struct file { struct inode *inode = filp->f_dentry->d_inode; struct rchan_buf *buf = RELAYFS_I(inode)->buf; - unsigned int read_start, read_end, avail, start_subbuf; - unsigned int buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs; + size_t read_start, read_end, avail, start_subbuf; + size_t buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs; void *from; avail = relayfs_read_avail(buf, &start_subbuf); diff -urpN -X dontdiff linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/relay.c linux-2.6.13-rc4-mm1-cur/fs/relayfs/relay.c --- linux-2.6.13-rc4-mm1-cur-prev/fs/relayfs/relay.c 2005-08-05 10:17:30.000000000 -0500 +++ linux-2.6.13-rc4-mm1-cur/fs/relayfs/relay.c 2005-08-06 11:20:10.000000000 -0500 @@ -37,7 +37,7 @@ int relay_buf_empty(struct rchan_buf *bu */ int relay_buf_full(struct rchan_buf *buf) { - unsigned int ready = buf->subbufs_produced - buf->subbufs_consumed; + size_t ready = buf->subbufs_produced - buf->subbufs_consumed; return (ready >= buf->chan->n_subbufs) ? 1 : 0; } @@ -56,7 +56,7 @@ int relay_buf_full(struct rchan_buf *buf static int subbuf_start_default_callback (struct rchan_buf *buf, void *subbuf, void *prev_subbuf, - unsigned int prev_padding) + size_t prev_padding) { return 1; } @@ -107,7 +107,7 @@ static void wakeup_readers(void *private */ static inline void __relay_reset(struct rchan_buf *buf, unsigned int init) { - unsigned int i; + size_t i; if (init) { init_waitqueue_head(&buf->read_wait); @@ -230,8 +230,8 @@ static inline void setup_callbacks(struc */ struct rchan *relay_open(const char *base_filename, struct dentry *parent, - unsigned int subbuf_size, - unsigned int n_subbufs, + size_t subbuf_size, + size_t n_subbufs, struct rchan_callbacks *cb) { unsigned int i; @@ -292,10 +292,10 @@ free_chan: * Performs sub-buffer-switch tasks such as invoking callbacks, * updating padding counts, waking up readers, etc. */ -unsigned int relay_switch_subbuf(struct rchan_buf *buf, unsigned int length) +size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length) { void *old, *new; - unsigned int old_subbuf, new_subbuf; + size_t old_subbuf, new_subbuf; if (unlikely(length > buf->chan->subbuf_size)) goto toobig; @@ -348,7 +348,7 @@ toobig: */ void relay_subbufs_consumed(struct rchan *chan, unsigned int cpu, - unsigned int subbufs_consumed) + size_t subbufs_consumed) { struct rchan_buf *buf; diff -urpN -X dontdiff linux-2.6.13-rc4-mm1-cur-prev/include/linux/relayfs_fs.h linux-2.6.13-rc4-mm1-cur/include/linux/relayfs_fs.h --- linux-2.6.13-rc4-mm1-cur-prev/include/linux/relayfs_fs.h 2005-08-05 10:17:30.000000000 -0500 +++ linux-2.6.13-rc4-mm1-cur/include/linux/relayfs_fs.h 2005-08-06 11:33:16.000000000 -0500 @@ -31,9 +31,9 @@ struct rchan_buf { void *start; /* start of channel buffer */ void *data; /* start of current sub-buffer */ - unsigned int offset; /* current offset into sub-buffer */ - unsigned int subbufs_produced; /* count of sub-buffers produced */ - unsigned int subbufs_consumed; /* count of sub-buffers consumed */ + size_t offset; /* current offset into sub-buffer */ + size_t subbufs_produced; /* count of sub-buffers produced */ + size_t subbufs_consumed; /* count of sub-buffers consumed */ struct rchan *chan; /* associated channel */ wait_queue_head_t read_wait; /* reader wait queue */ struct work_struct wake_readers; /* reader wake-up work struct */ @@ -42,8 +42,8 @@ struct rchan_buf struct page **page_array; /* array of current buffer pages */ unsigned int page_count; /* number of current buffer pages */ unsigned int finalized; /* buffer has been finalized */ - unsigned *padding; /* padding counts per sub-buffer */ - unsigned int prev_padding; /* temporary variable */ + size_t *padding; /* padding counts per sub-buffer */ + size_t prev_padding; /* temporary variable */ } ____cacheline_aligned; /* @@ -52,9 +52,9 @@ struct rchan_buf struct rchan { u32 version; /* the version of this struct */ - unsigned int subbuf_size; /* sub-buffer size */ - unsigned int n_subbufs; /* number of sub-buffers per buffer */ - unsigned int alloc_size; /* total buffer size allocated */ + size_t subbuf_size; /* sub-buffer size */ + size_t n_subbufs; /* number of sub-buffers per buffer */ + size_t alloc_size; /* total buffer size allocated */ struct rchan_callbacks *cb; /* client callbacks */ struct kref kref; /* channel refcount */ void *private_data; /* for user-defined data */ @@ -100,7 +100,7 @@ struct rchan_callbacks int (*subbuf_start) (struct rchan_buf *buf, void *subbuf, void *prev_subbuf, - unsigned int prev_padding); + size_t prev_padding); /* * buf_mapped - relayfs buffer mmap notification @@ -129,19 +129,19 @@ struct rchan_callbacks struct rchan *relay_open(const char *base_filename, struct dentry *parent, - unsigned int subbuf_size, - unsigned int n_subbufs, + size_t subbuf_size, + size_t n_subbufs, struct rchan_callbacks *cb); extern void relay_close(struct rchan *chan); extern void relay_flush(struct rchan *chan); extern void relay_subbufs_consumed(struct rchan *chan, unsigned int cpu, - unsigned int consumed); + size_t consumed); extern void relay_reset(struct rchan *chan); extern int relay_buf_full(struct rchan_buf *buf); -extern unsigned int relay_switch_subbuf(struct rchan_buf *buf, - unsigned int length); +extern size_t relay_switch_subbuf(struct rchan_buf *buf, + size_t length); extern struct dentry *relayfs_create_dir(const char *name, struct dentry *parent); extern int relayfs_remove_dir(struct dentry *dentry); @@ -161,7 +161,7 @@ extern int relayfs_remove_dir(struct den */ static inline void relay_write(struct rchan *chan, const void *data, - unsigned int length) + size_t length) { unsigned long flags; struct rchan_buf *buf; @@ -189,7 +189,7 @@ static inline void relay_write(struct rc */ static inline void __relay_write(struct rchan *chan, const void *data, - unsigned int length) + size_t length) { struct rchan_buf *buf; @@ -212,7 +212,7 @@ static inline void __relay_write(struct * Does not protect the buffer at all - caller must provide * appropriate synchronization. */ -static inline void *relay_reserve(struct rchan *chan, unsigned length) +static inline void *relay_reserve(struct rchan *chan, size_t length) { void *reserved; struct rchan_buf *buf = chan->buf[smp_processor_id()]; @@ -237,7 +237,7 @@ static inline void *relay_reserve(struct * a sub-buffer in the subbuf_start() callback. */ static inline void subbuf_start_reserve(struct rchan_buf *buf, - unsigned int length) + size_t length) { BUG_ON(length >= buf->chan->subbuf_size - 1); buf->offset = length; ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [-mm patch] relayfs: add read() support 2005-08-05 2:32 [-mm patch] relayfs: add read() support Tom Zanussi 2005-08-05 7:57 ` Andrew Morton @ 2005-08-05 14:49 ` Jens Axboe 2005-08-05 15:05 ` Tom Zanussi 1 sibling, 1 reply; 7+ messages in thread From: Jens Axboe @ 2005-08-05 14:49 UTC (permalink / raw) To: Tom Zanussi; +Cc: akpm, linux-kernel, karim, prasadav On Thu, Aug 04 2005, Tom Zanussi wrote: > At the kernel summit, there was some discussion of relayfs and the > consensus was that it didn't make sense for relayfs to not implement > read(). So here's a read implementation... It needs a few fixes to actually compile without errors. This works for me, just tested with the block tracing stuff, works a charm! diff -urp -X /home/axboe/cdrom/exclude /opt/kernel/linux-2.6.13-rc4-mm1/fs/relayfs/inode.c linux-2.6.13-rc4-mm1/fs/relayfs/inode.c --- /opt/kernel/linux-2.6.13-rc4-mm1/fs/relayfs/inode.c 2005-08-05 16:47:57.000000000 +0200 +++ linux-2.6.13-rc4-mm1/fs/relayfs/inode.c 2005-08-05 16:45:38.000000000 +0200 @@ -33,6 +33,8 @@ static struct backing_dev_info relayfs_ .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, }; +struct file_operations relayfs_file_operations; + static struct inode *relayfs_get_inode(struct super_block *sb, int mode, struct rchan *chan) { @@ -370,7 +372,7 @@ static inline unsigned int relayfs_read_ * */ static inline unsigned int relayfs_read_avail(struct rchan_buf *buf, - unsigned int *start_subbuf) + size_t *start_subbuf) { unsigned int avail, complete_subbufs, cur_subbuf, buf_offset; unsigned int subbuf_size = buf->chan->subbuf_size; @@ -378,12 +380,12 @@ static inline unsigned int relayfs_read_ buf_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset; - if (buf->subbufs_produced >= n_subbufs) { + if (atomic_read(&buf->subbufs_produced) >= n_subbufs) { complete_subbufs = n_subbufs - 1; cur_subbuf = (buf->data - buf->start) / subbuf_size; *start_subbuf = (cur_subbuf + 1) % n_subbufs; } else { - complete_subbufs = buf->subbufs_produced; + complete_subbufs = atomic_read(&buf->subbufs_produced); *start_subbuf = 0; } @@ -416,8 +418,8 @@ static ssize_t relayfs_read(struct file { struct inode *inode = filp->f_dentry->d_inode; struct rchan_buf *buf = RELAYFS_I(inode)->buf; - unsigned int read_start, read_end, avail, start_subbuf; - unsigned int buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs; + size_t read_start, read_end, avail, start_subbuf; + size_t buf_size = buf->chan->subbuf_size * buf->chan->n_subbufs; void *from; avail = relayfs_read_avail(buf, &start_subbuf); diff -urp -X /home/axboe/cdrom/exclude /opt/kernel/linux-2.6.13-rc4-mm1/include/linux/relayfs_fs.h linux-2.6.13-rc4-mm1/include/linux/relayfs_fs.h --- /opt/kernel/linux-2.6.13-rc4-mm1/include/linux/relayfs_fs.h 2005-08-05 16:47:44.000000000 +0200 +++ linux-2.6.13-rc4-mm1/include/linux/relayfs_fs.h 2005-08-05 16:45:47.000000000 +0200 @@ -253,15 +253,5 @@ static inline void *relay_reserve(struct return reserved; } -/* - * exported relayfs file operations, fs/relayfs/inode.c - */ - -extern struct file_operations relayfs_file_operations; -extern int relayfs_open(struct inode *inode, struct file *filp); -extern unsigned int relayfs_poll(struct file *filp, poll_table *wait); -extern int relayfs_mmap(struct file *filp, struct vm_area_struct *vma); -extern int relayfs_release(struct inode *inode, struct file *filp); - #endif /* _LINUX_RELAYFS_FS_H */ -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [-mm patch] relayfs: add read() support 2005-08-05 14:49 ` Jens Axboe @ 2005-08-05 15:05 ` Tom Zanussi 2005-08-05 15:58 ` Jens Axboe 0 siblings, 1 reply; 7+ messages in thread From: Tom Zanussi @ 2005-08-05 15:05 UTC (permalink / raw) To: Jens Axboe; +Cc: Tom Zanussi, akpm, linux-kernel, karim, prasadav Jens Axboe writes: > On Thu, Aug 04 2005, Tom Zanussi wrote: > > At the kernel summit, there was some discussion of relayfs and the > > consensus was that it didn't make sense for relayfs to not implement > > read(). So here's a read implementation... > > It needs a few fixes to actually compile without errors. This works for > me, just tested with the block tracing stuff, works a charm! Great, glad to hear it! I should have noted in the posting, though, that you should first apply the 'API cleanup' patch, in which case you shouldn't get the compile errors. Tom ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [-mm patch] relayfs: add read() support 2005-08-05 15:05 ` Tom Zanussi @ 2005-08-05 15:58 ` Jens Axboe 2005-08-05 19:01 ` Andrew Morton 0 siblings, 1 reply; 7+ messages in thread From: Jens Axboe @ 2005-08-05 15:58 UTC (permalink / raw) To: Tom Zanussi; +Cc: akpm, linux-kernel, karim, prasadav On Fri, Aug 05 2005, Tom Zanussi wrote: > Jens Axboe writes: > > On Thu, Aug 04 2005, Tom Zanussi wrote: > > > At the kernel summit, there was some discussion of relayfs and the > > > consensus was that it didn't make sense for relayfs to not implement > > > read(). So here's a read implementation... > > > > It needs a few fixes to actually compile without errors. This works for > > me, just tested with the block tracing stuff, works a charm! > > Great, glad to hear it! I should have noted in the posting, though, > that you should first apply the 'API cleanup' patch, in which case you > shouldn't get the compile errors. Ah, I see. The API is also much cleaner than what I looked at a few months ago (even before the cleanup). Andrew, can you merge it pretty please? -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [-mm patch] relayfs: add read() support 2005-08-05 15:58 ` Jens Axboe @ 2005-08-05 19:01 ` Andrew Morton 0 siblings, 0 replies; 7+ messages in thread From: Andrew Morton @ 2005-08-05 19:01 UTC (permalink / raw) To: Jens Axboe; +Cc: zanussi, linux-kernel, karim, prasadav Jens Axboe <axboe@suse.de> wrote: > > On Fri, Aug 05 2005, Tom Zanussi wrote: > > Jens Axboe writes: > > > On Thu, Aug 04 2005, Tom Zanussi wrote: > > > > At the kernel summit, there was some discussion of relayfs and the > > > > consensus was that it didn't make sense for relayfs to not implement > > > > read(). So here's a read implementation... > > > > > > It needs a few fixes to actually compile without errors. This works for > > > me, just tested with the block tracing stuff, works a charm! > > > > Great, glad to hear it! I should have noted in the posting, though, > > that you should first apply the 'API cleanup' patch, in which case you > > shouldn't get the compile errors. > > Ah, I see. The API is also much cleaner than what I looked at a few > months ago (even before the cleanup). > > Andrew, can you merge it pretty please? yup, we'll add relayfs to 2.6.14. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-05 19:12 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-08-05 2:32 [-mm patch] relayfs: add read() support Tom Zanussi 2005-08-05 7:57 ` Andrew Morton 2005-08-05 17:06 ` Tom Zanussi 2005-08-05 14:49 ` Jens Axboe 2005-08-05 15:05 ` Tom Zanussi 2005-08-05 15:58 ` Jens Axboe 2005-08-05 19:01 ` Andrew Morton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox