aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-28 23:44:56 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:38 -0400
commitc1c1d7092072093ad960db2f6c08f06705c57fa4 (patch)
tree115796528882ed5d8d21258ad8cf481765a5035a /fs
parentb1f6a4f294088b3fcf9ae67915ca550a1ded2819 (diff)
nilfs2: get rid of GCDAT inode
This applies prepared rollback function and redirect function of metadata file to DAT file, and eliminates GCDAT inode. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/Makefile2
-rw-r--r--fs/nilfs2/bmap.c16
-rw-r--r--fs/nilfs2/bmap.h2
-rw-r--r--fs/nilfs2/dat.c30
-rw-r--r--fs/nilfs2/gcdat.c87
-rw-r--r--fs/nilfs2/mdt.c9
-rw-r--r--fs/nilfs2/mdt.h1
-rw-r--r--fs/nilfs2/nilfs.h8
-rw-r--r--fs/nilfs2/page.c28
-rw-r--r--fs/nilfs2/segment.c14
-rw-r--r--fs/nilfs2/the_nilfs.c13
-rw-r--r--fs/nilfs2/the_nilfs.h2
12 files changed, 41 insertions, 171 deletions
diff --git a/fs/nilfs2/Makefile b/fs/nilfs2/Makefile
index df3e62c1ddc5..85c98737a146 100644
--- a/fs/nilfs2/Makefile
+++ b/fs/nilfs2/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_NILFS2_FS) += nilfs2.o
2nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \ 2nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \
3 btnode.o bmap.o btree.o direct.o dat.o recovery.o \ 3 btnode.o bmap.o btree.o direct.o dat.o recovery.o \
4 the_nilfs.o segbuf.o segment.o cpfile.o sufile.o \ 4 the_nilfs.o segbuf.o segment.o cpfile.o sufile.o \
5 ifile.o alloc.o gcinode.o ioctl.o gcdat.o 5 ifile.o alloc.o gcinode.o ioctl.o
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 00244402d59e..8b782b062baa 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -533,22 +533,6 @@ void nilfs_bmap_init_gc(struct nilfs_bmap *bmap)
533 nilfs_btree_init_gc(bmap); 533 nilfs_btree_init_gc(bmap);
534} 534}
535 535
536void nilfs_bmap_init_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
537{
538 memcpy(gcbmap, bmap, sizeof(*bmap));
539 init_rwsem(&gcbmap->b_sem);
540 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
541 gcbmap->b_inode = &NILFS_BMAP_I(gcbmap)->vfs_inode;
542}
543
544void nilfs_bmap_commit_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
545{
546 memcpy(bmap, gcbmap, sizeof(*bmap));
547 init_rwsem(&bmap->b_sem);
548 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
549 bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
550}
551
552void nilfs_bmap_save(const struct nilfs_bmap *bmap, 536void nilfs_bmap_save(const struct nilfs_bmap *bmap,
553 struct nilfs_bmap_store *store) 537 struct nilfs_bmap_store *store)
554{ 538{
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h
index 5f3339e3eac9..bde1c0aa2e15 100644
--- a/fs/nilfs2/bmap.h
+++ b/fs/nilfs2/bmap.h
@@ -159,8 +159,6 @@ int nilfs_bmap_lookup_at_level(struct nilfs_bmap *, __u64, int, __u64 *);
159int nilfs_bmap_mark(struct nilfs_bmap *, __u64, int); 159int nilfs_bmap_mark(struct nilfs_bmap *, __u64, int);
160 160
161void nilfs_bmap_init_gc(struct nilfs_bmap *); 161void nilfs_bmap_init_gc(struct nilfs_bmap *);
162void nilfs_bmap_init_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
163void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
164 162
165void nilfs_bmap_save(const struct nilfs_bmap *, struct nilfs_bmap_store *); 163void nilfs_bmap_save(const struct nilfs_bmap *, struct nilfs_bmap_store *);
166void nilfs_bmap_restore(struct nilfs_bmap *, const struct nilfs_bmap_store *); 164void nilfs_bmap_restore(struct nilfs_bmap *, const struct nilfs_bmap_store *);
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index 013146755683..7091c4e0f042 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -36,6 +36,7 @@
36struct nilfs_dat_info { 36struct nilfs_dat_info {
37 struct nilfs_mdt_info mi; 37 struct nilfs_mdt_info mi;
38 struct nilfs_palloc_cache palloc_cache; 38 struct nilfs_palloc_cache palloc_cache;
39 struct nilfs_shadow_map shadow;
39}; 40};
40 41
41static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat) 42static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat)
@@ -327,6 +328,23 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr)
327 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); 328 ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh);
328 if (ret < 0) 329 if (ret < 0)
329 return ret; 330 return ret;
331
332 /*
333 * The given disk block number (blocknr) is not yet written to
334 * the device at this point.
335 *
336 * To prevent nilfs_dat_translate() from returning the
337 * uncommited block number, this makes a copy of the entry
338 * buffer and redirects nilfs_dat_translate() to the copy.
339 */
340 if (!buffer_nilfs_redirected(entry_bh)) {
341 ret = nilfs_mdt_freeze_buffer(dat, entry_bh);
342 if (ret) {
343 brelse(entry_bh);
344 return ret;
345 }
346 }
347
330 kaddr = kmap_atomic(entry_bh->b_page, KM_USER0); 348 kaddr = kmap_atomic(entry_bh->b_page, KM_USER0);
331 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr); 349 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr);
332 if (unlikely(entry->de_blocknr == cpu_to_le64(0))) { 350 if (unlikely(entry->de_blocknr == cpu_to_le64(0))) {
@@ -371,7 +389,7 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr)
371 */ 389 */
372int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) 390int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp)
373{ 391{
374 struct buffer_head *entry_bh; 392 struct buffer_head *entry_bh, *bh;
375 struct nilfs_dat_entry *entry; 393 struct nilfs_dat_entry *entry;
376 sector_t blocknr; 394 sector_t blocknr;
377 void *kaddr; 395 void *kaddr;
@@ -381,6 +399,15 @@ int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp)
381 if (ret < 0) 399 if (ret < 0)
382 return ret; 400 return ret;
383 401
402 if (!nilfs_doing_gc() && buffer_nilfs_redirected(entry_bh)) {
403 bh = nilfs_mdt_get_frozen_buffer(dat, entry_bh);
404 if (bh) {
405 WARN_ON(!buffer_uptodate(bh));
406 brelse(entry_bh);
407 entry_bh = bh;
408 }
409 }
410
384 kaddr = kmap_atomic(entry_bh->b_page, KM_USER0); 411 kaddr = kmap_atomic(entry_bh->b_page, KM_USER0);
385 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr); 412 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr);
386 blocknr = le64_to_cpu(entry->de_blocknr); 413 blocknr = le64_to_cpu(entry->de_blocknr);
@@ -468,6 +495,7 @@ struct inode *nilfs_dat_new(struct the_nilfs *nilfs, size_t entry_size)
468 di = NILFS_DAT_I(dat); 495 di = NILFS_DAT_I(dat);
469 lockdep_set_class(&di->mi.mi_sem, &dat_lock_key); 496 lockdep_set_class(&di->mi.mi_sem, &dat_lock_key);
470 nilfs_palloc_setup_cache(dat, &di->palloc_cache); 497 nilfs_palloc_setup_cache(dat, &di->palloc_cache);
498 nilfs_mdt_setup_shadow_map(dat, &di->shadow);
471 } 499 }
472 return dat; 500 return dat;
473} 501}
diff --git a/fs/nilfs2/gcdat.c b/fs/nilfs2/gcdat.c
deleted file mode 100644
index 84a45d1d5464..000000000000
--- a/fs/nilfs2/gcdat.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * gcdat.c - NILFS shadow DAT inode for GC
3 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Written by Seiji Kihara <kihara@osrg.net>, Amagai Yoshiji <amagai@osrg.net>,
21 * and Ryusuke Konishi <ryusuke@osrg.net>.
22 *
23 */
24
25#include <linux/buffer_head.h>
26#include "nilfs.h"
27#include "page.h"
28#include "mdt.h"
29
30int nilfs_init_gcdat_inode(struct the_nilfs *nilfs)
31{
32 struct inode *dat = nilfs->ns_dat, *gcdat = nilfs->ns_gc_dat;
33 struct nilfs_inode_info *dii = NILFS_I(dat), *gii = NILFS_I(gcdat);
34 int err;
35
36 gcdat->i_state = 0;
37 gcdat->i_blocks = dat->i_blocks;
38 gii->i_flags = dii->i_flags;
39 gii->i_state = dii->i_state | (1 << NILFS_I_GCDAT);
40 gii->i_cno = 0;
41 nilfs_bmap_init_gcdat(gii->i_bmap, dii->i_bmap);
42 err = nilfs_copy_dirty_pages(gcdat->i_mapping, dat->i_mapping);
43 if (unlikely(err))
44 return err;
45
46 return nilfs_copy_dirty_pages(&gii->i_btnode_cache,
47 &dii->i_btnode_cache);
48}
49
50void nilfs_commit_gcdat_inode(struct the_nilfs *nilfs)
51{
52 struct inode *dat = nilfs->ns_dat, *gcdat = nilfs->ns_gc_dat;
53 struct nilfs_inode_info *dii = NILFS_I(dat), *gii = NILFS_I(gcdat);
54 struct address_space *mapping = dat->i_mapping;
55 struct address_space *gmapping = gcdat->i_mapping;
56
57 down_write(&NILFS_MDT(dat)->mi_sem);
58 dat->i_blocks = gcdat->i_blocks;
59 dii->i_flags = gii->i_flags;
60 dii->i_state = gii->i_state & ~(1 << NILFS_I_GCDAT);
61
62 nilfs_bmap_commit_gcdat(gii->i_bmap, dii->i_bmap);
63
64 nilfs_palloc_clear_cache(dat);
65 nilfs_palloc_clear_cache(gcdat);
66 nilfs_clear_dirty_pages(mapping);
67 nilfs_copy_back_pages(mapping, gmapping);
68 /* note: mdt dirty flags should be cleared by segctor. */
69
70 nilfs_clear_dirty_pages(&dii->i_btnode_cache);
71 nilfs_copy_back_pages(&dii->i_btnode_cache, &gii->i_btnode_cache);
72
73 up_write(&NILFS_MDT(dat)->mi_sem);
74}
75
76void nilfs_clear_gcdat_inode(struct the_nilfs *nilfs)
77{
78 struct inode *gcdat = nilfs->ns_gc_dat;
79 struct nilfs_inode_info *gii = NILFS_I(gcdat);
80
81 gcdat->i_state = I_FREEING | I_CLEAR;
82 gii->i_flags = 0;
83
84 nilfs_palloc_clear_cache(gcdat);
85 truncate_inode_pages(gcdat->i_mapping, 0);
86 truncate_inode_pages(&gii->i_btnode_cache, 0);
87}
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 532f85acf273..3bbd340a5136 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -414,8 +414,6 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
414 sb = inode->i_sb; 414 sb = inode->i_sb;
415 nilfs = NILFS_MDT(inode)->mi_nilfs; 415 nilfs = NILFS_MDT(inode)->mi_nilfs;
416 416
417 if (page->mapping->assoc_mapping)
418 return 0; /* Do not request flush for shadow page cache */
419 if (!sb) { 417 if (!sb) {
420 down_read(&nilfs->ns_writer_sem); 418 down_read(&nilfs->ns_writer_sem);
421 writer = nilfs->ns_writer; 419 writer = nilfs->ns_writer;
@@ -566,13 +564,6 @@ void nilfs_mdt_set_entry_size(struct inode *inode, unsigned entry_size,
566 mi->mi_first_entry_offset = DIV_ROUND_UP(header_size, entry_size); 564 mi->mi_first_entry_offset = DIV_ROUND_UP(header_size, entry_size);
567} 565}
568 566
569void nilfs_mdt_set_shadow(struct inode *orig, struct inode *shadow)
570{
571 shadow->i_mapping->assoc_mapping = orig->i_mapping;
572 NILFS_I(shadow)->i_btnode_cache.assoc_mapping =
573 &NILFS_I(orig)->i_btnode_cache;
574}
575
576static const struct address_space_operations shadow_map_aops = { 567static const struct address_space_operations shadow_map_aops = {
577 .sync_page = block_sync_page, 568 .sync_page = block_sync_page,
578}; 569};
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h
index e60bbfe899f1..1e0901c3fd6b 100644
--- a/fs/nilfs2/mdt.h
+++ b/fs/nilfs2/mdt.h
@@ -93,7 +93,6 @@ struct inode *nilfs_mdt_new_common(struct the_nilfs *, struct super_block *,
93 ino_t); 93 ino_t);
94void nilfs_mdt_destroy(struct inode *); 94void nilfs_mdt_destroy(struct inode *);
95void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned); 95void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
96void nilfs_mdt_set_shadow(struct inode *, struct inode *);
97 96
98int nilfs_mdt_setup_shadow_map(struct inode *inode, 97int nilfs_mdt_setup_shadow_map(struct inode *inode,
99 struct nilfs_shadow_map *shadow); 98 struct nilfs_shadow_map *shadow);
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index cf5507a2a178..e9f457951e32 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -101,7 +101,6 @@ enum {
101 NILFS_I_INODE_DIRTY, /* write_inode is requested */ 101 NILFS_I_INODE_DIRTY, /* write_inode is requested */
102 NILFS_I_BMAP, /* has bmap and btnode_cache */ 102 NILFS_I_BMAP, /* has bmap and btnode_cache */
103 NILFS_I_GCINODE, /* inode for GC, on memory only */ 103 NILFS_I_GCINODE, /* inode for GC, on memory only */
104 NILFS_I_GCDAT, /* shadow DAT, on memory only */
105}; 104};
106 105
107/* 106/*
@@ -193,7 +192,7 @@ static inline int nilfs_doing_construction(void)
193 192
194static inline struct inode *nilfs_dat_inode(const struct the_nilfs *nilfs) 193static inline struct inode *nilfs_dat_inode(const struct the_nilfs *nilfs)
195{ 194{
196 return nilfs_doing_gc() ? nilfs->ns_gc_dat : nilfs->ns_dat; 195 return nilfs->ns_dat;
197} 196}
198 197
199/* 198/*
@@ -294,11 +293,6 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *);
294int nilfs_init_gcinode(struct inode *inode); 293int nilfs_init_gcinode(struct inode *inode);
295void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs); 294void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs);
296 295
297/* gcdat.c */
298int nilfs_init_gcdat_inode(struct the_nilfs *);
299void nilfs_commit_gcdat_inode(struct the_nilfs *);
300void nilfs_clear_gcdat_inode(struct the_nilfs *);
301
302/* 296/*
303 * Inodes and files operations 297 * Inodes and files operations
304 */ 298 */
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 7083344ac881..a6c3c2e817f8 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -79,8 +79,8 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode,
79{ 79{
80 int blkbits = inode->i_blkbits; 80 int blkbits = inode->i_blkbits;
81 pgoff_t index = blkoff >> (PAGE_CACHE_SHIFT - blkbits); 81 pgoff_t index = blkoff >> (PAGE_CACHE_SHIFT - blkbits);
82 struct page *page, *opage; 82 struct page *page;
83 struct buffer_head *bh, *obh; 83 struct buffer_head *bh;
84 84
85 page = grab_cache_page(mapping, index); 85 page = grab_cache_page(mapping, index);
86 if (unlikely(!page)) 86 if (unlikely(!page))
@@ -92,30 +92,6 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode,
92 page_cache_release(page); 92 page_cache_release(page);
93 return NULL; 93 return NULL;
94 } 94 }
95 if (!buffer_uptodate(bh) && mapping->assoc_mapping != NULL) {
96 /*
97 * Shadow page cache uses assoc_mapping to point its original
98 * page cache. The following code tries the original cache
99 * if the given cache is a shadow and it didn't hit.
100 */
101 opage = find_lock_page(mapping->assoc_mapping, index);
102 if (!opage)
103 return bh;
104
105 obh = __nilfs_get_page_block(opage, blkoff, index, blkbits,
106 b_state);
107 if (buffer_uptodate(obh)) {
108 nilfs_copy_buffer(bh, obh);
109 if (buffer_dirty(obh)) {
110 nilfs_mark_buffer_dirty(bh);
111 if (!buffer_nilfs_node(bh) && NILFS_MDT(inode))
112 nilfs_mdt_mark_dirty(inode);
113 }
114 }
115 brelse(obh);
116 unlock_page(opage);
117 page_cache_release(opage);
118 }
119 return bh; 95 return bh;
120} 96}
121 97
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 91dc0668ec83..b0c5e08d06c8 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1945,11 +1945,9 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
1945 1945
1946 nilfs_drop_collected_inodes(&sci->sc_dirty_files); 1946 nilfs_drop_collected_inodes(&sci->sc_dirty_files);
1947 1947
1948 if (nilfs_doing_gc()) { 1948 if (nilfs_doing_gc())
1949 nilfs_drop_collected_inodes(&sci->sc_gc_inodes); 1949 nilfs_drop_collected_inodes(&sci->sc_gc_inodes);
1950 if (update_sr) 1950 else
1951 nilfs_commit_gcdat_inode(nilfs);
1952 } else
1953 nilfs->ns_nongc_ctime = sci->sc_seg_ctime; 1951 nilfs->ns_nongc_ctime = sci->sc_seg_ctime;
1954 1952
1955 sci->sc_nblk_inc += sci->sc_nblk_this_inc; 1953 sci->sc_nblk_inc += sci->sc_nblk_this_inc;
@@ -2472,13 +2470,15 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
2472 2470
2473 nilfs_transaction_lock(sbi, &ti, 1); 2471 nilfs_transaction_lock(sbi, &ti, 1);
2474 2472
2475 err = nilfs_init_gcdat_inode(nilfs); 2473 err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat);
2476 if (unlikely(err)) 2474 if (unlikely(err))
2477 goto out_unlock; 2475 goto out_unlock;
2478 2476
2479 err = nilfs_ioctl_prepare_clean_segments(nilfs, argv, kbufs); 2477 err = nilfs_ioctl_prepare_clean_segments(nilfs, argv, kbufs);
2480 if (unlikely(err)) 2478 if (unlikely(err)) {
2479 nilfs_mdt_restore_from_shadow_map(nilfs->ns_dat);
2481 goto out_unlock; 2480 goto out_unlock;
2481 }
2482 2482
2483 sci->sc_freesegs = kbufs[4]; 2483 sci->sc_freesegs = kbufs[4];
2484 sci->sc_nfreesegs = argv[4].v_nmembs; 2484 sci->sc_nfreesegs = argv[4].v_nmembs;
@@ -2510,7 +2510,7 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
2510 out_unlock: 2510 out_unlock:
2511 sci->sc_freesegs = NULL; 2511 sci->sc_freesegs = NULL;
2512 sci->sc_nfreesegs = 0; 2512 sci->sc_nfreesegs = 0;
2513 nilfs_clear_gcdat_inode(nilfs); 2513 nilfs_mdt_clear_shadow_map(nilfs->ns_dat);
2514 nilfs_transaction_unlock(sbi); 2514 nilfs_transaction_unlock(sbi);
2515 return err; 2515 return err;
2516} 2516}
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 6eeb4f072f83..b7666bc04256 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -96,7 +96,6 @@ void destroy_nilfs(struct the_nilfs *nilfs)
96 nilfs_mdt_destroy(nilfs->ns_sufile); 96 nilfs_mdt_destroy(nilfs->ns_sufile);
97 nilfs_mdt_destroy(nilfs->ns_cpfile); 97 nilfs_mdt_destroy(nilfs->ns_cpfile);
98 nilfs_mdt_destroy(nilfs->ns_dat); 98 nilfs_mdt_destroy(nilfs->ns_dat);
99 nilfs_mdt_destroy(nilfs->ns_gc_dat);
100 } 99 }
101 if (nilfs_init(nilfs)) { 100 if (nilfs_init(nilfs)) {
102 brelse(nilfs->ns_sbh[0]); 101 brelse(nilfs->ns_sbh[0]);
@@ -131,20 +130,14 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs, sector_t sr_block)
131 if (unlikely(!nilfs->ns_dat)) 130 if (unlikely(!nilfs->ns_dat))
132 goto failed; 131 goto failed;
133 132
134 nilfs->ns_gc_dat = nilfs_dat_new(nilfs, dat_entry_size);
135 if (unlikely(!nilfs->ns_gc_dat))
136 goto failed_dat;
137
138 nilfs->ns_cpfile = nilfs_cpfile_new(nilfs, checkpoint_size); 133 nilfs->ns_cpfile = nilfs_cpfile_new(nilfs, checkpoint_size);
139 if (unlikely(!nilfs->ns_cpfile)) 134 if (unlikely(!nilfs->ns_cpfile))
140 goto failed_gc_dat; 135 goto failed_dat;
141 136
142 nilfs->ns_sufile = nilfs_sufile_new(nilfs, segment_usage_size); 137 nilfs->ns_sufile = nilfs_sufile_new(nilfs, segment_usage_size);
143 if (unlikely(!nilfs->ns_sufile)) 138 if (unlikely(!nilfs->ns_sufile))
144 goto failed_cpfile; 139 goto failed_cpfile;
145 140
146 nilfs_mdt_set_shadow(nilfs->ns_dat, nilfs->ns_gc_dat);
147
148 err = nilfs_dat_read(nilfs->ns_dat, (void *)bh_sr->b_data + 141 err = nilfs_dat_read(nilfs->ns_dat, (void *)bh_sr->b_data +
149 NILFS_SR_DAT_OFFSET(inode_size)); 142 NILFS_SR_DAT_OFFSET(inode_size));
150 if (unlikely(err)) 143 if (unlikely(err))
@@ -173,9 +166,6 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs, sector_t sr_block)
173 failed_cpfile: 166 failed_cpfile:
174 nilfs_mdt_destroy(nilfs->ns_cpfile); 167 nilfs_mdt_destroy(nilfs->ns_cpfile);
175 168
176 failed_gc_dat:
177 nilfs_mdt_destroy(nilfs->ns_gc_dat);
178
179 failed_dat: 169 failed_dat:
180 nilfs_mdt_destroy(nilfs->ns_dat); 170 nilfs_mdt_destroy(nilfs->ns_dat);
181 goto failed; 171 goto failed;
@@ -371,7 +361,6 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
371 nilfs_mdt_destroy(nilfs->ns_cpfile); 361 nilfs_mdt_destroy(nilfs->ns_cpfile);
372 nilfs_mdt_destroy(nilfs->ns_sufile); 362 nilfs_mdt_destroy(nilfs->ns_sufile);
373 nilfs_mdt_destroy(nilfs->ns_dat); 363 nilfs_mdt_destroy(nilfs->ns_dat);
374 nilfs_mdt_destroy(nilfs->ns_gc_dat);
375 364
376 failed: 365 failed:
377 nilfs_clear_recovery_info(&ri); 366 nilfs_clear_recovery_info(&ri);
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index 1908dc7bbd8f..a5178dc43dfd 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -74,7 +74,6 @@ enum {
74 * @ns_dat: DAT file inode 74 * @ns_dat: DAT file inode
75 * @ns_cpfile: checkpoint file inode 75 * @ns_cpfile: checkpoint file inode
76 * @ns_sufile: segusage file inode 76 * @ns_sufile: segusage file inode
77 * @ns_gc_dat: shadow inode of the DAT file inode for GC
78 * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) 77 * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root)
79 * @ns_cptree_lock: lock protecting @ns_cptree 78 * @ns_cptree_lock: lock protecting @ns_cptree
80 * @ns_gc_inodes: dummy inodes to keep live blocks 79 * @ns_gc_inodes: dummy inodes to keep live blocks
@@ -149,7 +148,6 @@ struct the_nilfs {
149 struct inode *ns_dat; 148 struct inode *ns_dat;
150 struct inode *ns_cpfile; 149 struct inode *ns_cpfile;
151 struct inode *ns_sufile; 150 struct inode *ns_sufile;
152 struct inode *ns_gc_dat;
153 151
154 /* Checkpoint tree */ 152 /* Checkpoint tree */
155 struct rb_root ns_cptree; 153 struct rb_root ns_cptree;