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

bcachefs: split out ignore_blacklisted, ignore_not_dirty

prep work for replaying the journal backwards

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

+33 -21
+1 -1
fs/bcachefs/btree_journal_iter.c
··· 512 512 genradix_for_each(&c->journal_entries, iter, _i) { 513 513 i = *_i; 514 514 515 - if (!i || i->ignore) 515 + if (journal_replay_ignore(i)) 516 516 continue; 517 517 518 518 cond_resched();
+2 -2
fs/bcachefs/journal.c
··· 1204 1204 genradix_for_each_reverse(&c->journal_entries, iter, _i) { 1205 1205 i = *_i; 1206 1206 1207 - if (!i || i->ignore) 1207 + if (journal_replay_ignore(i)) 1208 1208 continue; 1209 1209 1210 1210 last_seq = le64_to_cpu(i->j.last_seq); ··· 1237 1237 genradix_for_each(&c->journal_entries, iter, _i) { 1238 1238 i = *_i; 1239 1239 1240 - if (!i || i->ignore) 1240 + if (journal_replay_ignore(i)) 1241 1241 continue; 1242 1242 1243 1243 seq = le64_to_cpu(i->j.seq);
+19 -14
fs/bcachefs/journal_io.c
··· 86 86 kvfree(i); 87 87 } 88 88 89 - static void journal_replay_free(struct bch_fs *c, struct journal_replay *i) 89 + static void journal_replay_free(struct bch_fs *c, struct journal_replay *i, bool blacklisted) 90 90 { 91 - i->ignore = true; 91 + if (blacklisted) 92 + i->ignore_blacklisted = true; 93 + else 94 + i->ignore_not_dirty = true; 92 95 93 96 if (!c->opts.read_entire_journal) 94 97 __journal_replay_free(c, i); ··· 141 138 journal_entry_radix_idx(c, jlist->last_seq)) { 142 139 i = *_i; 143 140 144 - if (!i || i->ignore) 141 + if (journal_replay_ignore(i)) 145 142 continue; 146 143 147 144 if (le64_to_cpu(i->j.seq) >= last_seq) 148 145 break; 149 - journal_replay_free(c, i); 146 + 147 + journal_replay_free(c, i, false); 150 148 } 151 149 } 152 150 ··· 203 199 return -BCH_ERR_ENOMEM_journal_entry_add; 204 200 205 201 darray_init(&i->ptrs); 206 - i->csum_good = entry_ptr.csum_good; 207 - i->ignore = false; 202 + i->csum_good = entry_ptr.csum_good; 203 + i->ignore_blacklisted = false; 204 + i->ignore_not_dirty = false; 208 205 unsafe_memcpy(&i->j, j, bytes, "embedded variable length struct"); 209 206 210 207 if (dup) { ··· 1260 1255 1261 1256 i = *_i; 1262 1257 1263 - if (!i || i->ignore) 1258 + if (journal_replay_ignore(i)) 1264 1259 continue; 1265 1260 1266 1261 if (!*start_seq) 1267 1262 *blacklist_seq = *start_seq = le64_to_cpu(i->j.seq) + 1; 1268 1263 1269 1264 if (JSET_NO_FLUSH(&i->j)) { 1270 - i->ignore = true; 1265 + i->ignore_blacklisted = true; 1271 1266 continue; 1272 1267 } 1273 1268 1274 1269 if (!last_write_torn && !i->csum_good) { 1275 1270 last_write_torn = true; 1276 - i->ignore = true; 1271 + i->ignore_blacklisted = true; 1277 1272 continue; 1278 1273 } 1279 1274 ··· 1312 1307 genradix_for_each(&c->journal_entries, radix_iter, _i) { 1313 1308 i = *_i; 1314 1309 1315 - if (!i || i->ignore) 1310 + if (journal_replay_ignore(i)) 1316 1311 continue; 1317 1312 1318 1313 seq = le64_to_cpu(i->j.seq); 1319 1314 if (seq < *last_seq) { 1320 - journal_replay_free(c, i); 1315 + journal_replay_free(c, i, false); 1321 1316 continue; 1322 1317 } 1323 1318 ··· 1325 1320 fsck_err_on(!JSET_NO_FLUSH(&i->j), c, 1326 1321 jset_seq_blacklisted, 1327 1322 "found blacklisted journal entry %llu", seq); 1328 - i->ignore = true; 1323 + i->ignore_blacklisted = true; 1329 1324 } 1330 1325 } 1331 1326 ··· 1334 1329 genradix_for_each(&c->journal_entries, radix_iter, _i) { 1335 1330 i = *_i; 1336 1331 1337 - if (!i || i->ignore) 1332 + if (journal_replay_ignore(i)) 1338 1333 continue; 1339 1334 1340 1335 BUG_ON(seq > le64_to_cpu(i->j.seq)); ··· 1387 1382 }; 1388 1383 1389 1384 i = *_i; 1390 - if (!i || i->ignore) 1385 + if (journal_replay_ignore(i)) 1391 1386 continue; 1392 1387 1393 1388 darray_for_each(i->ptrs, ptr) {
+7 -1
fs/bcachefs/journal_io.h
··· 20 20 DARRAY_PREALLOCATED(struct journal_ptr, 8) ptrs; 21 21 22 22 bool csum_good; 23 - bool ignore; 23 + bool ignore_blacklisted; 24 + bool ignore_not_dirty; 24 25 /* must be last: */ 25 26 struct jset j; 26 27 }; 28 + 29 + static inline bool journal_replay_ignore(struct journal_replay *i) 30 + { 31 + return !i || i->ignore_blacklisted || i->ignore_not_dirty; 32 + } 27 33 28 34 static inline struct jset_entry *__jset_entry_type_next(struct jset *jset, 29 35 struct jset_entry *entry, unsigned type)
+4 -3
fs/bcachefs/recovery.c
··· 366 366 genradix_for_each(&c->journal_entries, iter, _i) { 367 367 i = *_i; 368 368 369 - if (!i || i->ignore) 369 + if (journal_replay_ignore(i)) 370 370 continue; 371 371 372 372 vstruct_for_each(&i->j, entry) { ··· 868 868 goto out; 869 869 870 870 genradix_for_each_reverse(&c->journal_entries, iter, i) 871 - if (*i && !(*i)->ignore) { 871 + if (!journal_replay_ignore(*i)) { 872 872 last_journal_entry = &(*i)->j; 873 873 break; 874 874 } ··· 893 893 genradix_for_each_reverse(&c->journal_entries, iter, i) 894 894 if (*i) { 895 895 last_journal_entry = &(*i)->j; 896 - (*i)->ignore = false; 896 + (*i)->ignore_blacklisted = false; 897 + (*i)->ignore_not_dirty= false; 897 898 /* 898 899 * This was probably a NO_FLUSH entry, 899 900 * so last_seq was garbage - but we know