aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/inode.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-20 08:20:29 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:33 -0400
commit0e14a3595bddedfb27b51a6b0a29b5173aa2511a (patch)
treeec1e831c77a7de04315871e687082bb9230a17d7 /fs/nilfs2/inode.c
parent6c43f41000312fefa482c3bfdd97e7f81d6be0ec (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>
Diffstat (limited to 'fs/nilfs2/inode.c')
-rw-r--r--fs/nilfs2/inode.c37
1 files changed, 34 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
37struct 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
482static 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
497static 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
479struct inode *nilfs_iget(struct super_block *sb, unsigned long ino) 509struct 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))