Skip to content

Commit 9fcdd23

Browse files
author
Kent Overstreet
committed
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>
1 parent d3c7727 commit 9fcdd23

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

fs/bcachefs/btree_iter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static void bch2_btree_iter_verify(struct btree_iter *iter)
257257

258258
BUG_ON(!(iter->flags & __BTREE_ITER_ALL_SNAPSHOTS) &&
259259
(iter->flags & BTREE_ITER_ALL_SNAPSHOTS) &&
260-
!btree_type_has_snapshots(iter->btree_id));
260+
!btree_type_has_snapshot_field(iter->btree_id));
261261

262262
if (iter->update_path)
263263
bch2_btree_path_verify(trans, iter->update_path);

fs/bcachefs/btree_iter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ static inline unsigned __bch2_btree_iter_flags(struct btree_trans *trans,
416416
flags |= BTREE_ITER_IS_EXTENTS;
417417

418418
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))
421420
flags &= ~BTREE_ITER_ALL_SNAPSHOTS;
422421

423422
if (!(flags & BTREE_ITER_ALL_SNAPSHOTS) &&

fs/bcachefs/btree_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static inline bool btree_type_has_snapshots(enum btree_id id)
713713
static inline bool btree_type_has_snapshot_field(enum btree_id id)
714714
{
715715
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)
717717
BCH_BTREE_IDS()
718718
#undef x
719719
;

fs/bcachefs/io_write.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ static inline int bch2_extent_update_i_size_sectors(struct btree_trans *trans,
202202
struct btree_iter iter;
203203
struct bkey_i *k;
204204
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+
*/
205216
unsigned inode_update_flags = BTREE_UPDATE_NOJOURNAL;
206217
int ret;
207218

0 commit comments

Comments
 (0)