[PATCH v2 1/5] blk-cgroup: add a new helper blkg_print_dev_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yu Kuai <yukuai3@xxxxxxxxxx>

The bdi_dev_name() should not be used in blk-cgroup code, because bdi is
not related at all, add a new helper to print device name directly from
gendisk. The helper can also fix that "unknown" will be printed for
hidden disks.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
 block/blk-cgroup.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index b9e3265c1eb3..d62bcc2bae14 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -239,6 +239,18 @@ static inline bool bio_issue_as_root_blkg(struct bio *bio)
 	return (bio->bi_opf & (REQ_META | REQ_SWAP)) != 0;
 }
 
+static inline bool blkg_print_dev_name(struct seq_file *sf,
+				       struct blkcg_gq *blkg)
+{
+	struct gendisk *disk = blkg->q->disk;
+
+	if (!disk)
+		return false;
+
+	seq_printf(sf, "%u:%u", disk->major, disk->first_minor);
+	return true;
+}
+
 /**
  * blkg_lookup - lookup blkg for the specified blkcg - q pair
  * @blkcg: blkcg of interest
-- 
2.39.2





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux