Skip to contentSkip to conversation

Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits

PATCH In review Nikanth Karthikesan 2 participants 4 messages Apr 27, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits

The __REQ_NR_BITS was being used by blk_dump_rq_flags() long back, while printing the individual request flag bits as strings to limit to the used bits. But it does not use it now. Remove unused enum.

---

include/linux/blkdev.h +0 -1
index ba54c83..f41abbb 100644
@@ -118,7 +118,6 @@ enum rq_flag_bits {
 	__REQ_COPY_USER,	/* contains copies of user pages */
 	__REQ_INTEGRITY,	/* integrity metadata has been remapped */
 	__REQ_NOIDLE,		/* Don't anticipate more IO after this one */
-	__REQ_NR_BITS,		/* stops here */
 };
 
 #define REQ_RW		(1 << __REQ_RW)
#1 lore raw
Quoted 13 lines · Nikanth Karthikesan

The __REQ_NR_BITS was being used by blk_dump_rq_flags() long back, while printing the individual request flag bits as strings to limit to the used bits. But it does not use it now. Remove unused enum.

---

include/linux/blkdev.h +0 -0
index ba54c83..f41abbb 100644

include/linux/blkdev.h enum rq_flag_bits { · line 123

Quoted 7 lines
include/linux/blkdev.h +0 -1
@@ -118,7 +118,6 @@ enum rq_flag_bits {
 	__REQ_COPY_USER,	/* contains copies of user pages */
 	__REQ_INTEGRITY,	/* integrity metadata has been remapped */
 	__REQ_NOIDLE,		/* Don't anticipate more IO after this one */
-	__REQ_NR_BITS,		/* stops here */
 };
 
 #define REQ_RW		(1 << __REQ_RW)

Lets turn it into something useful instead. It's meant to catch someone adding too many flags, how about something like this:

Untested ;-)

block/blk-core.c +2 -0
index d73eb76..e62ef94 100644
@@ -2159,6 +2159,8 @@ EXPORT_SYMBOL(kblockd_schedule_work);
 
 int __init blk_dev_init(void)
 {
+	BUILD_BUG_ON(__REQ_NR_BITS > 8 * sizeof(int));
+
 	kblockd_workqueue = create_workqueue("kblockd");
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");
Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 32 lines · On Monday 27 April 2009 17:16:33 Jens Axboe wrote:
Quoted 13 lines · Nikanth Karthikesan

The __REQ_NR_BITS was being used by blk_dump_rq_flags() long back, while printing the individual request flag bits as strings to limit to the used bits. But it does not use it now. Remove unused enum.

---

include/linux/blkdev.h +0 -0
index ba54c83..f41abbb 100644

include/linux/blkdev.h enum rq_flag_bits { · line 123

Quoted 7 lines
include/linux/blkdev.h +0 -1
@@ -118,7 +118,6 @@ enum rq_flag_bits {
 	__REQ_COPY_USER,	/* contains copies of user pages */
 	__REQ_INTEGRITY,	/* integrity metadata has been remapped */
 	__REQ_NOIDLE,		/* Don't anticipate more IO after this one */
-	__REQ_NR_BITS,		/* stops here */
 };
 
 #define REQ_RW		(1 << __REQ_RW)

Lets turn it into something useful instead. It's meant to catch someone adding too many flags, how about something like this:

Untested ;-)

block/blk-core.c +0 -0
index d73eb76..e62ef94 100644

block/blk-core.c EXPORT_SYMBOL(kblockd_schedule_work); · line 2166

Quoted 8 lines
block/blk-core.c +2 -0
@@ -2159,6 +2159,8 @@ EXPORT_SYMBOL(kblockd_schedule_work);
 
 int __init blk_dev_init(void)
 {
+	BUILD_BUG_ON(__REQ_NR_BITS > 8 * sizeof(int));
+
 	kblockd_workqueue = create_workqueue("kblockd");
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");

Good idea. How about this?

Thanks
Nikanth

Catch trying to use more bits than request->cmd_flags has.

---

block/blk-core.c +3 -0
index 07ab754..218f745 100644
@@ -2156,6 +2156,9 @@ EXPORT_SYMBOL(kblockd_schedule_work);
 
 int __init blk_dev_init(void)
 {
+	BUILD_BUG_ON(__REQ_NR_BITS > 8 * 
+			sizeof(((struct request *)0)->cmd_flags));
+
 	kblockd_workqueue = create_workqueue("kblockd");
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");
#3 lore raw
Quoted 34 lines · Nikanth Karthikesan
Quoted 33 lines · On Monday 27 April 2009 17:16:33 Jens Axboe wrote:
Quoted 13 lines · Nikanth Karthikesan

The __REQ_NR_BITS was being used by blk_dump_rq_flags() long back, while printing the individual request flag bits as strings to limit to the used bits. But it does not use it now. Remove unused enum.

---

include/linux/blkdev.h +0 -0
index ba54c83..f41abbb 100644

include/linux/blkdev.h enum rq_flag_bits { · line 123

Quoted 7 lines
include/linux/blkdev.h +0 -1
@@ -118,7 +118,6 @@ enum rq_flag_bits {
 	__REQ_COPY_USER,	/* contains copies of user pages */
 	__REQ_INTEGRITY,	/* integrity metadata has been remapped */
 	__REQ_NOIDLE,		/* Don't anticipate more IO after this one */
-	__REQ_NR_BITS,		/* stops here */
 };
 
 #define REQ_RW		(1 << __REQ_RW)

Lets turn it into something useful instead. It's meant to catch someone adding too many flags, how about something like this:

Untested ;-)

block/blk-core.c +0 -0
index d73eb76..e62ef94 100644
@@ -2159,6 +2159,8 @@ EXPORT_SYMBOL(kblockd_schedule_work);
 
Quoted 9 lines

block/blk-core.c EXPORT_SYMBOL(kblockd_schedule_work); · line 2164

Quoted 7 lines
block/blk-core.c +2 -0
 int __init blk_dev_init(void)
 {
+	BUILD_BUG_ON(__REQ_NR_BITS > 8 * sizeof(int));
+
 	kblockd_workqueue = create_workqueue("kblockd");
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");

Good idea. How about this?

That's fine, better explains the check. It doesn't matter in practice though, since we will be restricted to 32 flags even on 64-bit archs (as long as we support 32-bit archs).

I'll add it, thanks.

Signature · 1 line
Jens Axboe