diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2013-07-12 06:34:42 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2013-07-12 06:34:42 -0400 |
| commit | f2006e27396f55276f24434f56e208d86e7f9908 (patch) | |
| tree | 71896db916d33888b4286f80117d3cac0da40e6d /fs/nilfs2 | |
| parent | e399eb56a6110e13f97e644658648602e2b08de7 (diff) | |
| parent | 9903883f1dd6e86f286b7bfa6e4b423f98c1cd9e (diff) | |
Merge branch 'linus' into timers/urgent
Get upstream changes so we can apply fixes against them
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/nilfs2')
| -rw-r--r-- | fs/nilfs2/alloc.c | 63 | ||||
| -rw-r--r-- | fs/nilfs2/alloc.h | 2 | ||||
| -rw-r--r-- | fs/nilfs2/ifile.c | 22 | ||||
| -rw-r--r-- | fs/nilfs2/ifile.h | 2 | ||||
| -rw-r--r-- | fs/nilfs2/inode.c | 8 | ||||
| -rw-r--r-- | fs/nilfs2/segment.c | 4 | ||||
| -rw-r--r-- | fs/nilfs2/super.c | 33 | ||||
| -rw-r--r-- | fs/nilfs2/the_nilfs.c | 4 | ||||
| -rw-r--r-- | fs/nilfs2/the_nilfs.h | 4 |
9 files changed, 127 insertions, 15 deletions
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index eed4d7b26249..741fd02e0444 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c | |||
| @@ -398,6 +398,69 @@ nilfs_palloc_rest_groups_in_desc_block(const struct inode *inode, | |||
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | /** | 400 | /** |
| 401 | * nilfs_palloc_count_desc_blocks - count descriptor blocks number | ||
| 402 | * @inode: inode of metadata file using this allocator | ||
| 403 | * @desc_blocks: descriptor blocks number [out] | ||
| 404 | */ | ||
| 405 | static int nilfs_palloc_count_desc_blocks(struct inode *inode, | ||
| 406 | unsigned long *desc_blocks) | ||
| 407 | { | ||
| 408 | unsigned long blknum; | ||
| 409 | int ret; | ||
| 410 | |||
| 411 | ret = nilfs_bmap_last_key(NILFS_I(inode)->i_bmap, &blknum); | ||
| 412 | if (likely(!ret)) | ||
| 413 | *desc_blocks = DIV_ROUND_UP( | ||
| 414 | blknum, NILFS_MDT(inode)->mi_blocks_per_desc_block); | ||
| 415 | return ret; | ||
| 416 | } | ||
| 417 | |||
| 418 | /** | ||
| 419 | * nilfs_palloc_mdt_file_can_grow - check potential opportunity for | ||
| 420 | * MDT file growing | ||
| 421 | * @inode: inode of metadata file using this allocator | ||
| 422 | * @desc_blocks: known current descriptor blocks count | ||
| 423 | */ | ||
| 424 | static inline bool nilfs_palloc_mdt_file_can_grow(struct inode *inode, | ||
| 425 | unsigned long desc_blocks) | ||
| 426 | { | ||
| 427 | return (nilfs_palloc_groups_per_desc_block(inode) * desc_blocks) < | ||
| 428 | nilfs_palloc_groups_count(inode); | ||
| 429 | } | ||
| 430 | |||
| 431 | /** | ||
| 432 | * nilfs_palloc_count_max_entries - count max number of entries that can be | ||
| 433 | * described by descriptor blocks count | ||
| 434 | * @inode: inode of metadata file using this allocator | ||
| 435 | * @nused: current number of used entries | ||
| 436 | * @nmaxp: max number of entries [out] | ||
| 437 | */ | ||
| 438 | int nilfs_palloc_count_max_entries(struct inode *inode, u64 nused, u64 *nmaxp) | ||
| 439 | { | ||
| 440 | unsigned long desc_blocks = 0; | ||
| 441 | u64 entries_per_desc_block, nmax; | ||
| 442 | int err; | ||
| 443 | |||
| 444 | err = nilfs_palloc_count_desc_blocks(inode, &desc_blocks); | ||
| 445 | if (unlikely(err)) | ||
| 446 | return err; | ||
| 447 | |||
| 448 | entries_per_desc_block = (u64)nilfs_palloc_entries_per_group(inode) * | ||
| 449 | nilfs_palloc_groups_per_desc_block(inode); | ||
| 450 | nmax = entries_per_desc_block * desc_blocks; | ||
| 451 | |||
| 452 | if (nused == nmax && | ||
| 453 | nilfs_palloc_mdt_file_can_grow(inode, desc_blocks)) | ||
| 454 | nmax += entries_per_desc_block; | ||
| 455 | |||
| 456 | if (nused > nmax) | ||
| 457 | return -ERANGE; | ||
| 458 | |||
| 459 | *nmaxp = nmax; | ||
| 460 | return 0; | ||
| 461 | } | ||
| 462 | |||
| 463 | /** | ||
| 401 | * nilfs_palloc_prepare_alloc_entry - prepare to allocate a persistent object | 464 | * nilfs_palloc_prepare_alloc_entry - prepare to allocate a persistent object |
| 402 | * @inode: inode of metadata file using this allocator | 465 | * @inode: inode of metadata file using this allocator |
| 403 | * @req: nilfs_palloc_req structure exchanged for the allocation | 466 | * @req: nilfs_palloc_req structure exchanged for the allocation |
diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h index fb7238100548..4bd6451b5703 100644 --- a/fs/nilfs2/alloc.h +++ b/fs/nilfs2/alloc.h | |||
| @@ -48,6 +48,8 @@ int nilfs_palloc_get_entry_block(struct inode *, __u64, int, | |||
| 48 | void *nilfs_palloc_block_get_entry(const struct inode *, __u64, | 48 | void *nilfs_palloc_block_get_entry(const struct inode *, __u64, |
| 49 | const struct buffer_head *, void *); | 49 | const struct buffer_head *, void *); |
| 50 | 50 | ||
| 51 | int nilfs_palloc_count_max_entries(struct inode *, u64, u64 *); | ||
| 52 | |||
| 51 | /** | 53 | /** |
| 52 | * nilfs_palloc_req - persistent allocator request and reply | 54 | * nilfs_palloc_req - persistent allocator request and reply |
| 53 | * @pr_entry_nr: entry number (vblocknr or inode number) | 55 | * @pr_entry_nr: entry number (vblocknr or inode number) |
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c index d8e65bde083c..6548c7851b48 100644 --- a/fs/nilfs2/ifile.c +++ b/fs/nilfs2/ifile.c | |||
| @@ -160,6 +160,28 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino, | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | /** | 162 | /** |
| 163 | * nilfs_ifile_count_free_inodes - calculate free inodes count | ||
| 164 | * @ifile: ifile inode | ||
| 165 | * @nmaxinodes: current maximum of available inodes count [out] | ||
| 166 | * @nfreeinodes: free inodes count [out] | ||
| 167 | */ | ||
| 168 | int nilfs_ifile_count_free_inodes(struct inode *ifile, | ||
| 169 | u64 *nmaxinodes, u64 *nfreeinodes) | ||
| 170 | { | ||
| 171 | u64 nused; | ||
| 172 | int err; | ||
| 173 | |||
| 174 | *nmaxinodes = 0; | ||
| 175 | *nfreeinodes = 0; | ||
| 176 | |||
| 177 | nused = atomic64_read(&NILFS_I(ifile)->i_root->inodes_count); | ||
| 178 | err = nilfs_palloc_count_max_entries(ifile, nused, nmaxinodes); | ||
| 179 | if (likely(!err)) | ||
| 180 | *nfreeinodes = *nmaxinodes - nused; | ||
| 181 | return err; | ||
| 182 | } | ||
| 183 | |||
| 184 | /** | ||
| 163 | * nilfs_ifile_read - read or get ifile inode | 185 | * nilfs_ifile_read - read or get ifile inode |
| 164 | * @sb: super block instance | 186 | * @sb: super block instance |
| 165 | * @root: root object | 187 | * @root: root object |
diff --git a/fs/nilfs2/ifile.h b/fs/nilfs2/ifile.h index 59b6f2b51df6..679674d13372 100644 --- a/fs/nilfs2/ifile.h +++ b/fs/nilfs2/ifile.h | |||
| @@ -49,6 +49,8 @@ int nilfs_ifile_create_inode(struct inode *, ino_t *, struct buffer_head **); | |||
| 49 | int nilfs_ifile_delete_inode(struct inode *, ino_t); | 49 | int nilfs_ifile_delete_inode(struct inode *, ino_t); |
| 50 | int nilfs_ifile_get_inode_block(struct inode *, ino_t, struct buffer_head **); | 50 | int nilfs_ifile_get_inode_block(struct inode *, ino_t, struct buffer_head **); |
| 51 | 51 | ||
| 52 | int nilfs_ifile_count_free_inodes(struct inode *, u64 *, u64 *); | ||
| 53 | |||
| 52 | int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root, | 54 | int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root, |
| 53 | size_t inode_size, struct nilfs_inode *raw_inode, | 55 | size_t inode_size, struct nilfs_inode *raw_inode, |
| 54 | struct inode **inodep); | 56 | struct inode **inodep); |
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index bccfec8343c5..b1a5277cfd18 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
| @@ -54,7 +54,7 @@ void nilfs_inode_add_blocks(struct inode *inode, int n) | |||
| 54 | 54 | ||
| 55 | inode_add_bytes(inode, (1 << inode->i_blkbits) * n); | 55 | inode_add_bytes(inode, (1 << inode->i_blkbits) * n); |
| 56 | if (root) | 56 | if (root) |
| 57 | atomic_add(n, &root->blocks_count); | 57 | atomic64_add(n, &root->blocks_count); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | void nilfs_inode_sub_blocks(struct inode *inode, int n) | 60 | void nilfs_inode_sub_blocks(struct inode *inode, int n) |
| @@ -63,7 +63,7 @@ void nilfs_inode_sub_blocks(struct inode *inode, int n) | |||
| 63 | 63 | ||
| 64 | inode_sub_bytes(inode, (1 << inode->i_blkbits) * n); | 64 | inode_sub_bytes(inode, (1 << inode->i_blkbits) * n); |
| 65 | if (root) | 65 | if (root) |
| 66 | atomic_sub(n, &root->blocks_count); | 66 | atomic64_sub(n, &root->blocks_count); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | /** | 69 | /** |
| @@ -369,7 +369,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) | |||
| 369 | goto failed_ifile_create_inode; | 369 | goto failed_ifile_create_inode; |
| 370 | /* reference count of i_bh inherits from nilfs_mdt_read_block() */ | 370 | /* reference count of i_bh inherits from nilfs_mdt_read_block() */ |
| 371 | 371 | ||
| 372 | atomic_inc(&root->inodes_count); | 372 | atomic64_inc(&root->inodes_count); |
| 373 | inode_init_owner(inode, dir, mode); | 373 | inode_init_owner(inode, dir, mode); |
| 374 | inode->i_ino = ino; | 374 | inode->i_ino = ino; |
| 375 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 375 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
| @@ -801,7 +801,7 @@ void nilfs_evict_inode(struct inode *inode) | |||
| 801 | 801 | ||
| 802 | ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); | 802 | ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); |
| 803 | if (!ret) | 803 | if (!ret) |
| 804 | atomic_dec(&ii->i_root->inodes_count); | 804 | atomic64_dec(&ii->i_root->inodes_count); |
| 805 | 805 | ||
| 806 | nilfs_clear_inode(inode); | 806 | nilfs_clear_inode(inode); |
| 807 | 807 | ||
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index a5752a589932..bd88a7461063 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
| @@ -835,9 +835,9 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) | |||
| 835 | raw_cp->cp_snapshot_list.ssl_next = 0; | 835 | raw_cp->cp_snapshot_list.ssl_next = 0; |
| 836 | raw_cp->cp_snapshot_list.ssl_prev = 0; | 836 | raw_cp->cp_snapshot_list.ssl_prev = 0; |
| 837 | raw_cp->cp_inodes_count = | 837 | raw_cp->cp_inodes_count = |
| 838 | cpu_to_le64(atomic_read(&sci->sc_root->inodes_count)); | 838 | cpu_to_le64(atomic64_read(&sci->sc_root->inodes_count)); |
| 839 | raw_cp->cp_blocks_count = | 839 | raw_cp->cp_blocks_count = |
| 840 | cpu_to_le64(atomic_read(&sci->sc_root->blocks_count)); | 840 | cpu_to_le64(atomic64_read(&sci->sc_root->blocks_count)); |
| 841 | raw_cp->cp_nblk_inc = | 841 | raw_cp->cp_nblk_inc = |
| 842 | cpu_to_le64(sci->sc_nblk_inc + sci->sc_nblk_this_inc); | 842 | cpu_to_le64(sci->sc_nblk_inc + sci->sc_nblk_this_inc); |
| 843 | raw_cp->cp_create = cpu_to_le64(sci->sc_seg_ctime); | 843 | raw_cp->cp_create = cpu_to_le64(sci->sc_seg_ctime); |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index c7d1f9f18b09..af3ba0478cdf 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
| @@ -554,8 +554,10 @@ int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, | |||
| 554 | if (err) | 554 | if (err) |
| 555 | goto failed_bh; | 555 | goto failed_bh; |
| 556 | 556 | ||
| 557 | atomic_set(&root->inodes_count, le64_to_cpu(raw_cp->cp_inodes_count)); | 557 | atomic64_set(&root->inodes_count, |
| 558 | atomic_set(&root->blocks_count, le64_to_cpu(raw_cp->cp_blocks_count)); | 558 | le64_to_cpu(raw_cp->cp_inodes_count)); |
| 559 | atomic64_set(&root->blocks_count, | ||
| 560 | le64_to_cpu(raw_cp->cp_blocks_count)); | ||
| 559 | 561 | ||
| 560 | nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); | 562 | nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); |
| 561 | 563 | ||
| @@ -609,6 +611,7 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 609 | unsigned long overhead; | 611 | unsigned long overhead; |
| 610 | unsigned long nrsvblocks; | 612 | unsigned long nrsvblocks; |
| 611 | sector_t nfreeblocks; | 613 | sector_t nfreeblocks; |
| 614 | u64 nmaxinodes, nfreeinodes; | ||
| 612 | int err; | 615 | int err; |
| 613 | 616 | ||
| 614 | /* | 617 | /* |
| @@ -633,14 +636,34 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 633 | if (unlikely(err)) | 636 | if (unlikely(err)) |
| 634 | return err; | 637 | return err; |
| 635 | 638 | ||
| 639 | err = nilfs_ifile_count_free_inodes(root->ifile, | ||
| 640 | &nmaxinodes, &nfreeinodes); | ||
| 641 | if (unlikely(err)) { | ||
| 642 | printk(KERN_WARNING | ||
| 643 | "NILFS warning: fail to count free inodes: err %d.\n", | ||
| 644 | err); | ||
| 645 | if (err == -ERANGE) { | ||
| 646 | /* | ||
| 647 | * If nilfs_palloc_count_max_entries() returns | ||
| 648 | * -ERANGE error code then we simply treat | ||
| 649 | * curent inodes count as maximum possible and | ||
| 650 | * zero as free inodes value. | ||
| 651 | */ | ||
| 652 | nmaxinodes = atomic64_read(&root->inodes_count); | ||
| 653 | nfreeinodes = 0; | ||
| 654 | err = 0; | ||
| 655 | } else | ||
| 656 | return err; | ||
| 657 | } | ||
| 658 | |||
| 636 | buf->f_type = NILFS_SUPER_MAGIC; | 659 | buf->f_type = NILFS_SUPER_MAGIC; |
| 637 | buf->f_bsize = sb->s_blocksize; | 660 | buf->f_bsize = sb->s_blocksize; |
| 638 | buf->f_blocks = blocks - overhead; | 661 | buf->f_blocks = blocks - overhead; |
| 639 | buf->f_bfree = nfreeblocks; | 662 | buf->f_bfree = nfreeblocks; |
| 640 | buf->f_bavail = (buf->f_bfree >= nrsvblocks) ? | 663 | buf->f_bavail = (buf->f_bfree >= nrsvblocks) ? |
| 641 | (buf->f_bfree - nrsvblocks) : 0; | 664 | (buf->f_bfree - nrsvblocks) : 0; |
| 642 | buf->f_files = atomic_read(&root->inodes_count); | 665 | buf->f_files = nmaxinodes; |
| 643 | buf->f_ffree = 0; /* nilfs_count_free_inodes(sb); */ | 666 | buf->f_ffree = nfreeinodes; |
| 644 | buf->f_namelen = NILFS_NAME_LEN; | 667 | buf->f_namelen = NILFS_NAME_LEN; |
| 645 | buf->f_fsid.val[0] = (u32)id; | 668 | buf->f_fsid.val[0] = (u32)id; |
| 646 | buf->f_fsid.val[1] = (u32)(id >> 32); | 669 | buf->f_fsid.val[1] = (u32)(id >> 32); |
| @@ -973,7 +996,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, | |||
| 973 | 996 | ||
| 974 | static int nilfs_tree_was_touched(struct dentry *root_dentry) | 997 | static int nilfs_tree_was_touched(struct dentry *root_dentry) |
| 975 | { | 998 | { |
| 976 | return root_dentry->d_count > 1; | 999 | return d_count(root_dentry) > 1; |
| 977 | } | 1000 | } |
| 978 | 1001 | ||
| 979 | /** | 1002 | /** |
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 41e6a04a561f..94c451ce6d24 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
| @@ -764,8 +764,8 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) | |||
| 764 | new->ifile = NULL; | 764 | new->ifile = NULL; |
| 765 | new->nilfs = nilfs; | 765 | new->nilfs = nilfs; |
| 766 | atomic_set(&new->count, 1); | 766 | atomic_set(&new->count, 1); |
| 767 | atomic_set(&new->inodes_count, 0); | 767 | atomic64_set(&new->inodes_count, 0); |
| 768 | atomic_set(&new->blocks_count, 0); | 768 | atomic64_set(&new->blocks_count, 0); |
| 769 | 769 | ||
| 770 | rb_link_node(&new->rb_node, parent, p); | 770 | rb_link_node(&new->rb_node, parent, p); |
| 771 | rb_insert_color(&new->rb_node, &nilfs->ns_cptree); | 771 | rb_insert_color(&new->rb_node, &nilfs->ns_cptree); |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index be1267a34cea..de8cc53b4a5c 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
| @@ -241,8 +241,8 @@ struct nilfs_root { | |||
| 241 | struct the_nilfs *nilfs; | 241 | struct the_nilfs *nilfs; |
| 242 | struct inode *ifile; | 242 | struct inode *ifile; |
| 243 | 243 | ||
| 244 | atomic_t inodes_count; | 244 | atomic64_t inodes_count; |
| 245 | atomic_t blocks_count; | 245 | atomic64_t blocks_count; |
| 246 | }; | 246 | }; |
| 247 | 247 | ||
| 248 | /* Special checkpoint number */ | 248 | /* Special checkpoint number */ |
