Re: [PATCH 4/5] md/raid10: improve raid10 discard request
From: Xiao Ni <hidden>
Date: 2021-02-04 02:02:02
On 02/03/2021 11:50 PM, Christoph Hellwig wrote:
On Wed, Feb 03, 2021 at 09:45:30PM +0800, Xiao Ni wrote:quoted
+static struct bio *raid10_split_bio(struct r10conf *conf, + struct bio *bio, sector_t sectors, bool want_first) +{ + struct bio *split; + + split = bio_split(bio, sectors, GFP_NOIO, &conf->bio_split); + bio_chain(split, bio); + allow_barrier(conf); + if (want_first) { + submit_bio_noacct(bio); + bio = split; + } else + submit_bio_noacct(split); + wait_barrier(conf); + + return bio;I'm not sure this helper makes much sense given that the two different cases could just be open coded into the two callers.
It makes sense. At first I want to make the codes look like simpler. But as you said, they are two different cases. We can code openly into the two callers.
quoted
+ /* raid10_remove_disk uses smp_mb to make sure rdev is set to + * replacement before setting replacement to NULL. It can read + * rdev first without barrier protect even replacment is NULL + */Not the normal kernel comment style.quoted
+/* There are some limitations to handle discard bio + * 1st, the discard size is bigger than stripe_size*2. + * 2st, if the discard bio spans reshape progress, we use the old way to + * handle discard bio + */Same here.quoted
+static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) +{ + struct r10conf *conf = mddev->private; + struct geom *geo = &conf->geo; + struct r10bio *r10_bio; + + int disk; + sector_t chunk; + unsigned int stripe_size; + unsigned int stripe_data_disks; + sector_t split_size; + + sector_t bio_start, bio_end;Empty lines between variabe declarations also are kinda strange.quoted
+ stripe_data_disks = geo->near_copies ? + geo->raid_disks / geo->near_copies + + geo->raid_disks % geo->near_copies : + geo->raid_disks;Normal style would be an if/else here.quoted
+ + bio_start = bio->bi_iter.bi_sector; + bio_end = bio_end_sector(bio); + + /* Maybe one discard bio is smaller than strip size or across one stripe + * and discard region is larger than one stripe size. For far offset layout,While there are occasional exceptions to the 80 char line rule, a block comment should never qualify.quoted
+ * if the discard region is not aligned with stripe size, there is hole + * when we submit discard bio to member disk. For simplicity, we only + * handle discard bio which discard region is bigger than stripe_size*2 + */ + if (bio_sectors(bio) < stripe_size*2)missing whitespaces around the *.
I'll fix these style problems. Thanks Xiao