Skip to contentSkip to conversation

Linux/Pro -- clusters

DISCUSSION [email protected] 3 participants 3 messages Dec 8, 2001 – Dec 9, 2001

lore
Share & tools
lore
#0 lore raw

From: Linus Torvalds <[email protected]>

The sad thing is that along the whole path, we actually end up needing the structure pointer in different places, so the IO code (which is supposed to be timing-critical) ends up doing various lookups on the kdev_t several times (both at a higher level and deep down in the IO submit layer).

So now we have to do "bdfind()" *kdev_t -> block_device", and "get_gendisk()" for "kdev_t -> struct gendisk" and about 5 different "index various arrays using the MAJOR number" on the way to actually doing the IO.

Even though the filesystems that want to _do_ the IO actually already have the structure pointer available, and all the indexing off major would actually fairly trivially just be about reading off the fields off that structure.

Oh, well. It _is_ going to be quite painful to switch things around.

I don't understand at all. It is not painful at all. Things are completely straightforward.

A kdev_t is a pointer to all information needed, nowhere a lookup, except at open time.

You make it kbdev_t, and then call it struct block_device *. OK, the name doesnt matter as long as the struct it points to has all information needed. In my version that is the case, and I would be rather surprised if it were otherwise in Al's version.

The changes are only of the easy, provably correct, mechanical kind. Boring work, and a bit slow - each step requires a grep over the kernel source and there are about a hundred steps.

I am sure also Al will tell you that there is no problem.

Andries

#1 lore raw
Quoted 8 lines · On Sat, 8 Dec 2001 [email protected] wrote:

Oh, well. It _is_ going to be quite painful to switch things around.

I don't understand at all. It is not painful at all. Things are completely straightforward.

A kdev_t is a pointer to all information needed, nowhere a lookup, except at open time.

No.

I refuse to have the same structure for block devices and character devices. We already know that they are different.

Which means that I _will_ rename the thing.

Which means that the patch will be straightforward, but painful.

Quoted 1 line

I am sure also Al will tell you that there is no problem.

To me, touching a few hundred files, even if it's almost a search-and-replace operation is always painful. Much more painful than touching just one subsystem..

Linus

#2 lore raw
Quoted 1 line · Linus Torvalds
Quoted 1 line

I am sure also Al will tell you that there is no problem.

<raised brows> What gave you such impression? IIRC, I've described the problems several months ago. Three words: object freeing policy.

Quoted 3 lines

To me, touching a few hundred files, even if it's almost a search-and-replace operation is always painful. Much more painful than touching just one subsystem..

Less painful, in that case.

kdev_t will have to stay what it is right now. We _still_ don't have clear lifetime logics for char_device (BTW, patches for long-living cache on bdev side might be worth resurrecting them).

We can switch to _use_ of pointers to block_device and char_device, but we can't turn kdev_t into such pointer and expect it to work correctly.

So this "touching just one subsystem" would involve a shitload of very
tricky audits of said few hundred files. I'll take straightforward
search-and-replace job over that any day, thank you very much.

As for kdev_t... Eventually it will die out. Arguments about code duplication on maintaining caches are BS - especially since we will end up with different allocation/freeing rules and thus almost definitely different locking.

IOW, for what I care the strategy for 2.5 should be:
* reduce amount of places where we pass kdev_t around while there
is better alternative. E.g. for bread() and friends in filesystems it's
definitely struct superblock.
* supply struct block_device * to the rest of places where we
are passing block devices around.
* switch i_rdev to dev_t.
* kill uses of kdev_t for block devices completely.

Character devices are both simpler and harder - we have fewer places using them, but we have no clean release point due to the games played by subsystems that replace ->f_op on a live struct file.

Andries, believe me, I understand the attractiveness of "let's use sma t macros to hide the complexity of chage", but that will do us no good since the real complexity will bite us anyway when we start chasing dangling pointers and having fun with races.

The fundamental reason why we can't replace kdev_t with pointer and hope to survive is that YOU DON'T FREE NUMBERS. Integer is an integer - it's always valid. We will need to free the structures and _that_ is where the problems will start.

Witness the fun with iput() changes around 2.4.15 - they were needed exactly because we used to be sloppy and left inodes in cache for too long; after the ->i_sb was garbage. That had been fixed - we finally have sane rules for inode lifetime and these rules guarantee that we won't have junk floating around.

For kdev_t situation is much more complex than for superblocks. More objects refering to them, different locking situation for these objects, etc.

Blind turning kdev_t into a pointer to dynamically allocated structure is a recipe for a huge fuckup. Sorry, but we'll have to do honest work.