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 | |
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')
-rw-r--r-- | fs/fuse/cuse.c | 2 | ||||
-rw-r--r-- | fs/fuse/dev.c | 13 | ||||
-rw-r--r-- | fs/fuse/dir.c | 38 | ||||
-rw-r--r-- | fs/fuse/file.c | 30 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 17 | ||||
-rw-r--r-- | fs/fuse/inode.c | 2 |
6 files changed, 57 insertions, 45 deletions
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index e397b675b029..5cc838f320d4 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c | |||
@@ -419,7 +419,7 @@ static int cuse_send_init(struct cuse_conn *cc) | |||
419 | 419 | ||
420 | BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE); | 420 | BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE); |
421 | 421 | ||
422 | req = fuse_get_req(fc); | 422 | req = fuse_get_req(fc, 1); |
423 | if (IS_ERR(req)) { | 423 | if (IS_ERR(req)) { |
424 | rc = PTR_ERR(req); | 424 | rc = PTR_ERR(req); |
425 | goto err; | 425 | goto err; |
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 | ||
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index dcc1e522c7d4..d04bcc5cccd0 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -178,7 +178,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) | |||
178 | return -ECHILD; | 178 | return -ECHILD; |
179 | 179 | ||
180 | fc = get_fuse_conn(inode); | 180 | fc = get_fuse_conn(inode); |
181 | req = fuse_get_req(fc); | 181 | req = fuse_get_req_nopages(fc); |
182 | if (IS_ERR(req)) | 182 | if (IS_ERR(req)) |
183 | return 0; | 183 | return 0; |
184 | 184 | ||
@@ -271,7 +271,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name, | |||
271 | if (name->len > FUSE_NAME_MAX) | 271 | if (name->len > FUSE_NAME_MAX) |
272 | goto out; | 272 | goto out; |
273 | 273 | ||
274 | req = fuse_get_req(fc); | 274 | req = fuse_get_req_nopages(fc); |
275 | err = PTR_ERR(req); | 275 | err = PTR_ERR(req); |
276 | if (IS_ERR(req)) | 276 | if (IS_ERR(req)) |
277 | goto out; | 277 | goto out; |
@@ -391,7 +391,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, | |||
391 | if (!forget) | 391 | if (!forget) |
392 | goto out_err; | 392 | goto out_err; |
393 | 393 | ||
394 | req = fuse_get_req(fc); | 394 | req = fuse_get_req_nopages(fc); |
395 | err = PTR_ERR(req); | 395 | err = PTR_ERR(req); |
396 | if (IS_ERR(req)) | 396 | if (IS_ERR(req)) |
397 | goto out_put_forget_req; | 397 | goto out_put_forget_req; |
@@ -592,7 +592,7 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, umode_t mode, | |||
592 | { | 592 | { |
593 | struct fuse_mknod_in inarg; | 593 | struct fuse_mknod_in inarg; |
594 | struct fuse_conn *fc = get_fuse_conn(dir); | 594 | struct fuse_conn *fc = get_fuse_conn(dir); |
595 | struct fuse_req *req = fuse_get_req(fc); | 595 | struct fuse_req *req = fuse_get_req_nopages(fc); |
596 | if (IS_ERR(req)) | 596 | if (IS_ERR(req)) |
597 | return PTR_ERR(req); | 597 | return PTR_ERR(req); |
598 | 598 | ||
@@ -623,7 +623,7 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode) | |||
623 | { | 623 | { |
624 | struct fuse_mkdir_in inarg; | 624 | struct fuse_mkdir_in inarg; |
625 | struct fuse_conn *fc = get_fuse_conn(dir); | 625 | struct fuse_conn *fc = get_fuse_conn(dir); |
626 | struct fuse_req *req = fuse_get_req(fc); | 626 | struct fuse_req *req = fuse_get_req_nopages(fc); |
627 | if (IS_ERR(req)) | 627 | if (IS_ERR(req)) |
628 | return PTR_ERR(req); | 628 | return PTR_ERR(req); |
629 | 629 | ||
@@ -647,7 +647,7 @@ static int fuse_symlink(struct inode *dir, struct dentry *entry, | |||
647 | { | 647 | { |
648 | struct fuse_conn *fc = get_fuse_conn(dir); | 648 | struct fuse_conn *fc = get_fuse_conn(dir); |
649 | unsigned len = strlen(link) + 1; | 649 | unsigned len = strlen(link) + 1; |
650 | struct fuse_req *req = fuse_get_req(fc); | 650 | struct fuse_req *req = fuse_get_req_nopages(fc); |
651 | if (IS_ERR(req)) | 651 | if (IS_ERR(req)) |
652 | return PTR_ERR(req); | 652 | return PTR_ERR(req); |
653 | 653 | ||
@@ -664,7 +664,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) | |||
664 | { | 664 | { |
665 | int err; | 665 | int err; |
666 | struct fuse_conn *fc = get_fuse_conn(dir); | 666 | struct fuse_conn *fc = get_fuse_conn(dir); |
667 | struct fuse_req *req = fuse_get_req(fc); | 667 | struct fuse_req *req = fuse_get_req_nopages(fc); |
668 | if (IS_ERR(req)) | 668 | if (IS_ERR(req)) |
669 | return PTR_ERR(req); | 669 | return PTR_ERR(req); |
670 | 670 | ||
@@ -696,7 +696,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) | |||
696 | { | 696 | { |
697 | int err; | 697 | int err; |
698 | struct fuse_conn *fc = get_fuse_conn(dir); | 698 | struct fuse_conn *fc = get_fuse_conn(dir); |
699 | struct fuse_req *req = fuse_get_req(fc); | 699 | struct fuse_req *req = fuse_get_req_nopages(fc); |
700 | if (IS_ERR(req)) | 700 | if (IS_ERR(req)) |
701 | return PTR_ERR(req); | 701 | return PTR_ERR(req); |
702 | 702 | ||
@@ -723,7 +723,7 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent, | |||
723 | int err; | 723 | int err; |
724 | struct fuse_rename_in inarg; | 724 | struct fuse_rename_in inarg; |
725 | struct fuse_conn *fc = get_fuse_conn(olddir); | 725 | struct fuse_conn *fc = get_fuse_conn(olddir); |
726 | struct fuse_req *req = fuse_get_req(fc); | 726 | struct fuse_req *req = fuse_get_req_nopages(fc); |
727 | 727 | ||
728 | if (IS_ERR(req)) | 728 | if (IS_ERR(req)) |
729 | return PTR_ERR(req); | 729 | return PTR_ERR(req); |
@@ -776,7 +776,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, | |||
776 | struct fuse_link_in inarg; | 776 | struct fuse_link_in inarg; |
777 | struct inode *inode = entry->d_inode; | 777 | struct inode *inode = entry->d_inode; |
778 | struct fuse_conn *fc = get_fuse_conn(inode); | 778 | struct fuse_conn *fc = get_fuse_conn(inode); |
779 | struct fuse_req *req = fuse_get_req(fc); | 779 | struct fuse_req *req = fuse_get_req_nopages(fc); |
780 | if (IS_ERR(req)) | 780 | if (IS_ERR(req)) |
781 | return PTR_ERR(req); | 781 | return PTR_ERR(req); |
782 | 782 | ||
@@ -848,7 +848,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat, | |||
848 | struct fuse_req *req; | 848 | struct fuse_req *req; |
849 | u64 attr_version; | 849 | u64 attr_version; |
850 | 850 | ||
851 | req = fuse_get_req(fc); | 851 | req = fuse_get_req_nopages(fc); |
852 | if (IS_ERR(req)) | 852 | if (IS_ERR(req)) |
853 | return PTR_ERR(req); | 853 | return PTR_ERR(req); |
854 | 854 | ||
@@ -1029,7 +1029,7 @@ static int fuse_access(struct inode *inode, int mask) | |||
1029 | if (fc->no_access) | 1029 | if (fc->no_access) |
1030 | return 0; | 1030 | return 0; |
1031 | 1031 | ||
1032 | req = fuse_get_req(fc); | 1032 | req = fuse_get_req_nopages(fc); |
1033 | if (IS_ERR(req)) | 1033 | if (IS_ERR(req)) |
1034 | return PTR_ERR(req); | 1034 | return PTR_ERR(req); |
1035 | 1035 | ||
@@ -1305,7 +1305,7 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) | |||
1305 | if (is_bad_inode(inode)) | 1305 | if (is_bad_inode(inode)) |
1306 | return -EIO; | 1306 | return -EIO; |
1307 | 1307 | ||
1308 | req = fuse_get_req(fc); | 1308 | req = fuse_get_req(fc, 1); |
1309 | if (IS_ERR(req)) | 1309 | if (IS_ERR(req)) |
1310 | return PTR_ERR(req); | 1310 | return PTR_ERR(req); |
1311 | 1311 | ||
@@ -1349,7 +1349,7 @@ static char *read_link(struct dentry *dentry) | |||
1349 | { | 1349 | { |
1350 | struct inode *inode = dentry->d_inode; | 1350 | struct inode *inode = dentry->d_inode; |
1351 | struct fuse_conn *fc = get_fuse_conn(inode); | 1351 | struct fuse_conn *fc = get_fuse_conn(inode); |
1352 | struct fuse_req *req = fuse_get_req(fc); | 1352 | struct fuse_req *req = fuse_get_req_nopages(fc); |
1353 | char *link; | 1353 | char *link; |
1354 | 1354 | ||
1355 | if (IS_ERR(req)) | 1355 | if (IS_ERR(req)) |
@@ -1562,7 +1562,7 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr, | |||
1562 | if (attr->ia_valid & ATTR_SIZE) | 1562 | if (attr->ia_valid & ATTR_SIZE) |
1563 | is_truncate = true; | 1563 | is_truncate = true; |
1564 | 1564 | ||
1565 | req = fuse_get_req(fc); | 1565 | req = fuse_get_req_nopages(fc); |
1566 | if (IS_ERR(req)) | 1566 | if (IS_ERR(req)) |
1567 | return PTR_ERR(req); | 1567 | return PTR_ERR(req); |
1568 | 1568 | ||
@@ -1670,7 +1670,7 @@ static int fuse_setxattr(struct dentry *entry, const char *name, | |||
1670 | if (fc->no_setxattr) | 1670 | if (fc->no_setxattr) |
1671 | return -EOPNOTSUPP; | 1671 | return -EOPNOTSUPP; |
1672 | 1672 | ||
1673 | req = fuse_get_req(fc); | 1673 | req = fuse_get_req_nopages(fc); |
1674 | if (IS_ERR(req)) | 1674 | if (IS_ERR(req)) |
1675 | return PTR_ERR(req); | 1675 | return PTR_ERR(req); |
1676 | 1676 | ||
@@ -1709,7 +1709,7 @@ static ssize_t fuse_getxattr(struct dentry *entry, const char *name, | |||
1709 | if (fc->no_getxattr) | 1709 | if (fc->no_getxattr) |
1710 | return -EOPNOTSUPP; | 1710 | return -EOPNOTSUPP; |
1711 | 1711 | ||
1712 | req = fuse_get_req(fc); | 1712 | req = fuse_get_req_nopages(fc); |
1713 | if (IS_ERR(req)) | 1713 | if (IS_ERR(req)) |
1714 | return PTR_ERR(req); | 1714 | return PTR_ERR(req); |
1715 | 1715 | ||
@@ -1761,7 +1761,7 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) | |||
1761 | if (fc->no_listxattr) | 1761 | if (fc->no_listxattr) |
1762 | return -EOPNOTSUPP; | 1762 | return -EOPNOTSUPP; |
1763 | 1763 | ||
1764 | req = fuse_get_req(fc); | 1764 | req = fuse_get_req_nopages(fc); |
1765 | if (IS_ERR(req)) | 1765 | if (IS_ERR(req)) |
1766 | return PTR_ERR(req); | 1766 | return PTR_ERR(req); |
1767 | 1767 | ||
@@ -1806,7 +1806,7 @@ static int fuse_removexattr(struct dentry *entry, const char *name) | |||
1806 | if (fc->no_removexattr) | 1806 | if (fc->no_removexattr) |
1807 | return -EOPNOTSUPP; | 1807 | return -EOPNOTSUPP; |
1808 | 1808 | ||
1809 | req = fuse_get_req(fc); | 1809 | req = fuse_get_req_nopages(fc); |
1810 | if (IS_ERR(req)) | 1810 | if (IS_ERR(req)) |
1811 | return PTR_ERR(req); | 1811 | return PTR_ERR(req); |
1812 | 1812 | ||
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2565f635c04f..882877125c1d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -25,7 +25,7 @@ static int fuse_send_open(struct fuse_conn *fc, u64 nodeid, struct file *file, | |||
25 | struct fuse_req *req; | 25 | struct fuse_req *req; |
26 | int err; | 26 | int err; |
27 | 27 | ||
28 | req = fuse_get_req(fc); | 28 | req = fuse_get_req_nopages(fc); |
29 | if (IS_ERR(req)) | 29 | if (IS_ERR(req)) |
30 | return PTR_ERR(req); | 30 | return PTR_ERR(req); |
31 | 31 | ||
@@ -368,7 +368,7 @@ static int fuse_flush(struct file *file, fl_owner_t id) | |||
368 | if (fc->no_flush) | 368 | if (fc->no_flush) |
369 | return 0; | 369 | return 0; |
370 | 370 | ||
371 | req = fuse_get_req_nofail(fc, file); | 371 | req = fuse_get_req_nofail_nopages(fc, file); |
372 | memset(&inarg, 0, sizeof(inarg)); | 372 | memset(&inarg, 0, sizeof(inarg)); |
373 | inarg.fh = ff->fh; | 373 | inarg.fh = ff->fh; |
374 | inarg.lock_owner = fuse_lock_owner_id(fc, id); | 374 | inarg.lock_owner = fuse_lock_owner_id(fc, id); |
@@ -436,7 +436,7 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, | |||
436 | 436 | ||
437 | fuse_sync_writes(inode); | 437 | fuse_sync_writes(inode); |
438 | 438 | ||
439 | req = fuse_get_req(fc); | 439 | req = fuse_get_req_nopages(fc); |
440 | if (IS_ERR(req)) { | 440 | if (IS_ERR(req)) { |
441 | err = PTR_ERR(req); | 441 | err = PTR_ERR(req); |
442 | goto out; | 442 | goto out; |
@@ -544,7 +544,7 @@ static int fuse_readpage(struct file *file, struct page *page) | |||
544 | */ | 544 | */ |
545 | fuse_wait_on_page_writeback(inode, page->index); | 545 | fuse_wait_on_page_writeback(inode, page->index); |
546 | 546 | ||
547 | req = fuse_get_req(fc); | 547 | req = fuse_get_req(fc, 1); |
548 | err = PTR_ERR(req); | 548 | err = PTR_ERR(req); |
549 | if (IS_ERR(req)) | 549 | if (IS_ERR(req)) |
550 | goto out; | 550 | goto out; |
@@ -657,7 +657,7 @@ static int fuse_readpages_fill(void *_data, struct page *page) | |||
657 | (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || | 657 | (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || |
658 | req->pages[req->num_pages - 1]->index + 1 != page->index)) { | 658 | req->pages[req->num_pages - 1]->index + 1 != page->index)) { |
659 | fuse_send_readpages(req, data->file); | 659 | fuse_send_readpages(req, data->file); |
660 | data->req = req = fuse_get_req(fc); | 660 | data->req = req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
661 | if (IS_ERR(req)) { | 661 | if (IS_ERR(req)) { |
662 | unlock_page(page); | 662 | unlock_page(page); |
663 | return PTR_ERR(req); | 663 | return PTR_ERR(req); |
@@ -683,7 +683,7 @@ static int fuse_readpages(struct file *file, struct address_space *mapping, | |||
683 | 683 | ||
684 | data.file = file; | 684 | data.file = file; |
685 | data.inode = inode; | 685 | data.inode = inode; |
686 | data.req = fuse_get_req(fc); | 686 | data.req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
687 | err = PTR_ERR(data.req); | 687 | err = PTR_ERR(data.req); |
688 | if (IS_ERR(data.req)) | 688 | if (IS_ERR(data.req)) |
689 | goto out; | 689 | goto out; |
@@ -890,7 +890,7 @@ static ssize_t fuse_perform_write(struct file *file, | |||
890 | struct fuse_req *req; | 890 | struct fuse_req *req; |
891 | ssize_t count; | 891 | ssize_t count; |
892 | 892 | ||
893 | req = fuse_get_req(fc); | 893 | req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
894 | if (IS_ERR(req)) { | 894 | if (IS_ERR(req)) { |
895 | err = PTR_ERR(req); | 895 | err = PTR_ERR(req); |
896 | break; | 896 | break; |
@@ -1072,7 +1072,7 @@ ssize_t fuse_direct_io(struct file *file, const char __user *buf, | |||
1072 | ssize_t res = 0; | 1072 | ssize_t res = 0; |
1073 | struct fuse_req *req; | 1073 | struct fuse_req *req; |
1074 | 1074 | ||
1075 | req = fuse_get_req(fc); | 1075 | req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
1076 | if (IS_ERR(req)) | 1076 | if (IS_ERR(req)) |
1077 | return PTR_ERR(req); | 1077 | return PTR_ERR(req); |
1078 | 1078 | ||
@@ -1108,7 +1108,7 @@ ssize_t fuse_direct_io(struct file *file, const char __user *buf, | |||
1108 | break; | 1108 | break; |
1109 | if (count) { | 1109 | if (count) { |
1110 | fuse_put_request(fc, req); | 1110 | fuse_put_request(fc, req); |
1111 | req = fuse_get_req(fc); | 1111 | req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
1112 | if (IS_ERR(req)) | 1112 | if (IS_ERR(req)) |
1113 | break; | 1113 | break; |
1114 | } | 1114 | } |
@@ -1471,7 +1471,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) | |||
1471 | struct fuse_lk_out outarg; | 1471 | struct fuse_lk_out outarg; |
1472 | int err; | 1472 | int err; |
1473 | 1473 | ||
1474 | req = fuse_get_req(fc); | 1474 | req = fuse_get_req_nopages(fc); |
1475 | if (IS_ERR(req)) | 1475 | if (IS_ERR(req)) |
1476 | return PTR_ERR(req); | 1476 | return PTR_ERR(req); |
1477 | 1477 | ||
@@ -1506,7 +1506,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) | |||
1506 | if (fl->fl_flags & FL_CLOSE) | 1506 | if (fl->fl_flags & FL_CLOSE) |
1507 | return 0; | 1507 | return 0; |
1508 | 1508 | ||
1509 | req = fuse_get_req(fc); | 1509 | req = fuse_get_req_nopages(fc); |
1510 | if (IS_ERR(req)) | 1510 | if (IS_ERR(req)) |
1511 | return PTR_ERR(req); | 1511 | return PTR_ERR(req); |
1512 | 1512 | ||
@@ -1575,7 +1575,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) | |||
1575 | if (!inode->i_sb->s_bdev || fc->no_bmap) | 1575 | if (!inode->i_sb->s_bdev || fc->no_bmap) |
1576 | return 0; | 1576 | return 0; |
1577 | 1577 | ||
1578 | req = fuse_get_req(fc); | 1578 | req = fuse_get_req_nopages(fc); |
1579 | if (IS_ERR(req)) | 1579 | if (IS_ERR(req)) |
1580 | return 0; | 1580 | return 0; |
1581 | 1581 | ||
@@ -1873,7 +1873,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, | |||
1873 | num_pages++; | 1873 | num_pages++; |
1874 | } | 1874 | } |
1875 | 1875 | ||
1876 | req = fuse_get_req(fc); | 1876 | req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ); |
1877 | if (IS_ERR(req)) { | 1877 | if (IS_ERR(req)) { |
1878 | err = PTR_ERR(req); | 1878 | err = PTR_ERR(req); |
1879 | req = NULL; | 1879 | req = NULL; |
@@ -2076,7 +2076,7 @@ unsigned fuse_file_poll(struct file *file, poll_table *wait) | |||
2076 | fuse_register_polled_file(fc, ff); | 2076 | fuse_register_polled_file(fc, ff); |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | req = fuse_get_req(fc); | 2079 | req = fuse_get_req_nopages(fc); |
2080 | if (IS_ERR(req)) | 2080 | if (IS_ERR(req)) |
2081 | return POLLERR; | 2081 | return POLLERR; |
2082 | 2082 | ||
@@ -2194,7 +2194,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
2194 | if (fc->no_fallocate) | 2194 | if (fc->no_fallocate) |
2195 | return -EOPNOTSUPP; | 2195 | return -EOPNOTSUPP; |
2196 | 2196 | ||
2197 | req = fuse_get_req(fc); | 2197 | req = fuse_get_req_nopages(fc); |
2198 | if (IS_ERR(req)) | 2198 | if (IS_ERR(req)) |
2199 | return PTR_ERR(req); | 2199 | return PTR_ERR(req); |
2200 | 2200 | ||
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 0c5b9310f930..5b21e6ab9e75 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -683,14 +683,25 @@ struct fuse_req *fuse_request_alloc_nofs(unsigned npages); | |||
683 | void fuse_request_free(struct fuse_req *req); | 683 | void fuse_request_free(struct fuse_req *req); |
684 | 684 | ||
685 | /** | 685 | /** |
686 | * Get a request, may fail with -ENOMEM | 686 | * Get a request, may fail with -ENOMEM, |
687 | * caller should specify # elements in req->pages[] explicitly | ||
687 | */ | 688 | */ |
688 | struct fuse_req *fuse_get_req(struct fuse_conn *fc); | 689 | struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages); |
690 | |||
691 | /** | ||
692 | * Get a request, may fail with -ENOMEM, | ||
693 | * useful for callers who doesn't use req->pages[] | ||
694 | */ | ||
695 | static inline struct fuse_req *fuse_get_req_nopages(struct fuse_conn *fc) | ||
696 | { | ||
697 | return fuse_get_req(fc, 0); | ||
698 | } | ||
689 | 699 | ||
690 | /** | 700 | /** |
691 | * Gets a requests for a file operation, always succeeds | 701 | * Gets a requests for a file operation, always succeeds |
692 | */ | 702 | */ |
693 | struct fuse_req *fuse_get_req_nofail(struct fuse_conn *fc, struct file *file); | 703 | struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc, |
704 | struct file *file); | ||
694 | 705 | ||
695 | /** | 706 | /** |
696 | * Decrement reference count of a request. If count goes to zero free | 707 | * Decrement reference count of a request. If count goes to zero free |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 9a937f0239e8..9d95a5a3d55c 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -413,7 +413,7 @@ static int fuse_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
413 | return 0; | 413 | return 0; |
414 | } | 414 | } |
415 | 415 | ||
416 | req = fuse_get_req(fc); | 416 | req = fuse_get_req_nopages(fc); |
417 | if (IS_ERR(req)) | 417 | if (IS_ERR(req)) |
418 | return PTR_ERR(req); | 418 | return PTR_ERR(req); |
419 | 419 | ||