28
28
* @ino: inode number
29
29
* @cno: checkpoint number
30
30
* @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
34
32
*/
35
33
struct nilfs_iget_args {
36
34
u64 ino ;
37
35
__u64 cno ;
38
36
struct nilfs_root * root ;
39
- bool for_gc ;
40
- bool for_btnc ;
41
- bool for_shadow ;
37
+ unsigned int type ;
42
38
};
43
39
44
40
static int nilfs_iget_test (struct inode * inode , void * opaque );
@@ -315,8 +311,7 @@ static int nilfs_insert_inode_locked(struct inode *inode,
315
311
unsigned long ino )
316
312
{
317
313
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
320
315
};
321
316
322
317
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)
343
338
root = NILFS_I (dir )-> i_root ;
344
339
ii = NILFS_I (inode );
345
340
ii -> i_state = BIT (NILFS_I_NEW );
341
+ ii -> i_type = NILFS_I_TYPE_NORMAL ;
346
342
ii -> i_root = root ;
347
343
348
344
err = nilfs_ifile_create_inode (root -> ifile , & ino , & bh );
@@ -546,23 +542,10 @@ static int nilfs_iget_test(struct inode *inode, void *opaque)
546
542
return 0 ;
547
543
548
544
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 )
553
546
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
- }
561
547
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 ;
566
549
}
567
550
568
551
static int nilfs_iget_set (struct inode * inode , void * opaque )
@@ -572,24 +555,17 @@ static int nilfs_iget_set(struct inode *inode, void *opaque)
572
555
inode -> i_ino = args -> ino ;
573
556
NILFS_I (inode )-> i_cno = args -> cno ;
574
557
NILFS_I (inode )-> i_root = args -> root ;
558
+ NILFS_I (inode )-> i_type = args -> type ;
575
559
if (args -> root && args -> ino == NILFS_ROOT_INO )
576
560
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 );
584
561
return 0 ;
585
562
}
586
563
587
564
struct inode * nilfs_ilookup (struct super_block * sb , struct nilfs_root * root ,
588
565
unsigned long ino )
589
566
{
590
567
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
593
569
};
594
570
595
571
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,
599
575
unsigned long ino )
600
576
{
601
577
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
604
579
};
605
580
606
581
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,
631
606
__u64 cno )
632
607
{
633
608
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
636
610
};
637
611
struct inode * inode ;
638
612
int err ;
@@ -677,9 +651,7 @@ int nilfs_attach_btree_node_cache(struct inode *inode)
677
651
args .ino = inode -> i_ino ;
678
652
args .root = ii -> i_root ;
679
653
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 ;
683
655
684
656
btnc_inode = iget5_locked (inode -> i_sb , inode -> i_ino , nilfs_iget_test ,
685
657
nilfs_iget_set , & args );
@@ -733,8 +705,8 @@ void nilfs_detach_btree_node_cache(struct inode *inode)
733
705
struct inode * nilfs_iget_for_shadow (struct inode * inode )
734
706
{
735
707
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
738
710
};
739
711
struct inode * s_inode ;
740
712
int err ;
@@ -900,7 +872,7 @@ static void nilfs_clear_inode(struct inode *inode)
900
872
if (test_bit (NILFS_I_BMAP , & ii -> i_state ))
901
873
nilfs_bmap_clear (ii -> i_bmap );
902
874
903
- if (!test_bit ( NILFS_I_BTNC , & ii -> i_state ))
875
+ if (!( ii -> i_type & NILFS_I_TYPE_BTNC ))
904
876
nilfs_detach_btree_node_cache (inode );
905
877
906
878
if (ii -> i_root && inode -> i_ino == NILFS_ROOT_INO )
0 commit comments