aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-10 14:26:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-10 14:26:52 -0400
commit5f248c9c251c60af3403902b26e08de43964ea0b (patch)
tree6d3328e72a7e4015a64017eb30be18095c6a3c64 /fs/nilfs2
parentf6cec0ae58c17522a7bc4e2f39dae19f199ab534 (diff)
parentdca332528bc69e05f67161e1ed59929633d5e63d (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (96 commits) no need for list_for_each_entry_safe()/resetting with superblock list Fix sget() race with failing mount vfs: don't hold s_umount over close_bdev_exclusive() call sysv: do not mark superblock dirty on remount sysv: do not mark superblock dirty on mount btrfs: remove junk sb_dirt change BFS: clean up the superblock usage AFFS: wait for sb synchronization when needed AFFS: clean up dirty flag usage cifs: truncate fallout mbcache: fix shrinker function return value mbcache: Remove unused features add f_flags to struct statfs(64) pass a struct path to vfs_statfs update VFS documentation for method changes. All filesystems that need invalidate_inode_buffers() are doing that explicitly convert remaining ->clear_inode() to ->evict_inode() Make ->drop_inode() just return whether inode needs to be dropped fs/inode.c:clear_inode() is gone fs/inode.c:evict() doesn't care about delete vs. non-delete paths now ... Fix up trivial conflicts in fs/nilfs2/super.c
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/dir.c25
-rw-r--r--fs/nilfs2/gcdat.c2
-rw-r--r--fs/nilfs2/inode.c78
-rw-r--r--fs/nilfs2/nilfs.h2
-rw-r--r--fs/nilfs2/recovery.c11
-rw-r--r--fs/nilfs2/super.c20
6 files changed, 80 insertions, 58 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index b60277b4446..cb003c8ee1f 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -80,23 +80,10 @@ static unsigned nilfs_last_byte(struct inode *inode, unsigned long page_nr)
80 return last_byte; 80 return last_byte;
81} 81}
82 82
83static int nilfs_prepare_chunk_uninterruptible(struct page *page, 83static int nilfs_prepare_chunk(struct page *page, unsigned from, unsigned to)
84 struct address_space *mapping,
85 unsigned from, unsigned to)
86{ 84{
87 loff_t pos = page_offset(page) + from; 85 loff_t pos = page_offset(page) + from;
88 return block_write_begin(NULL, mapping, pos, to - from, 86 return __block_write_begin(page, pos, to - from, nilfs_get_block);
89 AOP_FLAG_UNINTERRUPTIBLE, &page,
90 NULL, nilfs_get_block);
91}
92
93static int nilfs_prepare_chunk(struct page *page,
94 struct address_space *mapping,
95 unsigned from, unsigned to)
96{
97 loff_t pos = page_offset(page) + from;
98 return block_write_begin(NULL, mapping, pos, to - from, 0, &page,
99 NULL, nilfs_get_block);
100} 87}
101 88
102static void nilfs_commit_chunk(struct page *page, 89static void nilfs_commit_chunk(struct page *page,
@@ -447,7 +434,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
447 int err; 434 int err;
448 435
449 lock_page(page); 436 lock_page(page);
450 err = nilfs_prepare_chunk_uninterruptible(page, mapping, from, to); 437 err = nilfs_prepare_chunk(page, from, to);
451 BUG_ON(err); 438 BUG_ON(err);
452 de->inode = cpu_to_le64(inode->i_ino); 439 de->inode = cpu_to_le64(inode->i_ino);
453 nilfs_set_de_type(de, inode); 440 nilfs_set_de_type(de, inode);
@@ -528,7 +515,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
528got_it: 515got_it:
529 from = (char *)de - (char *)page_address(page); 516 from = (char *)de - (char *)page_address(page);
530 to = from + rec_len; 517 to = from + rec_len;
531 err = nilfs_prepare_chunk(page, page->mapping, from, to); 518 err = nilfs_prepare_chunk(page, from, to);
532 if (err) 519 if (err)
533 goto out_unlock; 520 goto out_unlock;
534 if (de->inode) { 521 if (de->inode) {
@@ -586,7 +573,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
586 if (pde) 573 if (pde)
587 from = (char *)pde - (char *)page_address(page); 574 from = (char *)pde - (char *)page_address(page);
588 lock_page(page); 575 lock_page(page);
589 err = nilfs_prepare_chunk(page, mapping, from, to); 576 err = nilfs_prepare_chunk(page, from, to);
590 BUG_ON(err); 577 BUG_ON(err);
591 if (pde) 578 if (pde)
592 pde->rec_len = nilfs_rec_len_to_disk(to - from); 579 pde->rec_len = nilfs_rec_len_to_disk(to - from);
@@ -614,7 +601,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
614 if (!page) 601 if (!page)
615 return -ENOMEM; 602 return -ENOMEM;
616 603
617 err = nilfs_prepare_chunk(page, mapping, 0, chunk_size); 604 err = nilfs_prepare_chunk(page, 0, chunk_size);
618 if (unlikely(err)) { 605 if (unlikely(err)) {
619 unlock_page(page); 606 unlock_page(page);
620 goto fail; 607 goto fail;
diff --git a/fs/nilfs2/gcdat.c b/fs/nilfs2/gcdat.c
index dd5f7e0a95f..84a45d1d546 100644
--- a/fs/nilfs2/gcdat.c
+++ b/fs/nilfs2/gcdat.c
@@ -78,7 +78,7 @@ void nilfs_clear_gcdat_inode(struct the_nilfs *nilfs)
78 struct inode *gcdat = nilfs->ns_gc_dat; 78 struct inode *gcdat = nilfs->ns_gc_dat;
79 struct nilfs_inode_info *gii = NILFS_I(gcdat); 79 struct nilfs_inode_info *gii = NILFS_I(gcdat);
80 80
81 gcdat->i_state = I_CLEAR; 81 gcdat->i_state = I_FREEING | I_CLEAR;
82 gii->i_flags = 0; 82 gii->i_flags = 0;
83 83
84 nilfs_palloc_clear_cache(gcdat); 84 nilfs_palloc_clear_cache(gcdat);
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 39e038ac8fc..eccb2f2e231 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -27,6 +27,7 @@
27#include <linux/writeback.h> 27#include <linux/writeback.h>
28#include <linux/uio.h> 28#include <linux/uio.h>
29#include "nilfs.h" 29#include "nilfs.h"
30#include "btnode.h"
30#include "segment.h" 31#include "segment.h"
31#include "page.h" 32#include "page.h"
32#include "mdt.h" 33#include "mdt.h"
@@ -197,11 +198,15 @@ static int nilfs_write_begin(struct file *file, struct address_space *mapping,
197 if (unlikely(err)) 198 if (unlikely(err))
198 return err; 199 return err;
199 200
200 *pagep = NULL; 201 err = block_write_begin(mapping, pos, len, flags, pagep,
201 err = block_write_begin(file, mapping, pos, len, flags, pagep, 202 nilfs_get_block);
202 fsdata, nilfs_get_block); 203 if (unlikely(err)) {
203 if (unlikely(err)) 204 loff_t isize = mapping->host->i_size;
205 if (pos + len > isize)
206 vmtruncate(mapping->host, isize);
207
204 nilfs_transaction_abort(inode->i_sb); 208 nilfs_transaction_abort(inode->i_sb);
209 }
205 return err; 210 return err;
206} 211}
207 212
@@ -237,6 +242,19 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
237 /* Needs synchronization with the cleaner */ 242 /* Needs synchronization with the cleaner */
238 size = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 243 size = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
239 offset, nr_segs, nilfs_get_block, NULL); 244 offset, nr_segs, nilfs_get_block, NULL);
245
246 /*
247 * In case of error extending write may have instantiated a few
248 * blocks outside i_size. Trim these off again.
249 */
250 if (unlikely((rw & WRITE) && size < 0)) {
251 loff_t isize = i_size_read(inode);
252 loff_t end = offset + iov_length(iov, nr_segs);
253
254 if (end > isize)
255 vmtruncate(inode, isize);
256 }
257
240 return size; 258 return size;
241} 259}
242 260
@@ -337,7 +355,6 @@ void nilfs_free_inode(struct inode *inode)
337 struct super_block *sb = inode->i_sb; 355 struct super_block *sb = inode->i_sb;
338 struct nilfs_sb_info *sbi = NILFS_SB(sb); 356 struct nilfs_sb_info *sbi = NILFS_SB(sb);
339 357
340 clear_inode(inode);
341 /* XXX: check error code? Is there any thing I can do? */ 358 /* XXX: check error code? Is there any thing I can do? */
342 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino); 359 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino);
343 atomic_dec(&sbi->s_inodes_count); 360 atomic_dec(&sbi->s_inodes_count);
@@ -597,16 +614,34 @@ void nilfs_truncate(struct inode *inode)
597 But truncate has no return value. */ 614 But truncate has no return value. */
598} 615}
599 616
600void nilfs_delete_inode(struct inode *inode) 617static void nilfs_clear_inode(struct inode *inode)
618{
619 struct nilfs_inode_info *ii = NILFS_I(inode);
620
621 /*
622 * Free resources allocated in nilfs_read_inode(), here.
623 */
624 BUG_ON(!list_empty(&ii->i_dirty));
625 brelse(ii->i_bh);
626 ii->i_bh = NULL;
627
628 if (test_bit(NILFS_I_BMAP, &ii->i_state))
629 nilfs_bmap_clear(ii->i_bmap);
630
631 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
632}
633
634void nilfs_evict_inode(struct inode *inode)
601{ 635{
602 struct nilfs_transaction_info ti; 636 struct nilfs_transaction_info ti;
603 struct super_block *sb = inode->i_sb; 637 struct super_block *sb = inode->i_sb;
604 struct nilfs_inode_info *ii = NILFS_I(inode); 638 struct nilfs_inode_info *ii = NILFS_I(inode);
605 639
606 if (unlikely(is_bad_inode(inode))) { 640 if (inode->i_nlink || unlikely(is_bad_inode(inode))) {
607 if (inode->i_data.nrpages) 641 if (inode->i_data.nrpages)
608 truncate_inode_pages(&inode->i_data, 0); 642 truncate_inode_pages(&inode->i_data, 0);
609 clear_inode(inode); 643 end_writeback(inode);
644 nilfs_clear_inode(inode);
610 return; 645 return;
611 } 646 }
612 nilfs_transaction_begin(sb, &ti, 0); /* never fails */ 647 nilfs_transaction_begin(sb, &ti, 0); /* never fails */
@@ -616,6 +651,8 @@ void nilfs_delete_inode(struct inode *inode)
616 651
617 nilfs_truncate_bmap(ii, 0); 652 nilfs_truncate_bmap(ii, 0);
618 nilfs_mark_inode_dirty(inode); 653 nilfs_mark_inode_dirty(inode);
654 end_writeback(inode);
655 nilfs_clear_inode(inode);
619 nilfs_free_inode(inode); 656 nilfs_free_inode(inode);
620 /* nilfs_free_inode() marks inode buffer dirty */ 657 /* nilfs_free_inode() marks inode buffer dirty */
621 if (IS_SYNC(inode)) 658 if (IS_SYNC(inode))
@@ -639,14 +676,27 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
639 err = nilfs_transaction_begin(sb, &ti, 0); 676 err = nilfs_transaction_begin(sb, &ti, 0);
640 if (unlikely(err)) 677 if (unlikely(err))
641 return err; 678 return err;
642 err = inode_setattr(inode, iattr); 679
643 if (!err && (iattr->ia_valid & ATTR_MODE)) 680 if ((iattr->ia_valid & ATTR_SIZE) &&
681 iattr->ia_size != i_size_read(inode)) {
682 err = vmtruncate(inode, iattr->ia_size);
683 if (unlikely(err))
684 goto out_err;
685 }
686
687 setattr_copy(inode, iattr);
688 mark_inode_dirty(inode);
689
690 if (iattr->ia_valid & ATTR_MODE) {
644 err = nilfs_acl_chmod(inode); 691 err = nilfs_acl_chmod(inode);
645 if (likely(!err)) 692 if (unlikely(err))
646 err = nilfs_transaction_commit(sb); 693 goto out_err;
647 else 694 }
648 nilfs_transaction_abort(sb); 695
696 return nilfs_transaction_commit(sb);
649 697
698out_err:
699 nilfs_transaction_abort(sb);
650 return err; 700 return err;
651} 701}
652 702
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 0842d775b3e..d3d54046e5f 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -250,7 +250,7 @@ extern void nilfs_write_inode_common(struct inode *, struct nilfs_inode *, int);
250extern struct inode *nilfs_iget(struct super_block *, unsigned long); 250extern struct inode *nilfs_iget(struct super_block *, unsigned long);
251extern void nilfs_update_inode(struct inode *, struct buffer_head *); 251extern void nilfs_update_inode(struct inode *, struct buffer_head *);
252extern void nilfs_truncate(struct inode *); 252extern void nilfs_truncate(struct inode *);
253extern void nilfs_delete_inode(struct inode *); 253extern void nilfs_evict_inode(struct inode *);
254extern int nilfs_setattr(struct dentry *, struct iattr *); 254extern int nilfs_setattr(struct dentry *, struct iattr *);
255extern int nilfs_load_inode_block(struct nilfs_sb_info *, struct inode *, 255extern int nilfs_load_inode_block(struct nilfs_sb_info *, struct inode *,
256 struct buffer_head **); 256 struct buffer_head **);
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index 83e3d8c61a0..d0c35ef39f6 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -523,11 +523,14 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
523 } 523 }
524 524
525 pos = rb->blkoff << inode->i_blkbits; 525 pos = rb->blkoff << inode->i_blkbits;
526 page = NULL; 526 err = block_write_begin(inode->i_mapping, pos, blocksize,
527 err = block_write_begin(NULL, inode->i_mapping, pos, blocksize, 527 0, &page, nilfs_get_block);
528 0, &page, NULL, nilfs_get_block); 528 if (unlikely(err)) {
529 if (unlikely(err)) 529 loff_t isize = inode->i_size;
530 if (pos + blocksize > isize)
531 vmtruncate(inode, isize);
530 goto failed_inode; 532 goto failed_inode;
533 }
531 534
532 err = nilfs_recovery_copy_block(nilfs, rb, page); 535 err = nilfs_recovery_copy_block(nilfs, rb, page);
533 if (unlikely(err)) 536 if (unlikely(err))
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 26078b3407c..1fa86b9df73 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -171,23 +171,6 @@ void nilfs_destroy_inode(struct inode *inode)
171 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode)); 171 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode));
172} 172}
173 173
174static void nilfs_clear_inode(struct inode *inode)
175{
176 struct nilfs_inode_info *ii = NILFS_I(inode);
177
178 /*
179 * Free resources allocated in nilfs_read_inode(), here.
180 */
181 BUG_ON(!list_empty(&ii->i_dirty));
182 brelse(ii->i_bh);
183 ii->i_bh = NULL;
184
185 if (test_bit(NILFS_I_BMAP, &ii->i_state))
186 nilfs_bmap_clear(ii->i_bmap);
187
188 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
189}
190
191static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag) 174static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag)
192{ 175{
193 struct the_nilfs *nilfs = sbi->s_nilfs; 176 struct the_nilfs *nilfs = sbi->s_nilfs;
@@ -548,7 +531,7 @@ static const struct super_operations nilfs_sops = {
548 /* .write_inode = nilfs_write_inode, */ 531 /* .write_inode = nilfs_write_inode, */
549 /* .put_inode = nilfs_put_inode, */ 532 /* .put_inode = nilfs_put_inode, */
550 /* .drop_inode = nilfs_drop_inode, */ 533 /* .drop_inode = nilfs_drop_inode, */
551 .delete_inode = nilfs_delete_inode, 534 .evict_inode = nilfs_evict_inode,
552 .put_super = nilfs_put_super, 535 .put_super = nilfs_put_super,
553 /* .write_super = nilfs_write_super, */ 536 /* .write_super = nilfs_write_super, */
554 .sync_fs = nilfs_sync_fs, 537 .sync_fs = nilfs_sync_fs,
@@ -556,7 +539,6 @@ static const struct super_operations nilfs_sops = {
556 /* .unlockfs */ 539 /* .unlockfs */
557 .statfs = nilfs_statfs, 540 .statfs = nilfs_statfs,
558 .remount_fs = nilfs_remount, 541 .remount_fs = nilfs_remount,
559 .clear_inode = nilfs_clear_inode,
560 /* .umount_begin */ 542 /* .umount_begin */
561 .show_options = nilfs_show_options 543 .show_options = nilfs_show_options
562}; 544};