scsi_scan.c (e63ed0d7a98014fdfc2cfeb3f6dada313dcabb59) | scsi_scan.c (f2495e228fce9f9cec84367547813cbb0d6db15a) |
---|---|
1/* 2 * scsi_scan.c 3 * 4 * Copyright (C) 2000 Eric Youngdale, 5 * Copyright (C) 2002 Patrick Mansfield 6 * 7 * The general scanning/probing algorithm is as follows, exceptions are 8 * made to it depending on device specific flags, compilation options, and --- 306 unchanged lines hidden (view full) --- 315} 316 317static void scsi_target_destroy(struct scsi_target *starget) 318{ 319 struct device *dev = &starget->dev; 320 struct Scsi_Host *shost = dev_to_shost(dev->parent); 321 unsigned long flags; 322 | 1/* 2 * scsi_scan.c 3 * 4 * Copyright (C) 2000 Eric Youngdale, 5 * Copyright (C) 2002 Patrick Mansfield 6 * 7 * The general scanning/probing algorithm is as follows, exceptions are 8 * made to it depending on device specific flags, compilation options, and --- 306 unchanged lines hidden (view full) --- 315} 316 317static void scsi_target_destroy(struct scsi_target *starget) 318{ 319 struct device *dev = &starget->dev; 320 struct Scsi_Host *shost = dev_to_shost(dev->parent); 321 unsigned long flags; 322 |
323 starget->state = STARGET_DEL; |
|
323 transport_destroy_device(dev); 324 spin_lock_irqsave(shost->host_lock, flags); 325 if (shost->hostt->target_destroy) 326 shost->hostt->target_destroy(starget); 327 list_del_init(&starget->siblings); 328 spin_unlock_irqrestore(shost->host_lock, flags); 329 put_device(dev); 330} --- 48 unchanged lines hidden (view full) --- 379 * sysfs. Note: we have to be in user context here because the target reaps 380 * should be done in places where the scsi device visibility is being removed. 381 */ 382static void scsi_target_reap_ref_release(struct kref *kref) 383{ 384 struct scsi_target *starget 385 = container_of(kref, struct scsi_target, reap_ref); 386 | 324 transport_destroy_device(dev); 325 spin_lock_irqsave(shost->host_lock, flags); 326 if (shost->hostt->target_destroy) 327 shost->hostt->target_destroy(starget); 328 list_del_init(&starget->siblings); 329 spin_unlock_irqrestore(shost->host_lock, flags); 330 put_device(dev); 331} --- 48 unchanged lines hidden (view full) --- 380 * sysfs. Note: we have to be in user context here because the target reaps 381 * should be done in places where the scsi device visibility is being removed. 382 */ 383static void scsi_target_reap_ref_release(struct kref *kref) 384{ 385 struct scsi_target *starget 386 = container_of(kref, struct scsi_target, reap_ref); 387 |
387 transport_remove_device(&starget->dev); 388 device_del(&starget->dev); 389 starget->state = STARGET_DEL; | 388 /* 389 * if we get here and the target is still in the CREATED state that 390 * means it was allocated but never made visible (because a scan 391 * turned up no LUNs), so don't call device_del() on it. 392 */ 393 if (starget->state != STARGET_CREATED) { 394 transport_remove_device(&starget->dev); 395 device_del(&starget->dev); 396 } |
390 scsi_target_destroy(starget); 391} 392 393static void scsi_target_reap_ref_put(struct scsi_target *starget) 394{ 395 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); 396} 397 --- 103 unchanged lines hidden (view full) --- 501 * @starget: target to be checked 502 * 503 * This is used after removing a LUN or doing a last put of the target 504 * it checks atomically that nothing is using the target and removes 505 * it if so. 506 */ 507void scsi_target_reap(struct scsi_target *starget) 508{ | 397 scsi_target_destroy(starget); 398} 399 400static void scsi_target_reap_ref_put(struct scsi_target *starget) 401{ 402 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); 403} 404 --- 103 unchanged lines hidden (view full) --- 508 * @starget: target to be checked 509 * 510 * This is used after removing a LUN or doing a last put of the target 511 * it checks atomically that nothing is using the target and removes 512 * it if so. 513 */ 514void scsi_target_reap(struct scsi_target *starget) 515{ |
516 /* 517 * serious problem if this triggers: STARGET_DEL is only set in the if 518 * the reap_ref drops to zero, so we're trying to do another final put 519 * on an already released kref 520 */ |
|
509 BUG_ON(starget->state == STARGET_DEL); | 521 BUG_ON(starget->state == STARGET_DEL); |
510 if (starget->state == STARGET_CREATED) 511 scsi_target_destroy(starget); 512 else 513 scsi_target_reap_ref_put(starget); | 522 scsi_target_reap_ref_put(starget); |
514} 515 516/** 517 * sanitize_inquiry_string - remove non-graphical chars from an INQUIRY result string 518 * @s: INQUIRY result string to sanitize 519 * @len: length of the string 520 * 521 * Description: --- 1462 unchanged lines hidden --- | 523} 524 525/** 526 * sanitize_inquiry_string - remove non-graphical chars from an INQUIRY result string 527 * @s: INQUIRY result string to sanitize 528 * @len: length of the string 529 * 530 * Description: --- 1462 unchanged lines hidden --- |