@@ -138,7 +138,7 @@ static void wait_log_commit(struct btrfs_root *root, int transid);
138
138
* and once to do all the other items.
139
139
*/
140
140
141
- static struct inode * btrfs_iget_logging (u64 objectid , struct btrfs_root * root )
141
+ static struct btrfs_inode * btrfs_iget_logging (u64 objectid , struct btrfs_root * root )
142
142
{
143
143
unsigned int nofs_flag ;
144
144
struct inode * inode ;
@@ -154,7 +154,10 @@ static struct inode *btrfs_iget_logging(u64 objectid, struct btrfs_root *root)
154
154
inode = btrfs_iget (objectid , root );
155
155
memalloc_nofs_restore (nofs_flag );
156
156
157
- return inode ;
157
+ if (IS_ERR (inode ))
158
+ return ERR_CAST (inode );
159
+
160
+ return BTRFS_I (inode );
158
161
}
159
162
160
163
/*
@@ -616,12 +619,12 @@ static int read_alloc_one_name(struct extent_buffer *eb, void *start, int len,
616
619
static noinline struct inode * read_one_inode (struct btrfs_root * root ,
617
620
u64 objectid )
618
621
{
619
- struct inode * inode ;
622
+ struct btrfs_inode * inode ;
620
623
621
624
inode = btrfs_iget_logging (objectid , root );
622
625
if (IS_ERR (inode ))
623
- inode = NULL ;
624
- return inode ;
626
+ return NULL ;
627
+ return & inode -> vfs_inode ;
625
628
}
626
629
627
630
/* replays a single extent in 'eb' at 'slot' with 'key' into the
@@ -5481,7 +5484,6 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5481
5484
ihold (& curr_inode -> vfs_inode );
5482
5485
5483
5486
while (true) {
5484
- struct inode * vfs_inode ;
5485
5487
struct btrfs_key key ;
5486
5488
struct btrfs_key found_key ;
5487
5489
u64 next_index ;
@@ -5497,7 +5499,7 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5497
5499
struct extent_buffer * leaf = path -> nodes [0 ];
5498
5500
struct btrfs_dir_item * di ;
5499
5501
struct btrfs_key di_key ;
5500
- struct inode * di_inode ;
5502
+ struct btrfs_inode * di_inode ;
5501
5503
int log_mode = LOG_INODE_EXISTS ;
5502
5504
int type ;
5503
5505
@@ -5524,17 +5526,16 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5524
5526
goto out ;
5525
5527
}
5526
5528
5527
- if (!need_log_inode (trans , BTRFS_I ( di_inode ) )) {
5528
- btrfs_add_delayed_iput (BTRFS_I ( di_inode ) );
5529
+ if (!need_log_inode (trans , di_inode )) {
5530
+ btrfs_add_delayed_iput (di_inode );
5529
5531
break ;
5530
5532
}
5531
5533
5532
5534
ctx -> log_new_dentries = false;
5533
5535
if (type == BTRFS_FT_DIR )
5534
5536
log_mode = LOG_INODE_ALL ;
5535
- ret = btrfs_log_inode (trans , BTRFS_I (di_inode ),
5536
- log_mode , ctx );
5537
- btrfs_add_delayed_iput (BTRFS_I (di_inode ));
5537
+ ret = btrfs_log_inode (trans , di_inode , log_mode , ctx );
5538
+ btrfs_add_delayed_iput (di_inode );
5538
5539
if (ret )
5539
5540
goto out ;
5540
5541
if (ctx -> log_new_dentries ) {
@@ -5576,14 +5577,13 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5576
5577
kfree (dir_elem );
5577
5578
5578
5579
btrfs_add_delayed_iput (curr_inode );
5579
- curr_inode = NULL ;
5580
5580
5581
- vfs_inode = btrfs_iget_logging (ino , root );
5582
- if (IS_ERR (vfs_inode )) {
5583
- ret = PTR_ERR (vfs_inode );
5581
+ curr_inode = btrfs_iget_logging (ino , root );
5582
+ if (IS_ERR (curr_inode )) {
5583
+ ret = PTR_ERR (curr_inode );
5584
+ curr_inode = NULL ;
5584
5585
break ;
5585
5586
}
5586
- curr_inode = BTRFS_I (vfs_inode );
5587
5587
}
5588
5588
out :
5589
5589
btrfs_free_path (path );
@@ -5661,7 +5661,7 @@ static int add_conflicting_inode(struct btrfs_trans_handle *trans,
5661
5661
struct btrfs_log_ctx * ctx )
5662
5662
{
5663
5663
struct btrfs_ino_list * ino_elem ;
5664
- struct inode * inode ;
5664
+ struct btrfs_inode * inode ;
5665
5665
5666
5666
/*
5667
5667
* It's rare to have a lot of conflicting inodes, in practice it is not
@@ -5752,12 +5752,12 @@ static int add_conflicting_inode(struct btrfs_trans_handle *trans,
5752
5752
* inode in LOG_INODE_EXISTS mode and rename operations update the log,
5753
5753
* so that the log ends up with the new name and without the old name.
5754
5754
*/
5755
- if (!need_log_inode (trans , BTRFS_I ( inode ) )) {
5756
- btrfs_add_delayed_iput (BTRFS_I ( inode ) );
5755
+ if (!need_log_inode (trans , inode )) {
5756
+ btrfs_add_delayed_iput (inode );
5757
5757
return 0 ;
5758
5758
}
5759
5759
5760
- btrfs_add_delayed_iput (BTRFS_I ( inode ) );
5760
+ btrfs_add_delayed_iput (inode );
5761
5761
5762
5762
ino_elem = kmalloc (sizeof (* ino_elem ), GFP_NOFS );
5763
5763
if (!ino_elem )
@@ -5793,7 +5793,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
5793
5793
*/
5794
5794
while (!list_empty (& ctx -> conflict_inodes )) {
5795
5795
struct btrfs_ino_list * curr ;
5796
- struct inode * inode ;
5796
+ struct btrfs_inode * inode ;
5797
5797
u64 ino ;
5798
5798
u64 parent ;
5799
5799
@@ -5829,9 +5829,8 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
5829
5829
* dir index key range logged for the directory. So we
5830
5830
* must make sure the deletion is recorded.
5831
5831
*/
5832
- ret = btrfs_log_inode (trans , BTRFS_I (inode ),
5833
- LOG_INODE_ALL , ctx );
5834
- btrfs_add_delayed_iput (BTRFS_I (inode ));
5832
+ ret = btrfs_log_inode (trans , inode , LOG_INODE_ALL , ctx );
5833
+ btrfs_add_delayed_iput (inode );
5835
5834
if (ret )
5836
5835
break ;
5837
5836
continue ;
@@ -5847,8 +5846,8 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
5847
5846
* it again because if some other task logged the inode after
5848
5847
* that, we can avoid doing it again.
5849
5848
*/
5850
- if (!need_log_inode (trans , BTRFS_I ( inode ) )) {
5851
- btrfs_add_delayed_iput (BTRFS_I ( inode ) );
5849
+ if (!need_log_inode (trans , inode )) {
5850
+ btrfs_add_delayed_iput (inode );
5852
5851
continue ;
5853
5852
}
5854
5853
@@ -5859,8 +5858,8 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
5859
5858
* well because during a rename we pin the log and update the
5860
5859
* log with the new name before we unpin it.
5861
5860
*/
5862
- ret = btrfs_log_inode (trans , BTRFS_I ( inode ) , LOG_INODE_EXISTS , ctx );
5863
- btrfs_add_delayed_iput (BTRFS_I ( inode ) );
5861
+ ret = btrfs_log_inode (trans , inode , LOG_INODE_EXISTS , ctx );
5862
+ btrfs_add_delayed_iput (inode );
5864
5863
if (ret )
5865
5864
break ;
5866
5865
}
@@ -6351,7 +6350,7 @@ static int log_new_delayed_dentries(struct btrfs_trans_handle *trans,
6351
6350
6352
6351
list_for_each_entry (item , delayed_ins_list , log_list ) {
6353
6352
struct btrfs_dir_item * dir_item ;
6354
- struct inode * di_inode ;
6353
+ struct btrfs_inode * di_inode ;
6355
6354
struct btrfs_key key ;
6356
6355
int log_mode = LOG_INODE_EXISTS ;
6357
6356
@@ -6367,21 +6366,21 @@ static int log_new_delayed_dentries(struct btrfs_trans_handle *trans,
6367
6366
break ;
6368
6367
}
6369
6368
6370
- if (!need_log_inode (trans , BTRFS_I ( di_inode ) )) {
6371
- btrfs_add_delayed_iput (BTRFS_I ( di_inode ) );
6369
+ if (!need_log_inode (trans , di_inode )) {
6370
+ btrfs_add_delayed_iput (di_inode );
6372
6371
continue ;
6373
6372
}
6374
6373
6375
6374
if (btrfs_stack_dir_ftype (dir_item ) == BTRFS_FT_DIR )
6376
6375
log_mode = LOG_INODE_ALL ;
6377
6376
6378
6377
ctx -> log_new_dentries = false;
6379
- ret = btrfs_log_inode (trans , BTRFS_I ( di_inode ) , log_mode , ctx );
6378
+ ret = btrfs_log_inode (trans , di_inode , log_mode , ctx );
6380
6379
6381
6380
if (!ret && ctx -> log_new_dentries )
6382
- ret = log_new_dir_dentries (trans , BTRFS_I ( di_inode ) , ctx );
6381
+ ret = log_new_dir_dentries (trans , di_inode , ctx );
6383
6382
6384
- btrfs_add_delayed_iput (BTRFS_I ( di_inode ) );
6383
+ btrfs_add_delayed_iput (di_inode );
6385
6384
6386
6385
if (ret )
6387
6386
break ;
@@ -6789,7 +6788,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
6789
6788
ptr = btrfs_item_ptr_offset (leaf , slot );
6790
6789
while (cur_offset < item_size ) {
6791
6790
struct btrfs_key inode_key ;
6792
- struct inode * dir_inode ;
6791
+ struct btrfs_inode * dir_inode ;
6793
6792
6794
6793
inode_key .type = BTRFS_INODE_ITEM_KEY ;
6795
6794
inode_key .offset = 0 ;
@@ -6838,18 +6837,16 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
6838
6837
goto out ;
6839
6838
}
6840
6839
6841
- if (!need_log_inode (trans , BTRFS_I ( dir_inode ) )) {
6842
- btrfs_add_delayed_iput (BTRFS_I ( dir_inode ) );
6840
+ if (!need_log_inode (trans , dir_inode )) {
6841
+ btrfs_add_delayed_iput (dir_inode );
6843
6842
continue ;
6844
6843
}
6845
6844
6846
6845
ctx -> log_new_dentries = false;
6847
- ret = btrfs_log_inode (trans , BTRFS_I (dir_inode ),
6848
- LOG_INODE_ALL , ctx );
6846
+ ret = btrfs_log_inode (trans , dir_inode , LOG_INODE_ALL , ctx );
6849
6847
if (!ret && ctx -> log_new_dentries )
6850
- ret = log_new_dir_dentries (trans ,
6851
- BTRFS_I (dir_inode ), ctx );
6852
- btrfs_add_delayed_iput (BTRFS_I (dir_inode ));
6848
+ ret = log_new_dir_dentries (trans , dir_inode , ctx );
6849
+ btrfs_add_delayed_iput (dir_inode );
6853
6850
if (ret )
6854
6851
goto out ;
6855
6852
}
@@ -6874,7 +6871,7 @@ static int log_new_ancestors(struct btrfs_trans_handle *trans,
6874
6871
struct extent_buffer * leaf ;
6875
6872
int slot ;
6876
6873
struct btrfs_key search_key ;
6877
- struct inode * inode ;
6874
+ struct btrfs_inode * inode ;
6878
6875
u64 ino ;
6879
6876
int ret = 0 ;
6880
6877
@@ -6889,11 +6886,10 @@ static int log_new_ancestors(struct btrfs_trans_handle *trans,
6889
6886
if (IS_ERR (inode ))
6890
6887
return PTR_ERR (inode );
6891
6888
6892
- if (BTRFS_I (inode )-> generation >= trans -> transid &&
6893
- need_log_inode (trans , BTRFS_I (inode )))
6894
- ret = btrfs_log_inode (trans , BTRFS_I (inode ),
6895
- LOG_INODE_EXISTS , ctx );
6896
- btrfs_add_delayed_iput (BTRFS_I (inode ));
6889
+ if (inode -> generation >= trans -> transid &&
6890
+ need_log_inode (trans , inode ))
6891
+ ret = btrfs_log_inode (trans , inode , LOG_INODE_EXISTS , ctx );
6892
+ btrfs_add_delayed_iput (inode );
6897
6893
if (ret )
6898
6894
return ret ;
6899
6895
0 commit comments