Hello Kent Overstreet,
The patch 3d86e847fdd2: "bcachefs: Improve assorted error messages"
from Jun 3, 2020 (linux-next), leads to the following Smatch static
checker warning:
fs/bcachefs/buckets.c:697 check_bucket_ref()
warn: sleeping in atomic context
fs/bcachefs/buckets.c
673 static int check_bucket_ref(struct btree_trans *trans,
674 struct bkey_s_c k,
675 const struct bch_extent_ptr *ptr,
676 s64 sectors, enum bch_data_type
ptr_data_type,
677 u8 b_gen, u8 bucket_data_type,
678 u32 dirty_sectors, u32 cached_sectors)
679 {
680 struct bch_fs *c = trans->c;
681 struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
682 size_t bucket_nr = PTR_BUCKET_NR(ca, ptr);
683 u32 bucket_sectors = !ptr->cached
684 ? dirty_sectors
685 : cached_sectors;
686 struct printbuf buf = PRINTBUF;
687 int ret = 0;
688
689 if (bucket_data_type == BCH_DATA_cached)
690 bucket_data_type = BCH_DATA_user;
691
692 if ((bucket_data_type == BCH_DATA_stripe && ptr_data_type ==
BCH_DATA_user) ||
693 (bucket_data_type == BCH_DATA_user && ptr_data_type ==
BCH_DATA_stripe))
694 bucket_data_type = ptr_data_type = BCH_DATA_stripe;
695
696 if (gen_after(ptr->gen, b_gen)) {
--> 697 bch2_fsck_err(c, FSCK_CAN_IGNORE|FSCK_NEED_FSCK,
bch2_fsck_err() takes a mutex, but we're holding a spinlock so that's
not allowed. The spinlocks are in:
mark_stripe_bucket() <- disables preempt
bch2_mark_pointer() <- disables preempt
-> __mark_pointer()
-> check_bucket_ref()
(This warning requires two cross function database rebuilds before it
shows up).
698 "bucket %u:%zu gen %u data type %s: ptr gen %u
newer than bucket gen\n"
699 "while marking %s",
700 ptr->dev, bucket_nr, b_gen,
701 bch2_data_types[bucket_data_type ?:
ptr_data_type],
702 ptr->gen,
703 (bch2_bkey_val_to_text(&buf, c, k), buf.buf));
704 ret = -EIO;
705 goto err;
706 }
707
regards,
dan carpenter