aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2013-02-04 06:03:03 -0500
committerJ. Bruce Fields <bfields@redhat.com>2013-02-15 10:43:48 -0500
commitd94af6dea9cd680fb795dbc409a7360f1c63dc34 (patch)
treee96151ec9bc95871bf3ebc92baaaad13bfab6775 /net
parent21cd1254d3402a72927ed744e8ac1a7cf532f1ea (diff)
SUNRPC: move cache_detail->cache_request callback call to cache_read()
The reason to move cache_request() callback call from sunrpc_cache_pipe_upcall() to cache_read() is that this garantees, that cache access will be done userspace process context (only userspace process have proper root context). This is required for NFSd support in container: svc_export_request() (which is cache_request callback) calls d_path(), which, in turn, traverse dentry up to current->fs->root. Kernel threads always have global root, while container have be in "root jail" - i.e. have it's own nested root. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/cache.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 8ffec5aebeff..55024714f001 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -750,6 +750,18 @@ struct cache_reader {
750 int offset; /* if non-0, we have a refcnt on next request */ 750 int offset; /* if non-0, we have a refcnt on next request */
751}; 751};
752 752
753static int cache_request(struct cache_detail *detail,
754 struct cache_request *crq)
755{
756 char *bp = crq->buf;
757 int len = PAGE_SIZE;
758
759 detail->cache_request(detail, crq->item, &bp, &len);
760 if (len < 0)
761 return -EAGAIN;
762 return PAGE_SIZE - len;
763}
764
753static ssize_t cache_read(struct file *filp, char __user *buf, size_t count, 765static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
754 loff_t *ppos, struct cache_detail *cd) 766 loff_t *ppos, struct cache_detail *cd)
755{ 767{
@@ -784,6 +796,13 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
784 rq->readers++; 796 rq->readers++;
785 spin_unlock(&queue_lock); 797 spin_unlock(&queue_lock);
786 798
799 if (rq->len == 0) {
800 err = cache_request(cd, rq);
801 if (err < 0)
802 goto out;
803 rq->len = err;
804 }
805
787 if (rp->offset == 0 && !test_bit(CACHE_PENDING, &rq->item->flags)) { 806 if (rp->offset == 0 && !test_bit(CACHE_PENDING, &rq->item->flags)) {
788 err = -EAGAIN; 807 err = -EAGAIN;
789 spin_lock(&queue_lock); 808 spin_lock(&queue_lock);
@@ -1145,8 +1164,6 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
1145 1164
1146 char *buf; 1165 char *buf;
1147 struct cache_request *crq; 1166 struct cache_request *crq;
1148 char *bp;
1149 int len;
1150 1167
1151 if (!detail->cache_request) 1168 if (!detail->cache_request)
1152 return -EINVAL; 1169 return -EINVAL;
@@ -1166,19 +1183,10 @@ int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
1166 return -EAGAIN; 1183 return -EAGAIN;
1167 } 1184 }
1168 1185
1169 bp = buf; len = PAGE_SIZE;
1170
1171 detail->cache_request(detail, h, &bp, &len);
1172
1173 if (len < 0) {
1174 kfree(buf);
1175 kfree(crq);
1176 return -EAGAIN;
1177 }
1178 crq->q.reader = 0; 1186 crq->q.reader = 0;
1179 crq->item = cache_get(h); 1187 crq->item = cache_get(h);
1180 crq->buf = buf; 1188 crq->buf = buf;
1181 crq->len = PAGE_SIZE - len; 1189 crq->len = 0;
1182 crq->readers = 0; 1190 crq->readers = 0;
1183 spin_lock(&queue_lock); 1191 spin_lock(&queue_lock);
1184 list_add_tail(&crq->q.list, &detail->queue); 1192 list_add_tail(&crq->q.list, &detail->queue);