[RFC PATCH blktrace-tools 03/10] act-mask: add blktrace extension to act_mask

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

 



This patch adds the support for blktrace action mask to accommodate
more operations like write-zeroes and zone reset etc.

Also, we add support to use the priority mask in the existing
infrastructure. We also update the existing helpers to manage
action mask and add similar helpers for priority mask.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx>
---
 act_mask.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 blktrace.h |  6 ++++++
 2 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/act_mask.c b/act_mask.c
index 8f1b8d7..09bda08 100644
--- a/act_mask.c
+++ b/act_mask.c
@@ -1,7 +1,15 @@
 #include <strings.h>
+
+#ifdef CONFIG_BLKTRACE_EXT
+#include <stdint.h>
+#endif /* CONFIG_BLKTRACE_EXT */
 #include "blktrace.h"
 
 #define DECLARE_MASK_MAP(mask)          { BLK_TC_##mask, #mask, "BLK_TC_"#mask }
+#ifdef CONFIG_BLKTRACE_EXT
+#define DECLARE_PRIO_CLASS_MASK_MAP(mask) \
+	{ (1 << IOPRIO_CLASS_##mask), #mask, "IOPRIO_CLASS_"#mask }
+#endif /* CONFIG_BLKTRACE_EXT */
 #define COMPARE_MASK_MAP(mmp, str)                                      \
         (!strcasecmp((mmp)->short_form, (str)) ||                      \
          !strcasecmp((mmp)->long_form, (str)))
@@ -29,20 +37,64 @@ static struct mask_map mask_maps[] = {
 	DECLARE_MASK_MAP(DISCARD),
 	DECLARE_MASK_MAP(DRV_DATA),
 	DECLARE_MASK_MAP(FUA),
+#ifdef CONFIG_BLKTRACE_EXT
+	DECLARE_MASK_MAP(WRITE_ZEROES),
+	DECLARE_MASK_MAP(ZONE_RESET),
+#endif /* CONFIG_BLKTRACE_EXT */
 };
 
-int find_mask_map(char *string)
+#ifdef CONFIG_BLKTRACE_EXT
+
+/**
+ * I/O Priority Map mask based on ${KERNEL_SRC_DIR}/include/linux/ioprio.h.
+ */
+static struct mask_map prio_map[] = {
+	DECLARE_PRIO_CLASS_MASK_MAP(NONE),
+	DECLARE_PRIO_CLASS_MASK_MAP(RT),
+	DECLARE_PRIO_CLASS_MASK_MAP(BE),
+	DECLARE_PRIO_CLASS_MASK_MAP(IDLE),
+};
+
+/**
+ * I/O Priority Map mask search for valid ioprio string value.
+ */
+int find_prio_mask_map(char *string)
 {
 	unsigned int i;
 
-	for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
-		if (COMPARE_MASK_MAP(&mask_maps[i], string))
-			return mask_maps[i].mask;
+	for (i = 0; i < sizeof(prio_maps)/sizeof(prio_maps[0]); i++)
+		if (COMPARE_MASK_MAP(&prio_map[i], string))
+			return prio_map[i].mask;
 
 	return -1;
 }
 
+/**
+ * I/O Priority Map mask search for valid ioprio mask.
+ */
+bool valid_prio_opt(uint32_t x)
+{
+	return (x & 0xFFFFFFF0) ? false : true;
+}
+
+uint64_t valid_act_opt(uint64_t x)
+{
+	return (1 <= x) && (x < (1ULL << BLK_TC_SHIFT));
+}
+#else
 int valid_act_opt(int x)
 {
 	return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
 }
+#endif /* CONFIG_BLKTRACE_EXT */
+
+int find_mask_map(char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
+		if (COMPARE_MASK_MAP(&mask_maps[i], string))
+			return mask_maps[i].mask;
+
+	return -1;
+}
diff --git a/blktrace.h b/blktrace.h
index 17f9f8d..c860bf9 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -181,7 +181,13 @@ extern void set_all_format_specs(char *);
 extern int add_format_spec(char *);
 extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
 			unsigned long long, int, unsigned char *);
+#ifdef CONFIG_BLKTRACE_EXT
+extern uint64_t valid_act_opt(uint64_t); /* adjusted act mask for extension */
+extern bool valid_prio_opt(uint32_t x);  /* validate priority mask */
+int find_prio_mask_map(char *string);    /* find prio mask from user input */
+#else
 extern int valid_act_opt(int);
+#endif /* CONFIG_BLKTRACE_EXT */
 extern int find_mask_map(char *);
 extern char *find_process_name(pid_t);
 
-- 
2.19.1




[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