Re: [PATCH V2 1/2] scsi: core: avoid to pre-allocate big chunk for protection meta data

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

 



> -	if (scsi_prot_sg_count(cmd))
> -		sg_free_table_chained(&cmd->prot_sdb->table, true);
> +	if (scsi_prot_sg_count(cmd) && cmd->prot_sdb->table.sgl !=
> +			scsi_prot_inline_sg(cmd))
> +		sg_free_table_chained(&cmd->prot_sdb->table, false);

Nipick: I usually find it easier to read if we break around conditions
instead of inside them:

	if (scsi_prot_sg_count(cmd) &&
	    cmd->prot_sdb->table.sgl != scsi_prot_inline_sg(cmd))

> +		if (ivecs <= SCSI_INLINE_PROT_SG_CNT) {
> +			scsi_init_inline_sg_table(&prot_sdb->table,
> +						  scsi_prot_inline_sg(cmd),
> +						  SCSI_INLINE_PROT_SG_CNT);
> +		} else if (sg_alloc_table_chained(&prot_sdb->table,
> +						  ivecs, NULL)) {

Hmm.  Maybe we just need to pass an nr_inline_vecs argument
to sg_alloc_table_chained to replace the SG_CHUNK_SIZE argument instead
of open coding this logic?

If we'd also pass it to sg_free_table_chained we could also simplify
those checks in all callers.



[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