This is not for the "discard_granularity" reported in the sysfs, but for granularity that users "implied" when setting "discard_max_bytes" for devices that is not capable of reporting their actual granularity (SATA SSDs, as I've mentioned). This is not strictly necessary to be honest since in FITRIM cases the requests can still be misaligned, but it helps on BLKDISCARD. Also I don't think it's a bad thing anyway to make sure there is no "remainder" when the request is split (so that every split is equal). On 28 March 2016 at 15:19, Bart Van Assche <bart.vanassche@xxxxxxxxxxx> wrote: > 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