Re: [PATCH 3 of 6] scsi: Support devices with protection information

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

 



On Thu, 2008-07-17 at 04:28 -0400, Martin K. Petersen wrote:
> -struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
> +struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask, int protection)
>  {
>  	struct scsi_cmnd *cmd;
>  	unsigned char *buf;
>  
>  	cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask);
>  
> -	if (unlikely(!cmd)) {
> +	if (protection)
> +		cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp_mask);

Really, no.  if cmd is NULL, this will cause an immediate oops.

> +
> +	if (unlikely(!cmd) || unlikely(protection && cmd->prot_sdb == NULL)) {

And here, too ...

>  		unsigned long flags;
>  		spin_lock_irqsave(&shost->free_list_lock, flags);

In general, you're on the right lines, the problem is with this
protection flag.  To use the poll like this, the protection is going to
have to be always on or always off.  If you try and gate it by a flag,
the command on the free list is going to lose the protection buffer
eventually (because it can get allocated on low memory, but it won't
necessarily be the command returned to the free list, and if the
returned command is allocated without protection, we lose the buffer).

James


--
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