Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 353

kernel-2.6.18-238.el5.src.rpm

From: Tomas Henzl <thenzl@redhat.com>
Date: Sun, 29 Aug 2010 15:49:25 -0400
Subject: [block] cciss: zero out drive info on removal
Message-id: <1283097002-3341-27-git-send-email-thenzl@redhat.com>
Patchwork-id: 27870
O-Subject: [RHEL6 PATCH 26/63] cciss: zero out drive info on removal
Bugzilla: 568830
RH-Acked-by: Neil Horman <nhorman@redhat.com>

zero out sysfs exposed drive data on logical drive removal
When removing a logical drive, clear all the information that is
now exposed by sysfs (e.g. vendor, model, serial number.)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index c0e58b1..eb82a20 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2041,16 +2041,8 @@ static void cciss_add_controller_node(ctlr_info_t *h)
 	drv_index = cciss_add_gendisk(h, CTLR_LUNID, 1);
 	if (drv_index == -1)
 		goto error;
+	cciss_clear_drive_info(&h->drv[drv_index]);
 	h->drv[drv_index].block_size = 512;
-	h->drv[drv_index].nr_blocks = 0;
-	h->drv[drv_index].heads = 0;
-	h->drv[drv_index].sectors = 0;
-	h->drv[drv_index].cylinders = 0;
-	h->drv[drv_index].raid_level = -1;
-	memset(h->drv[drv_index].uid, 0, sizeof(h->drv[drv_index].uid));
-	memset(h->drv[drv_index].vendor, 0, sizeof(h->drv[drv_index].vendor));
-	memset(h->drv[drv_index].model, 0, sizeof(h->drv[drv_index].model));
-	memset(h->drv[drv_index].rev, 0, sizeof(h->drv[drv_index].rev));
 	disk = h->gendisk[drv_index];
 	if (cciss_add_disk(h, disk, drv_index) == 0)
 		return;
@@ -2205,6 +2197,25 @@ mem_msg:
 	goto freeret;
 }
 
+static void cciss_clear_drive_info(drive_info_struct *drive_info)
+{
+	/* zero out the disk size info */
+	drive_info->nr_blocks = 0;
+	drive_info->block_size = 0;
+	drive_info->heads = 0;
+	drive_info->sectors = 0;
+	drive_info->cylinders = 0;
+	drive_info->raid_level = -1;
+	memset(drive_info->uid, 0, sizeof(drive_info->uid));
+	memset(drive_info->model, 0, sizeof(drive_info->model));
+	memset(drive_info->rev, 0, sizeof(drive_info->rev));
+	memset(drive_info->vendor, 0, sizeof(drive_info->vendor));
+	/*
+	 * don't clear the LUNID though, we need to remember which
+	 * one this one is.
+	 */
+}
+
 /* This function will deregister the disk and it's queue from the
  * kernel.  It must be called with the controller lock held and the
  * drv structures busy_configuring flag set.  It's parameters are:
@@ -2285,16 +2296,7 @@ static int deregister_disk(ctlr_info_t *h, int drv_index,
 	}
 
 	--h->num_luns;
-	/* zero out the disk size info */
-	drv->nr_blocks = 0;
-	drv->block_size = 0;
-	drv->heads = 0;
-	drv->sectors = 0;
-	drv->cylinders = 0;
-	drv->raid_level = -1;	/* This can be used as a flag variable to
-				 * indicate that this element of the drive
-				 * array is free.
-				 */
+	cciss_clear_drive_info(drv);
 
 	if (clear_all) {
 		/* check to see if it was the last disk */