summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bcachefs_format.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-10 23:42:30 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:10:12 +0300
commitb030e262b517b6bddc4bfa88ed8d335ef9de7671 (patch)
treeb0a1aea8f9773b926352e091f9d4a2c8ef31fcf5 /fs/bcachefs/bcachefs_format.h
parentaaad530ac6b1c836de4a29d227ab68be97e39a73 (diff)
downloadlinux-b030e262b517b6bddc4bfa88ed8d335ef9de7671.tar.xz
bcachefs: Log truncate operations
Previously, we guaranteed atomicity of truncate after unclean shutdown with the BCH_INODE_I_SIZE_DIRTY flag - which required a full scan of the inodes btree. Recently the deleted inodes btree was added so that we no longer have to scan for deleted inodes, but truncate was unfinished and that change left it broken. This patch uses the new logged operations btree to fix truncate atomicity; we now log an operation that can be replayed at the start of a truncate. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bcachefs_format.h')
-rw-r--r--fs/bcachefs/bcachefs_format.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index 31efa9e381ce..3c9e788f1c9d 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -370,7 +370,8 @@ static inline void bkey_init(struct bkey *k)
x(backpointer, 28) \
x(inode_v3, 29) \
x(bucket_gens, 30) \
- x(snapshot_tree, 31)
+ x(snapshot_tree, 31) \
+ x(logged_op_truncate, 32)
enum bch_bkey_type {
#define x(name, nr) KEY_TYPE_##name = nr,
@@ -847,8 +848,8 @@ enum {
__BCH_INODE_NODUMP = 3,
__BCH_INODE_NOATIME = 4,
- __BCH_INODE_I_SIZE_DIRTY = 5,
- __BCH_INODE_I_SECTORS_DIRTY = 6,
+ __BCH_INODE_I_SIZE_DIRTY = 5, /* obsolete */
+ __BCH_INODE_I_SECTORS_DIRTY = 6, /* obsolete */
__BCH_INODE_UNLINKED = 7,
__BCH_INODE_BACKPTR_UNTRUSTED = 8,
@@ -1183,6 +1184,16 @@ struct bch_lru {
#define LRU_ID_STRIPES (1U << 16)
+/* Logged operations btree: */
+
+struct bch_logged_op_truncate {
+ struct bch_val v;
+ __le32 subvol;
+ __le32 pad;
+ __le64 inum;
+ __le64 new_i_size;
+};
+
/* Optional/variable size superblock sections: */
struct bch_sb_field {
@@ -2251,7 +2262,7 @@ enum btree_id_flags {
x(deleted_inodes, 16, BTREE_ID_SNAPSHOTS, \
BIT_ULL(KEY_TYPE_set)) \
x(logged_ops, 17, 0, \
- 0)
+ BIT_ULL(KEY_TYPE_logged_op_truncate))
enum btree_id {
#define x(name, nr, ...) BTREE_ID_##name = nr,