Skip to contentSkip to conversation

cciss: add put_disk into cleanup routines

PATCH Applied mikem 2 participants 2 messages Nov 18, 2005

Subsystems (2)
lore
Share & tools
lore

mikem

author
#0 lore raw

PATCH 3/3 cciss: add put_disk into cleanup routines

Patch 3 of 3

Jeff Garzik pointed me to his code to see how to remove a disk from the system _properly_. Well, here it is...
Every place we remove disks we are now testing before calling del_gendisk or blk_cleanup_queue and then call put_disk.

--------------------------------------------------------------------------------

 drivers/block/cciss.c       |   33 ++++++++++++++++++++++++---------
 include/linux/cciss_ioctl.h |    2 +-
 2 files changed, 25 insertions(+), 10 deletions(-)

diff -L cciss.c -puN /dev/null /dev/null

drivers/block/cciss.c renamed from drivers/block/cciss.c~cciss_del_gendisk_fixes +24 -9
diff -puN drivers/block/cciss.c~cciss_del_gendisk_fixes drivers/block/cciss.c
@@ -1138,8 +1138,15 @@ static int revalidate_allvol(ctlr_info_t
 
 	for(i=0; i< NWD; i++) {
 		struct gendisk *disk = host->gendisk[i];
-		if (disk->flags & GENHD_FL_UP)
-			del_gendisk(disk);
+		if (disk) {
+			request_queue_t *q = disk->queue;
+
+			if (disk->flags & GENHD_FL_UP)
+				del_gendisk(disk);
+			if (q)
+				blk_cleanup_queue(q);
+			put_disk(disk);
+		}
 	}
 
         /*
@@ -1453,10 +1460,13 @@ static int deregister_disk(struct gendis
 	 * allows us to delete disk zero but keep the controller registered.
 	*/
 	if (h->gendisk[0] != disk){
-		if (disk->flags & GENHD_FL_UP){
-			blk_cleanup_queue(disk->queue);
-		del_gendisk(disk);
-			drv->queue = NULL;
+		if (disk) {
+			request_queue_t *q = disk->queue;
+			if (disk->flags & GENHD_FL_UP)
+				del_gendisk(disk);
+			if (q)	
+				blk_cleanup_queue(q);
+			put_disk(disk);	
 		}
 	}
 
@@ -3094,9 +3104,14 @@ static void __devexit cciss_remove_one (
 	/* remove it from the disk list */
 	for (j = 0; j < NWD; j++) {
 		struct gendisk *disk = hba[i]->gendisk[j];
-		if (disk->flags & GENHD_FL_UP) {
-			del_gendisk(disk);
-			blk_cleanup_queue(disk->queue);
+		if (disk) {
+			request_queue_t *q = disk->queue;
+
+			if (disk->flags & GENHD_FL_UP) 
+				del_gendisk(disk);
+			if (q)
+				blk_cleanup_queue(q);
+			put_disk(disk);
 		}
 	}
 
Applied
#1 lore raw
Quoted 6 lines · mikem

Patch 3 of 3

Jeff Garzik pointed me to his code to see how to remove a disk from the system _properly_. Well, here it is...
Every place we remove disks we are now testing before calling del_gendisk or blk_cleanup_queue and then call put_disk.

Thanks, applied.

Signature · 1 line
Jens Axboe