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.c216
1 files changed, 137 insertions, 79 deletions
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 698a8636d39c..76d2a79ef93e 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -31,6 +31,7 @@
31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 */ 32 */
33 33
34#include <linux/slab.h>
34#include <linux/writeback.h> 35#include <linux/writeback.h>
35#include <linux/buffer_head.h> 36#include <linux/buffer_head.h>
36#include <scsi/scsi_device.h> 37#include <scsi/scsi_device.h>
@@ -41,16 +42,18 @@
41 42
42enum { BIO_MAX_PAGES_KMALLOC = 43enum { BIO_MAX_PAGES_KMALLOC =
43 (PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec), 44 (PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec),
45 MAX_PAGES_KMALLOC =
46 PAGE_SIZE / sizeof(struct page *),
44}; 47};
45 48
46struct page_collect { 49struct page_collect {
47 struct exofs_sb_info *sbi; 50 struct exofs_sb_info *sbi;
48 struct request_queue *req_q;
49 struct inode *inode; 51 struct inode *inode;
50 unsigned expected_pages; 52 unsigned expected_pages;
51 struct exofs_io_state *ios; 53 struct exofs_io_state *ios;
52 54
53 struct bio *bio; 55 struct page **pages;
56 unsigned alloc_pages;
54 unsigned nr_pages; 57 unsigned nr_pages;
55 unsigned long length; 58 unsigned long length;
56 loff_t pg_first; /* keep 64bit also in 32-arches */ 59 loff_t pg_first; /* keep 64bit also in 32-arches */
@@ -62,15 +65,12 @@ static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
62 struct exofs_sb_info *sbi = inode->i_sb->s_fs_info; 65 struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
63 66
64 pcol->sbi = sbi; 67 pcol->sbi = sbi;
65 /* Create master bios on first Q, later on cloning, each clone will be
66 * allocated on it's destination Q
67 */
68 pcol->req_q = osd_request_queue(sbi->s_ods[0]);
69 pcol->inode = inode; 68 pcol->inode = inode;
70 pcol->expected_pages = expected_pages; 69 pcol->expected_pages = expected_pages;
71 70
72 pcol->ios = NULL; 71 pcol->ios = NULL;
73 pcol->bio = NULL; 72 pcol->pages = NULL;
73 pcol->alloc_pages = 0;
74 pcol->nr_pages = 0; 74 pcol->nr_pages = 0;
75 pcol->length = 0; 75 pcol->length = 0;
76 pcol->pg_first = -1; 76 pcol->pg_first = -1;
@@ -80,7 +80,8 @@ static void _pcol_reset(struct page_collect *pcol)
80{ 80{
81 pcol->expected_pages -= min(pcol->nr_pages, pcol->expected_pages); 81 pcol->expected_pages -= min(pcol->nr_pages, pcol->expected_pages);
82 82
83 pcol->bio = NULL; 83 pcol->pages = NULL;
84 pcol->alloc_pages = 0;
84 pcol->nr_pages = 0; 85 pcol->nr_pages = 0;
85 pcol->length = 0; 86 pcol->length = 0;
86 pcol->pg_first = -1; 87 pcol->pg_first = -1;
@@ -90,38 +91,43 @@ static void _pcol_reset(struct page_collect *pcol)
90 * it might not end here. don't be left with nothing 91 * it might not end here. don't be left with nothing
91 */ 92 */
92 if (!pcol->expected_pages) 93 if (!pcol->expected_pages)
93 pcol->expected_pages = BIO_MAX_PAGES_KMALLOC; 94 pcol->expected_pages = MAX_PAGES_KMALLOC;
94} 95}
95 96
96static int pcol_try_alloc(struct page_collect *pcol) 97static int pcol_try_alloc(struct page_collect *pcol)
97{ 98{
98 int pages = min_t(unsigned, pcol->expected_pages, 99 unsigned pages = min_t(unsigned, pcol->expected_pages,
99 BIO_MAX_PAGES_KMALLOC); 100 MAX_PAGES_KMALLOC);
100 101
101 if (!pcol->ios) { /* First time allocate io_state */ 102 if (!pcol->ios) { /* First time allocate io_state */
102 int ret = exofs_get_io_state(pcol->sbi, &pcol->ios); 103 int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios);
103 104
104 if (ret) 105 if (ret)
105 return ret; 106 return ret;
106 } 107 }
107 108
109 /* TODO: easily support bio chaining */
110 pages = min_t(unsigned, pages,
111 pcol->sbi->layout.group_width * BIO_MAX_PAGES_KMALLOC);
112
108 for (; pages; pages >>= 1) { 113 for (; pages; pages >>= 1) {
109 pcol->bio = bio_kmalloc(GFP_KERNEL, pages); 114 pcol->pages = kmalloc(pages * sizeof(struct page *),
110 if (likely(pcol->bio)) 115 GFP_KERNEL);
116 if (likely(pcol->pages)) {
117 pcol->alloc_pages = pages;
111 return 0; 118 return 0;
119 }
112 } 120 }
113 121
114 EXOFS_ERR("Failed to bio_kmalloc expected_pages=%u\n", 122 EXOFS_ERR("Failed to kmalloc expected_pages=%u\n",
115 pcol->expected_pages); 123 pcol->expected_pages);
116 return -ENOMEM; 124 return -ENOMEM;
117} 125}
118 126
119static void pcol_free(struct page_collect *pcol) 127static void pcol_free(struct page_collect *pcol)
120{ 128{
121 if (pcol->bio) { 129 kfree(pcol->pages);
122 bio_put(pcol->bio); 130 pcol->pages = NULL;
123 pcol->bio = NULL;
124 }
125 131
126 if (pcol->ios) { 132 if (pcol->ios) {
127 exofs_put_io_state(pcol->ios); 133 exofs_put_io_state(pcol->ios);
@@ -132,11 +138,10 @@ static void pcol_free(struct page_collect *pcol)
132static int pcol_add_page(struct page_collect *pcol, struct page *page, 138static int pcol_add_page(struct page_collect *pcol, struct page *page,
133 unsigned len) 139 unsigned len)
134{ 140{
135 int added_len = bio_add_pc_page(pcol->req_q, pcol->bio, page, len, 0); 141 if (unlikely(pcol->nr_pages >= pcol->alloc_pages))
136 if (unlikely(len != added_len))
137 return -ENOMEM; 142 return -ENOMEM;
138 143
139 ++pcol->nr_pages; 144 pcol->pages[pcol->nr_pages++] = page;
140 pcol->length += len; 145 pcol->length += len;
141 return 0; 146 return 0;
142} 147}
@@ -181,7 +186,6 @@ static void update_write_page(struct page *page, int ret)
181 */ 186 */
182static int __readpages_done(struct page_collect *pcol, bool do_unlock) 187static int __readpages_done(struct page_collect *pcol, bool do_unlock)
183{ 188{
184 struct bio_vec *bvec;
185 int i; 189 int i;
186 u64 resid; 190 u64 resid;
187 u64 good_bytes; 191 u64 good_bytes;
@@ -193,13 +197,13 @@ static int __readpages_done(struct page_collect *pcol, bool do_unlock)
193 else 197 else
194 good_bytes = pcol->length - resid; 198 good_bytes = pcol->length - resid;
195 199
196 EXOFS_DBGMSG("readpages_done(0x%lx) good_bytes=0x%llx" 200 EXOFS_DBGMSG2("readpages_done(0x%lx) good_bytes=0x%llx"
197 " length=0x%lx nr_pages=%u\n", 201 " length=0x%lx nr_pages=%u\n",
198 pcol->inode->i_ino, _LLU(good_bytes), pcol->length, 202 pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
199 pcol->nr_pages); 203 pcol->nr_pages);
200 204
201 __bio_for_each_segment(bvec, pcol->bio, i, 0) { 205 for (i = 0; i < pcol->nr_pages; i++) {
202 struct page *page = bvec->bv_page; 206 struct page *page = pcol->pages[i];
203 struct inode *inode = page->mapping->host; 207 struct inode *inode = page->mapping->host;
204 int page_stat; 208 int page_stat;
205 209
@@ -218,11 +222,11 @@ static int __readpages_done(struct page_collect *pcol, bool do_unlock)
218 ret = update_read_page(page, page_stat); 222 ret = update_read_page(page, page_stat);
219 if (do_unlock) 223 if (do_unlock)
220 unlock_page(page); 224 unlock_page(page);
221 length += bvec->bv_len; 225 length += PAGE_SIZE;
222 } 226 }
223 227
224 pcol_free(pcol); 228 pcol_free(pcol);
225 EXOFS_DBGMSG("readpages_done END\n"); 229 EXOFS_DBGMSG2("readpages_done END\n");
226 return ret; 230 return ret;
227} 231}
228 232
@@ -238,11 +242,10 @@ static void readpages_done(struct exofs_io_state *ios, void *p)
238 242
239static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw) 243static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw)
240{ 244{
241 struct bio_vec *bvec;
242 int i; 245 int i;
243 246
244 __bio_for_each_segment(bvec, pcol->bio, i, 0) { 247 for (i = 0; i < pcol->nr_pages; i++) {
245 struct page *page = bvec->bv_page; 248 struct page *page = pcol->pages[i];
246 249
247 if (rw == READ) 250 if (rw == READ)
248 update_read_page(page, ret); 251 update_read_page(page, ret);
@@ -260,13 +263,14 @@ static int read_exec(struct page_collect *pcol, bool is_sync)
260 struct page_collect *pcol_copy = NULL; 263 struct page_collect *pcol_copy = NULL;
261 int ret; 264 int ret;
262 265
263 if (!pcol->bio) 266 if (!pcol->pages)
264 return 0; 267 return 0;
265 268
266 /* see comment in _readpage() about sync reads */ 269 /* see comment in _readpage() about sync reads */
267 WARN_ON(is_sync && (pcol->nr_pages != 1)); 270 WARN_ON(is_sync && (pcol->nr_pages != 1));
268 271
269 ios->bio = pcol->bio; 272 ios->pages = pcol->pages;
273 ios->nr_pages = pcol->nr_pages;
270 ios->length = pcol->length; 274 ios->length = pcol->length;
271 ios->offset = pcol->pg_first << PAGE_CACHE_SHIFT; 275 ios->offset = pcol->pg_first << PAGE_CACHE_SHIFT;
272 276
@@ -290,7 +294,7 @@ static int read_exec(struct page_collect *pcol, bool is_sync)
290 294
291 atomic_inc(&pcol->sbi->s_curr_pending); 295 atomic_inc(&pcol->sbi->s_curr_pending);
292 296
293 EXOFS_DBGMSG("read_exec obj=0x%llx start=0x%llx length=0x%lx\n", 297 EXOFS_DBGMSG2("read_exec obj=0x%llx start=0x%llx length=0x%lx\n",
294 ios->obj.id, _LLU(ios->offset), pcol->length); 298 ios->obj.id, _LLU(ios->offset), pcol->length);
295 299
296 /* pages ownership was passed to pcol_copy */ 300 /* pages ownership was passed to pcol_copy */
@@ -366,7 +370,7 @@ try_again:
366 goto try_again; 370 goto try_again;
367 } 371 }
368 372
369 if (!pcol->bio) { 373 if (!pcol->pages) {
370 ret = pcol_try_alloc(pcol); 374 ret = pcol_try_alloc(pcol);
371 if (unlikely(ret)) 375 if (unlikely(ret))
372 goto fail; 376 goto fail;
@@ -448,7 +452,6 @@ static int exofs_readpage(struct file *file, struct page *page)
448static void writepages_done(struct exofs_io_state *ios, void *p) 452static void writepages_done(struct exofs_io_state *ios, void *p)
449{ 453{
450 struct page_collect *pcol = p; 454 struct page_collect *pcol = p;
451 struct bio_vec *bvec;
452 int i; 455 int i;
453 u64 resid; 456 u64 resid;
454 u64 good_bytes; 457 u64 good_bytes;
@@ -462,13 +465,13 @@ static void writepages_done(struct exofs_io_state *ios, void *p)
462 else 465 else
463 good_bytes = pcol->length - resid; 466 good_bytes = pcol->length - resid;
464 467
465 EXOFS_DBGMSG("writepages_done(0x%lx) good_bytes=0x%llx" 468 EXOFS_DBGMSG2("writepages_done(0x%lx) good_bytes=0x%llx"
466 " length=0x%lx nr_pages=%u\n", 469 " length=0x%lx nr_pages=%u\n",
467 pcol->inode->i_ino, _LLU(good_bytes), pcol->length, 470 pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
468 pcol->nr_pages); 471 pcol->nr_pages);
469 472
470 __bio_for_each_segment(bvec, pcol->bio, i, 0) { 473 for (i = 0; i < pcol->nr_pages; i++) {
471 struct page *page = bvec->bv_page; 474 struct page *page = pcol->pages[i];
472 struct inode *inode = page->mapping->host; 475 struct inode *inode = page->mapping->host;
473 int page_stat; 476 int page_stat;
474 477
@@ -485,12 +488,12 @@ static void writepages_done(struct exofs_io_state *ios, void *p)
485 EXOFS_DBGMSG2(" writepages_done(0x%lx, 0x%lx) status=%d\n", 488 EXOFS_DBGMSG2(" writepages_done(0x%lx, 0x%lx) status=%d\n",
486 inode->i_ino, page->index, page_stat); 489 inode->i_ino, page->index, page_stat);
487 490
488 length += bvec->bv_len; 491 length += PAGE_SIZE;
489 } 492 }
490 493
491 pcol_free(pcol); 494 pcol_free(pcol);
492 kfree(pcol); 495 kfree(pcol);
493 EXOFS_DBGMSG("writepages_done END\n"); 496 EXOFS_DBGMSG2("writepages_done END\n");
494} 497}
495 498
496static int write_exec(struct page_collect *pcol) 499static int write_exec(struct page_collect *pcol)
@@ -500,7 +503,7 @@ static int write_exec(struct page_collect *pcol)
500 struct page_collect *pcol_copy = NULL; 503 struct page_collect *pcol_copy = NULL;
501 int ret; 504 int ret;
502 505
503 if (!pcol->bio) 506 if (!pcol->pages)
504 return 0; 507 return 0;
505 508
506 pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL); 509 pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
@@ -512,9 +515,8 @@ static int write_exec(struct page_collect *pcol)
512 515
513 *pcol_copy = *pcol; 516 *pcol_copy = *pcol;
514 517
515 pcol_copy->bio->bi_rw |= (1 << BIO_RW); /* FIXME: bio_set_dir() */ 518 ios->pages = pcol_copy->pages;
516 519 ios->nr_pages = pcol_copy->nr_pages;
517 ios->bio = pcol_copy->bio;
518 ios->offset = pcol_copy->pg_first << PAGE_CACHE_SHIFT; 520 ios->offset = pcol_copy->pg_first << PAGE_CACHE_SHIFT;
519 ios->length = pcol_copy->length; 521 ios->length = pcol_copy->length;
520 ios->done = writepages_done; 522 ios->done = writepages_done;
@@ -527,7 +529,7 @@ static int write_exec(struct page_collect *pcol)
527 } 529 }
528 530
529 atomic_inc(&pcol->sbi->s_curr_pending); 531 atomic_inc(&pcol->sbi->s_curr_pending);
530 EXOFS_DBGMSG("write_exec(0x%lx, 0x%llx) start=0x%llx length=0x%lx\n", 532 EXOFS_DBGMSG2("write_exec(0x%lx, 0x%llx) start=0x%llx length=0x%lx\n",
531 pcol->inode->i_ino, pcol->pg_first, _LLU(ios->offset), 533 pcol->inode->i_ino, pcol->pg_first, _LLU(ios->offset),
532 pcol->length); 534 pcol->length);
533 /* pages ownership was passed to pcol_copy */ 535 /* pages ownership was passed to pcol_copy */
@@ -605,7 +607,7 @@ try_again:
605 goto try_again; 607 goto try_again;
606 } 608 }
607 609
608 if (!pcol->bio) { 610 if (!pcol->pages) {
609 ret = pcol_try_alloc(pcol); 611 ret = pcol_try_alloc(pcol);
610 if (unlikely(ret)) 612 if (unlikely(ret))
611 goto fail; 613 goto fail;
@@ -616,7 +618,7 @@ try_again:
616 618
617 ret = pcol_add_page(pcol, page, len); 619 ret = pcol_add_page(pcol, page, len);
618 if (unlikely(ret)) { 620 if (unlikely(ret)) {
619 EXOFS_DBGMSG("Failed pcol_add_page " 621 EXOFS_DBGMSG2("Failed pcol_add_page "
620 "nr_pages=%u total_length=0x%lx\n", 622 "nr_pages=%u total_length=0x%lx\n",
621 pcol->nr_pages, pcol->length); 623 pcol->nr_pages, pcol->length);
622 624
@@ -663,7 +665,7 @@ static int exofs_writepages(struct address_space *mapping,
663 if (expected_pages < 32L) 665 if (expected_pages < 32L)
664 expected_pages = 32L; 666 expected_pages = 32L;
665 667
666 EXOFS_DBGMSG("inode(0x%lx) wbc->start=0x%llx wbc->end=0x%llx " 668 EXOFS_DBGMSG2("inode(0x%lx) wbc->start=0x%llx wbc->end=0x%llx "
667 "nrpages=%lu start=0x%lx end=0x%lx expected_pages=%ld\n", 669 "nrpages=%lu start=0x%lx end=0x%lx expected_pages=%ld\n",
668 mapping->host->i_ino, wbc->range_start, wbc->range_end, 670 mapping->host->i_ino, wbc->range_start, wbc->range_end,
669 mapping->nrpages, start, end, expected_pages); 671 mapping->nrpages, start, end, expected_pages);
@@ -738,13 +740,28 @@ static int exofs_write_begin_export(struct file *file,
738 fsdata); 740 fsdata);
739} 741}
740 742
743static int exofs_write_end(struct file *file, struct address_space *mapping,
744 loff_t pos, unsigned len, unsigned copied,
745 struct page *page, void *fsdata)
746{
747 struct inode *inode = mapping->host;
748 /* According to comment in simple_write_end i_mutex is held */
749 loff_t i_size = inode->i_size;
750 int ret;
751
752 ret = simple_write_end(file, mapping,pos, len, copied, page, fsdata);
753 if (i_size != inode->i_size)
754 mark_inode_dirty(inode);
755 return ret;
756}
757
741const struct address_space_operations exofs_aops = { 758const struct address_space_operations exofs_aops = {
742 .readpage = exofs_readpage, 759 .readpage = exofs_readpage,
743 .readpages = exofs_readpages, 760 .readpages = exofs_readpages,
744 .writepage = exofs_writepage, 761 .writepage = exofs_writepage,
745 .writepages = exofs_writepages, 762 .writepages = exofs_writepages,
746 .write_begin = exofs_write_begin_export, 763 .write_begin = exofs_write_begin_export,
747 .write_end = simple_write_end, 764 .write_end = exofs_write_end,
748}; 765};
749 766
750/****************************************************************************** 767/******************************************************************************
@@ -844,20 +861,33 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
844 return error; 861 return error;
845} 862}
846 863
864static const struct osd_attr g_attr_inode_file_layout = ATTR_DEF(
865 EXOFS_APAGE_FS_DATA,
866 EXOFS_ATTR_INODE_FILE_LAYOUT,
867 0);
868static const struct osd_attr g_attr_inode_dir_layout = ATTR_DEF(
869 EXOFS_APAGE_FS_DATA,
870 EXOFS_ATTR_INODE_DIR_LAYOUT,
871 0);
872
847/* 873/*
848 * Read an inode from the OSD, and return it as is. We also return the size 874 * Read the Linux inode info from the OSD, and return it as is. In exofs the
849 * attribute in the 'obj_size' argument. 875 * inode info is in an application specific page/attribute of the osd-object.
850 */ 876 */
851static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi, 877static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
852 struct exofs_fcb *inode, uint64_t *obj_size) 878 struct exofs_fcb *inode)
853{ 879{
854 struct exofs_sb_info *sbi = sb->s_fs_info; 880 struct exofs_sb_info *sbi = sb->s_fs_info;
855 struct osd_attr attrs[2]; 881 struct osd_attr attrs[] = {
882 [0] = g_attr_inode_data,
883 [1] = g_attr_inode_file_layout,
884 [2] = g_attr_inode_dir_layout,
885 };
856 struct exofs_io_state *ios; 886 struct exofs_io_state *ios;
887 struct exofs_on_disk_inode_layout *layout;
857 int ret; 888 int ret;
858 889
859 *obj_size = ~0; 890 ret = exofs_get_io_state(&sbi->layout, &ios);
860 ret = exofs_get_io_state(sbi, &ios);
861 if (unlikely(ret)) { 891 if (unlikely(ret)) {
862 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); 892 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
863 return ret; 893 return ret;
@@ -867,14 +897,25 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
867 exofs_make_credential(oi->i_cred, &ios->obj); 897 exofs_make_credential(oi->i_cred, &ios->obj);
868 ios->cred = oi->i_cred; 898 ios->cred = oi->i_cred;
869 899
870 attrs[0] = g_attr_inode_data; 900 attrs[1].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
871 attrs[1] = g_attr_logical_length; 901 attrs[2].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
902
872 ios->in_attr = attrs; 903 ios->in_attr = attrs;
873 ios->in_attr_len = ARRAY_SIZE(attrs); 904 ios->in_attr_len = ARRAY_SIZE(attrs);
874 905
875 ret = exofs_sbi_read(ios); 906 ret = exofs_sbi_read(ios);
876 if (ret) 907 if (unlikely(ret)) {
908 EXOFS_ERR("object(0x%llx) corrupted, return empty file=>%d\n",
909 _LLU(ios->obj.id), ret);
910 memset(inode, 0, sizeof(*inode));
911 inode->i_mode = 0040000 | (0777 & ~022);
912 /* If object is lost on target we might as well enable it's
913 * delete.
914 */
915 if ((ret == -ENOENT) || (ret == -EINVAL))
916 ret = 0;
877 goto out; 917 goto out;
918 }
878 919
879 ret = extract_attr_from_ios(ios, &attrs[0]); 920 ret = extract_attr_from_ios(ios, &attrs[0]);
880 if (ret) { 921 if (ret) {
@@ -886,11 +927,33 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
886 927
887 ret = extract_attr_from_ios(ios, &attrs[1]); 928 ret = extract_attr_from_ios(ios, &attrs[1]);
888 if (ret) { 929 if (ret) {
889 EXOFS_ERR("%s: extract_attr of logical_length failed\n", 930 EXOFS_ERR("%s: extract_attr of inode_data failed\n", __func__);
890 __func__);
891 goto out; 931 goto out;
892 } 932 }
893 *obj_size = get_unaligned_be64(attrs[1].val_ptr); 933 if (attrs[1].len) {
934 layout = attrs[1].val_ptr;
935 if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
936 EXOFS_ERR("%s: unsupported files layout %d\n",
937 __func__, layout->gen_func);
938 ret = -ENOTSUPP;
939 goto out;
940 }
941 }
942
943 ret = extract_attr_from_ios(ios, &attrs[2]);
944 if (ret) {
945 EXOFS_ERR("%s: extract_attr of inode_data failed\n", __func__);
946 goto out;
947 }
948 if (attrs[2].len) {
949 layout = attrs[2].val_ptr;
950 if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
951 EXOFS_ERR("%s: unsupported meta-data layout %d\n",
952 __func__, layout->gen_func);
953 ret = -ENOTSUPP;
954 goto out;
955 }
956 }
894 957
895out: 958out:
896 exofs_put_io_state(ios); 959 exofs_put_io_state(ios);
@@ -910,7 +973,6 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
910 struct exofs_i_info *oi; 973 struct exofs_i_info *oi;
911 struct exofs_fcb fcb; 974 struct exofs_fcb fcb;
912 struct inode *inode; 975 struct inode *inode;
913 uint64_t obj_size;
914 int ret; 976 int ret;
915 977
916 inode = iget_locked(sb, ino); 978 inode = iget_locked(sb, ino);
@@ -922,7 +984,7 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
922 __oi_init(oi); 984 __oi_init(oi);
923 985
924 /* read the inode from the osd */ 986 /* read the inode from the osd */
925 ret = exofs_get_inode(sb, oi, &fcb, &obj_size); 987 ret = exofs_get_inode(sb, oi, &fcb);
926 if (ret) 988 if (ret)
927 goto bad_inode; 989 goto bad_inode;
928 990
@@ -943,13 +1005,6 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
943 inode->i_blkbits = EXOFS_BLKSHIFT; 1005 inode->i_blkbits = EXOFS_BLKSHIFT;
944 inode->i_generation = le32_to_cpu(fcb.i_generation); 1006 inode->i_generation = le32_to_cpu(fcb.i_generation);
945 1007
946 if ((inode->i_size != obj_size) &&
947 (!exofs_inode_is_fast_symlink(inode))) {
948 EXOFS_ERR("WARNING: Size of inode=%llu != object=%llu\n",
949 inode->i_size, _LLU(obj_size));
950 /* FIXME: call exofs_inode_recovery() */
951 }
952
953 oi->i_dir_start_lookup = 0; 1008 oi->i_dir_start_lookup = 0;
954 1009
955 if ((inode->i_nlink == 0) && (inode->i_mode == 0)) { 1010 if ((inode->i_nlink == 0) && (inode->i_mode == 0)) {
@@ -1028,7 +1083,7 @@ static void create_done(struct exofs_io_state *ios, void *p)
1028 1083
1029 if (unlikely(ret)) { 1084 if (unlikely(ret)) {
1030 EXOFS_ERR("object=0x%llx creation faild in pid=0x%llx", 1085 EXOFS_ERR("object=0x%llx creation faild in pid=0x%llx",
1031 _LLU(exofs_oi_objno(oi)), _LLU(sbi->s_pid)); 1086 _LLU(exofs_oi_objno(oi)), _LLU(sbi->layout.s_pid));
1032 /*TODO: When FS is corrupted creation can fail, object already 1087 /*TODO: When FS is corrupted creation can fail, object already
1033 * exist. Get rid of this asynchronous creation, if exist 1088 * exist. Get rid of this asynchronous creation, if exist
1034 * increment the obj counter and try the next object. Until we 1089 * increment the obj counter and try the next object. Until we
@@ -1089,7 +1144,7 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)
1089 1144
1090 mark_inode_dirty(inode); 1145 mark_inode_dirty(inode);
1091 1146
1092 ret = exofs_get_io_state(sbi, &ios); 1147 ret = exofs_get_io_state(&sbi->layout, &ios);
1093 if (unlikely(ret)) { 1148 if (unlikely(ret)) {
1094 EXOFS_ERR("exofs_new_inode: exofs_get_io_state failed\n"); 1149 EXOFS_ERR("exofs_new_inode: exofs_get_io_state failed\n");
1095 return ERR_PTR(ret); 1150 return ERR_PTR(ret);
@@ -1155,8 +1210,10 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
1155 int ret; 1210 int ret;
1156 1211
1157 args = kzalloc(sizeof(*args), GFP_KERNEL); 1212 args = kzalloc(sizeof(*args), GFP_KERNEL);
1158 if (!args) 1213 if (!args) {
1214 EXOFS_DBGMSG("Faild kzalloc of args\n");
1159 return -ENOMEM; 1215 return -ENOMEM;
1216 }
1160 1217
1161 fcb = &args->fcb; 1218 fcb = &args->fcb;
1162 1219
@@ -1185,7 +1242,7 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
1185 } else 1242 } else
1186 memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data)); 1243 memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data));
1187 1244
1188 ret = exofs_get_io_state(sbi, &ios); 1245 ret = exofs_get_io_state(&sbi->layout, &ios);
1189 if (unlikely(ret)) { 1246 if (unlikely(ret)) {
1190 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); 1247 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
1191 goto free_args; 1248 goto free_args;
@@ -1219,13 +1276,14 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
1219free_args: 1276free_args:
1220 kfree(args); 1277 kfree(args);
1221out: 1278out:
1222 EXOFS_DBGMSG("ret=>%d\n", ret); 1279 EXOFS_DBGMSG("(0x%lx) do_sync=%d ret=>%d\n",
1280 inode->i_ino, do_sync, ret);
1223 return ret; 1281 return ret;
1224} 1282}
1225 1283
1226int exofs_write_inode(struct inode *inode, int wait) 1284int exofs_write_inode(struct inode *inode, struct writeback_control *wbc)
1227{ 1285{
1228 return exofs_update_inode(inode, wait); 1286 return exofs_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
1229} 1287}
1230 1288
1231/* 1289/*
@@ -1268,7 +1326,7 @@ void exofs_delete_inode(struct inode *inode)
1268 1326
1269 clear_inode(inode); 1327 clear_inode(inode);
1270 1328
1271 ret = exofs_get_io_state(sbi, &ios); 1329 ret = exofs_get_io_state(&sbi->layout, &ios);
1272 if (unlikely(ret)) { 1330 if (unlikely(ret)) {
1273 EXOFS_ERR("%s: exofs_get_io_state failed\n", __func__); 1331 EXOFS_ERR("%s: exofs_get_io_state failed\n", __func__);
1274 return; 1332 return;