Skip to contentSkip to conversation

don't increment use count twice on open

PATCH In review Christoph Hellwig 2 participants 2 messages Nov 1, 2002 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't increment use count twice on open

Since 2.4 drivers get their usecount managed by higher levels if they supply a owner field in block_device_operations/file_operations.

Remove managment of the additional usecount in ->open/->close.

drivers/scsi/osst.c +0 -6
@@ -4178,8 +4178,6 @@
 
 	if (STp->device->host->hostt->module)
 		 __MOD_INC_USE_COUNT(STp->device->host->hostt->module);
-	if (osst_template.module)
-		 __MOD_INC_USE_COUNT(osst_template.module);
 	STp->device->access_count++;
 
 	if (mode != STp->current_mode) {
@@ -4522,8 +4520,6 @@
 
 	if (STp->device->host->hostt->module)
 	    __MOD_DEC_USE_COUNT(STp->device->host->hostt->module);
-	if (osst_template.module)
-	    __MOD_DEC_USE_COUNT(osst_template.module);
 
 	return retval;
 }
@@ -4667,8 +4663,6 @@
 
 	if (STp->device->host->hostt->module)
 		__MOD_DEC_USE_COUNT(STp->device->host->hostt->module);
-	if(osst_template.module)
-		__MOD_DEC_USE_COUNT(osst_template.module);
 
 	return result;
 }
drivers/scsi/sd.c +0 -7
@@ -452,8 +452,6 @@
 	 */
 	if (sdp->host->hostt->module)
 		__MOD_INC_USE_COUNT(sdp->host->hostt->module);
-	if (sd_template.module)
-		__MOD_INC_USE_COUNT(sd_template.module);
 	sdp->access_count++;
 
 	if (sdp->removable) {
@@ -497,8 +495,6 @@
 	sdp->access_count--;
 	if (sdp->host->hostt->module)
 		__MOD_DEC_USE_COUNT(sdp->host->hostt->module);
-	if (sd_template.module)
-		__MOD_DEC_USE_COUNT(sd_template.module);
 	return retval;	
 }
 
@@ -535,9 +531,6 @@
 	}
 	if (sdp->host->hostt->module)
 		__MOD_DEC_USE_COUNT(sdp->host->hostt->module);
-	if (sd_template.module)
-		__MOD_DEC_USE_COUNT(sd_template.module);
-
 	return 0;
 }
 
drivers/scsi/sr.c +0 -4
@@ -105,8 +105,6 @@
 	cd->device->access_count--;
 	if (cd->device->host->hostt->module)
 		__MOD_DEC_USE_COUNT(cd->device->host->hostt->module);
-	if (sr_template.module)
-		__MOD_DEC_USE_COUNT(sr_template.module);
 }
 
 static struct cdrom_device_ops sr_dops = {
@@ -443,8 +441,6 @@
 	cd->device->access_count++;
 	if (cd->device->host->hostt->module)
 		__MOD_INC_USE_COUNT(cd->device->host->hostt->module);
-	if (sr_template.module)
-		__MOD_INC_USE_COUNT(sr_template.module);
 
 	/* If this device did not have media in the drive at boot time, then
 	 * we would have been unable to get the sector size.  Check to see if
#1 lore raw

drivers/scsi/osst.c line 4180

Quoted 12 lines · Christoph Hellwig

Since 2.4 drivers get their usecount managed by higher levels if they supply a owner field in block_device_operations/file_operations.

Remove managment of the additional usecount in ->open/->close.

drivers/scsi/osst.c +0 -0
@@ -4178,8 +4178,6 @@
 
 	if (STp->device->host->hostt->module)
 		 __MOD_INC_USE_COUNT(STp->device->host->hostt->module);

BTW, that (and similar in other drivers) is a walking rmmod race. Think what happens if module is already in the middle of unload - it's done with checking the refcount, decision is already made. try_inc_mod_count() is needed here...