mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-08 14:23:19 +00:00
bcachefs: bch_dev->dev
Add a field to bch_dev for the dev_t of the underlying block device - this fixes a null ptr deref in tracepoints. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
d8601afca8
commit
eacb2574f0
@ -432,6 +432,7 @@ struct bch_dev {
|
||||
struct bch_sb_handle disk_sb;
|
||||
struct bch_sb *sb_read_scratch;
|
||||
int sb_write_error;
|
||||
dev_t dev;
|
||||
|
||||
struct bch_devs_mask self;
|
||||
|
||||
|
@ -568,8 +568,11 @@ static long bch2_ioctl_disk_get_idx(struct bch_fs *c,
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if (!dev)
|
||||
return -EINVAL;
|
||||
|
||||
for_each_online_member(ca, c, i)
|
||||
if (ca->disk_sb.bdev->bd_dev == dev) {
|
||||
if (ca->dev == dev) {
|
||||
percpu_ref_put(&ca->io_ref);
|
||||
return i;
|
||||
}
|
||||
|
@ -1257,6 +1257,8 @@ static int __bch2_dev_attach_bdev(struct bch_dev *ca, struct bch_sb_handle *sb)
|
||||
ca->disk_sb = *sb;
|
||||
memset(sb, 0, sizeof(*sb));
|
||||
|
||||
ca->dev = ca->disk_sb.bdev->bd_dev;
|
||||
|
||||
percpu_ref_reinit(&ca->io_ref);
|
||||
|
||||
return 0;
|
||||
@ -1875,7 +1877,7 @@ struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *path)
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_member_device_rcu(ca, c, i, NULL)
|
||||
if (ca->disk_sb.bdev->bd_dev == dev)
|
||||
if (ca->dev == dev)
|
||||
goto found;
|
||||
ca = ERR_PTR(-ENOENT);
|
||||
found:
|
||||
|
@ -387,7 +387,7 @@ TRACE_EVENT(alloc_scan,
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->dev = ca->disk_sb.bdev->bd_dev;
|
||||
__entry->dev = ca->dev;
|
||||
__entry->found = found;
|
||||
__entry->inc_gen = inc_gen;
|
||||
__entry->inc_gen_skipped = inc_gen_skipped;
|
||||
@ -409,7 +409,7 @@ TRACE_EVENT(invalidate,
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->dev = ca->disk_sb.bdev->bd_dev;
|
||||
__entry->dev = ca->dev;
|
||||
__entry->offset = offset,
|
||||
__entry->sectors = sectors;
|
||||
),
|
||||
@ -431,7 +431,7 @@ DECLARE_EVENT_CLASS(bucket_alloc,
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->dev = ca->disk_sb.bdev->bd_dev;
|
||||
__entry->dev = ca->dev;
|
||||
__entry->reserve = reserve;
|
||||
),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user