Re: [PATCH 1/1] block: make sure bi_size is aligned to discard_max_bytes

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

 



On 03/26/16 06:03, tom.ty89@xxxxxxxxx wrote:
@@ -82,7 +82,12 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
  		}

  		/* Make sure bi_size doesn't overflow */
-		req_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9);
+		max_discard_sectors = UINT_MAX >> 9;
+
+		/* Make sure bi_size aligns to discard_max_bytes */
+		max_discard_sectors -= max_discard_sectors % q->limits.max_discard_sectors;
+
+		req_sects = min_t(sector_t, nr_sects, max_discard_sectors);

  		/*
  		 * If splitting a request, and the next starting sector would be

Hello Tom,

Why do you think this change is needed? Please have a look at blk_bio_discard_split(). That function already limits the maximum size of a single discard request and also guarantees that the size of each discard request is a multiple of the discard granularity.

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



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux