From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Trond.Myklebust@netapp.com,
linux-kernel@vger.kernel.org, devel@openvz.org
Subject: [PATCH 4/4] SUNRPC: move cache_detail->cache_request callback call to cache_read()
Date: Tue, 15 Jan 2013 11:09:46 +0300 [thread overview]
Message-ID: <20130115080946.2996.96945.stgit@localhost.localdomain> (raw)
In-Reply-To: <20130115080402.2996.74320.stgit@localhost.localdomain>
function
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>
---
net/sunrpc/cache.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 901fdca..55f044c 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -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)
{
@@ -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);
@@ -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 (!cache_listeners_exist(detail)) {
warn_no_listener(detail);
@@ -1163,19 +1180,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);
next prev parent reply other threads:[~2013-01-15 8:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 8:09 [RFC PATCH 0/4] SUNRPC: rework cache upcall to avoid NFSd root swapping Stanislav Kinsbursky
2013-01-15 8:09 ` [PATCH 1/4] SUNRPC: introduce cache_detail->cache_request callback Stanislav Kinsbursky
2013-01-15 8:09 ` [PATCH 2/4] SUNRPC: remove cache_detail->cache_upcall callback Stanislav Kinsbursky
2013-02-04 16:50 ` Jeff Layton
2013-02-04 17:15 ` J. Bruce Fields
2013-02-05 5:37 ` Stanislav Kinsbursky
2013-01-15 8:09 ` [PATCH 3/4] SUNRPC: remove "cache_request" argument in sunrpc_cache_pipe_upcall() function Stanislav Kinsbursky
2013-01-15 8:09 ` Stanislav Kinsbursky [this message]
2013-01-30 23:00 ` [RFC PATCH 0/4] SUNRPC: rework cache upcall to avoid NFSd root swapping J. Bruce Fields
2013-01-31 5:15 ` Stanislav Kinsbursky
2013-02-04 10:22 ` Stanislav Kinsbursky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130115080946.2996.96945.stgit@localhost.localdomain \
--to=skinsbursky@parallels.com \
--cc=Trond.Myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox