aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/mdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/mdt.c')
-rw-r--r--fs/nilfs2/mdt.c33
1 files changed, 2 insertions, 31 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