<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/md/raid1.c, branch v7.1.7</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v7.1.7</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v7.1.7'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-07-24T14:20:20+00:00</updated>
<entry>
<title>md/raid1: free r1_bio when REQ_NOWAIT is set and read would block on retry</title>
<updated>2026-07-24T14:20:20+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-06-11T10:13:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c6e6354295845698d2fdfa20b71fc404786f7e93'/>
<id>urn:sha1:c6e6354295845698d2fdfa20b71fc404786f7e93</id>
<content type='text'>
[ Upstream commit 69ad6ce47f9bf2b9fe0ed69b042db993d33bbf12 ]

When a read is retried, raid1_read_request() may be called with a
pre-allocated r1_bio. If wait_read_barrier() fails for a REQ_NOWAIT
read, the bio is completed and the function returns immediately. In this
case the existing r1_bio is leaked.

This fixes a leak of pre-allocated r1_bio structures for retried reads.

Fixes: 5aa705039c4f ("md: raid1 add nowait support")
Reported-by: sashiko-bot &lt;sashiko-bot@kernel.org&gt;
Closes: https://sashiko.dev/#/patchset/20260611083514.754922-1-abd.masalkhi@gmail.com?part=1
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Link: https://patch.msgid.link/20260611101350.759154-1-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md/raid1: honor REQ_NOWAIT when waiting for behind writes</title>
<updated>2026-07-24T14:20:20+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-06-11T08:35:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=937c3e44ecaf5425c892256007dbfc1f78748d1f'/>
<id>urn:sha1:937c3e44ecaf5425c892256007dbfc1f78748d1f</id>
<content type='text'>
[ Upstream commit a286cb88ddb26c5f4377859d8e77233d9181eb82 ]

raid1 supports REQ_NOWAIT reads by avoiding waits in the barrier path
through wait_read_barrier(). However, a read can still block on a
WriteMostly device when the array uses a bitmap and there are
outstanding behind writes.

In that case raid1 unconditionally calls wait_behind_writes(), which
may sleep until all behind writes complete. As a result, a REQ_NOWAIT
read can block despite the caller explicitly requesting non-blocking
behavior.

This ensures that raid1 consistently honors REQ_NOWAIT reads across all
paths that may otherwise wait for behind writes.

Fixes: 5aa705039c4f ("md: raid1 add nowait support")
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Link: https://patch.msgid.link/20260611083514.754922-1-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md/raid1: fix writes_pending and barrier reference leaks on write failures</title>
<updated>2026-07-24T14:20:20+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-06-13T18:28:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bffbbfcbd9393e315a7a4286dcd70e875265db9a'/>
<id>urn:sha1:bffbbfcbd9393e315a7a4286dcd70e875265db9a</id>
<content type='text'>
[ Upstream commit 8e065a1602511282fc0da2dc89445e0eb71a681c ]

raid1_make_request() acquires a writes_pending reference with
md_write_start() before calling raid1_write_request(). Several failure
paths in raid1_write_request() complete the bio and return without
reaching the normal write completion path, causing the corresponding
md_write_end() to be skipped.

Make raid1_write_request() return a status indicating whether the write
request was successfully queued. This allows raid1_make_request() to
call md_write_end() when raid1_write_request() fails.

Additionally, if wait_blocked_rdev() fails after wait_barrier()
succeeds, the associated barrier reference is not released.

Call allow_barrier() before returning from that path to keep the barrier
accounting balanced.

Fixes: b1a7ad8b5c4f ("md/raid1: Handle bio_split() errors")
Fixes: f2a38abf5f1c ("md/raid1: Atomic write support")
Fixes: 5aa705039c4f ("md: raid1 add nowait support")
Reported-by: sashiko-bot &lt;sashiko-bot@kernel.org&gt;
Closes: https://sashiko.dev/#/patchset/20260611083514.754922-1-abd.masalkhi@gmail.com?part=1
Closes: https://sashiko.dev/#/patchset/20260611132500.763528-1-abd.masalkhi@gmail.com?part=1
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Link: https://patch.msgid.link/20260613182810.1317258-2-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>raid1: fix nr_pending leak in REQ_ATOMIC bad-block error path</title>
<updated>2026-07-24T14:19:26+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-05-30T15:14:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=731485617bf862f1289c3f40ed1f800d0475826f'/>
<id>urn:sha1:731485617bf862f1289c3f40ed1f800d0475826f</id>
<content type='text'>
[ Upstream commit 909d9dc3b5730c8ed7b764c68bc788342df2a07b ]

In raid1_write_request(), each per-mirror loop iteration begins by
incrementing rdev-&gt;nr_pending. If a REQ_ATOMIC write encounters a
badblock within the requested range, the code jumps to err_handle
without dropping the reference taken for the current mirror.

err_handle's cleanup loop will only decrements for k &lt; i and
r1_bio-&gt;bios[k] is non-NULL. The current slot is therefore skipped,
leaving its nr_pending reference leaked permanently. The reference
prevents the rdev from ever being removed, since raid1_remove_conf()
refuses to remove an rdev with nr_pending &gt; 0.

Fix this by calling rdev_dec_pending() before jumping to err_handle.

Fixes: f2a38abf5f1c ("md/raid1: Atomic write support")
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Link: https://patch.msgid.link/20260530151411.4119-1-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md/raid1,raid10: fix bio accounting for split md cloned bios</title>
<updated>2026-07-24T14:19:26+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-05-01T11:46:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bb8d7ea74206b419aa05d7773a15a923b668c9f0'/>
<id>urn:sha1:bb8d7ea74206b419aa05d7773a15a923b668c9f0</id>
<content type='text'>
[ Upstream commit ba976e3501111d11c550848b3b7341a73035f582 ]

Use md_cloned_bio() to control bio accounting instead of relying
on r1bio_existed in raid1 or the io_accounting flag in raid10.

The previous logic does not reliably reflect whether a bio is an
md cloned bio. When a failed bio is split and resubmitted via
bio_submit_split_bioset() on the error path, this can lead to either
double accounting for md cloned bios, or missing accounting for bios
returned from bio_submit_split_bioset()

Fix this by using md_cloned_bio() to detect md cloned bios and
skip accounting accordingly.

Fixes: bb2a9acefaf9 ("md/raid1: switch to use md_account_bio() for io accounting")
Fixes: 820455238366 ("md/raid10: switch to use md_account_bio() for io accounting")
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Reviewed-by: Xiao Ni &lt;xiao@kernel.org&gt;
Link: https://patch.msgid.link/20260501114652.590037-4-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md/raid1,raid10: fix error-path detection with md_cloned_bio()</title>
<updated>2026-07-24T14:19:26+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-05-01T11:46:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=20fb582c92fd64e5c8bd83c6176264b2794603b7'/>
<id>urn:sha1:20fb582c92fd64e5c8bd83c6176264b2794603b7</id>
<content type='text'>
[ Upstream commit 811545e0926d02a6a0b1a1258bb5544777c164d4 ]

Detect the error path using md_cloned_bio() instead of relying
on r1_bio in raid1 or r10_bio-&gt;read_slot in raid10, which may be
NULL or -1 after splitting and resubmitting a failed bio.

As a result, the error path may not be recognized and memory
allocations can incorrectly use GFP_NOIO instead of
(GFP_NOIO | __GFP_HIGH), which can lead to a deadlock under
memory pressure.

Fixes: 689389a06ce7 ("md/raid1: simplify handle_read_error().")
Fixes: 545250f24809 ("md/raid10: simplify handle_read_error()")
Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Reviewed-by: Xiao Ni &lt;xiao@kernel.org&gt;
Link: https://patch.msgid.link/20260501114652.590037-3-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fygo.io&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>md/raid1: replace wait loop with wait_event_idle() in raid1_write_request()</title>
<updated>2026-04-28T12:44:38+00:00</updated>
<author>
<name>Abd-Alrhman Masalkhi</name>
<email>abd.masalkhi@gmail.com</email>
</author>
<published>2026-04-23T10:13:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c1a3cdb0b49fff28d90e2c33114a7c0058261f60'/>
<id>urn:sha1:c1a3cdb0b49fff28d90e2c33114a7c0058261f60</id>
<content type='text'>
The wait loop is equivalent to wait_event_idle(); use it to improve
readability.

Signed-off-by: Abd-Alrhman Masalkhi &lt;abd.masalkhi@gmail.com&gt;
Link: https://lore.kernel.org/linux-raid/20260423101303.48196-2-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai &lt;yukuai@fnnas.com&gt;
</content>
</entry>
<entry>
<title>md/raid1: serialize overlap io for writemostly disk</title>
<updated>2026-04-07T05:09:22+00:00</updated>
<author>
<name>Xiao Ni</name>
<email>xni@redhat.com</email>
</author>
<published>2026-03-24T07:24:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=808cec74601cfddea87b6970134febfdc7f574b9'/>
<id>urn:sha1:808cec74601cfddea87b6970134febfdc7f574b9</id>
<content type='text'>
Previously, using wait_event() would wake up all waiters simultaneously,
and they would compete for the tree lock. The bio which gets the lock
first will be handled, so the write sequence cannot be guaranteed.

For example:
bio1(100,200)
bio2(150,200)
bio3(150,300)

The write sequence of fast device is bio1,bio2,bio3. But the write sequence
of slow device could be bio1,bio3,bio2 due to lock competition. This causes
data corruption.

Replace waitqueue with a fifo list to guarantee the write sequence. And it
also needs to iterate the list when removing one entry. If not, it may miss
the opportunity to wake up the waiting io.

For example:
bio1(1,3), bio2(2,4)
bio3(5,7), bio4(6,8)
These four bios are in the same bucket. bio1 and bio3 are inserted into
the rbtree. bio2 and bio4 are added to the waiting list and bio2 is the
first one. bio3 returns from slow disk and tries to wake up the waiting
bios. bio2 is removed from the list and will be handled. But bio1 hasn't
finished. So bio2 will be added into waiting list again. Then bio1 returns
from slow disk and wakes up waiting bios. bio4 is removed from the list
and will be handled. Now bio1, bio3 and bio4 all finish and bio2 is left
on the waiting list. So it needs to iterate the waiting list to wake up
the right bio.

Signed-off-by: Xiao Ni &lt;xni@redhat.com&gt;
Link: https://lore.kernel.org/linux-raid/20260324072501.59865-1-xni@redhat.com/
Signed-off-by: Yu Kuai &lt;yukuai@fnnas.com&gt;
</content>
</entry>
<entry>
<title>md/raid1: fix the comparing region of interval tree</title>
<updated>2026-03-22T18:15:10+00:00</updated>
<author>
<name>Xiao Ni</name>
<email>xni@redhat.com</email>
</author>
<published>2026-03-05T01:18:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=de3544d2e5ea99064498de3c21ba490155864657'/>
<id>urn:sha1:de3544d2e5ea99064498de3c21ba490155864657</id>
<content type='text'>
Interval tree uses [start, end] as a region which stores in the tree.
In raid1, it uses the wrong end value. For example:
bio(A,B) is too big and needs to be split to bio1(A,C-1), bio2(C,B).
The region of bio1 is [A,C] and the region of bio2 is [C,B]. So bio1 and
bio2 overlap which is not right.

Fix this problem by using right end value of the region.

Fixes: d0d2d8ba0494 ("md/raid1: introduce wait_for_serialization")
Signed-off-by: Xiao Ni &lt;xni@redhat.com&gt;
Link: https://lore.kernel.org/linux-raid/20260305011839.5118-2-xni@redhat.com/
Signed-off-by: Yu Kuai &lt;yukuai3@huawei.com&gt;
</content>
</entry>
<entry>
<title>block: remove bdev_nonrot()</title>
<updated>2026-03-09T20:30:00+00:00</updated>
<author>
<name>Damien Le Moal</name>
<email>dlemoal@kernel.org</email>
</author>
<published>2026-02-26T07:54:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ecd92cfec5349876d6a80f8188ea98c5920094b6'/>
<id>urn:sha1:ecd92cfec5349876d6a80f8188ea98c5920094b6</id>
<content type='text'>
bdev_nonrot() is simply the negative return value of bdev_rot().
So replace all call sites of bdev_nonrot() with calls to bdev_rot()
and remove bdev_nonrot().

Signed-off-by: Damien Le Moal &lt;dlemoal@kernel.org&gt;
Reviewed-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Reviewed-by: Paul Menzel &lt;pmenzel@molgen.mpg.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
