2828 * @ino: inode number
2929 * @cno: checkpoint number
3030 * @root: pointer on NILFS root object (mounted checkpoint)
31- * @for_gc: inode for GC flag
32- * @for_btnc: inode for B-tree node cache flag
33- * @for_shadow: inode for shadowed page cache flag
31+ * @type: inode type
3432 */
3533struct nilfs_iget_args {
3634 u64 ino ;
3735 __u64 cno ;
3836 struct nilfs_root * root ;
39- bool for_gc ;
40- bool for_btnc ;
41- bool for_shadow ;
37+ unsigned int type ;
4238};
4339
4440static int nilfs_iget_test (struct inode * inode , void * opaque );
@@ -315,8 +311,7 @@ static int nilfs_insert_inode_locked(struct inode *inode,
315311 unsigned long ino )
316312{
317313 struct nilfs_iget_args args = {
318- .ino = ino , .root = root , .cno = 0 , .for_gc = false,
319- .for_btnc = false, .for_shadow = false
314+ .ino = ino , .root = root , .cno = 0 , .type = NILFS_I_TYPE_NORMAL
320315 };
321316
322317 return insert_inode_locked4 (inode , ino , nilfs_iget_test , & args );
@@ -343,6 +338,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
343338 root = NILFS_I (dir )-> i_root ;
344339 ii = NILFS_I (inode );
345340 ii -> i_state = BIT (NILFS_I_NEW );
341+ ii -> i_type = NILFS_I_TYPE_NORMAL ;
346342 ii -> i_root = root ;
347343
348344 err = nilfs_ifile_create_inode (root -> ifile , & ino , & bh );
@@ -546,23 +542,10 @@ static int nilfs_iget_test(struct inode *inode, void *opaque)
546542 return 0 ;
547543
548544 ii = NILFS_I (inode );
549- if (test_bit (NILFS_I_BTNC , & ii -> i_state )) {
550- if (!args -> for_btnc )
551- return 0 ;
552- } else if (args -> for_btnc ) {
545+ if (ii -> i_type != args -> type )
553546 return 0 ;
554- }
555- if (test_bit (NILFS_I_SHADOW , & ii -> i_state )) {
556- if (!args -> for_shadow )
557- return 0 ;
558- } else if (args -> for_shadow ) {
559- return 0 ;
560- }
561547
562- if (!test_bit (NILFS_I_GCINODE , & ii -> i_state ))
563- return !args -> for_gc ;
564-
565- return args -> for_gc && args -> cno == ii -> i_cno ;
548+ return !(args -> type & NILFS_I_TYPE_GC ) || args -> cno == ii -> i_cno ;
566549}
567550
568551static int nilfs_iget_set (struct inode * inode , void * opaque )
@@ -572,24 +555,17 @@ static int nilfs_iget_set(struct inode *inode, void *opaque)
572555 inode -> i_ino = args -> ino ;
573556 NILFS_I (inode )-> i_cno = args -> cno ;
574557 NILFS_I (inode )-> i_root = args -> root ;
558+ NILFS_I (inode )-> i_type = args -> type ;
575559 if (args -> root && args -> ino == NILFS_ROOT_INO )
576560 nilfs_get_root (args -> root );
577-
578- if (args -> for_gc )
579- NILFS_I (inode )-> i_state = BIT (NILFS_I_GCINODE );
580- if (args -> for_btnc )
581- NILFS_I (inode )-> i_state |= BIT (NILFS_I_BTNC );
582- if (args -> for_shadow )
583- NILFS_I (inode )-> i_state |= BIT (NILFS_I_SHADOW );
584561 return 0 ;
585562}
586563
587564struct inode * nilfs_ilookup (struct super_block * sb , struct nilfs_root * root ,
588565 unsigned long ino )
589566{
590567 struct nilfs_iget_args args = {
591- .ino = ino , .root = root , .cno = 0 , .for_gc = false,
592- .for_btnc = false, .for_shadow = false
568+ .ino = ino , .root = root , .cno = 0 , .type = NILFS_I_TYPE_NORMAL
593569 };
594570
595571 return ilookup5 (sb , ino , nilfs_iget_test , & args );
@@ -599,8 +575,7 @@ struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root,
599575 unsigned long ino )
600576{
601577 struct nilfs_iget_args args = {
602- .ino = ino , .root = root , .cno = 0 , .for_gc = false,
603- .for_btnc = false, .for_shadow = false
578+ .ino = ino , .root = root , .cno = 0 , .type = NILFS_I_TYPE_NORMAL
604579 };
605580
606581 return iget5_locked (sb , ino , nilfs_iget_test , nilfs_iget_set , & args );
@@ -631,8 +606,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,
631606 __u64 cno )
632607{
633608 struct nilfs_iget_args args = {
634- .ino = ino , .root = NULL , .cno = cno , .for_gc = true,
635- .for_btnc = false, .for_shadow = false
609+ .ino = ino , .root = NULL , .cno = cno , .type = NILFS_I_TYPE_GC
636610 };
637611 struct inode * inode ;
638612 int err ;
@@ -677,9 +651,7 @@ int nilfs_attach_btree_node_cache(struct inode *inode)
677651 args .ino = inode -> i_ino ;
678652 args .root = ii -> i_root ;
679653 args .cno = ii -> i_cno ;
680- args .for_gc = test_bit (NILFS_I_GCINODE , & ii -> i_state ) != 0 ;
681- args .for_btnc = true;
682- args .for_shadow = test_bit (NILFS_I_SHADOW , & ii -> i_state ) != 0 ;
654+ args .type = ii -> i_type | NILFS_I_TYPE_BTNC ;
683655
684656 btnc_inode = iget5_locked (inode -> i_sb , inode -> i_ino , nilfs_iget_test ,
685657 nilfs_iget_set , & args );
@@ -733,8 +705,8 @@ void nilfs_detach_btree_node_cache(struct inode *inode)
733705struct inode * nilfs_iget_for_shadow (struct inode * inode )
734706{
735707 struct nilfs_iget_args args = {
736- .ino = inode -> i_ino , .root = NULL , .cno = 0 , . for_gc = false,
737- .for_btnc = false, . for_shadow = true
708+ .ino = inode -> i_ino , .root = NULL , .cno = 0 ,
709+ .type = NILFS_I_TYPE_SHADOW
738710 };
739711 struct inode * s_inode ;
740712 int err ;
@@ -900,7 +872,7 @@ static void nilfs_clear_inode(struct inode *inode)
900872 if (test_bit (NILFS_I_BMAP , & ii -> i_state ))
901873 nilfs_bmap_clear (ii -> i_bmap );
902874
903- if (!test_bit ( NILFS_I_BTNC , & ii -> i_state ))
875+ if (!( ii -> i_type & NILFS_I_TYPE_BTNC ))
904876 nilfs_detach_btree_node_cache (inode );
905877
906878 if (ii -> i_root && inode -> i_ino == NILFS_ROOT_INO )
0 commit comments