diff options
author | Maxim Patlasov <mpatlasov@parallels.com> | 2012-10-26 11:48:30 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-01-24 10:21:25 -0500 |
commit | b111c8c0e3e5e780ae0758fc4c1c376a7c9d5997 (patch) | |
tree | cf9485ea3195b9945dc0064906d28ccb8032aa0f /fs/fuse/dev.c | |
parent | 4250c0668ea10a19f3d37b1733f54ce6c8a37234 (diff) |
fuse: categorize fuse_get_req()
The patch categorizes all fuse_get_req() invocations into two categories:
- fuse_get_req_nopages(fc) - when caller doesn't care about req->pages
- fuse_get_req(fc, n) - when caller need n page pointers (n > 0)
Adding fuse_get_req_nopages() helps to avoid numerous fuse_get_req(fc, 0)
scattered over code. Now it's clear from the first glance when a caller need
fuse_req with page pointers.
The patch doesn't make any logic changes. In multi-page case, it silly
allocates array of FUSE_MAX_PAGES_PER_REQ page pointers. This will be amended
by future patches.
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r-- | fs/fuse/dev.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index af37ae138252..ff5e8bed5d88 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -118,7 +118,7 @@ static void fuse_req_init_context(struct fuse_req *req) | |||
118 | req->in.h.pid = current->pid; | 118 | req->in.h.pid = current->pid; |
119 | } | 119 | } |
120 | 120 | ||
121 | struct fuse_req *fuse_get_req(struct fuse_conn *fc) | 121 | struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages) |
122 | { | 122 | { |
123 | struct fuse_req *req; | 123 | struct fuse_req *req; |
124 | sigset_t oldset; | 124 | sigset_t oldset; |
@@ -137,7 +137,7 @@ struct fuse_req *fuse_get_req(struct fuse_conn *fc) | |||
137 | if (!fc->connected) | 137 | if (!fc->connected) |
138 | goto out; | 138 | goto out; |
139 | 139 | ||
140 | req = fuse_request_alloc(FUSE_MAX_PAGES_PER_REQ); | 140 | req = fuse_request_alloc(npages); |
141 | err = -ENOMEM; | 141 | err = -ENOMEM; |
142 | if (!req) | 142 | if (!req) |
143 | goto out; | 143 | goto out; |
@@ -207,13 +207,14 @@ static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req) | |||
207 | * filesystem should not have it's own file open. If deadlock is | 207 | * filesystem should not have it's own file open. If deadlock is |
208 | * intentional, it can still be broken by "aborting" the filesystem. | 208 | * intentional, it can still be broken by "aborting" the filesystem. |
209 | */ | 209 | */ |
210 | struct fuse_req *fuse_get_req_nofail(struct fuse_conn *fc, struct file *file) | 210 | struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc, |
211 | struct file *file) | ||
211 | { | 212 | { |
212 | struct fuse_req *req; | 213 | struct fuse_req *req; |
213 | 214 | ||
214 | atomic_inc(&fc->num_waiting); | 215 | atomic_inc(&fc->num_waiting); |
215 | wait_event(fc->blocked_waitq, !fc->blocked); | 216 | wait_event(fc->blocked_waitq, !fc->blocked); |
216 | req = fuse_request_alloc(FUSE_MAX_PAGES_PER_REQ); | 217 | req = fuse_request_alloc(0); |
217 | if (!req) | 218 | if (!req) |
218 | req = get_reserved_req(fc, file); | 219 | req = get_reserved_req(fc, file); |
219 | 220 | ||
@@ -521,7 +522,7 @@ void fuse_force_forget(struct file *file, u64 nodeid) | |||
521 | 522 | ||
522 | memset(&inarg, 0, sizeof(inarg)); | 523 | memset(&inarg, 0, sizeof(inarg)); |
523 | inarg.nlookup = 1; | 524 | inarg.nlookup = 1; |
524 | req = fuse_get_req_nofail(fc, file); | 525 | req = fuse_get_req_nofail_nopages(fc, file); |
525 | req->in.h.opcode = FUSE_FORGET; | 526 | req->in.h.opcode = FUSE_FORGET; |
526 | req->in.h.nodeid = nodeid; | 527 | req->in.h.nodeid = nodeid; |
527 | req->in.numargs = 1; | 528 | req->in.numargs = 1; |
@@ -1577,7 +1578,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode, | |||
1577 | unsigned int offset; | 1578 | unsigned int offset; |
1578 | size_t total_len = 0; | 1579 | size_t total_len = 0; |
1579 | 1580 | ||
1580 | req = fuse_get_req(fc); | 1581 | req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
1581 | if (IS_ERR(req)) | 1582 | if (IS_ERR(req)) |
1582 | return PTR_ERR(req); | 1583 | return PTR_ERR(req); |
1583 | 1584 | ||