diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-08-20 08:20:29 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-10-22 20:24:33 -0400 |
commit | 0e14a3595bddedfb27b51a6b0a29b5173aa2511a (patch) | |
tree | ec1e831c77a7de04315871e687082bb9230a17d7 | |
parent | 6c43f41000312fefa482c3bfdd97e7f81d6be0ec (diff) |
nilfs2: use iget5_locked to get inode
This uses iget5_locked instead of iget_locked so that gc cache can
look up inodes with an inode number and an optional checkpoint number.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r-- | fs/nilfs2/inode.c | 37 | ||||
-rw-r--r-- | fs/nilfs2/super.c | 1 |
2 files changed, 35 insertions, 3 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index f1750caa362c..6e9df85b5824 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
@@ -34,6 +34,11 @@ | |||
34 | #include "cpfile.h" | 34 | #include "cpfile.h" |
35 | #include "ifile.h" | 35 | #include "ifile.h" |
36 | 36 | ||
37 | struct nilfs_iget_args { | ||
38 | u64 ino; | ||
39 | __u64 cno; | ||
40 | int for_gc; | ||
41 | }; | ||
37 | 42 | ||
38 | /** | 43 | /** |
39 | * nilfs_get_block() - get a file block on the filesystem (callback function) | 44 | * nilfs_get_block() - get a file block on the filesystem (callback function) |
@@ -320,7 +325,6 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode) | |||
320 | /* ii->i_file_acl = 0; */ | 325 | /* ii->i_file_acl = 0; */ |
321 | /* ii->i_dir_acl = 0; */ | 326 | /* ii->i_dir_acl = 0; */ |
322 | ii->i_dir_start_lookup = 0; | 327 | ii->i_dir_start_lookup = 0; |
323 | ii->i_cno = 0; | ||
324 | nilfs_set_inode_flags(inode); | 328 | nilfs_set_inode_flags(inode); |
325 | spin_lock(&sbi->s_next_gen_lock); | 329 | spin_lock(&sbi->s_next_gen_lock); |
326 | inode->i_generation = sbi->s_next_generation++; | 330 | inode->i_generation = sbi->s_next_generation++; |
@@ -410,7 +414,6 @@ int nilfs_read_inode_common(struct inode *inode, | |||
410 | 0 : le32_to_cpu(raw_inode->i_dir_acl); | 414 | 0 : le32_to_cpu(raw_inode->i_dir_acl); |
411 | #endif | 415 | #endif |
412 | ii->i_dir_start_lookup = 0; | 416 | ii->i_dir_start_lookup = 0; |
413 | ii->i_cno = 0; | ||
414 | inode->i_generation = le32_to_cpu(raw_inode->i_generation); | 417 | inode->i_generation = le32_to_cpu(raw_inode->i_generation); |
415 | 418 | ||
416 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 419 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
@@ -476,12 +479,40 @@ static int __nilfs_read_inode(struct super_block *sb, unsigned long ino, | |||
476 | return err; | 479 | return err; |
477 | } | 480 | } |
478 | 481 | ||
482 | static int nilfs_iget_test(struct inode *inode, void *opaque) | ||
483 | { | ||
484 | struct nilfs_iget_args *args = opaque; | ||
485 | struct nilfs_inode_info *ii; | ||
486 | |||
487 | if (args->ino != inode->i_ino) | ||
488 | return 0; | ||
489 | |||
490 | ii = NILFS_I(inode); | ||
491 | if (!test_bit(NILFS_I_GCINODE, &ii->i_state)) | ||
492 | return !args->for_gc; | ||
493 | |||
494 | return args->for_gc && args->cno == ii->i_cno; | ||
495 | } | ||
496 | |||
497 | static int nilfs_iget_set(struct inode *inode, void *opaque) | ||
498 | { | ||
499 | struct nilfs_iget_args *args = opaque; | ||
500 | |||
501 | inode->i_ino = args->ino; | ||
502 | if (args->for_gc) { | ||
503 | NILFS_I(inode)->i_state = 1 << NILFS_I_GCINODE; | ||
504 | NILFS_I(inode)->i_cno = args->cno; | ||
505 | } | ||
506 | return 0; | ||
507 | } | ||
508 | |||
479 | struct inode *nilfs_iget(struct super_block *sb, unsigned long ino) | 509 | struct inode *nilfs_iget(struct super_block *sb, unsigned long ino) |
480 | { | 510 | { |
511 | struct nilfs_iget_args args = { .ino = ino, .cno = 0, .for_gc = 0 }; | ||
481 | struct inode *inode; | 512 | struct inode *inode; |
482 | int err; | 513 | int err; |
483 | 514 | ||
484 | inode = iget_locked(sb, ino); | 515 | inode = iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args); |
485 | if (unlikely(!inode)) | 516 | if (unlikely(!inode)) |
486 | return ERR_PTR(-ENOMEM); | 517 | return ERR_PTR(-ENOMEM); |
487 | if (!(inode->i_state & I_NEW)) | 518 | if (!(inode->i_state & I_NEW)) |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 51576b4dbf7a..f3a00a3b2a03 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -155,6 +155,7 @@ struct inode *nilfs_alloc_inode_common(struct the_nilfs *nilfs) | |||
155 | return NULL; | 155 | return NULL; |
156 | ii->i_bh = NULL; | 156 | ii->i_bh = NULL; |
157 | ii->i_state = 0; | 157 | ii->i_state = 0; |
158 | ii->i_cno = 0; | ||
158 | ii->vfs_inode.i_version = 1; | 159 | ii->vfs_inode.i_version = 1; |
159 | nilfs_btnode_cache_init(&ii->i_btnode_cache, nilfs->ns_bdi); | 160 | nilfs_btnode_cache_init(&ii->i_btnode_cache, nilfs->ns_bdi); |
160 | return &ii->vfs_inode; | 161 | return &ii->vfs_inode; |