]> err.no Git - linux-2.6/blobdiff - kernel/relay.c
[GFS2] Use zero_user_page() in stuffed_readpage()
[linux-2.6] / kernel / relay.c
index 61a504900eaa5ba5acb5f3362d5d8105bafe9745..95db8c79fe8f3371249029a19e48e817ffc34d12 100644 (file)
@@ -310,7 +310,7 @@ static struct rchan_callbacks default_channel_callbacks = {
 
 /**
  *     wakeup_readers - wake up readers waiting on a channel
- *     @data: contains the the channel buffer
+ *     @data: contains the channel buffer
  *
  *     This is the timer function used to defer reader waking.
  */
@@ -812,7 +812,10 @@ static void relay_file_read_consume(struct rchan_buf *buf,
        }
 
        buf->bytes_consumed += bytes_consumed;
-       read_subbuf = read_pos / buf->chan->subbuf_size;
+       if (!read_pos)
+               read_subbuf = buf->subbufs_consumed % n_subbufs;
+       else
+               read_subbuf = read_pos / buf->chan->subbuf_size;
        if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) {
                if ((read_subbuf == buf->subbufs_produced % n_subbufs) &&
                    (buf->offset == subbuf_size))
@@ -841,8 +844,9 @@ static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
        }
 
        if (unlikely(produced - consumed >= n_subbufs)) {
-               consumed = (produced / n_subbufs) * n_subbufs;
+               consumed = produced - n_subbufs + 1;
                buf->subbufs_consumed = consumed;
+               buf->bytes_consumed = 0;
        }
        
        produced = (produced % n_subbufs) * subbuf_size + buf->offset;
@@ -899,7 +903,10 @@ static size_t relay_file_read_start_pos(size_t read_pos,
        size_t read_subbuf, padding, padding_start, padding_end;
        size_t subbuf_size = buf->chan->subbuf_size;
        size_t n_subbufs = buf->chan->n_subbufs;
+       size_t consumed = buf->subbufs_consumed % n_subbufs;
 
+       if (!read_pos)
+               read_pos = consumed * subbuf_size + buf->bytes_consumed;
        read_subbuf = read_pos / subbuf_size;
        padding = buf->padding[read_subbuf];
        padding_start = (read_subbuf + 1) * subbuf_size - padding;