Re: [PATCH 06/12] btrfs: change lockdep class size check using ks->names

From: David Sterba
Date: Tue Feb 08 2022 - 14:06:51 EST


On Tue, Feb 08, 2022 at 10:42:02AM -0800, Namhyung Kim wrote:
> With upcoming lock tracepoints config, it'd allow some lockdep
> annotation code without enabling CONFIG_LOCKDEP actually. In that
> config, size of the struct lock_class_key would be 0.
>
> But it'd cause divide-by-zero in btrfs_set_buffer_lockdep_class() due
> to ARRAY_SIZE macro. Let's change it to use ks->names[] instead. It
> should have the same size as with ks->keys[].
>
> Cc: Chris Mason <clm@xxxxxx>
> Cc: Josef Bacik <josef@xxxxxxxxxxxxxx>
> Cc: David Sterba <dsterba@xxxxxxxx>
> Cc: linux-btrfs@xxxxxxxxxxxxxxx
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>

Acked-by: David Sterba <dsterba@xxxxxxxx>