diff options
Diffstat (limited to 'fs/exofs/inode.c')
-rw-r--r-- | fs/exofs/inode.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 5badb0c039de..1562c27a2fab 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
@@ -37,15 +37,12 @@ | |||
37 | 37 | ||
38 | #define EXOFS_DBGMSG2(M...) do {} while (0) | 38 | #define EXOFS_DBGMSG2(M...) do {} while (0) |
39 | 39 | ||
40 | enum {MAX_PAGES_KMALLOC = PAGE_SIZE / sizeof(struct page *), }; | ||
41 | |||
42 | unsigned exofs_max_io_pages(struct ore_layout *layout, | 40 | unsigned exofs_max_io_pages(struct ore_layout *layout, |
43 | unsigned expected_pages) | 41 | unsigned expected_pages) |
44 | { | 42 | { |
45 | unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC); | 43 | unsigned pages = min_t(unsigned, expected_pages, |
44 | layout->max_io_length / PAGE_SIZE); | ||
46 | 45 | ||
47 | /* TODO: easily support bio chaining */ | ||
48 | pages = min_t(unsigned, pages, layout->max_io_length / PAGE_SIZE); | ||
49 | return pages; | 46 | return pages; |
50 | } | 47 | } |
51 | 48 | ||
@@ -101,7 +98,8 @@ static void _pcol_reset(struct page_collect *pcol) | |||
101 | * it might not end here. don't be left with nothing | 98 | * it might not end here. don't be left with nothing |
102 | */ | 99 | */ |
103 | if (!pcol->expected_pages) | 100 | if (!pcol->expected_pages) |
104 | pcol->expected_pages = MAX_PAGES_KMALLOC; | 101 | pcol->expected_pages = |
102 | exofs_max_io_pages(&pcol->sbi->layout, ~0); | ||
105 | } | 103 | } |
106 | 104 | ||
107 | static int pcol_try_alloc(struct page_collect *pcol) | 105 | static int pcol_try_alloc(struct page_collect *pcol) |
@@ -389,6 +387,8 @@ static int readpage_strip(void *data, struct page *page) | |||
389 | size_t len; | 387 | size_t len; |
390 | int ret; | 388 | int ret; |
391 | 389 | ||
390 | BUG_ON(!PageLocked(page)); | ||
391 | |||
392 | /* FIXME: Just for debugging, will be removed */ | 392 | /* FIXME: Just for debugging, will be removed */ |
393 | if (PageUptodate(page)) | 393 | if (PageUptodate(page)) |
394 | EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino, | 394 | EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino, |
@@ -572,8 +572,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) | |||
572 | 572 | ||
573 | if (!pcol->that_locked_page || | 573 | if (!pcol->that_locked_page || |
574 | (pcol->that_locked_page->index != index)) { | 574 | (pcol->that_locked_page->index != index)) { |
575 | struct page *page = find_get_page(pcol->inode->i_mapping, index); | 575 | struct page *page; |
576 | loff_t i_size = i_size_read(pcol->inode); | ||
577 | |||
578 | if (offset >= i_size) { | ||
579 | *uptodate = true; | ||
580 | EXOFS_DBGMSG("offset >= i_size index=0x%lx\n", index); | ||
581 | return ZERO_PAGE(0); | ||
582 | } | ||
576 | 583 | ||
584 | page = find_get_page(pcol->inode->i_mapping, index); | ||
577 | if (!page) { | 585 | if (!page) { |
578 | page = find_or_create_page(pcol->inode->i_mapping, | 586 | page = find_or_create_page(pcol->inode->i_mapping, |
579 | index, GFP_NOFS); | 587 | index, GFP_NOFS); |
@@ -602,12 +610,13 @@ static void __r4w_put_page(void *priv, struct page *page) | |||
602 | { | 610 | { |
603 | struct page_collect *pcol = priv; | 611 | struct page_collect *pcol = priv; |
604 | 612 | ||
605 | if (pcol->that_locked_page != page) { | 613 | if ((pcol->that_locked_page != page) && (ZERO_PAGE(0) != page)) { |
606 | EXOFS_DBGMSG("index=0x%lx\n", page->index); | 614 | EXOFS_DBGMSG("index=0x%lx\n", page->index); |
607 | page_cache_release(page); | 615 | page_cache_release(page); |
608 | return; | 616 | return; |
609 | } | 617 | } |
610 | EXOFS_DBGMSG("that_locked_page index=0x%lx\n", page->index); | 618 | EXOFS_DBGMSG("that_locked_page index=0x%lx\n", |
619 | ZERO_PAGE(0) == page ? -1 : page->index); | ||
611 | } | 620 | } |
612 | 621 | ||
613 | static const struct _ore_r4w_op _r4w_op = { | 622 | static const struct _ore_r4w_op _r4w_op = { |