summaryrefslogtreecommitdiff
path: root/drivers/md/md.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-03-03 17:01:42 +0300
committerSong Liu <song@kernel.org>2024-03-06 19:59:53 +0300
commit176df894d7974166c65d0cce3b3b019678f9e698 (patch)
tree0974ddbd3a00c500268df57aa16a702717fea92e /drivers/md/md.h
parent28be4fd310d146e9a43d7b1bb55cb7e9f5e06e88 (diff)
downloadlinux-176df894d7974166c65d0cce3b3b019678f9e698.tar.xz
md: add a mddev_is_dm helper
Add a helper to check for a DM-mapped MD device instead of using the obfuscated ->gendisk or ->queue NULL checks. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed--by: Song Liu <song@kernel.org> Tested-by: Song Liu <song@kernel.org> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20240303140150.5435-4-hch@lst.de
Diffstat (limited to 'drivers/md/md.h')
-rw-r--r--drivers/md/md.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/md/md.h b/drivers/md/md.h
index e2e1ddd397ea..d5e99653c690 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -911,16 +911,24 @@ int do_md_run(struct mddev *mddev);
extern const struct block_device_operations md_fops;
+/*
+ * MD devices can be used undeneath by DM, in which case ->gendisk is NULL.
+ */
+static inline bool mddev_is_dm(struct mddev *mddev)
+{
+ return !mddev->gendisk;
+}
+
static inline void mddev_trace_remap(struct mddev *mddev, struct bio *bio,
sector_t sector)
{
- if (mddev->gendisk)
+ if (!mddev_is_dm(mddev))
trace_block_bio_remap(bio, disk_devt(mddev->gendisk), sector);
}
#define mddev_add_trace_msg(mddev, fmt, args...) \
do { \
- if ((mddev)->gendisk) \
+ if (!mddev_is_dm(mddev)) \
blk_add_trace_msg((mddev)->queue, fmt, ##args); \
} while (0)