anolis-cloud-kernel/drivers/md
Coly Li 696ebde695 bcache: call force_wake_up_gc() if necessary in check_should_bypass()
ANBZ: #20948

commit 05356938a4 upstream

If there are extreme heavy write I/O continuously hit on relative small
cache device (512GB in my testing), it is possible to make counter
c->gc_stats.in_use continue to increase and exceed CUTOFF_CACHE_ADD.

If 'c->gc_stats.in_use > CUTOFF_CACHE_ADD' happens, all following write
requests will bypass the cache device because check_should_bypass()
returns 'true'. Because all writes bypass the cache device, counter
c->sectors_to_gc has no chance to be negative value, and garbage
collection thread won't be waken up even the whole cache becomes clean
after writeback accomplished. The aftermath is that all write I/Os go
directly into backing device even the cache device is clean.

To avoid the above situation, this patch uses a quite conservative way
to fix: if 'c->gc_stats.in_use > CUTOFF_CACHE_ADD' happens, only wakes
up garbage collection thread when the whole cache device is clean.

Before the fix, the writes-always-bypass situation happens after 10+
hours write I/O pressure on 512GB Intel optane memory which acts as
cache device. After this fix, such situation doesn't happen after 36+
hours testing.

Change-Id: I5debdd63b06f14764fd35f4769955f8cfac09fda
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20240528120914.28705-3-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: geshifei <geshifei@hygon.cn>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/5258
2025-05-27 07:31:09 +00:00
..
bcache bcache: call force_wake_up_gc() if necessary in check_should_bypass() 2025-05-27 07:31:09 +00:00
persistent-data dm array: fix releasing a faulty array block twice in dm_array_cursor_end 2025-01-21 02:09:59 +08:00
Kconfig dm integrity: select CRYPTO_SKCIPHER 2021-01-27 11:54:57 +01:00
Makefile md: move the early init autodetect code to drivers/md/ 2020-07-16 15:34:47 +02:00
dm-bio-prison-v1.c
dm-bio-prison-v1.h
dm-bio-prison-v2.c dm bio prison v2: use true/false for bool variable 2020-01-07 12:07:08 -05:00
dm-bio-prison-v2.h
dm-bio-record.h dm bio record: save/restore bi_end_io and bi_integrity 2020-03-03 10:02:46 -05:00
dm-bufio.c dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size 2021-03-09 11:11:12 +01:00
dm-builtin.c
dm-cache-background-tracker.c
dm-cache-background-tracker.h
dm-cache-block-types.h
dm-cache-metadata.c dm cache: Fix ABBA deadlock between shrink_slab and dm_cache_metadata_abort 2023-09-06 07:56:48 +00:00
dm-cache-metadata.h
dm-cache-policy-internal.h
dm-cache-policy-smq.c dm cache policy smq: ensure IO doesn't prevent cleaner policy progress 2024-08-02 06:20:48 +00:00
dm-cache-policy.c
dm-cache-policy.h
dm-cache-target.c dm cache: fix potential out-of-bounds access on the first resume 2024-12-12 02:36:39 +00:00
dm-clone-metadata.c bitmap: introduce generic optimized bitmap_size() 2024-10-08 11:17:56 +08:00
dm-clone-metadata.h dm clone metadata: Fix return type of dm_clone_nr_of_hydrated_regions() 2020-03-27 14:42:51 -04:00
dm-clone-target.c dm clone: call kmem_cache_destroy() in dm_clone_init() error path 2024-08-02 06:20:48 +00:00
dm-core.h dm: limit the number of targets and parameter size area 2024-07-22 06:33:17 +00:00
dm-crypt.c dm-crypt, dm-verity: disable tasklets 2025-01-11 11:40:45 +00:00
dm-delay.c dm-delay: fix a race between delay_presuspend and delay_bio 2024-07-22 06:33:17 +00:00
dm-dust.c dm dust: add interface to list all badblocks 2020-07-20 11:17:41 -04:00
dm-ebs-target.c dm ebs: Fix incorrect checking for REQ_OP_FLUSH 2020-08-04 16:01:40 -04:00
dm-era-target.c dm era: commit metadata in postsuspend after worker stops 2022-06-29 08:59:45 +02:00
dm-exception-store.c
dm-exception-store.h
dm-flakey.c dm flakey: fix a crash with invalid table line 2024-08-02 06:20:48 +00:00
dm-historical-service-time.c dm mpath: only use ktime_get_ns() in historical selector 2022-04-20 09:23:18 +02:00
dm-init.c dm init: Set file local variable static 2020-08-04 15:51:28 -04:00
dm-integrity.c dm integrity: fix out-of-range warning 2024-08-02 06:20:48 +00:00
dm-io.c treewide: Remove uninitialized_var() usage 2020-07-16 12:35:15 -07:00
dm-ioctl.c dm resume: don't return EINVAL when signalled 2024-12-12 02:36:39 +00:00
dm-kcopyd.c
dm-linear.c dm: add support for REQ_NOWAIT and enable it for linear target 2020-09-25 08:20:03 -06:00
dm-log-userspace-base.c
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log-writes.c dm: replace zero-length array with flexible-array 2020-05-20 17:09:44 -04:00
dm-log.c dm mirror log: clear log bits up to BITS_PER_LONG boundary 2022-06-29 08:59:45 +02:00
dm-mpath.c dm: use dm_table_get_device_name() where appropriate in targets 2020-09-29 16:33:08 -04:00
dm-mpath.h
dm-path-selector.c
dm-path-selector.h dm mpath: pass IO start time to path selector 2020-05-15 10:29:36 -04:00
dm-queue-length.c dm mpath: pass IO start time to path selector 2020-05-15 10:29:36 -04:00
dm-raid.c dm-raid: fix lockdep waring in "pers->hot_add_disk" 2024-07-22 06:33:17 +00:00
dm-raid1.c block: rename generic_make_request to submit_bio_noacct 2020-07-01 07:27:24 -06:00
dm-region-hash.c
dm-round-robin.c
dm-rq.c Revert "dm: requeue IO if mapping table not yet available" 2024-12-12 02:36:39 +00:00
dm-rq.h
dm-service-time.c dm mpath: pass IO start time to path selector 2020-05-15 10:29:36 -04:00
dm-snap-persistent.c dm snap persistent: simplify area_io() 2020-09-29 16:33:12 -04:00
dm-snap-transient.c
dm-snap.c dm snapshot: fix lockup in dm_exception_table_exit 2024-07-22 06:33:17 +00:00
dm-stats.c dm stats: check for and propagate alloc_percpu failure 2023-09-06 07:56:48 +00:00
dm-stats.h dm stats: check for and propagate alloc_percpu failure 2023-09-06 07:56:48 +00:00
dm-stripe.c dm: add support for DM_TARGET_NOWAIT for various targets 2022-08-01 11:01:45 +00:00
dm-switch.c dm: add support for DM_TARGET_NOWAIT for various targets 2022-08-01 11:01:45 +00:00
dm-sysfs.c
dm-table.c dm: limit the number of targets and parameter size area 2024-07-22 06:33:17 +00:00
dm-target.c
dm-thin-metadata.c dm thin: Use last transaction's pmd->root when commit failed 2023-09-06 07:56:48 +00:00
dm-thin-metadata.h
dm-thin.c dm thin: make get_first_thin use rcu-safe list first function 2025-03-03 06:13:28 +00:00
dm-uevent.c
dm-uevent.h
dm-unstripe.c dm: add support for DM_TARGET_NOWAIT for various targets 2022-08-01 11:01:45 +00:00
dm-verity-fec.c dm-verity: align struct dm_verity_fec_io properly 2024-01-15 01:36:30 +00:00
dm-verity-fec.h dm verity fec: fix misaligned RS roots IO 2021-04-21 13:00:54 +02:00
dm-verity-target.c dm verity: fix error handling for check_at_most_once on FEC 2024-08-02 06:20:48 +00:00
dm-verity-verify-sig.c dm verity: fix require_signatures module_param permissions 2021-06-16 12:01:37 +02:00
dm-verity-verify-sig.h dm verity: Fix compilation warning 2020-08-04 15:48:13 -04:00
dm-verity.h dm-verity, dm-crypt: align "struct bvec_iter" correctly 2024-07-22 06:33:17 +00:00
dm-writecache.c dm writecache: set a default MAX_WRITEBACK_JOBS 2023-09-06 07:56:48 +00:00
dm-zero.c dm: add support for DM_TARGET_NOWAIT for various targets 2022-08-01 11:01:45 +00:00
dm-zoned-metadata.c dm zoned: check zone capacity 2021-07-19 09:45:01 +02:00
dm-zoned-reclaim.c dm zoned: Fix zone reclaim trigger 2020-07-08 12:21:53 -04:00
dm-zoned-target.c dm zoned: free dmz->ddev array in dmz_put_zoned_devices 2024-01-15 01:36:30 +00:00
dm-zoned.h dm zoned: select reclaim zone based on device index 2020-06-05 14:59:53 -04:00
dm.c Revert "dm: requeue IO if mapping table not yet available" 2024-12-12 02:36:39 +00:00
dm.h dm table: fix DAX iterate_devices based device capability checks 2021-03-04 11:38:44 +01:00
md-autodetect.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
md-bitmap.c md: fix resync softlockup when bitmap size is less than array size 2024-08-02 06:20:48 +00:00
md-bitmap.h
md-cluster.c md/cluster: fix deadlock when node is doing resync job 2020-12-30 11:54:25 +01:00
md-cluster.h
md-faulty.c block: rename generic_make_request to submit_bio_noacct 2020-07-01 07:27:24 -06:00
md-linear.c block: add a new revalidate_disk_size helper 2020-09-02 08:00:07 -06:00
md-linear.h md/raid1: Replace zero-length array with flexible-array 2020-05-13 12:02:23 -07:00
md-multipath.c writeback: remove bdi->congested_fn 2020-07-08 17:20:46 -06:00
md-multipath.h
md.c md: clean up invalid BUG_ON in md_ioctl 2024-12-12 02:36:39 +00:00
md.h md: revert io stats accounting 2022-01-16 09:14:21 +01:00
raid0.c md/raid0: add discard support for the 'original' layout 2024-08-02 06:20:48 +00:00
raid0.h md/raid0: add discard support for the 'original' layout 2024-08-02 06:20:48 +00:00
raid1-10.c
raid1.c md/raid1: stop mdx_raid1 thread when raid1 array run failed 2024-08-02 06:20:48 +00:00
raid1.h md/raid1: Replace zero-length array with flexible-array 2020-05-13 12:02:23 -07:00
raid5-cache.c raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show 2020-08-02 23:03:52 -07:00
raid5-log.h
raid5-ppl.c md/raid456: convert macro STRIPE_* to RAID5_STRIPE_* 2020-07-21 17:18:12 -07:00
raid5.c md/raid5: avoid BUG_ON() while continue reshape after reassembling 2025-03-19 08:04:16 +00:00
raid5.h md/raid5: let multiple devices of stripe_head share page 2020-09-24 16:44:44 -07:00
raid10.c md/raid10: prevent soft lockup while flush writes 2024-07-22 09:23:01 +00:00
raid10.h Revert "md/raid10: improve discard request for far layout" 2020-12-09 20:46:00 -08:00