Skip to contentSkip to conversation

struct char_device

PATCH [email protected] 5 participants 7 messages May 22, 2001 – May 23, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines · Martin Dalecki

Erm... I wasn't talking about the DESIRED state of affairs! I was talking about the CURRENT state of affairs. OK?

Oh, but in 1995 it was quite possible to compile the kernel with kdev_t a pointer type, and I have done it several times since.

The kernel keeps growing, so each time it is more work than the previous time.

Quoted 2 lines

At least you have admitted that you where the one responsible for the design of this MESS.

Thank you! However, you give me too much honour.

Andries

#1 lore raw
Quoted 8 lines · [email protected] wrote:
Quoted 2 lines · Martin Dalecki

Erm... I wasn't talking about the DESIRED state of affairs! I was talking about the CURRENT state of affairs. OK?

Oh, but in 1995 it was quite possible to compile the kernel with kdev_t a pointer type, and I have done it several times since.

Yes I remember but unfortunately some big L* did ignore your *fine* efforts entierly in favour of developing /proc and /dev/random and other crap maybe?

Quoted 7 lines

The kernel keeps growing, so each time it is more work than the previous time.

Quoted 2 lines

At least you have admitted that you where the one responsible for the design of this MESS.

Thank you! However, you give me too much honour.

Well ... you ask for it in the corresponding header ;-). But it isn't yours fault indeed I admit...
I know the discussions from memmory since I'm returning REGULARLY to this
topic in intervals of about between 6 and 24 months since about maybe already 6 years!!! Currently they have just started to hurt seriously. And please remember the change I have mentioned above wasn't intended as developement but just only as an experiment...

Well let's us stop throw flames at each other. Please have a tight look at the following *EXPERIMENT* I have already done. It's really really only intended to mark the places where the full mess shows it's ugly head:

http://www.dalecki.de/big-002.diff

#2 lore raw
In reply to [email protected]

And if we are at the topic... Those are the places where blk_size[] get's
abused, since it's in fact a property of a FS in fact and not the property of
a particular device... blksect_size is the array describing the physical access limits of a device and blk_size get's usually checked against it. However due to the bad naming and the fact that this information is associated with major/minor number usage same device driver writers got *very* confused as you can see below:

./fs/block_dev.c: Here this information should be passed entierly insice the request.

./fs/partitions/check.c: Here it basically get's reset or ignored

Here it's serving the purpose of a sector size, which is bogous!

./mm/swapfile.c:#include <linux/blkdev.h> /* for blk_size */
./mm/swapfile.c: if (!dev || (blk_size[MAJOR(dev)] &&
./mm/swapfile.c: !blk_size[MAJOR(dev)][MINOR(dev)]))
./mm/swapfile.c: if (blk_size[MAJOR(dev)])
./mm/swapfile.c: swapfilesize = blk_size[MAJOR(dev)][MINOR(dev)]

Here it shouldn't be needed
./drivers/block/ll_rw_blk.c:

./drivers/block/floppy.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/block/nbd.c: blk_size[MAJOR_NR] = nbd_sizes;
./drivers/block/rd.c: * and set blk_size for -ENOSPC, Werner Fink
<[email protected]>, Apr '99
./drivers/block/amiflop.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/block/loop.c: if (blk_size[MAJOR(lodev)])
./drivers/block/ataflop.c: * - Set blk_size for proper size checking
./drivers/block/ataflop.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/block/cpqarray.c: drv->blk_size;
./drivers/block/z2ram.c: blk_size[ MAJOR_NR ] = z2_sizes;
./drivers/block/swim3.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/block/swim_iop.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/char/raw.c: if (blk_size[MAJOR(dev)])
./drivers/scsi/advansys.c: ASC_DCNT blk_size;
./drivers/scsi/sd.c: blk_size[SD_MAJOR(i)] = NULL;
./drivers/scsi/sr.c: blk_size[MAJOR_NR] = sr_sizes;
./drivers/scsi/sr.c: blk_size[MAJOR_NR] = NULL;
./drivers/sbus/char/jsflash.c: blk_size[JSFD_MAJOR] = jsfd_sizes;
./drivers/ide/ide-cd.c: blk_size[HWIF(drive)->major] =
HWIF(drive)->gd->sizes;
./drivers/ide/ide-floppy.c: * Revalidate the new media. Should set
blk_size[]
./drivers/acorn/block/fd1772.c: blk_size[MAJOR_NR] = floppy_sizes;
./drivers/i2o/i2o_block.c: blk_size[MAJOR_NR] = i2ob_sizes;

In the following they are REALLY confusing it and then compensating for this misunderstanding in lvm.h by redefining the corresponding default values.

./drivers/s390/*

And then some minor confusions follow...

./drivers/mtd/mtdblock.c: blk_size[MAJOR_NR] = NULL;
./drivers/md/md.c: if (blk_size[MAJOR(dev)])
./arch/m68k/atari/stram.c: blk_size[STRAM_MAJOR] = stram_sizes;

Basically one should just stop setting blk_size[][] inside *ANY* driver and anything should still work fine unless the driver is broken...

Well that's the point for another fine kernel experiment I will do and report whatever it works really out like this in reality 8-)

#3 lore raw
In reply to [email protected]

IMHO it would be nice to (for 2.4) create wrappers for accessing the block arrays, so that we can more easily dispose of the arrays when 2.5 rolls around...

Signature · 3 lines
Jeff Garzik      | "Are you the police?"
Building 1024    | "No, ma'am.  We're musicians."
MandrakeSoft     |
#4 lore raw
Quoted 4 lines · Jeff Garzik

IMHO it would be nice to (for 2.4) create wrappers for accessing the block arrays, so that we can more easily dispose of the arrays when 2.5 rolls around...

No.

We do not create wrappers "so that we can easily change the implementation when xxx happens".

That way lies bad implementations.

We do the _good_ implementation first, and then we create the "kcompat-2.4" file later that makes people able to use the good implementation.

Why this way? Because wrapping for wrappings sake just makes code unreadable (see acpi), and often makes it less obvious what you actually _have_ to do, and what you don't. So get the design right _first_, and once the design is right, _then_ you worry about kcompat-2.4.

Linus

#5 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 4 lines · Jeff Garzik

IMHO it would be nice to (for 2.4) create wrappers for accessing the block arrays, so that we can more easily dispose of the arrays when 2.5 rolls around...

Quoted 6 lines

No.

We do not create wrappers "so that we can easily change the implementation when xxx happens".

That way lies bad implementations.

However Linus please note that in the case of the bould arrays used in device handling code we have code patterns like this:

	if (blah[major]) {
		size = blah[major][minor]
	} else
		size = some default;

And those have to by dragged throughout the whole places where the arrays get used. Thus making some wrappers (many are already in place):

1. Prevents typo kind of programming errors.

2. Possibly make the code more explicit.

and please don't forget:

3. Allows to change the underlying implementation in some soon point in time.

However I agree that *without* the above arguments such kind of wrappers would make the overall code as unreadable as C++ code frequently is, which
tryies to preserve private: attributes at simple field cases..

#6 lore raw
In reply to [email protected]
Quoted 3 lines · Jeff Garzik

IMHO it would be nice to (for 2.4) create wrappers for accessing the block arrays, so that we can more easily dispose of the arrays when 2.5 rolls around...

Agreed, in fact I have a lot of stuff that could be included in the kcompat files for 2.4 (of course still changing :)

BTW, max_sectors/max_segments/hardsect_size already in place. Still some to go.

Signature · 1 line
Jens Axboe