Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-6.11/block-20240722' of git://git.kernel.dk/linux

Pull more block updates from Jens Axboe:

- MD fixes via Song:
- md-cluster fixes (Heming Zhao)
- raid1 fix (Mateusz Jończyk)

- s390/dasd module description (Jeff)

- Series cleaning up and hardening the blk-mq debugfs flag handling
(John, Christoph)

- blk-cgroup cleanup (Xiu)

- Error polled IO attempts if backend doesn't support it (hexue)

- Fix for an sbitmap hang (Yang)

* tag 'for-6.11/block-20240722' of git://git.kernel.dk/linux: (23 commits)
blk-cgroup: move congestion_count to struct blkcg
sbitmap: fix io hung due to race on sbitmap_word::cleared
block: avoid polling configuration errors
block: Catch possible entries missing from rqf_name[]
block: Simplify definition of RQF_NAME()
block: Use enum to define RQF_x bit indexes
block: Catch possible entries missing from cmd_flag_name[]
block: Catch possible entries missing from alloc_policy_name[]
block: Catch possible entries missing from hctx_flag_name[]
block: Catch possible entries missing from hctx_state_name[]
block: Catch possible entries missing from blk_queue_flag_name[]
block: Make QUEUE_FLAG_x as an enum
block: Relocate BLK_MQ_MAX_DEPTH
block: Relocate BLK_MQ_CPU_WORK_BATCH
block: remove QUEUE_FLAG_STOPPED
block: Add missing entry to hctx_flag_name[]
block: Add zone write plugging entry to rqf_name[]
block: Add missing entries from cmd_flag_name[]
s390/dasd: fix error checks in dasd_copy_pair_store()
s390/dasd: add missing MODULE_DESCRIPTION() macros
...

+233 -102
+4 -3
block/blk-cgroup.c
··· 2182 2182 2183 2183 bool blk_cgroup_congested(void) 2184 2184 { 2185 - struct cgroup_subsys_state *css; 2185 + struct blkcg *blkcg; 2186 2186 bool ret = false; 2187 2187 2188 2188 rcu_read_lock(); 2189 - for (css = blkcg_css(); css; css = css->parent) { 2190 - if (atomic_read(&css->cgroup->congestion_count)) { 2189 + for (blkcg = css_to_blkcg(blkcg_css()); blkcg; 2190 + blkcg = blkcg_parent(blkcg)) { 2191 + if (atomic_read(&blkcg->congestion_count)) { 2191 2192 ret = true; 2192 2193 break; 2193 2194 }
+6 -4
block/blk-cgroup.h
··· 95 95 struct cgroup_subsys_state css; 96 96 spinlock_t lock; 97 97 refcount_t online_pin; 98 + /* If there is block congestion on this cgroup. */ 99 + atomic_t congestion_count; 98 100 99 101 struct radix_tree_root blkg_tree; 100 102 struct blkcg_gq __rcu *blkg_hint; ··· 376 374 if (WARN_ON_ONCE(atomic_read(&blkg->use_delay) < 0)) 377 375 return; 378 376 if (atomic_add_return(1, &blkg->use_delay) == 1) 379 - atomic_inc(&blkg->blkcg->css.cgroup->congestion_count); 377 + atomic_inc(&blkg->blkcg->congestion_count); 380 378 } 381 379 382 380 static inline int blkcg_unuse_delay(struct blkcg_gq *blkg) ··· 401 399 if (old == 0) 402 400 return 0; 403 401 if (old == 1) 404 - atomic_dec(&blkg->blkcg->css.cgroup->congestion_count); 402 + atomic_dec(&blkg->blkcg->congestion_count); 405 403 return 1; 406 404 } 407 405 ··· 420 418 421 419 /* We only want 1 person setting the congestion count for this blkg. */ 422 420 if (!old && atomic_try_cmpxchg(&blkg->use_delay, &old, -1)) 423 - atomic_inc(&blkg->blkcg->css.cgroup->congestion_count); 421 + atomic_inc(&blkg->blkcg->congestion_count); 424 422 425 423 atomic64_set(&blkg->delay_nsec, delay); 426 424 } ··· 437 435 438 436 /* We only want 1 person clearing the congestion count for this blkg. */ 439 437 if (old && atomic_try_cmpxchg(&blkg->use_delay, &old, 0)) 440 - atomic_dec(&blkg->blkcg->css.cgroup->congestion_count); 438 + atomic_dec(&blkg->blkcg->congestion_count); 441 439 } 442 440 443 441 /**
+4 -1
block/blk-core.c
··· 791 791 } 792 792 } 793 793 794 - if (!(q->limits.features & BLK_FEAT_POLL)) 794 + if (!(q->limits.features & BLK_FEAT_POLL) && 795 + (bio->bi_opf & REQ_POLLED)) { 795 796 bio_clear_polled(bio); 797 + goto not_supported; 798 + } 796 799 797 800 switch (bio_op(bio)) { 798 801 case REQ_OP_READ:
+21 -5
block/blk-mq-debugfs.c
··· 5 5 6 6 #include <linux/kernel.h> 7 7 #include <linux/blkdev.h> 8 + #include <linux/build_bug.h> 8 9 #include <linux/debugfs.h> 9 10 10 11 #include "blk.h" ··· 80 79 81 80 #define QUEUE_FLAG_NAME(name) [QUEUE_FLAG_##name] = #name 82 81 static const char *const blk_queue_flag_name[] = { 83 - QUEUE_FLAG_NAME(STOPPED), 84 82 QUEUE_FLAG_NAME(DYING), 85 83 QUEUE_FLAG_NAME(NOMERGES), 86 84 QUEUE_FLAG_NAME(SAME_COMP), ··· 100 100 { 101 101 struct request_queue *q = data; 102 102 103 + BUILD_BUG_ON(ARRAY_SIZE(blk_queue_flag_name) != QUEUE_FLAG_MAX); 103 104 blk_flags_show(m, q->queue_flags, blk_queue_flag_name, 104 105 ARRAY_SIZE(blk_queue_flag_name)); 105 106 seq_puts(m, "\n"); ··· 165 164 { 166 165 struct blk_mq_hw_ctx *hctx = data; 167 166 167 + BUILD_BUG_ON(ARRAY_SIZE(hctx_state_name) != BLK_MQ_S_MAX); 168 168 blk_flags_show(m, hctx->state, hctx_state_name, 169 169 ARRAY_SIZE(hctx_state_name)); 170 170 seq_puts(m, "\n"); ··· 183 181 static const char *const hctx_flag_name[] = { 184 182 HCTX_FLAG_NAME(SHOULD_MERGE), 185 183 HCTX_FLAG_NAME(TAG_QUEUE_SHARED), 186 - HCTX_FLAG_NAME(BLOCKING), 187 - HCTX_FLAG_NAME(NO_SCHED), 188 184 HCTX_FLAG_NAME(STACKING), 189 185 HCTX_FLAG_NAME(TAG_HCTX_SHARED), 186 + HCTX_FLAG_NAME(BLOCKING), 187 + HCTX_FLAG_NAME(NO_SCHED), 188 + HCTX_FLAG_NAME(NO_SCHED_BY_DEFAULT), 190 189 }; 191 190 #undef HCTX_FLAG_NAME 192 191 ··· 195 192 { 196 193 struct blk_mq_hw_ctx *hctx = data; 197 194 const int alloc_policy = BLK_MQ_FLAG_TO_ALLOC_POLICY(hctx->flags); 195 + 196 + BUILD_BUG_ON(ARRAY_SIZE(hctx_flag_name) != 197 + BLK_MQ_F_ALLOC_POLICY_START_BIT); 198 + BUILD_BUG_ON(ARRAY_SIZE(alloc_policy_name) != BLK_TAG_ALLOC_MAX); 198 199 199 200 seq_puts(m, "alloc_policy="); 200 201 if (alloc_policy < ARRAY_SIZE(alloc_policy_name) && ··· 230 223 CMD_FLAG_NAME(RAHEAD), 231 224 CMD_FLAG_NAME(BACKGROUND), 232 225 CMD_FLAG_NAME(NOWAIT), 233 - CMD_FLAG_NAME(NOUNMAP), 234 226 CMD_FLAG_NAME(POLLED), 227 + CMD_FLAG_NAME(ALLOC_CACHE), 228 + CMD_FLAG_NAME(SWAP), 229 + CMD_FLAG_NAME(DRV), 230 + CMD_FLAG_NAME(FS_PRIVATE), 231 + CMD_FLAG_NAME(ATOMIC), 232 + CMD_FLAG_NAME(NOUNMAP), 235 233 }; 236 234 #undef CMD_FLAG_NAME 237 235 238 - #define RQF_NAME(name) [ilog2((__force u32)RQF_##name)] = #name 236 + #define RQF_NAME(name) [__RQF_##name] = #name 239 237 static const char *const rqf_name[] = { 240 238 RQF_NAME(STARTED), 241 239 RQF_NAME(FLUSH_SEQ), ··· 255 243 RQF_NAME(HASHED), 256 244 RQF_NAME(STATS), 257 245 RQF_NAME(SPECIAL_PAYLOAD), 246 + RQF_NAME(ZONE_WRITE_PLUGGING), 258 247 RQF_NAME(TIMED_OUT), 259 248 RQF_NAME(RESV), 260 249 }; ··· 280 267 const struct blk_mq_ops *const mq_ops = rq->q->mq_ops; 281 268 const enum req_op op = req_op(rq); 282 269 const char *op_str = blk_op_str(op); 270 + 271 + BUILD_BUG_ON(ARRAY_SIZE(cmd_flag_name) != __REQ_NR_BITS); 272 + BUILD_BUG_ON(ARRAY_SIZE(rqf_name) != __RQF_BITS); 283 273 284 274 seq_printf(m, "%p {.op=", rq); 285 275 if (strcmp(op_str, "UNKNOWN") == 0)
+2
block/blk-mq.h
··· 36 36 BLK_MQ_TAG_MAX = BLK_MQ_NO_TAG - 1, 37 37 }; 38 38 39 + #define BLK_MQ_CPU_WORK_BATCH (8) 40 + 39 41 typedef unsigned int __bitwise blk_insert_t; 40 42 #define BLK_MQ_INSERT_AT_HEAD ((__force blk_insert_t)0x01) 41 43
+39 -10
drivers/md/md-cluster.c
··· 15 15 16 16 #define LVB_SIZE 64 17 17 #define NEW_DEV_TIMEOUT 5000 18 + #define WAIT_DLM_LOCK_TIMEOUT (30 * HZ) 18 19 19 20 struct dlm_lock_resource { 20 21 dlm_lockspace_t *ls; ··· 57 56 #define MD_CLUSTER_ALREADY_IN_CLUSTER 6 58 57 #define MD_CLUSTER_PENDING_RECV_EVENT 7 59 58 #define MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD 8 59 + #define MD_CLUSTER_WAITING_FOR_SYNC 9 60 60 61 61 struct md_cluster_info { 62 62 struct mddev *mddev; /* the md device which md_cluster_info belongs to */ ··· 93 91 sector_t sync_hi; 94 92 }; 95 93 94 + /* For compatibility, add the new msg_type at the end. */ 96 95 enum msg_type { 97 96 METADATA_UPDATED = 0, 98 97 RESYNCING, ··· 103 100 BITMAP_NEEDS_SYNC, 104 101 CHANGE_CAPACITY, 105 102 BITMAP_RESIZE, 103 + RESYNCING_START, 106 104 }; 107 105 108 106 struct cluster_msg { ··· 134 130 0, sync_ast, res, res->bast); 135 131 if (ret) 136 132 return ret; 137 - wait_event(res->sync_locking, res->sync_locking_done); 133 + ret = wait_event_timeout(res->sync_locking, res->sync_locking_done, 134 + WAIT_DLM_LOCK_TIMEOUT); 138 135 res->sync_locking_done = false; 136 + if (!ret) { 137 + pr_err("locking DLM '%s' timeout!\n", res->name); 138 + return -EBUSY; 139 + } 139 140 if (res->lksb.sb_status == 0) 140 141 res->mode = mode; 141 142 return res->lksb.sb_status; ··· 464 455 clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery); 465 456 remove_suspend_info(mddev, slot); 466 457 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 458 + clear_bit(MD_CLUSTER_WAITING_FOR_SYNC, &cinfo->state); 467 459 md_wakeup_thread(mddev->thread); 468 460 return; 469 461 } ··· 535 525 res = -1; 536 526 } 537 527 clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); 528 + set_bit(MD_CLUSTER_WAITING_FOR_SYNC, &cinfo->state); 538 529 return res; 539 530 } 540 531 ··· 603 592 break; 604 593 case CHANGE_CAPACITY: 605 594 set_capacity_and_notify(mddev->gendisk, mddev->array_sectors); 595 + break; 596 + case RESYNCING_START: 597 + clear_bit(MD_CLUSTER_WAITING_FOR_SYNC, &mddev->cluster_info->state); 606 598 break; 607 599 case RESYNCING: 608 600 set_bit(MD_RESYNCING_REMOTE, &mddev->recovery); ··· 757 743 */ 758 744 static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) 759 745 { 760 - int error; 746 + int error, unlock_error; 761 747 int slot = cinfo->slot_number - 1; 762 748 763 749 cmsg->slot = cpu_to_le32(slot); ··· 765 751 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX); 766 752 if (error) { 767 753 pr_err("md-cluster: failed to get EX on MESSAGE (%d)\n", error); 768 - goto failed_message; 754 + return error; 769 755 } 770 756 771 757 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg, ··· 795 781 } 796 782 797 783 failed_ack: 798 - error = dlm_unlock_sync(cinfo->message_lockres); 799 - if (unlikely(error != 0)) { 784 + while ((unlock_error = dlm_unlock_sync(cinfo->message_lockres))) 800 785 pr_err("md-cluster: failed convert to NL on MESSAGE(%d)\n", 801 - error); 802 - /* in case the message can't be released due to some reason */ 803 - goto failed_ack; 804 - } 805 - failed_message: 786 + unlock_error); 787 + 806 788 return error; 807 789 } 808 790 ··· 1353 1343 spin_unlock_irq(&cinfo->suspend_lock); 1354 1344 } 1355 1345 1346 + static int resync_status_get(struct mddev *mddev) 1347 + { 1348 + struct md_cluster_info *cinfo = mddev->cluster_info; 1349 + 1350 + return test_bit(MD_CLUSTER_WAITING_FOR_SYNC, &cinfo->state); 1351 + } 1352 + 1353 + static int resync_start_notify(struct mddev *mddev) 1354 + { 1355 + struct md_cluster_info *cinfo = mddev->cluster_info; 1356 + struct cluster_msg cmsg = {0}; 1357 + 1358 + cmsg.type = cpu_to_le32(RESYNCING_START); 1359 + 1360 + return sendmsg(cinfo, &cmsg, 0); 1361 + } 1362 + 1356 1363 static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi) 1357 1364 { 1358 1365 struct md_cluster_info *cinfo = mddev->cluster_info; ··· 1604 1577 .resync_start = resync_start, 1605 1578 .resync_finish = resync_finish, 1606 1579 .resync_info_update = resync_info_update, 1580 + .resync_start_notify = resync_start_notify, 1581 + .resync_status_get = resync_status_get, 1607 1582 .resync_info_get = resync_info_get, 1608 1583 .metadata_update_start = metadata_update_start, 1609 1584 .metadata_update_finish = metadata_update_finish,
+2
drivers/md/md-cluster.h
··· 14 14 int (*leave)(struct mddev *mddev); 15 15 int (*slot_number)(struct mddev *mddev); 16 16 int (*resync_info_update)(struct mddev *mddev, sector_t lo, sector_t hi); 17 + int (*resync_start_notify)(struct mddev *mddev); 18 + int (*resync_status_get)(struct mddev *mddev); 17 19 void (*resync_info_get)(struct mddev *mddev, sector_t *lo, sector_t *hi); 18 20 int (*metadata_update_start)(struct mddev *mddev); 19 21 int (*metadata_update_finish)(struct mddev *mddev);
+14 -3
drivers/md/md.c
··· 8978 8978 * This will mean we have to start checking from the beginning again. 8979 8979 * 8980 8980 */ 8981 - 8981 + if (mddev_is_clustered(mddev)) 8982 + md_cluster_ops->resync_start_notify(mddev); 8982 8983 do { 8983 8984 int mddev2_minor = -1; 8984 8985 mddev->curr_resync = MD_RESYNC_DELAYED; ··· 9993 9992 */ 9994 9993 if (rdev2->raid_disk == -1 && role != MD_DISK_ROLE_SPARE && 9995 9994 !(le32_to_cpu(sb->feature_map) & 9996 - MD_FEATURE_RESHAPE_ACTIVE)) { 9997 - rdev2->saved_raid_disk = role; 9995 + MD_FEATURE_RESHAPE_ACTIVE) && 9996 + !md_cluster_ops->resync_status_get(mddev)) { 9997 + /* 9998 + * -1 to make raid1_add_disk() set conf->fullsync 9999 + * to 1. This could avoid skipping sync when the 10000 + * remote node is down during resyncing. 10001 + */ 10002 + if ((le32_to_cpu(sb->feature_map) 10003 + & MD_FEATURE_RECOVERY_OFFSET)) 10004 + rdev2->saved_raid_disk = -1; 10005 + else 10006 + rdev2->saved_raid_disk = role; 9998 10007 ret = remove_and_add_spares(mddev, rdev2); 9999 10008 pr_info("Activated spare: %pg\n", 10000 10009 rdev2->bdev);
+1
drivers/md/raid1.c
··· 680 680 len = r1_bio->sectors; 681 681 read_len = raid1_check_read_range(rdev, this_sector, &len); 682 682 if (read_len == r1_bio->sectors) { 683 + *max_sectors = read_len; 683 684 update_read_sectors(conf, disk, this_sector, read_len); 684 685 return disk; 685 686 }
+8 -2
drivers/s390/block/dasd_devmap.c
··· 2248 2248 2249 2249 /* allocate primary devmap if needed */ 2250 2250 prim_devmap = dasd_find_busid(prim_busid); 2251 - if (IS_ERR(prim_devmap)) 2251 + if (IS_ERR(prim_devmap)) { 2252 2252 prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT); 2253 + if (IS_ERR(prim_devmap)) 2254 + return PTR_ERR(prim_devmap); 2255 + } 2253 2256 2254 2257 /* allocate secondary devmap if needed */ 2255 2258 sec_devmap = dasd_find_busid(sec_busid); 2256 - if (IS_ERR(sec_devmap)) 2259 + if (IS_ERR(sec_devmap)) { 2257 2260 sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT); 2261 + if (IS_ERR(sec_devmap)) 2262 + return PTR_ERR(sec_devmap); 2263 + } 2258 2264 2259 2265 /* setting copy relation is only allowed for offline secondary */ 2260 2266 if (sec_devmap->device)
+1
drivers/s390/block/dasd_diag.c
··· 29 29 #include "dasd_int.h" 30 30 #include "dasd_diag.h" 31 31 32 + MODULE_DESCRIPTION("S/390 Support for DIAG access to DASD Disks"); 32 33 MODULE_LICENSE("GPL"); 33 34 34 35 /* The maximum number of blocks per request (max_blocks) is dependent on the
+1
drivers/s390/block/dasd_eckd.c
··· 44 44 /* 64k are 128 x 512 byte sectors */ 45 45 #define DASD_RAW_SECTORS_PER_TRACK 128 46 46 47 + MODULE_DESCRIPTION("S/390 DASD ECKD Disks device driver"); 47 48 MODULE_LICENSE("GPL"); 48 49 49 50 static struct dasd_discipline dasd_eckd_discipline;
+1
drivers/s390/block/dasd_fba.c
··· 32 32 #define DASD_FBA_CCW_LOCATE 0x43 33 33 #define DASD_FBA_CCW_DEFINE_EXTENT 0x63 34 34 35 + MODULE_DESCRIPTION("S/390 DASD FBA Disks device driver"); 35 36 MODULE_LICENSE("GPL"); 36 37 37 38 static struct dasd_discipline dasd_fba_discipline;
+78 -49
include/linux/blk-mq.h
··· 27 27 * request flags */ 28 28 typedef __u32 __bitwise req_flags_t; 29 29 30 - /* drive already may have started this one */ 31 - #define RQF_STARTED ((__force req_flags_t)(1 << 1)) 32 - /* request for flush sequence */ 33 - #define RQF_FLUSH_SEQ ((__force req_flags_t)(1 << 4)) 34 - /* merge of different types, fail separately */ 35 - #define RQF_MIXED_MERGE ((__force req_flags_t)(1 << 5)) 36 - /* don't call prep for this one */ 37 - #define RQF_DONTPREP ((__force req_flags_t)(1 << 7)) 38 - /* use hctx->sched_tags */ 39 - #define RQF_SCHED_TAGS ((__force req_flags_t)(1 << 8)) 40 - /* use an I/O scheduler for this request */ 41 - #define RQF_USE_SCHED ((__force req_flags_t)(1 << 9)) 42 - /* vaguely specified driver internal error. Ignored by the block layer */ 43 - #define RQF_FAILED ((__force req_flags_t)(1 << 10)) 44 - /* don't warn about errors */ 45 - #define RQF_QUIET ((__force req_flags_t)(1 << 11)) 46 - /* account into disk and partition IO statistics */ 47 - #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) 48 - /* runtime pm request */ 49 - #define RQF_PM ((__force req_flags_t)(1 << 15)) 50 - /* on IO scheduler merge hash */ 51 - #define RQF_HASHED ((__force req_flags_t)(1 << 16)) 52 - /* track IO completion time */ 53 - #define RQF_STATS ((__force req_flags_t)(1 << 17)) 54 - /* Look at ->special_vec for the actual data payload instead of the 55 - bio chain. */ 56 - #define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18)) 57 - /* The request completion needs to be signaled to zone write pluging. */ 58 - #define RQF_ZONE_WRITE_PLUGGING ((__force req_flags_t)(1 << 20)) 59 - /* ->timeout has been called, don't expire again */ 60 - #define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21)) 61 - #define RQF_RESV ((__force req_flags_t)(1 << 23)) 30 + /* Keep rqf_name[] in sync with the definitions below */ 31 + enum { 32 + /* drive already may have started this one */ 33 + __RQF_STARTED, 34 + /* request for flush sequence */ 35 + __RQF_FLUSH_SEQ, 36 + /* merge of different types, fail separately */ 37 + __RQF_MIXED_MERGE, 38 + /* don't call prep for this one */ 39 + __RQF_DONTPREP, 40 + /* use hctx->sched_tags */ 41 + __RQF_SCHED_TAGS, 42 + /* use an I/O scheduler for this request */ 43 + __RQF_USE_SCHED, 44 + /* vaguely specified driver internal error. Ignored by block layer */ 45 + __RQF_FAILED, 46 + /* don't warn about errors */ 47 + __RQF_QUIET, 48 + /* account into disk and partition IO statistics */ 49 + __RQF_IO_STAT, 50 + /* runtime pm request */ 51 + __RQF_PM, 52 + /* on IO scheduler merge hash */ 53 + __RQF_HASHED, 54 + /* track IO completion time */ 55 + __RQF_STATS, 56 + /* Look at ->special_vec for the actual data payload instead of the 57 + bio chain. */ 58 + __RQF_SPECIAL_PAYLOAD, 59 + /* request completion needs to be signaled to zone write plugging. */ 60 + __RQF_ZONE_WRITE_PLUGGING, 61 + /* ->timeout has been called, don't expire again */ 62 + __RQF_TIMED_OUT, 63 + __RQF_RESV, 64 + __RQF_BITS 65 + }; 66 + 67 + #define RQF_STARTED ((__force req_flags_t)(1 << __RQF_STARTED)) 68 + #define RQF_FLUSH_SEQ ((__force req_flags_t)(1 << __RQF_FLUSH_SEQ)) 69 + #define RQF_MIXED_MERGE ((__force req_flags_t)(1 << __RQF_MIXED_MERGE)) 70 + #define RQF_DONTPREP ((__force req_flags_t)(1 << __RQF_DONTPREP)) 71 + #define RQF_SCHED_TAGS ((__force req_flags_t)(1 << __RQF_SCHED_TAGS)) 72 + #define RQF_USE_SCHED ((__force req_flags_t)(1 << __RQF_USE_SCHED)) 73 + #define RQF_FAILED ((__force req_flags_t)(1 << __RQF_FAILED)) 74 + #define RQF_QUIET ((__force req_flags_t)(1 << __RQF_QUIET)) 75 + #define RQF_IO_STAT ((__force req_flags_t)(1 << __RQF_IO_STAT)) 76 + #define RQF_PM ((__force req_flags_t)(1 << __RQF_PM)) 77 + #define RQF_HASHED ((__force req_flags_t)(1 << __RQF_HASHED)) 78 + #define RQF_STATS ((__force req_flags_t)(1 << __RQF_STATS)) 79 + #define RQF_SPECIAL_PAYLOAD \ 80 + ((__force req_flags_t)(1 << __RQF_SPECIAL_PAYLOAD)) 81 + #define RQF_ZONE_WRITE_PLUGGING \ 82 + ((__force req_flags_t)(1 << __RQF_ZONE_WRITE_PLUGGING)) 83 + #define RQF_TIMED_OUT ((__force req_flags_t)(1 << __RQF_TIMED_OUT)) 84 + #define RQF_RESV ((__force req_flags_t)(1 << __RQF_RESV)) 62 85 63 86 /* flags that prevent us from merging requests: */ 64 87 #define RQF_NOMERGE_FLAGS \ ··· 301 278 BLK_EH_RESET_TIMER, 302 279 }; 303 280 304 - #define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */ 305 - #define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */ 281 + /* Keep alloc_policy_name[] in sync with the definitions below */ 282 + enum { 283 + BLK_TAG_ALLOC_FIFO, /* allocate starting from 0 */ 284 + BLK_TAG_ALLOC_RR, /* allocate starting from last allocated tag */ 285 + BLK_TAG_ALLOC_MAX 286 + }; 306 287 307 288 /** 308 289 * struct blk_mq_hw_ctx - State for a hardware queue facing the hardware ··· 671 644 #endif 672 645 }; 673 646 647 + /* Keep hctx_flag_name[] in sync with the definitions below */ 674 648 enum { 675 649 BLK_MQ_F_SHOULD_MERGE = 1 << 0, 676 650 BLK_MQ_F_TAG_QUEUE_SHARED = 1 << 1, ··· 681 653 */ 682 654 BLK_MQ_F_STACKING = 1 << 2, 683 655 BLK_MQ_F_TAG_HCTX_SHARED = 1 << 3, 684 - BLK_MQ_F_BLOCKING = 1 << 5, 656 + BLK_MQ_F_BLOCKING = 1 << 4, 685 657 /* Do not allow an I/O scheduler to be configured. */ 686 - BLK_MQ_F_NO_SCHED = 1 << 6, 658 + BLK_MQ_F_NO_SCHED = 1 << 5, 659 + 687 660 /* 688 661 * Select 'none' during queue registration in case of a single hwq 689 662 * or shared hwqs instead of 'mq-deadline'. 690 663 */ 691 - BLK_MQ_F_NO_SCHED_BY_DEFAULT = 1 << 7, 692 - BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, 664 + BLK_MQ_F_NO_SCHED_BY_DEFAULT = 1 << 6, 665 + BLK_MQ_F_ALLOC_POLICY_START_BIT = 7, 693 666 BLK_MQ_F_ALLOC_POLICY_BITS = 1, 694 - 695 - BLK_MQ_S_STOPPED = 0, 696 - BLK_MQ_S_TAG_ACTIVE = 1, 697 - BLK_MQ_S_SCHED_RESTART = 2, 698 - 699 - /* hw queue is inactive after all its CPUs become offline */ 700 - BLK_MQ_S_INACTIVE = 3, 701 - 702 - BLK_MQ_MAX_DEPTH = 10240, 703 - 704 - BLK_MQ_CPU_WORK_BATCH = 8, 705 667 }; 706 668 #define BLK_MQ_FLAG_TO_ALLOC_POLICY(flags) \ 707 669 ((flags >> BLK_MQ_F_ALLOC_POLICY_START_BIT) & \ ··· 700 682 ((policy & ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) \ 701 683 << BLK_MQ_F_ALLOC_POLICY_START_BIT) 702 684 685 + #define BLK_MQ_MAX_DEPTH (10240) 703 686 #define BLK_MQ_NO_HCTX_IDX (-1U) 687 + 688 + enum { 689 + /* Keep hctx_state_name[] in sync with the definitions below */ 690 + BLK_MQ_S_STOPPED, 691 + BLK_MQ_S_TAG_ACTIVE, 692 + BLK_MQ_S_SCHED_RESTART, 693 + /* hw queue is inactive after all its CPUs become offline */ 694 + BLK_MQ_S_INACTIVE, 695 + BLK_MQ_S_MAX 696 + }; 704 697 705 698 struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, 706 699 struct queue_limits *lim, void *queuedata,
+1
include/linux/blk_types.h
··· 354 354 REQ_OP_LAST = (__force blk_opf_t)36, 355 355 }; 356 356 357 + /* Keep cmd_flag_name[] in sync with the definitions below */ 357 358 enum req_flag_bits { 358 359 __REQ_FAILFAST_DEV = /* no driver retries of device errors */ 359 360 REQ_OP_BITS,
+16 -15
include/linux/blkdev.h
··· 588 588 }; 589 589 590 590 /* Keep blk_queue_flag_name[] in sync with the definitions below */ 591 - #define QUEUE_FLAG_STOPPED 0 /* queue is stopped */ 592 - #define QUEUE_FLAG_DYING 1 /* queue being torn down */ 593 - #define QUEUE_FLAG_NOMERGES 3 /* disable merge attempts */ 594 - #define QUEUE_FLAG_SAME_COMP 4 /* complete on same CPU-group */ 595 - #define QUEUE_FLAG_FAIL_IO 5 /* fake timeout */ 596 - #define QUEUE_FLAG_NOXMERGES 9 /* No extended merges */ 597 - #define QUEUE_FLAG_SAME_FORCE 12 /* force complete on same CPU */ 598 - #define QUEUE_FLAG_INIT_DONE 14 /* queue is initialized */ 599 - #define QUEUE_FLAG_STATS 20 /* track IO start and completion times */ 600 - #define QUEUE_FLAG_REGISTERED 22 /* queue has been registered to a disk */ 601 - #define QUEUE_FLAG_QUIESCED 24 /* queue has been quiesced */ 602 - #define QUEUE_FLAG_RQ_ALLOC_TIME 27 /* record rq->alloc_time_ns */ 603 - #define QUEUE_FLAG_HCTX_ACTIVE 28 /* at least one blk-mq hctx is active */ 604 - #define QUEUE_FLAG_SQ_SCHED 30 /* single queue style io dispatch */ 591 + enum { 592 + QUEUE_FLAG_DYING, /* queue being torn down */ 593 + QUEUE_FLAG_NOMERGES, /* disable merge attempts */ 594 + QUEUE_FLAG_SAME_COMP, /* complete on same CPU-group */ 595 + QUEUE_FLAG_FAIL_IO, /* fake timeout */ 596 + QUEUE_FLAG_NOXMERGES, /* No extended merges */ 597 + QUEUE_FLAG_SAME_FORCE, /* force complete on same CPU */ 598 + QUEUE_FLAG_INIT_DONE, /* queue is initialized */ 599 + QUEUE_FLAG_STATS, /* track IO start and completion times */ 600 + QUEUE_FLAG_REGISTERED, /* queue has been registered to a disk */ 601 + QUEUE_FLAG_QUIESCED, /* queue has been quiesced */ 602 + QUEUE_FLAG_RQ_ALLOC_TIME, /* record rq->alloc_time_ns */ 603 + QUEUE_FLAG_HCTX_ACTIVE, /* at least one blk-mq hctx is active */ 604 + QUEUE_FLAG_SQ_SCHED, /* single queue style io dispatch */ 605 + QUEUE_FLAG_MAX 606 + }; 605 607 606 608 #define QUEUE_FLAG_MQ_DEFAULT (1UL << QUEUE_FLAG_SAME_COMP) 607 609 608 610 void blk_queue_flag_set(unsigned int flag, struct request_queue *q); 609 611 void blk_queue_flag_clear(unsigned int flag, struct request_queue *q); 610 612 611 - #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 612 613 #define blk_queue_dying(q) test_bit(QUEUE_FLAG_DYING, &(q)->queue_flags) 613 614 #define blk_queue_init_done(q) test_bit(QUEUE_FLAG_INIT_DONE, &(q)->queue_flags) 614 615 #define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
-3
include/linux/cgroup-defs.h
··· 539 539 /* used to store eBPF programs */ 540 540 struct cgroup_bpf bpf; 541 541 542 - /* If there is block congestion on this cgroup. */ 543 - atomic_t congestion_count; 544 - 545 542 /* Used to store internal freezer state */ 546 543 struct cgroup_freezer_state freezer; 547 544
+5
include/linux/sbitmap.h
··· 36 36 * @cleared: word holding cleared bits 37 37 */ 38 38 unsigned long cleared ____cacheline_aligned_in_smp; 39 + 40 + /** 41 + * @swap_lock: serializes simultaneous updates of ->word and ->cleared 42 + */ 43 + spinlock_t swap_lock; 39 44 } ____cacheline_aligned_in_smp; 40 45 41 46 /**
+29 -7
lib/sbitmap.c
··· 60 60 /* 61 61 * See if we have deferred clears that we can batch move 62 62 */ 63 - static inline bool sbitmap_deferred_clear(struct sbitmap_word *map) 63 + static inline bool sbitmap_deferred_clear(struct sbitmap_word *map, 64 + unsigned int depth, unsigned int alloc_hint, bool wrap) 64 65 { 65 - unsigned long mask; 66 + unsigned long mask, word_mask; 66 67 67 - if (!READ_ONCE(map->cleared)) 68 - return false; 68 + guard(spinlock_irqsave)(&map->swap_lock); 69 + 70 + if (!map->cleared) { 71 + if (depth == 0) 72 + return false; 73 + 74 + word_mask = (~0UL) >> (BITS_PER_LONG - depth); 75 + /* 76 + * The current behavior is to always retry after moving 77 + * ->cleared to word, and we change it to retry in case 78 + * of any free bits. To avoid an infinite loop, we need 79 + * to take wrap & alloc_hint into account, otherwise a 80 + * soft lockup may occur. 81 + */ 82 + if (!wrap && alloc_hint) 83 + word_mask &= ~((1UL << alloc_hint) - 1); 84 + 85 + return (READ_ONCE(map->word) & word_mask) != word_mask; 86 + } 69 87 70 88 /* 71 89 * First get a stable cleared mask, setting the old mask to 0. ··· 103 85 bool alloc_hint) 104 86 { 105 87 unsigned int bits_per_word; 88 + int i; 106 89 107 90 if (shift < 0) 108 91 shift = sbitmap_calculate_shift(depth); ··· 135 116 return -ENOMEM; 136 117 } 137 118 119 + for (i = 0; i < sb->map_nr; i++) 120 + spin_lock_init(&sb->map[i].swap_lock); 121 + 138 122 return 0; 139 123 } 140 124 EXPORT_SYMBOL_GPL(sbitmap_init_node); ··· 148 126 unsigned int i; 149 127 150 128 for (i = 0; i < sb->map_nr; i++) 151 - sbitmap_deferred_clear(&sb->map[i]); 129 + sbitmap_deferred_clear(&sb->map[i], 0, 0, 0); 152 130 153 131 sb->depth = depth; 154 132 sb->map_nr = DIV_ROUND_UP(sb->depth, bits_per_word); ··· 201 179 alloc_hint, wrap); 202 180 if (nr != -1) 203 181 break; 204 - if (!sbitmap_deferred_clear(map)) 182 + if (!sbitmap_deferred_clear(map, depth, alloc_hint, wrap)) 205 183 break; 206 184 } while (1); 207 185 ··· 518 496 unsigned int map_depth = __map_depth(sb, index); 519 497 unsigned long val; 520 498 521 - sbitmap_deferred_clear(map); 499 + sbitmap_deferred_clear(map, 0, 0, 0); 522 500 val = READ_ONCE(map->word); 523 501 if (val == (1UL << (map_depth - 1)) - 1) 524 502 goto next;