Skip to content

Commit dd83757

Browse files
committed
Merge tag 'bcachefs-2025-02-26' of git://evilpiepirate.org/bcachefs
Pull bcachefs fixes from Kent Overstreet: "A couple small ones, the main user visible changes/fixes are: - Fix a bug where truncate would rarely fail and return 1 - Revert the directory i_size code: this turned out to have a number of issues that weren't noticed because the fsck code wasn't correctly reporting errors (ouch), and we're late enough in the cycle that it can just wait until 6.15" * tag 'bcachefs-2025-02-26' of git://evilpiepirate.org/bcachefs: bcachefs: Fix truncate sometimes failing and returning 1 bcachefs: Fix deadlock bcachefs: Check for -BCH_ERR_open_buckets_empty in journal resize bcachefs: Revert directory i_size bcachefs: fix bch2_extent_ptr_eq() bcachefs: Fix memmove when move keys down bcachefs: print op->nonce on data update inconsistency
2 parents 102c16a + eb54d26 commit dd83757

15 files changed

+25
-57
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c)
203203
return NULL;
204204
}
205205

206-
bch2_btree_lock_init(&b->c, 0);
206+
bch2_btree_lock_init(&b->c, 0, GFP_KERNEL);
207207

208208
__bch2_btree_node_to_freelist(bc, b);
209209
return b;
@@ -795,17 +795,18 @@ struct btree *bch2_btree_node_mem_alloc(struct btree_trans *trans, bool pcpu_rea
795795
}
796796

797797
b = __btree_node_mem_alloc(c, GFP_NOWAIT|__GFP_NOWARN);
798-
if (!b) {
798+
if (b) {
799+
bch2_btree_lock_init(&b->c, pcpu_read_locks ? SIX_LOCK_INIT_PCPU : 0, GFP_NOWAIT);
800+
} else {
799801
mutex_unlock(&bc->lock);
800802
bch2_trans_unlock(trans);
801803
b = __btree_node_mem_alloc(c, GFP_KERNEL);
802804
if (!b)
803805
goto err;
806+
bch2_btree_lock_init(&b->c, pcpu_read_locks ? SIX_LOCK_INIT_PCPU : 0, GFP_KERNEL);
804807
mutex_lock(&bc->lock);
805808
}
806809

807-
bch2_btree_lock_init(&b->c, pcpu_read_locks ? SIX_LOCK_INIT_PCPU : 0);
808-
809810
BUG_ON(!six_trylock_intent(&b->c.lock));
810811
BUG_ON(!six_trylock_write(&b->c.lock));
811812

fs/bcachefs/btree_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
996996
}
997997
got_good_key:
998998
le16_add_cpu(&i->u64s, -next_good_key);
999-
memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
999+
memmove_u64s_down(k, (u64 *) k + next_good_key, (u64 *) vstruct_end(i) - (u64 *) k);
10001000
set_btree_node_need_rewrite(b);
10011001
}
10021002
fsck_err:

fs/bcachefs/btree_key_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bkey_cached_alloc(struct btree_trans *trans, struct btree_path *path, unsigned k
156156
}
157157

158158
if (ck) {
159-
bch2_btree_lock_init(&ck->c, pcpu_readers ? SIX_LOCK_INIT_PCPU : 0);
159+
bch2_btree_lock_init(&ck->c, pcpu_readers ? SIX_LOCK_INIT_PCPU : 0, GFP_KERNEL);
160160
ck->c.cached = true;
161161
goto lock;
162162
}

fs/bcachefs/btree_locking.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
static struct lock_class_key bch2_btree_node_lock_key;
88

99
void bch2_btree_lock_init(struct btree_bkey_cached_common *b,
10-
enum six_lock_init_flags flags)
10+
enum six_lock_init_flags flags,
11+
gfp_t gfp)
1112
{
12-
__six_lock_init(&b->lock, "b->c.lock", &bch2_btree_node_lock_key, flags);
13+
__six_lock_init(&b->lock, "b->c.lock", &bch2_btree_node_lock_key, flags, gfp);
1314
lockdep_set_notrack_class(&b->lock);
1415
}
1516

fs/bcachefs/btree_locking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "btree_iter.h"
1414
#include "six.h"
1515

16-
void bch2_btree_lock_init(struct btree_bkey_cached_common *, enum six_lock_init_flags);
16+
void bch2_btree_lock_init(struct btree_bkey_cached_common *, enum six_lock_init_flags, gfp_t gfp);
1717

1818
void bch2_trans_unlock_noassert(struct btree_trans *);
1919
void bch2_trans_unlock_write(struct btree_trans *);

fs/bcachefs/data_update.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
340340
struct printbuf buf = PRINTBUF;
341341

342342
prt_str(&buf, "about to insert invalid key in data update path");
343+
prt_printf(&buf, "\nop.nonce: %u", m->op.nonce);
343344
prt_str(&buf, "\nold: ");
344345
bch2_bkey_val_to_text(&buf, c, old);
345346
prt_str(&buf, "\nk: ");

fs/bcachefs/dirent.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ static inline unsigned dirent_val_u64s(unsigned len)
3131
sizeof(u64));
3232
}
3333

34-
static inline unsigned int dirent_occupied_size(const struct qstr *name)
35-
{
36-
return (BKEY_U64s + dirent_val_u64s(name->len)) * sizeof(u64);
37-
}
38-
3934
int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
4035
struct bkey_s_c_dirent, subvol_inum *);
4136

fs/bcachefs/extents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static inline bool bch2_extent_ptr_eq(struct bch_extent_ptr ptr1,
704704
ptr1.unwritten == ptr2.unwritten &&
705705
ptr1.offset == ptr2.offset &&
706706
ptr1.dev == ptr2.dev &&
707-
ptr1.dev == ptr2.dev);
707+
ptr1.gen == ptr2.gen);
708708
}
709709

710710
void bch2_ptr_swab(struct bkey_s);

fs/bcachefs/fs-common.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ int bch2_create_trans(struct btree_trans *trans,
152152
if (is_subdir_for_nlink(new_inode))
153153
dir_u->bi_nlink++;
154154
dir_u->bi_mtime = dir_u->bi_ctime = now;
155-
dir_u->bi_size += dirent_occupied_size(name);
156155

157156
ret = bch2_inode_write(trans, &dir_iter, dir_u);
158157
if (ret)
@@ -221,7 +220,6 @@ int bch2_link_trans(struct btree_trans *trans,
221220
}
222221

223222
dir_u->bi_mtime = dir_u->bi_ctime = now;
224-
dir_u->bi_size += dirent_occupied_size(name);
225223

226224
dir_hash = bch2_hash_info_init(c, dir_u);
227225

@@ -324,7 +322,6 @@ int bch2_unlink_trans(struct btree_trans *trans,
324322

325323
dir_u->bi_mtime = dir_u->bi_ctime = inode_u->bi_ctime = now;
326324
dir_u->bi_nlink -= is_subdir_for_nlink(inode_u);
327-
dir_u->bi_size -= dirent_occupied_size(name);
328325

329326
ret = bch2_hash_delete_at(trans, bch2_dirent_hash_desc,
330327
&dir_hash, &dirent_iter,
@@ -463,14 +460,6 @@ int bch2_rename_trans(struct btree_trans *trans,
463460
goto err;
464461
}
465462

466-
if (mode == BCH_RENAME) {
467-
src_dir_u->bi_size -= dirent_occupied_size(src_name);
468-
dst_dir_u->bi_size += dirent_occupied_size(dst_name);
469-
}
470-
471-
if (mode == BCH_RENAME_OVERWRITE)
472-
src_dir_u->bi_size -= dirent_occupied_size(src_name);
473-
474463
if (src_inode_u->bi_parent_subvol)
475464
src_inode_u->bi_parent_subvol = dst_dir.subvol;
476465

fs/bcachefs/fs-io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ int bchfs_truncate(struct mnt_idmap *idmap,
466466
ret = bch2_truncate_folio(inode, iattr->ia_size);
467467
if (unlikely(ret < 0))
468468
goto err;
469+
ret = 0;
469470

470471
truncate_setsize(&inode->v, iattr->ia_size);
471472

0 commit comments

Comments
 (0)