BUG: cat /proc/partitions endless loop
Christoph Hellwig <[email protected]> schrieb am 28.09.01:
Quoted 9 lines
Quoted 6 lines · In article <[email protected]> you wrote:
I traced the problem down to
drivers/block/genhd.c,
where the functionget_partition_list()outer loop does not terminate due to the last element in the structured list starting withgendisk_headis not initialized to NULL, by whatever reason. My fix does not cure the pointered endless loop, but prevents from looping when stepping thru the pointered list.I think the fix could be simpler. What about:
[...]
Quoted 1 line
+ for (gp =
gendisk_head; gp !=gendisk_head; gp =gp->next) {
This will break your for loop immedeately, because the loop criteria is already violated by the initialization !
But I tried another solution:
for (gp = gendisk_head; gp && (gp->next != gendisk_head); gp = gp->next) {
with no success - the cat /proc/partition only printed the heading line. This proofed to me, that the pointered list is created the wrong way, in other words, gendisk_head->next is a pointer to itself. It looks to me, that the "next" field in
/*static*/ struct gendisk *gendisk_head;
is not initialized (by the compiler ?) correctly to NULL.
Quoted 4 lines
if (gp->part[n].nr_sects == 0)
continue;_______________________________________________________________________
1.000.000 DM gewinnen - kostenlos tippen - http://millionenklick.web.de
[email protected], 8MB Speicher, Verschluesselung - http://freemail.web.de
Quoted 20 lines · Joachim Weller
Christoph Hellwig <[email protected]> schrieb am 28.09.01:
Quoted 9 lines
Quoted 6 lines · In article <[email protected]> you wrote:
I traced the problem down to
drivers/block/genhd.c,
where the functionget_partition_list()outer loop does not terminate due to the last element in the structured list starting withgendisk_headis not initialized to NULL, by whatever reason. My fix does not cure the pointered endless loop, but prevents from looping when stepping thru the pointered list.I think the fix could be simpler. What about:
[...]
Quoted 1 line
+ for (gp =
gendisk_head; gp !=gendisk_head; gp =gp->next) {This will break your for loop immedeately, because the loop criteria is already violated by the initialization !
But I tried another solution:
for (gp =gendisk_head; gp && (gp->next!=gendisk_head); gp =gp->next) {
Quoted 6 lines
with no success - the cat
/proc/partitiononly printed the heading line. This proofed to me, that the pointered list is created the wrong way, in other words,gendisk_head->nextis a pointer to itself. It looks to me, that the "next" field in
/*static*/ struct gendisk*gendisk_head;
is not initialized (by the compiler ?) correctly to NULL.
That's odd, could you try initilazing gendisk_head to NULL explicitly and try my proposed fix? The gendisk list handling starts to smell _really_ funny.
Christoph
Signature · 1 line
Of course it doesn't work. We've performed a software upgrade.
Quoted 21 lines · Christoph Hellwig
Quoted 12 lines · Joachim Weller
Christoph Hellwig <[email protected]> schrieb am 28.09.01:
Quoted 1 line
I think the fix could be simpler. What about:
[...]
Quoted 1 line
+ for (gp =
gendisk_head; gp !=gendisk_head; gp =gp->next) {This will break your for loop immedeately, because the loop criteria is already violated by the initialization !
But I tried another solution:
for (gp =gendisk_head; gp && (gp->next!=gendisk_head); gp =gp->next) {Quoted 6 lines
with no success - the cat
/proc/partitiononly printed the heading line. This proofed to me, that the pointered list is created the wrong way, in other words,gendisk_head->nextis a pointer to itself. It looks to me, that the "next" field in
/*static*/ struct gendisk*gendisk_head;
is not initialized (by the compiler ?) correctly to NULL.
Quoted 2 lines
That's odd, could you try initilazing
gendisk_headto NULL explicitly and try my proposed fix? The gendisk list handling starts to smell _really_ funny.
You would need to initialize gendisk_head->next to NULL *before* any call to add_gendisk(struct gendisk *gp) takes place. The latter is used in many other sources, to grow up the pointered list with additional partition info. gendisk_head always points to the most recently added item.
When you step through the list, you reach the very first entry, which existed before any call to add_gendisk() was made. And the "next" field of that should point to NULL.
But instead of this, it points to itself, thus forming a ring pointered loop. I don't know in which part of the kernel sources, that pre-initialization of gendisk_head->next to NULL should be made. Maybe it is expected to be done by the compiler.
But my fix works perfectly for me, resulting in exactly the same behaviour as 2.4.9.
I should point out, that my 2.4.9 was compiled under gcc 2.95.2 (SuSE-6.4) , whereas 2.4.10 was compiled under 2.95.3 delivered by SuSE-7.2 ! Maybe that's the point.
Signature · 7 lines
Joachim Weller Philips Medizinsysteme Boeblingen GmbH Mail: [email protected] Cardiac and Monitoring Systems (CMS) Phone: {+49|0}-7031-463-1891 New Product Engineering Fax: {+49|0}-7031-463-2112 Hewlett-Packard Str. 2, D 71034 Boeblingen -GERMANY-