Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359738
b: refs/heads/master
c: d94af6d
h: refs/heads/master
v: v3
  • Loading branch information
Stanislav Kinsbursky authored and J. Bruce Fields committed Feb 15, 2013
1 parent ed9a0ba commit b489892
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 21cd1254d3402a72927ed744e8ac1a7cf532f1ea
refs/heads/master: d94af6dea9cd680fb795dbc409a7360f1c63dc34
32 changes: 20 additions & 12 deletions trunk/net/sunrpc/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,18 @@ struct cache_reader {
int offset; /* if non-0, we have a refcnt on next request */
};

static int cache_request(struct cache_detail *detail,
struct cache_request *crq)
{
char *bp = crq->buf;
int len = PAGE_SIZE;

detail->cache_request(detail, crq->item, &bp, &len);
if (len < 0)
return -EAGAIN;
return PAGE_SIZE - len;
}

static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
loff_t *ppos, struct cache_detail *cd)
{
Expand Down Expand Up @@ -784,6 +796,13 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
rq->readers++;
spin_unlock(&queue_lock);

if (rq->len == 0) {
err = cache_request(cd, rq);
if (err < 0)
goto out;
rq->len = err;
}

if (rp->offset == 0 && !test_bit(CACHE_PENDING, &rq->item->flags)) {
err = -EAGAIN;
spin_lock(&queue_lock);
Expand Down Expand Up @@ -1145,8 +1164,6 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)

char *buf;
struct cache_request *crq;
char *bp;
int len;

if (!detail->cache_request)
return -EINVAL;
Expand All @@ -1166,19 +1183,10 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
return -EAGAIN;
}

bp = buf; len = PAGE_SIZE;

detail->cache_request(detail, h, &bp, &len);

if (len < 0) {
kfree(buf);
kfree(crq);
return -EAGAIN;
}
crq->q.reader = 0;
crq->item = cache_get(h);
crq->buf = buf;
crq->len = PAGE_SIZE - len;
crq->len = 0;
crq->readers = 0;
spin_lock(&queue_lock);
list_add_tail(&crq->q.list, &detail->queue);
Expand Down

0 comments on commit b489892

Please sign in to comment.