bcachefs: Annotate bch_replicas_entry_{v0,v1} with __counted_by()
authorThorsten Blum <thorsten.blum@toblux.com>
Mon, 26 Aug 2024 10:11:36 +0000 (12:11 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 9 Sep 2024 13:41:49 +0000 (09:41 -0400)
commitfa1ab1b46608f6fdc155203c6e4aa7f3da1db434
treea5fd5747586760e9e5b663726c80715399cf8fe3
parentc24adfa0dfc2754f11d91576eabe188671c97209
bcachefs: Annotate bch_replicas_entry_{v0,v1} with __counted_by()

Add the __counted_by compiler attribute to the flexible array members
devs to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Increment nr_devs before adding a new device to the devs array and
adjust the array indexes accordingly. Add a helper macro for adding a
new device.

In bch2_journal_read(), explicitly set nr_devs to 0.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/buckets.c
fs/bcachefs/journal_io.c
fs/bcachefs/replicas.c
fs/bcachefs/replicas_format.h