Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] block: improve struct request_queue layout && md: remove rcu protection to access rdev from conf#1996

Merged
opsiff merged 9 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-20-update
Jul 20, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] block: improve struct request_queue layout && md: remove rcu protection to access rdev from conf#1996
opsiff merged 9 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-20-update

Conversation

@opsiff

@opsiff opsiff commented Jul 20, 2026

Copy link
Copy Markdown
Member

Link: https://lore.kernel.org/all/[email protected]/#r

From: Yu Kuai [email protected]

Changes in v3:

  • remove patch 1 from v2, and since all the print_conf() is called
    while 'reconfig_mutex' is held, it's safe to remove
    rcu_read_lock/unlock() directly.
  • remove the definition of flag RemoveSynchronized;

Changes in v2:

  • add cover leter in details.

The lifetime of rdev:

  1. md_import_device() generate a rdev based on underlying disk;

    mddev_lock()
    rdev = kzalloc();
    rdev->bdev = blkdev_get_by_dev();
    mddev_unlock()

  2. bind_rdev_to_array() add this rdev to mddev->disks;

    mddev_lock()
    kobject_add(&rdev->kobj, &mddev->kobj, ...);
    list_add_rcu(&rdev->same_set, &mddev->disks);
    mddev_unlock()

  3. remove_and_add_spares() add this rdev to conf;

    mddev_lock()
    rdev_addable();
    pers->hot_add_disk();
    rcu_assign_pointer(conf->rdev, rdev);
    mddev_unlock()

  4. Use this array with rdev;

  5. remove_and_add_spares() remove rdev from conf;

    // triggered by sysfs/ioctl
    mddev_lock()
    rdev_removeable();
    pers->hot_remove_disk();
    rcu_assign_pointer(conf->rdev, NULL);
    synchronize_rcu();
    mddev_unlock()

    // triggered by daemon
    mddev_lock()
    rdev_removeable();
    synchronize_rcu(); -> this can't protect accessing rdev from conf
    pers->hot_remove_disk();
    rcu_assign_pointer(conf->rdev, NULL);
    mddev_unlock()

  6. md_kick_rdev_from_array() remove rdev from mddev->disks;

    mddev_lock()
    list_del_rcu(&rdev->same_set);
    synchronize_rcu();
    list_add(&rdev->same_set, &mddev->deleting)
    mddev_unlock()
    export_rdev

There are two separate rcu protection for rdev, and this pathset remove
the protection of conf(step 3 and 5), because it's safe to access rdev
from conf in following cases:

  • If 'reconfig_mutex' is held, because rdev can't be added or rmoved to
    conf;
  • If there is normal IO inflight, because mddev_suspend() will wait for
    IO to be done and prevent rdev to be added or removed to conf;
  • If sync thread is running, because remove_and_add_spares() can only be
    called from daemon thread when sync thread is done, and
    'MD_RECOVERY_RUNNING' is also checked for ioctl/sysfs;
  • if any spinlock or rcu_read_lock() is held, because synchronize_rcu()
    from step 6 prevent rdev to be freed until spinlock is released or
    rcu_read_unlock();

Yu Kuai (5):
md: remove flag RemoveSynchronized
md/raid10: remove rcu protection to access rdev from conf
md/raid1: remove rcu protection to access rdev from conf
md/raid5: remove rcu protection to access rdev from conf
md/md-multipath: remove rcu protection to access rdev from conf

drivers/md/md-multipath.c | 32 +++---
drivers/md/md.c | 37 ++-----
drivers/md/md.h | 5 -
drivers/md/raid1.c | 71 ++++--------
drivers/md/raid10.c | 222 ++++++++++----------------------------
drivers/md/raid5-cache.c | 11 +-
drivers/md/raid5-ppl.c | 16 +--
drivers/md/raid5.c | 191 +++++++++++---------------------
drivers/md/raid5.h | 4 +-
9 files changed, 168 insertions(+), 421 deletions(-)

Summary by Sourcery

Simplify md RAID and multipath device handling by removing RCU-based protection around conf->rdev access and reworking device removal rules, while also tightening block queue and zoned block device interfaces.

Bug Fixes:

  • Prevent unsafe rdev removal by tightening checks on pending I/O, fault, journal, and in_sync states instead of relying on RCU synchronization.

Enhancements:

  • Refine removal criteria for md_rdev devices with a new helper and simplify spare removal logic in md core.
  • Replace RCU-protected md device pointers in RAID1, RAID5, RAID10, and md-multipath with direct/WRITE_ONCE access patterns, adding appropriate lockdep assertions.
  • Streamline RAID queue status and configuration printing paths to assume existing locks instead of per-call RCU sections.
  • Reorganize struct request_queue fields to improve layout and clarify lifetime/ownership semantics in the block layer.
  • Unify zoned block device APIs by centralizing bdev_nr_zones and blkdev_zone_mgmt definitions under CONFIG_BLK_DEV_ZONED guards.

axboe and others added 9 commits July 20, 2026 09:55
mainline inclusion
from mainline-v6.8-rc1
category: performance

It's clearly been a while since someone looked at this, so I gave it a
quick shot. There are few issues in here:

- Random bundling of members that are mostly read-only and often written
- Random holes that need not be there

This moves the most frequently used bits into cacheline 1 and 2, with
the 2nd one being more write intensive than the first one, which is
basically read-only.

Outside of making this work a bit more efficiently, it also reduces the
size of struct request_queue for my test setup from 864 bytes (spanning
14 cachelines!) to 832 bytes and 13 cachelines.

Reviewed-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
(cherry picked from commit 0c734c5)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
categroy: other

Allow using a few symbols with IS_ENABLED instead of #idef by moving
the declarations out of #idef CONFIG_BLK_DEV_ZONED, and move
bdev_nr_zones into the remaining  #idef CONFIG_BLK_DEV_ZONED, #else
block below.

Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
(cherry picked from commit 668bfee)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.7-rc1
category: other

There are no functional changes, just to make the code simpler and
prepare to delay remove_and_add_spares() to md_start_sync().

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit 3389d57)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
category: other

rcu is not used correctly here, because synchronize_rcu() is called
before replacing old value, for example:

remove_and_add_spares   // other path
 synchronize_rcu
 // called before replacing old value
 set_bit(RemoveSynchronized)
                        rcu_read_lock()
                        rdev = conf->mirros[].rdev
 pers->hot_remove_disk
  conf->mirros[].rdev = NULL;
  if (!test_bit(RemoveSynchronized))
   synchronize_rcu
   /*
    * won't be called, and won't wait
    * for concurrent readers to be done.
    */
                        // access rdev after remove_and_add_spares()
                        rcu_read_unlock()

Fortunately, there is a separate rcu protection to prevent such rdev
to be freed:

md_kick_rdev_from_array		//other path
				rcu_read_lock()
				rdev = conf->mirros[].rdev
list_del_rcu(&rdev->same_set)

				rcu_read_unlock()
				/*
				 * rdev can be removed from conf, but
				 * rdev won't be freed.
				 */
synchronize_rcu()
free rdev

Hence remove this useless flag and prepare to remove rcu protection to
access rdev from 'conf'.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit c891f1f)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
category: other

Because it's safe to accees rdev from conf:
 - If any spinlock is held, because synchronize_rcu() from
   md_kick_rdev_from_array() will prevent 'rdev' to be freed until
   spinlock is released;
 - If 'reconfig_lock' is held, because rdev can't be added or removed from
   array;
 - If there is normal IO inflight, because mddev_suspend() will prevent
   rdev to be added or removed from array;
 - If there is sync IO inflight, because 'MD_RECOVERY_RUNNING' is
   checked in remove_and_add_spares().

And these will cover all the scenarios in raid10.

This patch also cleanup the code to handle the case that replacement
replace rdev while IO is still inflight.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit a448af2)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
category: other

Because it's safe to accees rdev from conf:
 - If any spinlock is held, because synchronize_rcu() from
   md_kick_rdev_from_array() will prevent 'rdev' to be freed until
   spinlock is released;
 - If 'reconfig_lock' is held, because rdev can't be added or removed from
   array;
 - If there is normal IO inflight, because mddev_suspend() will prevent
   rdev to be added or removed from array;
 - If there is sync IO inflight, because 'MD_RECOVERY_RUNNING' is
   checked in remove_and_add_spares().

And these will cover all the scenarios in raid1.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit 2d32777)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
category: other

Because it's safe to accees rdev from conf:
 - If any spinlock is held, because synchronize_rcu() from
   md_kick_rdev_from_array() will prevent 'rdev' to be freed until
   spinlock is released;
 - If 'reconfig_lock' is held, because rdev can't be added or removed from
   array;
 - If there is normal IO inflight, because mddev_suspend() will prevent
   rdev to be added or removed from array;
 - If there is sync IO inflight, because 'MD_RECOVERY_RUNNING' is
   checked in remove_and_add_spares().

And these will cover all the scenarios in raid456.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit ad86067)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.8-rc1
category: other

Because it's safe to accees rdev from conf:
 - If any spinlock is held, because synchronize_rcu() from
   md_kick_rdev_from_array() will prevent 'rdev' to be freed until
   spinlock is released;
 - If there is normal IO inflight, because mddev_suspend() will prevent
   rdev to be added or removed from array;

And these will cover all the scenarios in md-multipath.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit 7ecab28)
Signed-off-by: Wentao Guan <[email protected]>
mainline inclusion
from mainline-v6.11-rc1
category: bugfix

As commit ad86067 ("md/raid5: remove rcu protection to access rdev
from conf") explains, rcu protection can be removed, however, there are
three places left, there won't be any real problems.

drivers/md/raid5.c:8071:24: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:8071:24:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:8071:24:    struct md_rdev *
drivers/md/raid5.c:7569:25: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:7569:25:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:7569:25:    struct md_rdev *
drivers/md/raid5.c:7573:25: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:7573:25:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:7573:25:    struct md_rdev *

Fixes: ad86067 ("md/raid5: remove rcu protection to access rdev from conf")
Cc: [email protected]
Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit 2314c2e)
Signed-off-by: Wentao Guan <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors md RAID personalities and block queue structures to remove RCU-based protection for accessing rdevs from in-memory configurations, relying instead on higher-level locking and inflight IO guarantees, while simplifying request_queue layout and zoned-block APIs.

Sequence diagram for rdev lifecycle and removal without RCU from conf

sequenceDiagram
    participant U as User_or_daemon
    participant mddev as mddev
    participant rdev as md_rdev
    participant conf as md_personality_conf

    U->>mddev: md_import_device()
    activate mddev
    mddev->>mddev: mddev_lock()
    mddev->>rdev: kzalloc(md_rdev)
    mddev->>rdev: rdev->bdev = blkdev_get_by_dev()
    mddev->>mddev: mddev_unlock()
    deactivate mddev

    U->>mddev: bind_rdev_to_array()
    activate mddev
    mddev->>mddev: mddev_lock()
    mddev->>mddev: kobject_add(rdev->kobj, mddev->kobj)
    mddev->>mddev: list_add_rcu(rdev->same_set, mddev->disks)
    mddev->>mddev: mddev_unlock()
    deactivate mddev

    U->>mddev: remove_and_add_spares()
    activate mddev
    mddev->>mddev: mddev_lock()
    loop for_each_rdev
        mddev->>mddev: rdev_removeable(rdev)
        alt removable
            mddev->>mddev: pers->hot_remove_disk(mddev, rdev)
            mddev->>conf: /* conf->rdev/replacement updated with WRITE_ONCE, no RCU */
            mddev->>mddev: sysfs_unlink_rdev(mddev, rdev)
            mddev->>rdev: rdev->saved_raid_disk = rdev->raid_disk
            mddev->>rdev: rdev->raid_disk = -1
        end
    end
    mddev->>mddev: mddev_unlock()
    deactivate mddev

    U->>mddev: md_kick_rdev_from_array()
    activate mddev
    mddev->>mddev: mddev_lock()
    mddev->>mddev: list_del_rcu(rdev->same_set)
    mddev->>mddev: synchronize_rcu()
    mddev->>mddev: list_add(rdev->same_set, mddev->deleting)
    mddev->>mddev: export_rdev(rdev)
    mddev->>mddev: mddev_unlock()
    deactivate mddev
Loading

File-Level Changes

Change Details Files
Remove RCU protection when accessing rdevs from RAID configurations and rely on explicit locking, inflight IO tracking, and READ/WRITE_ONCE for safety.
  • Replace rcu_dereference/rcu_read_lock usage on conf->mirrors/conf->disks/conf->multipaths with direct pointer loads or READ_ONCE where appropriate.
  • Use WRITE_ONCE when updating rdev and replacement pointers to preserve ordering and visibility without RCU.
  • Add lockdep_assert_held checks to status/print_conf paths that rely on mddev->lock or reconfig_mutex, documenting required locking context.
  • Simplify replacement-selection logic in RAID1/RAID10/RAID5 paths by removing custom dereference helpers and RCU barriers.
drivers/md/raid10.c
drivers/md/raid1.c
drivers/md/raid5.c
drivers/md/raid5-cache.c
drivers/md/raid5-ppl.c
drivers/md/md-multipath.c
drivers/md/md.h
drivers/md/raid5.h
Redesign rdev removal flow to avoid per-call synchronize_rcu and remove the RemoveSynchronized flag, using a new helper that checks rdev state and inflight IO before removal.
  • Introduce rdev_removeable() to centralize checks on raid_disk index, nr_pending, Blocked, Faulty, Journal, and In_sync flags when deciding if an rdev can be hot-removed.
  • Rewrite remove_and_add_spares() to rely on rdev_removeable() and hot_remove_disk() directly, dropping the two-phase RemoveSynchronized plus synchronize_rcu scheme.
  • Drop the RemoveSynchronized flag from md.h and remove all callsites that set or clear it.
  • Update RAID1, RAID5, and multipath remove_disk implementations to clear rdev pointers with WRITE_ONCE and no longer perform synchronize_rcu loops.
drivers/md/md.c
drivers/md/raid1.c
drivers/md/raid5.c
drivers/md/md-multipath.c
drivers/md/md.h
Make RAID rdev pointer fields non-RCU and adjust helper APIs and structures accordingly.
  • Change disk_info.rdev and disk_info.replacement from __rcu pointers to plain struct md_rdev* and update all users accordingly.
  • Remove rdev_pend_deref() and rdev_mdlock_deref() helpers that wrap rcu_dereference_protected, replacing their usage with direct pointer dereferences guarded by existing locks or state.
  • Ensure reshape, recovery, and log-handling code treats rdev pointers as stable under mddev locking and inflight IO guarantees rather than RCU.
  • Adjust RAID run/reshape/spare operations to use direct rdev/replacement access and to enforce constraints (e.g., no replacement during reshape) via simple pointer checks.
drivers/md/raid5.c
drivers/md/raid5-cache.c
drivers/md/raid5-ppl.c
drivers/md/raid5.h
Reorganize struct request_queue and blk zoned-device APIs to improve layout and configuration-guarding of zoned helpers.
  • Reorder fields in struct request_queue to group related members (queuedata/elevator/mq_ops, queue flags and depth, refs, xarray hw queues, usage counter, last_merge, locks, disk, limits, pm_only, stats, rq_qos, id, dma_pad_mask, nr_requests, crypto, timeout, work, shared tags, icq/blkcg, node, requeue structures, flush queues, sysfs locks, mq_freeze_lock, tag_set) and move quiesce_depth closer to mq_freeze_lock.
  • Move blkdev zoned APIs so blkdev_report_zones, blkdev_zone_mgmt, and blk_revalidate_disk_zones are always declared, with bdev_nr_zones only available when CONFIG_BLK_DEV_ZONED, and provide a stub bdev_nr_zones() returning 0 otherwise.
  • Export bdev_nr_zones() declaration under CONFIG_BLK_DEV_ZONED and add a stub implementation in the !CONFIG_BLK_DEV_ZONED section to keep callers simple.
include/linux/blkdev.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
deepin-ci-robot requested a review from BLumia July 20, 2026 02:11
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Now that rdev/replacement pointers are no longer RCU-protected, consider consistently using READ_ONCE/WRITE_ONCE for all unsynchronized pointer loads/stores (not just status paths) to make the concurrency assumptions explicit and avoid accidental compiler reordering.
  • The new helper is named rdev_removeable(); for clarity and consistency with existing terminology, consider renaming it to rdev_removable() (and updating call sites) to avoid the spelling mismatch.
  • You’ve added lockdep_assert_held() in some paths that rely on mddev->lock or reconfig_mutex instead of RCU; it may be worth auditing other code that now directly dereferences conf->*rdev fields and adding similar assertions where lock-based protection is assumed, to document and verify those invariants.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that rdev/replacement pointers are no longer RCU-protected, consider consistently using READ_ONCE/WRITE_ONCE for all unsynchronized pointer loads/stores (not just status paths) to make the concurrency assumptions explicit and avoid accidental compiler reordering.
- The new helper is named rdev_removeable(); for clarity and consistency with existing terminology, consider renaming it to rdev_removable() (and updating call sites) to avoid the spelling mismatch.
- You’ve added lockdep_assert_held() in some paths that rely on mddev->lock or reconfig_mutex instead of RCU; it may be worth auditing other code that now directly dereferences conf->*rdev fields and adding similar assertions where lock-based protection is assumed, to document and verify those invariants.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR removes RCU-based protection around conf->rdev access across multiple md personalities (raid1/10/5 and multipath), replaces it with direct / READ_ONCE / WRITE_ONCE accesses plus lockdep assertions, and also reorganizes struct request_queue layout and zoned block prototypes.

Changes:

  • Remove RemoveSynchronized flag and simplify md core spare remove logic via a new rdev_removeable() helper.
  • Drop rcu_read_lock()/rcu_dereference() usage for conf->{rdev,replacement} across raid1/10/5/multipath; add lockdep_assert_held() in config/status printing.
  • Rework block layer header layout: reorganize struct request_queue fields and adjust zoned API declarations/guards.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
include/linux/blkdev.h Reorders struct request_queue fields; adjusts zoned API declarations/guards.
drivers/md/md.h Removes RemoveSynchronized flag bit.
drivers/md/md.c Adds rdev_removeable() helper; simplifies remove_and_add_spares() logic.
drivers/md/md-multipath.c Removes RCU around conf->multipaths[].rdev accesses; switches to READ_ONCE/WRITE_ONCE and lockdep assertions.
drivers/md/raid1.c Removes RCU around conf->mirrors[].rdev accesses; adds lockdep assertions; uses WRITE_ONCE in updates.
drivers/md/raid10.c Removes RCU and ordering barriers around mirrors[].{rdev,replacement} access and transitions; adds lockdep assertions.
drivers/md/raid5.h Converts disk_info.{rdev,replacement} from __rcu pointers to plain pointers.
drivers/md/raid5.c Removes RCU dereferences/locks across many paths; uses READ_ONCE/WRITE_ONCE in some updates; removes helper deref wrappers and ordering barriers.
drivers/md/raid5-cache.c Removes RCU sections around disk pointer access during recovery and cache checks.
drivers/md/raid5-ppl.c Removes RCU dereference usage in PPL recovery/init paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/md/raid10.c
Comment on lines +1262 to 1265
rdev = replacement ? conf->mirrors[devnum].replacement :
conf->mirrors[devnum].rdev;

mbio = bio_alloc_clone(rdev->bdev, bio, GFP_NOIO, &mddev->bio_set);
Comment thread drivers/md/raid10.c
Comment on lines +1571 to 1575
rdev = repl ? conf->mirrors[dev].replacement :
conf->mirrors[dev].rdev;

raid_end_discard_bio(r10_bio);
rdev_dec_pending(rdev, conf->mddev);
Comment thread drivers/md/raid10.c
Comment on lines +5095 to 5098
rdev = repl ? conf->mirrors[d].replacement :
conf->mirrors[d].rdev;

if (bio->bi_status) {
Comment thread drivers/md/raid5.c
Comment on lines +8243 to +8255
WRITE_ONCE(*rdevp, NULL);
if (!err) {
err = log_modify(conf, rdev, false);
if (err)
goto abort;
}

tmp = rcu_access_pointer(p->replacement);
tmp = p->replacement;
if (tmp) {
/* We must have just cleared 'rdev' */
rcu_assign_pointer(p->rdev, tmp);
WRITE_ONCE(p->rdev, tmp);
clear_bit(Replacement, &tmp->flags);
smp_mb(); /* Make sure other CPUs may see both as identical
* but will never see neither - if they are careful
*/
rcu_assign_pointer(p->replacement, NULL);
WRITE_ONCE(p->replacement, NULL);
Comment thread drivers/md/raid5.c
Comment on lines +1181 to +1182
rdev = conf->disks[i].rdev;
rrdev = conf->disks[i].replacement;
Comment thread drivers/md/md.c
}
EXPORT_SYMBOL_GPL(md_do_sync);

static bool rdev_removeable(struct md_rdev *rdev)
Comment thread drivers/md/md.c
if (test_bit(Blocked, &rdev->flags))
return false;

/* Fautly rdev is not used, it's safe to remove it. */
@opsiff
opsiff merged commit 837e085 into deepin-community:linux-6.6.y Jul 20, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants