On 2016/12/8 上午12:59, Shaohua Li wrote: > On Wed, Dec 07, 2016 at 07:50:33PM +0800, Coly Li wrote: [snip] > Thanks for doing this, Coly! For raid0, this totally makes sense. The raid0 > zones make things a little complicated though. I just had a brief look of your > proposed patch, which looks really complicated. I'd suggest something like > this: > 1. split the bio according to zone boundary. > 2. handle the splitted bio. since the bio is within zone range, calculating > the start and end sector for each rdev should be easy. > Hi Shaohua, Thanks for your suggestion! I try to modify the code by your suggestion, it is even more hard to make the code that way ... Because even split bios for each zone, all the corner cases still exist and should be taken care in every zoon. The code will be more complicated. > This will create slightly more bio to each rdev (not too many, since there > aren't too many zones in practice) and block layer should easily merge these > bios without much overhead. The benefit is a much simpler implementation. > >> I compose a prototype patch, the code is not simple, indeed it is quite >> complicated IMHO. >> >> I do a little research, some NVMe SSDs support whole device size >> DISCARD, also I observe mkfs.xfs sends out a raid0 device size DISCARD >> bio to block layer. But raid0_make_request() only receives 512KB size >> DISCARD bio, block/blk-lib.c:__blkdev_issue_discard() splits the >> original large bio into 512KB small bios, the limitation is from >> q->limits.discard_granularity. > > please adjust the max discard sectors for the queue. The original setting is > chunk size. This is a powerful suggestion, I change the max_discard_sectors to raid0 size, and fix some bugs, now the patch looks working well. The performance number is not bad. On 4x3TB NVMe raid0, format it with mkfs.xfs. Current upstream kernel spends 306 seconds, the patched kernel spends 15 seconds. I see average request size increases from 1 chunk (1024 sectors) to 2048 chunks (2097152 sectors). I don't know why the bios are still be split before raid0_make_request() receives them, after I set q->limits.max_discard_sectors to mddev->array_sectors. Can anybody give me a hint ? Here I attach the RFC v2 patch, if anybody wants to try it, please do it and response the result :-) I will take time to write a very detailed commit log and code comments to make this patch more easier to be understood. Ugly code, that's what I have to pay to gain better performance .... Thanks in advance. Coly