Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bcachefs: Don't delete open files in online fsck

If a file is unlinked but still open, we don't want online fsck to
delete it - or fun inconsistencies will happen.

https://github.com/koverstreet/bcachefs/issues/727

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+33
+8
fs/bcachefs/fs.c
··· 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);
+7
fs/bcachefs/fs.h
··· 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: ··· 195 193 #else 196 194 197 195 #define bch2_inode_update_after_write(_trans, _inode, _inode_u, _fields) ({ do {} while (0); }) 196 + 197 + static inline struct bch_inode_info *__bch2_inode_hash_find(struct bch_fs *c, subvol_inum inum) 198 + { 199 + return NULL; 200 + } 198 201 199 202 static inline void bch2_evict_subvolume_inodes(struct bch_fs *c, 200 203 snapshot_id_list *s) {}
+18
fs/bcachefs/fsck.c
··· 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" ··· 963 962 return ret; 964 963 } 965 964 965 + static bool bch2_inode_open(struct bch_fs *c, struct bpos p) 966 + { 967 + subvol_inum inum = { 968 + .subvol = snapshot_t(c, p.snapshot)->subvol, 969 + .inum = p.offset, 970 + }; 971 + 972 + /* snapshot tree corruption, can't safely delete */ 973 + if (!inum.subvol) { 974 + bch_err_ratelimited(c, "%s(): snapshot %u has no subvol", __func__, p.snapshot); 975 + return true; 976 + } 977 + 978 + return __bch2_inode_hash_find(c, inum) != NULL; 979 + } 980 + 966 981 static int check_inode(struct btree_trans *trans, 967 982 struct btree_iter *iter, 968 983 struct bkey_s_c k, ··· 1057 1040 } 1058 1041 1059 1042 if (u.bi_flags & BCH_INODE_unlinked && 1043 + !bch2_inode_open(c, k.k->p) && 1060 1044 (!c->sb.clean || 1061 1045 fsck_err(trans, inode_unlinked_but_clean, 1062 1046 "filesystem marked clean, but inode %llu unlinked",