aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exofs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exofs/inode.c')
-rw-r--r--fs/exofs/inode.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index fb9d3805610..681b3cb9b4d 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -43,6 +43,17 @@ enum { BIO_MAX_PAGES_KMALLOC =
43 PAGE_SIZE / sizeof(struct page *), 43 PAGE_SIZE / sizeof(struct page *),
44}; 44};
45 45
46unsigned exofs_max_io_pages(struct exofs_layout *layout,
47 unsigned expected_pages)
48{
49 unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC);
50
51 /* TODO: easily support bio chaining */
52 pages = min_t(unsigned, pages,
53 layout->group_width * BIO_MAX_PAGES_KMALLOC);
54 return pages;
55}
56
46struct page_collect { 57struct page_collect {
47 struct exofs_sb_info *sbi; 58 struct exofs_sb_info *sbi;
48 struct inode *inode; 59 struct inode *inode;
@@ -97,8 +108,7 @@ static void _pcol_reset(struct page_collect *pcol)
97 108
98static int pcol_try_alloc(struct page_collect *pcol) 109static int pcol_try_alloc(struct page_collect *pcol)
99{ 110{
100 unsigned pages = min_t(unsigned, pcol->expected_pages, 111 unsigned pages;
101 MAX_PAGES_KMALLOC);
102 112
103 if (!pcol->ios) { /* First time allocate io_state */ 113 if (!pcol->ios) { /* First time allocate io_state */
104 int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios); 114 int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios);
@@ -108,8 +118,7 @@ static int pcol_try_alloc(struct page_collect *pcol)
108 } 118 }
109 119
110 /* TODO: easily support bio chaining */ 120 /* TODO: easily support bio chaining */
111 pages = min_t(unsigned, pages, 121 pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages);
112 pcol->sbi->layout.group_width * BIO_MAX_PAGES_KMALLOC);
113 122
114 for (; pages; pages >>= 1) { 123 for (; pages; pages >>= 1) {
115 pcol->pages = kmalloc(pages * sizeof(struct page *), 124 pcol->pages = kmalloc(pages * sizeof(struct page *),
@@ -1049,6 +1058,7 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
1049 memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data)); 1058 memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data));
1050 } 1059 }
1051 1060
1061 inode->i_mapping->backing_dev_info = sb->s_bdi;
1052 if (S_ISREG(inode->i_mode)) { 1062 if (S_ISREG(inode->i_mode)) {
1053 inode->i_op = &exofs_file_inode_operations; 1063 inode->i_op = &exofs_file_inode_operations;
1054 inode->i_fop = &exofs_file_operations; 1064 inode->i_fop = &exofs_file_operations;
@@ -1149,6 +1159,7 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)
1149 1159
1150 sbi = sb->s_fs_info; 1160 sbi = sb->s_fs_info;
1151 1161
1162 inode->i_mapping->backing_dev_info = sb->s_bdi;
1152 sb->s_dirt = 1; 1163 sb->s_dirt = 1;
1153 inode_init_owner(inode, dir, mode); 1164 inode_init_owner(inode, dir, mode);
1154 inode->i_ino = sbi->s_nextid++; 1165 inode->i_ino = sbi->s_nextid++;