public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits
@ 2009-04-27 11:35 Nikanth Karthikesan
  2009-04-27 11:46 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Nikanth Karthikesan @ 2009-04-27 11:35 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

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.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ba54c83..f41abbb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -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)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits
  2009-04-27 11:35 [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits Nikanth Karthikesan
@ 2009-04-27 11:46 ` Jens Axboe
  2009-04-27 12:05   ` Nikanth Karthikesan
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2009-04-27 11:46 UTC (permalink / raw)
  To: Nikanth Karthikesan; +Cc: linux-kernel

On Mon, Apr 27 2009, Nikanth Karthikesan wrote:
> 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.
> 
> Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
> 
> ---
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index ba54c83..f41abbb 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -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 ;-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d73eb76..e62ef94 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -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");

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits
  2009-04-27 11:46 ` Jens Axboe
@ 2009-04-27 12:05   ` Nikanth Karthikesan
  2009-04-27 12:11     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Nikanth Karthikesan @ 2009-04-27 12:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Monday 27 April 2009 17:16:33 Jens Axboe wrote:
> On Mon, Apr 27 2009, Nikanth Karthikesan wrote:
> > 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.
> >
> > Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
> >
> > ---
> >
> > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> > index ba54c83..f41abbb 100644
> > --- a/include/linux/blkdev.h
> > +++ b/include/linux/blkdev.h
> > @@ -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 ;-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index d73eb76..e62ef94 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -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.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/block/blk-core.c b/block/blk-core.c
index 07ab754..218f745 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -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");



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits
  2009-04-27 12:05   ` Nikanth Karthikesan
@ 2009-04-27 12:11     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2009-04-27 12:11 UTC (permalink / raw)
  To: Nikanth Karthikesan; +Cc: linux-kernel

On Mon, Apr 27 2009, Nikanth Karthikesan wrote:
> On Monday 27 April 2009 17:16:33 Jens Axboe wrote:
> > On Mon, Apr 27 2009, Nikanth Karthikesan wrote:
> > > 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.
> > >
> > > Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
> > >
> > > ---
> > >
> > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> > > index ba54c83..f41abbb 100644
> > > --- a/include/linux/blkdev.h
> > > +++ b/include/linux/blkdev.h
> > > @@ -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 ;-)
> >
> > diff --git a/block/blk-core.c b/block/blk-core.c
> > index d73eb76..e62ef94 100644
> > --- a/block/blk-core.c
> > +++ b/block/blk-core.c
> > @@ -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?

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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-27 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-27 11:35 [PATCH] Cleanup: Remove unused __REQ_NR_BITS from enum rq_flag_bits Nikanth Karthikesan
2009-04-27 11:46 ` Jens Axboe
2009-04-27 12:05   ` Nikanth Karthikesan
2009-04-27 12:11     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox