diff options
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/mdt.c | 33 | ||||
-rw-r--r-- | fs/nilfs2/recovery.c | 4 | ||||
-rw-r--r-- | fs/nilfs2/segment.c | 4 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 1 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.h | 21 |
5 files changed, 2 insertions, 61 deletions
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 32695f3c4b9a..0a2ccfc0d6f9 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c | |||
@@ -78,25 +78,11 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
78 | struct buffer_head *, | 78 | struct buffer_head *, |
79 | void *)) | 79 | void *)) |
80 | { | 80 | { |
81 | struct the_nilfs *nilfs = NILFS_I_NILFS(inode); | ||
82 | struct super_block *sb = inode->i_sb; | 81 | struct super_block *sb = inode->i_sb; |
83 | struct nilfs_transaction_info ti; | 82 | struct nilfs_transaction_info ti; |
84 | struct buffer_head *bh; | 83 | struct buffer_head *bh; |
85 | int err; | 84 | int err; |
86 | 85 | ||
87 | if (!sb) { | ||
88 | /* | ||
89 | * Make sure this function is not called from any | ||
90 | * read-only context. | ||
91 | */ | ||
92 | if (!nilfs->ns_writer) { | ||
93 | WARN_ON(1); | ||
94 | err = -EROFS; | ||
95 | goto out; | ||
96 | } | ||
97 | sb = nilfs->ns_writer->s_super; | ||
98 | } | ||
99 | |||
100 | nilfs_transaction_begin(sb, &ti, 0); | 86 | nilfs_transaction_begin(sb, &ti, 0); |
101 | 87 | ||
102 | err = -ENOMEM; | 88 | err = -ENOMEM; |
@@ -112,7 +98,7 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
112 | if (buffer_uptodate(bh)) | 98 | if (buffer_uptodate(bh)) |
113 | goto failed_bh; | 99 | goto failed_bh; |
114 | 100 | ||
115 | bh->b_bdev = nilfs->ns_bdev; | 101 | bh->b_bdev = sb->s_bdev; |
116 | err = nilfs_mdt_insert_new_block(inode, block, bh, init_block); | 102 | err = nilfs_mdt_insert_new_block(inode, block, bh, init_block); |
117 | if (likely(!err)) { | 103 | if (likely(!err)) { |
118 | get_bh(bh); | 104 | get_bh(bh); |
@@ -129,7 +115,7 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
129 | err = nilfs_transaction_commit(sb); | 115 | err = nilfs_transaction_commit(sb); |
130 | else | 116 | else |
131 | nilfs_transaction_abort(sb); | 117 | nilfs_transaction_abort(sb); |
132 | out: | 118 | |
133 | return err; | 119 | return err; |
134 | } | 120 | } |
135 | 121 | ||
@@ -398,8 +384,6 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) | |||
398 | { | 384 | { |
399 | struct inode *inode; | 385 | struct inode *inode; |
400 | struct super_block *sb; | 386 | struct super_block *sb; |
401 | struct the_nilfs *nilfs; | ||
402 | struct nilfs_sb_info *writer = NULL; | ||
403 | int err = 0; | 387 | int err = 0; |
404 | 388 | ||
405 | redirty_page_for_writepage(wbc, page); | 389 | redirty_page_for_writepage(wbc, page); |
@@ -410,25 +394,12 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) | |||
410 | return 0; | 394 | return 0; |
411 | 395 | ||
412 | sb = inode->i_sb; | 396 | sb = inode->i_sb; |
413 | nilfs = NILFS_SB(sb)->s_nilfs; | ||
414 | |||
415 | if (!sb) { | ||
416 | down_read(&nilfs->ns_writer_sem); | ||
417 | writer = nilfs->ns_writer; | ||
418 | if (!writer) { | ||
419 | up_read(&nilfs->ns_writer_sem); | ||
420 | return -EROFS; | ||
421 | } | ||
422 | sb = writer->s_super; | ||
423 | } | ||
424 | 397 | ||
425 | if (wbc->sync_mode == WB_SYNC_ALL) | 398 | if (wbc->sync_mode == WB_SYNC_ALL) |
426 | err = nilfs_construct_segment(sb); | 399 | err = nilfs_construct_segment(sb); |
427 | else if (wbc->for_reclaim) | 400 | else if (wbc->for_reclaim) |
428 | nilfs_flush_segment(sb, inode->i_ino); | 401 | nilfs_flush_segment(sb, inode->i_ino); |
429 | 402 | ||
430 | if (writer) | ||
431 | up_read(&nilfs->ns_writer_sem); | ||
432 | return err; | 403 | return err; |
433 | } | 404 | } |
434 | 405 | ||
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c index dcb5a9812c6c..5d2711c28da7 100644 --- a/fs/nilfs2/recovery.c +++ b/fs/nilfs2/recovery.c | |||
@@ -440,7 +440,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | |||
440 | segnum[2] = ri->ri_segnum; | 440 | segnum[2] = ri->ri_segnum; |
441 | segnum[3] = ri->ri_nextnum; | 441 | segnum[3] = ri->ri_nextnum; |
442 | 442 | ||
443 | nilfs_attach_writer(nilfs, sbi); | ||
444 | /* | 443 | /* |
445 | * Releasing the next segment of the latest super root. | 444 | * Releasing the next segment of the latest super root. |
446 | * The next segment is invalidated by this recovery. | 445 | * The next segment is invalidated by this recovery. |
@@ -480,7 +479,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | |||
480 | 479 | ||
481 | failed: | 480 | failed: |
482 | /* No need to recover sufile because it will be destroyed on error */ | 481 | /* No need to recover sufile because it will be destroyed on error */ |
483 | nilfs_detach_writer(nilfs, sbi); | ||
484 | return err; | 482 | return err; |
485 | } | 483 | } |
486 | 484 | ||
@@ -599,7 +597,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
599 | }; | 597 | }; |
600 | int state = RF_INIT_ST; | 598 | int state = RF_INIT_ST; |
601 | 599 | ||
602 | nilfs_attach_writer(nilfs, sbi); | ||
603 | pseg_start = ri->ri_lsegs_start; | 600 | pseg_start = ri->ri_lsegs_start; |
604 | seg_seq = ri->ri_lsegs_start_seq; | 601 | seg_seq = ri->ri_lsegs_start_seq; |
605 | segnum = nilfs_get_segnum_of_block(nilfs, pseg_start); | 602 | segnum = nilfs_get_segnum_of_block(nilfs, pseg_start); |
@@ -690,7 +687,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
690 | out: | 687 | out: |
691 | brelse(bh_sum); | 688 | brelse(bh_sum); |
692 | dispose_recovery_list(&dsync_blocks); | 689 | dispose_recovery_list(&dsync_blocks); |
693 | nilfs_detach_writer(nilfs, sbi); | ||
694 | return err; | 690 | return err; |
695 | 691 | ||
696 | confused: | 692 | confused: |
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index b0c5e08d06c8..56350bf1f79f 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -2799,7 +2799,6 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2799 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | 2799 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, |
2800 | struct nilfs_root *root) | 2800 | struct nilfs_root *root) |
2801 | { | 2801 | { |
2802 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2803 | int err; | 2802 | int err; |
2804 | 2803 | ||
2805 | if (NILFS_SC(sbi)) { | 2804 | if (NILFS_SC(sbi)) { |
@@ -2815,10 +2814,8 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | |||
2815 | if (!sbi->s_sc_info) | 2814 | if (!sbi->s_sc_info) |
2816 | return -ENOMEM; | 2815 | return -ENOMEM; |
2817 | 2816 | ||
2818 | nilfs_attach_writer(nilfs, sbi); | ||
2819 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); | 2817 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); |
2820 | if (err) { | 2818 | if (err) { |
2821 | nilfs_detach_writer(nilfs, sbi); | ||
2822 | kfree(sbi->s_sc_info); | 2819 | kfree(sbi->s_sc_info); |
2823 | sbi->s_sc_info = NULL; | 2820 | sbi->s_sc_info = NULL; |
2824 | } | 2821 | } |
@@ -2855,5 +2852,4 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) | |||
2855 | up_write(&nilfs->ns_segctor_sem); | 2852 | up_write(&nilfs->ns_segctor_sem); |
2856 | 2853 | ||
2857 | nilfs_dispose_list(sbi, &garbage_list, 1); | 2854 | nilfs_dispose_list(sbi, &garbage_list, 1); |
2858 | nilfs_detach_writer(nilfs, sbi); | ||
2859 | } | 2855 | } |
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 4cc705a1d135..a94aa57c4bd9 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -75,7 +75,6 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) | |||
75 | nilfs->ns_bdev = bdev; | 75 | nilfs->ns_bdev = bdev; |
76 | atomic_set(&nilfs->ns_ndirtyblks, 0); | 76 | atomic_set(&nilfs->ns_ndirtyblks, 0); |
77 | init_rwsem(&nilfs->ns_sem); | 77 | init_rwsem(&nilfs->ns_sem); |
78 | init_rwsem(&nilfs->ns_writer_sem); | ||
79 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); | 78 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); |
80 | spin_lock_init(&nilfs->ns_last_segment_lock); | 79 | spin_lock_init(&nilfs->ns_last_segment_lock); |
81 | nilfs->ns_cptree = RB_ROOT; | 80 | nilfs->ns_cptree = RB_ROOT; |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index cae56f338b64..bbbc1c748aac 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
@@ -48,9 +48,7 @@ enum { | |||
48 | * @ns_flags: flags | 48 | * @ns_flags: flags |
49 | * @ns_bdev: block device | 49 | * @ns_bdev: block device |
50 | * @ns_bdi: backing dev info | 50 | * @ns_bdi: backing dev info |
51 | * @ns_writer: back pointer to writable nilfs_sb_info | ||
52 | * @ns_sem: semaphore for shared states | 51 | * @ns_sem: semaphore for shared states |
53 | * @ns_writer_sem: semaphore protecting ns_writer attach/detach | ||
54 | * @ns_sbh: buffer heads of on-disk super blocks | 52 | * @ns_sbh: buffer heads of on-disk super blocks |
55 | * @ns_sbp: pointers to super block data | 53 | * @ns_sbp: pointers to super block data |
56 | * @ns_sbwtime: previous write time of super block | 54 | * @ns_sbwtime: previous write time of super block |
@@ -93,9 +91,7 @@ struct the_nilfs { | |||
93 | 91 | ||
94 | struct block_device *ns_bdev; | 92 | struct block_device *ns_bdev; |
95 | struct backing_dev_info *ns_bdi; | 93 | struct backing_dev_info *ns_bdi; |
96 | struct nilfs_sb_info *ns_writer; | ||
97 | struct rw_semaphore ns_sem; | 94 | struct rw_semaphore ns_sem; |
98 | struct rw_semaphore ns_writer_sem; | ||
99 | 95 | ||
100 | /* | 96 | /* |
101 | * used for | 97 | * used for |
@@ -252,23 +248,6 @@ static inline void nilfs_get_root(struct nilfs_root *root) | |||
252 | atomic_inc(&root->count); | 248 | atomic_inc(&root->count); |
253 | } | 249 | } |
254 | 250 | ||
255 | static inline void | ||
256 | nilfs_attach_writer(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | ||
257 | { | ||
258 | down_write(&nilfs->ns_writer_sem); | ||
259 | nilfs->ns_writer = sbi; | ||
260 | up_write(&nilfs->ns_writer_sem); | ||
261 | } | ||
262 | |||
263 | static inline void | ||
264 | nilfs_detach_writer(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | ||
265 | { | ||
266 | down_write(&nilfs->ns_writer_sem); | ||
267 | if (sbi == nilfs->ns_writer) | ||
268 | nilfs->ns_writer = NULL; | ||
269 | up_write(&nilfs->ns_writer_sem); | ||
270 | } | ||
271 | |||
272 | static inline int nilfs_valid_fs(struct the_nilfs *nilfs) | 251 | static inline int nilfs_valid_fs(struct the_nilfs *nilfs) |
273 | { | 252 | { |
274 | unsigned valid_fs; | 253 | unsigned valid_fs; |