Re: [PATCH 7/8] SCSI: add a field to scsi_device to count open file references

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 Mar 2008, Stefan Richter wrote:

> Alan Stern wrote:
> > So I need a
> > way to know whether anything is mounted on a device below a SCSI host.
> 
> Actually I have been thinking of something related for a while but 
> didn't send a patch yet.  Consider this:
> 
> [include/scsi/scsi_host.h]
> 
>   struct scsi_host_template {
> 	...
> +	int (* slave_sdev_get)(struct scsi_device *);
> +	void (* slave_sdev_put)(struct scsi_device *);
> 	...
>   }
> 
> [drivers/scsi/scsi.c]
> 
>   int scsi_device_get(struct scsi_device *sdev)
>   {
> +	int err = 0;
> +
>   	if (sdev->sdev_state == SDEV_DEL)
>   		return -ENXIO;
>   	if (!get_device(&sdev->sdev_gendev))
>   		return -ENXIO;
>   	/* We can fail this if we're doing SCSI operations
>   	 * from module exit (like cache flush) */
>   	try_module_get(sdev->host->hostt->module);
> 
> -	return 0;
> +	if (sdev->host->hostt->slave_sdev_get)
> +		err = sdev->host->hostt->slave_sdev_get(sdev);
> +	if (err) {
> +		...some ifdef'd module_put stuff...;
> +		put_device(&sdev->sdev_gendev);
> +	}
> +	return err;
> }
> 
> and equivalent additions to scsi_device_put().

On second thought, I'm not so sure this would work the way I want.  
scsi_device_get() ends up being called for all sorts of extra things 
unrelated to device opens.  For instance, scsi_probe_and_add_lun() 
calls it whenever a new LUN is discovered.

Would it be acceptable to add a similar pair of callbacks to the host
template, invoked by the upper-level driver's open and release
routines?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux