File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,14 @@ static unsigned bch2_inode_hash(subvol_inum inum)
177
177
return jhash_3words (inum .subvol , inum .inum >> 32 , inum .inum , JHASH_INITVAL );
178
178
}
179
179
180
+ struct bch_inode_info * __bch2_inode_hash_find (struct bch_fs * c , subvol_inum inum )
181
+ {
182
+ return to_bch_ei (ilookup5_nowait (c -> vfs_sb ,
183
+ bch2_inode_hash (inum ),
184
+ bch2_iget5_test ,
185
+ & inum ));
186
+ }
187
+
180
188
static struct bch_inode_info * bch2_inode_insert (struct bch_fs * c , struct bch_inode_info * inode )
181
189
{
182
190
subvol_inum inum = inode_inum (inode );
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ static inline subvol_inum inode_inum(struct bch_inode_info *inode)
56
56
};
57
57
}
58
58
59
+ struct bch_inode_info * __bch2_inode_hash_find (struct bch_fs * , subvol_inum );
60
+
59
61
/*
60
62
* Set if we've gotten a btree error for this inode, and thus the vfs inode and
61
63
* btree inode may be inconsistent:
@@ -194,6 +196,11 @@ int bch2_vfs_init(void);
194
196
195
197
#define bch2_inode_update_after_write (_trans , _inode , _inode_u , _fields ) ({ do {} while (0); })
196
198
199
+ static inline struct bch_inode_info * __bch2_inode_hash_find (struct bch_fs * c , subvol_inum inum )
200
+ {
201
+ return NULL ;
202
+ }
203
+
197
204
static inline void bch2_evict_subvolume_inodes (struct bch_fs * c ,
198
205
snapshot_id_list * s ) {}
199
206
static inline void bch2_vfs_exit (void ) {}
Original file line number Diff line number Diff line change 8
8
#include "darray.h"
9
9
#include "dirent.h"
10
10
#include "error.h"
11
+ #include "fs.h"
11
12
#include "fs-common.h"
12
13
#include "fsck.h"
13
14
#include "inode.h"
@@ -962,6 +963,22 @@ static int check_inode_dirent_inode(struct btree_trans *trans, struct bkey_s_c i
962
963
return ret ;
963
964
}
964
965
966
+ static bool bch2_inode_open (struct bch_fs * c , struct bpos p )
967
+ {
968
+ subvol_inum inum = {
969
+ .subvol = snapshot_t (c , p .snapshot )-> subvol ,
970
+ .inum = p .offset ,
971
+ };
972
+
973
+ /* snapshot tree corruption, can't safely delete */
974
+ if (!inum .subvol ) {
975
+ bch_err_ratelimited (c , "%s(): snapshot %u has no subvol" , __func__ , p .snapshot );
976
+ return true;
977
+ }
978
+
979
+ return __bch2_inode_hash_find (c , inum ) != NULL ;
980
+ }
981
+
965
982
static int check_inode (struct btree_trans * trans ,
966
983
struct btree_iter * iter ,
967
984
struct bkey_s_c k ,
@@ -1040,6 +1057,7 @@ static int check_inode(struct btree_trans *trans,
1040
1057
}
1041
1058
1042
1059
if (u .bi_flags & BCH_INODE_unlinked &&
1060
+ !bch2_inode_open (c , k .k -> p ) &&
1043
1061
(!c -> sb .clean ||
1044
1062
fsck_err (trans , inode_unlinked_but_clean ,
1045
1063
"filesystem marked clean, but inode %llu unlinked" ,
You can’t perform that action at this time.
0 commit comments