Thread (16 messages) flat view 16 messages, 2 authors, 2021-02-04

Re: [PATCH 4/5] md/raid10: improve raid10 discard request

From: Christoph Hellwig <hch@infradead.org>
Date: 2021-02-03 15:52:14

On Wed, Feb 03, 2021 at 09:45:30PM +0800, Xiao Ni wrote:
+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.
+		/* 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.
+/* 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.
+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.
+	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.
+
+	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.
+	 * 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 *.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help