linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wrong disk index in /proc/stat
@ 2001-06-25 19:40 Martin Wilck
  2001-06-26  2:56 ` Guest section DW
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2001-06-25 19:40 UTC (permalink / raw)
  To: Linux Kernel mailing list


Hi,

I posted this patch already from my home mail account on June 20 (subject:
disk_index weirdness), but no one seems to have noticed - therefore I
try again. Those who _have_ noticed the other mail - sorry for bothering).

The disk_index routine erroneously adds 2 to the index of disks on the
first IDE controller which is wriong in 2.4, because disks are indexed
by major number now. The patch fixes this and adds support for some more
major numbers. (To fully benefit, DK_MAX_MAJOR in
include/linux/kernel_stat.h must be increased).

The patch is against plain 2.4.5.

Regards,
Martin

-- 
Martin Wilck     <Martin.Wilck@fujitsu-siemens.com>
FSC EP PS DS1, Paderborn      Tel. +49 5251 8 15113

diff -ru linux-2.4.5/include/linux/genhd.h linux-2.4.5mw/include/linux/genhd.h
--- linux-2.4.5/include/linux/genhd.h	Tue Mar 27 01:48:11 2001
+++ linux-2.4.5mw/include/linux/genhd.h	Mon Jun 25 14:23:57 2001
@@ -248,21 +248,30 @@
 	unsigned int index;

 	switch (major) {
-		case DAC960_MAJOR+0:
-			index = (minor & 0x00f8) >> 3;
-			break;
 		case SCSI_DISK0_MAJOR:
 			index = (minor & 0x00f0) >> 4;
 			break;
 		case IDE0_MAJOR:	/* same as HD_MAJOR */
 		case XT_DISK_MAJOR:
+		case IDE1_MAJOR:
+		case IDE2_MAJOR:
+		case IDE3_MAJOR:
+		case IDE4_MAJOR:
+		case IDE5_MAJOR:
 			index = (minor & 0x0040) >> 6;
 			break;
-		case IDE1_MAJOR:
-			index = ((minor & 0x0040) >> 6) + 2;
+		case SCSI_CDROM_MAJOR:
+			index = minor & 0x000f;
 			break;
 		default:
-			return 0;
+			if (major >= SCSI_DISK1_MAJOR && major <= SCSI_DISK7_MAJOR)
+				index = (minor & 0x00f0) >> 4;
+			else if (major >= DAC960_MAJOR && major <= DAC960_MAJOR + 7)
+				index = (minor & 0x00f8) >> 3;
+			else if (major >= IDE6_MAJOR && major <= IDE9_MAJOR)
+				index = (minor & 0x0040) >> 6;
+			else
+				return 0;
 	}
 	return index;
 }



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

* Re: [PATCH] wrong disk index in /proc/stat
  2001-06-25 19:40 [PATCH] wrong disk index in /proc/stat Martin Wilck
@ 2001-06-26  2:56 ` Guest section DW
  2001-06-26 14:07   ` Martin Wilck
  0 siblings, 1 reply; 6+ messages in thread
From: Guest section DW @ 2001-06-26  2:56 UTC (permalink / raw)
  To: Martin Wilck, Linux Kernel mailing list

On Mon, Jun 25, 2001 at 09:40:56PM +0200, Martin Wilck wrote:

> no one seems to have noticed

Don't worry. The set of people who noticed was nonempty.

On the other hand, in my tree:

static inline unsigned int disk_index (kdev_t dev)
{
        struct gendisk *g = get_gendisk(dev);
        return g ? (MINOR(dev) >> g->minor_shift) : 0;
}

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

* Re: [PATCH] wrong disk index in /proc/stat
  2001-06-26  2:56 ` Guest section DW
@ 2001-06-26 14:07   ` Martin Wilck
  2001-06-26 15:49     ` Guest section DW
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2001-06-26 14:07 UTC (permalink / raw)
  To: Guest section DW; +Cc: Linux Kernel mailing list

Hi,

> On the other hand, in my tree:
>
> static inline unsigned int disk_index (kdev_t dev)
> {
>         struct gendisk *g = get_gendisk(dev);
>         return g ? (MINOR(dev) >> g->minor_shift) : 0;
> }

Well,

a) this is not in the official kernel,
b) the original genhd.h says that's too slow (is it really slower?)

Regards,
Martin

-- 
Martin Wilck     <Martin.Wilck@fujitsu-siemens.com>
FSC EP PS DS1, Paderborn      Tel. +49 5251 8 15113




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

* Re: [PATCH] wrong disk index in /proc/stat
  2001-06-26 14:07   ` Martin Wilck
@ 2001-06-26 15:49     ` Guest section DW
  2001-06-26 16:55       ` Martin Wilck
  0 siblings, 1 reply; 6+ messages in thread
From: Guest section DW @ 2001-06-26 15:49 UTC (permalink / raw)
  To: Martin Wilck; +Cc: Linux Kernel mailing list

On Tue, Jun 26, 2001 at 04:07:33PM +0200, Martin Wilck wrote:

> > static inline unsigned int disk_index (kdev_t dev)
> > {
> >         struct gendisk *g = get_gendisk(dev);
> >         return g ? (MINOR(dev) >> g->minor_shift) : 0;
> > }
> 
> Well,
> 
> a) this is not in the official kernel,
> b) the original genhd.h says that's too slow (is it really slower?)

Ad a): true.
Ad b): if you only make this change then it will be faster or slower
  depending on how many disks you have (because get_gendisk() used
  to be a linear search through a list that has as length the number
  of disk majors); however, my get_gendisk today is

	static inline struct gendisk *
	get_gendisk(kdev_t dev) {
	        return blk_gendisk[MAJOR(dev)];
	}

  hence is faster.

Andries

[go to ftp://ftp.XX.kernel.org/pub/linux/kernel/people/aeb/ or so
and get patches 01*, 02*, ... and apply them successively to 2.4.6pre5.
complain to aeb@cwi.nl if anything is wrong]

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

* Re: [PATCH] wrong disk index in /proc/stat
  2001-06-26 15:49     ` Guest section DW
@ 2001-06-26 16:55       ` Martin Wilck
  2001-06-26 17:16         ` Guest section DW
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2001-06-26 16:55 UTC (permalink / raw)
  To: Guest section DW; +Cc: Martin Wilck, Linux Kernel mailing list


> [go to ftp://ftp.XX.kernel.org/pub/linux/kernel/people/aeb/ or so
> and get patches 01*, 02*, ... and apply them successively to 2.4.6pre5.
> complain to aeb@cwi.nl if anything is wrong]

I see, you're going for a much deeper patch. No objections whatsoever,
that's certainly a better solution, but I can't start testing it now (my
IA-64 machine has enough other problems to solve yet).

My patch was merely intended to correct the index for disks on the 1st
IDE controller, which is just plain wrong.

I (being new to kernel hacking) have yet to understand what needs
to happen for patches to enter the main branches.

Cheers,
Martin

-- 
Martin Wilck     <Martin.Wilck@fujitsu-siemens.com>
FSC EP PS DS1, Paderborn      Tel. +49 5251 8 15113




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

* Re: [PATCH] wrong disk index in /proc/stat
  2001-06-26 16:55       ` Martin Wilck
@ 2001-06-26 17:16         ` Guest section DW
  0 siblings, 0 replies; 6+ messages in thread
From: Guest section DW @ 2001-06-26 17:16 UTC (permalink / raw)
  To: Martin Wilck; +Cc: Linux Kernel mailing list

On Tue, Jun 26, 2001 at 06:55:54PM +0200, Martin Wilck wrote:

> I (being new to kernel hacking) have yet to understand what needs
> to happen for patches to enter the main branches.

You mail them to Linus, with a cc to linux-kernel.
If he likes the patch it will be part of the next (pre)release.
Since your patch is short and corrects an actual bug,
your chances may be good.
If Linus starts 2.5 and Alan takes 2.4 the patch may be
relevant to both branches.

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

end of thread, other threads:[~2001-06-26 17:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-25 19:40 [PATCH] wrong disk index in /proc/stat Martin Wilck
2001-06-26  2:56 ` Guest section DW
2001-06-26 14:07   ` Martin Wilck
2001-06-26 15:49     ` Guest section DW
2001-06-26 16:55       ` Martin Wilck
2001-06-26 17:16         ` Guest section DW

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).