Re: [PATCH v2] scsi: support packing multi-segment in UNMAP command

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

 



On Wed, Jun 15, 2022 at 09:28:46PM +0800, Chao Yu wrote:
> As SPEC describes that it can support unmapping one or more LBA range

s/SPEC/<insert SPC reference here>/

>  {
>  	struct scsi_device *sdp = cmd->device;
>  	struct request *rq = scsi_cmd_to_rq(cmd);
> +	struct bio *bio;
>  	struct scsi_disk *sdkp = scsi_disk(rq->q->disk);
> +	unsigned short segments = blk_rq_nr_discard_segments(rq);
> +	unsigned int data_len = 8 + 16 * segments, i = 0;
>  	char *buf;

Nit: for readability I'd move the bio declaration just above the buf
line.

> +
> +	__rq_for_each_bio(bio, rq) {
> +		u64 lba = sectors_to_logical(sdp, bio->bi_iter.bi_sector);
> +		u32 nr_blocks = sectors_to_logical(sdp, bio_sectors(bio));
> +
> +		put_unaligned_be64(lba, &buf[8 + 16 * i]);
> +		put_unaligned_be32(nr_blocks, &buf[8 + 16 * i + 8]);

Can we have a local variable here?

	unsigned int data_offset = 8;

	....

		put_unaligned_be64(lba, &buf[data_offset]);
		put_unaligned_be64(lba, &buf[data_offset + 8]);
		data_offset += 16;
	}




[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