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

bcachefs: Add a comment for BTREE_INSERT_NOJOURNAL usage

BTREE_INSERT_NOJOURNAL is primarily used for a performance optimization
related to inode updates and fsync - document it.

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

+14 -4
+1 -1
fs/bcachefs/btree_iter.c
··· 257 257 258 258 BUG_ON(!(iter->flags & __BTREE_ITER_ALL_SNAPSHOTS) && 259 259 (iter->flags & BTREE_ITER_ALL_SNAPSHOTS) && 260 - !btree_type_has_snapshots(iter->btree_id)); 260 + !btree_type_has_snapshot_field(iter->btree_id)); 261 261 262 262 if (iter->update_path) 263 263 bch2_btree_path_verify(trans, iter->update_path);
+1 -2
fs/bcachefs/btree_iter.h
··· 416 416 flags |= BTREE_ITER_IS_EXTENTS; 417 417 418 418 if (!(flags & __BTREE_ITER_ALL_SNAPSHOTS) && 419 - !btree_type_has_snapshot_field(btree_id) && 420 - !btree_type_has_snapshots(btree_id)) 419 + !btree_type_has_snapshot_field(btree_id)) 421 420 flags &= ~BTREE_ITER_ALL_SNAPSHOTS; 422 421 423 422 if (!(flags & BTREE_ITER_ALL_SNAPSHOTS) &&
+1 -1
fs/bcachefs/btree_types.h
··· 713 713 static inline bool btree_type_has_snapshot_field(enum btree_id id) 714 714 { 715 715 const unsigned mask = 0 716 - #define x(name, nr, flags, ...) |((!!((flags) & BTREE_ID_SNAPSHOT_FIELD)) << nr) 716 + #define x(name, nr, flags, ...) |((!!((flags) & (BTREE_ID_SNAPSHOT_FIELD|BTREE_ID_SNAPSHOTS))) << nr) 717 717 BCH_BTREE_IDS() 718 718 #undef x 719 719 ;
+11
fs/bcachefs/io_write.c
··· 202 202 struct btree_iter iter; 203 203 struct bkey_i *k; 204 204 struct bkey_i_inode_v3 *inode; 205 + /* 206 + * Crazy performance optimization: 207 + * Every extent update needs to also update the inode: the inode trigger 208 + * will set bi->journal_seq to the journal sequence number of this 209 + * transaction - for fsync. 210 + * 211 + * But if that's the only reason we're updating the inode (we're not 212 + * updating bi_size or bi_sectors), then we don't need the inode update 213 + * to be journalled - if we crash, the bi_journal_seq update will be 214 + * lost, but that's fine. 215 + */ 205 216 unsigned inode_update_flags = BTREE_UPDATE_NOJOURNAL; 206 217 int ret; 207 218