# Re: \[PATCH V2\] raid1: ensure write behind bio has less than BIO\_MAX\_VECS sectors

- From: Christoph Hellwig \<hch@infradead.org\>
- Date: 2021-08-19 08:56:35 
- List: linux-raid
- Page: https://ratatoskr.run/linux-raid/2021/08/6404847
- Thread: https://ratatoskr.run/linux-block/2021/08/6404794/t.md

```text
On Wed, Aug 18, 2021 at 03:37:38PM +0800, Guoqing Jiang wrote:
>  	for (i = 0;  i < disks; i++) {
>  		struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
> +
> +		if (test_bit(WriteMostly, &mirror->rdev->flags))
> +			write_behind = true;

How does this condition relate to the ones used for actually calling
alloc_behind_master_bio?  It looks related, but as someone not familiar
with the code I can't really verify if this is correct, so a comment
explaining it might be useful.

> +	/*
> +	 * When using a bitmap, we may call alloc_behind_master_bio below.
> +	 * alloc_behind_master_bio allocates a copy of the data payload a page
> +	 * at a time and thus needs a new bio that can fit the whole payload
> +	 * this bio in page sized chunks.
> +	 */
> +	if (write_behind && bitmap)
> +		max_sectors = min_t(int, max_sectors, BIO_MAX_VECS * PAGE_SECTORS);

Overly long line here.
```
