* block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
@ 2025-07-03 3:33 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-07-03 3:33 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Nilay Shroff <nilay@linux.ibm.com>
CC: Jens Axboe <axboe@kernel.dk>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b4911fb0b060899e4eebca0151eb56deb86921ec
commit: 9730763f4756e32520cb86778331465e8d063a8f block: correct locking order for protecting blk-wbt parameters
date: 4 months ago
:::::: branch date: 11 hours ago
:::::: commit date: 4 months ago
config: x86_64-randconfig-161-20250703 (https://download.01.org/0day-ci/archive/20250703/202507031125.MFzlNgrz-lkp@intel.com/config)
compiler: clang version 20.1.7 (https://github.com/llvm/llvm-project 6146a88f60492b520a36f8f8f3231e15f3cc6082)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202507031125.MFzlNgrz-lkp@intel.com/
smatch warnings:
block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
vim +845 block/blk-cgroup.c
faffaab2895914 Tejun Heo 2023-04-12 767
faffaab2895914 Tejun Heo 2023-04-12 768 /**
faffaab2895914 Tejun Heo 2023-04-12 769 * blkg_conf_open_bdev - parse and open bdev for per-blkg config update
faffaab2895914 Tejun Heo 2023-04-12 770 * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
015d254cb02b6d Tejun Heo 2019-08-28 771 *
faffaab2895914 Tejun Heo 2023-04-12 772 * Parse the device node prefix part, MAJ:MIN, of per-blkg config update from
faffaab2895914 Tejun Heo 2023-04-12 773 * @ctx->input and get and store the matching bdev in @ctx->bdev. @ctx->body is
faffaab2895914 Tejun Heo 2023-04-12 774 * set to point past the device node prefix.
015d254cb02b6d Tejun Heo 2019-08-28 775 *
faffaab2895914 Tejun Heo 2023-04-12 776 * This function may be called multiple times on @ctx and the extra calls become
faffaab2895914 Tejun Heo 2023-04-12 777 * NOOPs. blkg_conf_prep() implicitly calls this function. Use this function
faffaab2895914 Tejun Heo 2023-04-12 778 * explicitly if bdev access is needed without resolving the blkcg / policy part
faffaab2895914 Tejun Heo 2023-04-12 779 * of @ctx->input. Returns -errno on error.
015d254cb02b6d Tejun Heo 2019-08-28 780 */
faffaab2895914 Tejun Heo 2023-04-12 781 int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
015d254cb02b6d Tejun Heo 2019-08-28 782 {
faffaab2895914 Tejun Heo 2023-04-12 783 char *input = ctx->input;
015d254cb02b6d Tejun Heo 2019-08-28 784 unsigned int major, minor;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 785 struct block_device *bdev;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 786 int key_len;
015d254cb02b6d Tejun Heo 2019-08-28 787
faffaab2895914 Tejun Heo 2023-04-12 788 if (ctx->bdev)
faffaab2895914 Tejun Heo 2023-04-12 789 return 0;
faffaab2895914 Tejun Heo 2023-04-12 790
015d254cb02b6d Tejun Heo 2019-08-28 791 if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
faffaab2895914 Tejun Heo 2023-04-12 792 return -EINVAL;
015d254cb02b6d Tejun Heo 2019-08-28 793
015d254cb02b6d Tejun Heo 2019-08-28 794 input += key_len;
015d254cb02b6d Tejun Heo 2019-08-28 795 if (!isspace(*input))
faffaab2895914 Tejun Heo 2023-04-12 796 return -EINVAL;
015d254cb02b6d Tejun Heo 2019-08-28 797 input = skip_spaces(input);
015d254cb02b6d Tejun Heo 2019-08-28 798
22ae8ce8b89241 Christoph Hellwig 2020-11-26 799 bdev = blkdev_get_no_open(MKDEV(major, minor));
22ae8ce8b89241 Christoph Hellwig 2020-11-26 800 if (!bdev)
faffaab2895914 Tejun Heo 2023-04-12 801 return -ENODEV;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 802 if (bdev_is_partition(bdev)) {
22ae8ce8b89241 Christoph Hellwig 2020-11-26 803 blkdev_put_no_open(bdev);
faffaab2895914 Tejun Heo 2023-04-12 804 return -ENODEV;
015d254cb02b6d Tejun Heo 2019-08-28 805 }
015d254cb02b6d Tejun Heo 2019-08-28 806
a13bd91be22318 Yu Kuai 2023-04-14 807 mutex_lock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be22318 Yu Kuai 2023-04-14 808 if (!disk_live(bdev->bd_disk)) {
a13bd91be22318 Yu Kuai 2023-04-14 809 blkdev_put_no_open(bdev);
a13bd91be22318 Yu Kuai 2023-04-14 810 mutex_unlock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be22318 Yu Kuai 2023-04-14 811 return -ENODEV;
a13bd91be22318 Yu Kuai 2023-04-14 812 }
a13bd91be22318 Yu Kuai 2023-04-14 813
faffaab2895914 Tejun Heo 2023-04-12 814 ctx->body = input;
faffaab2895914 Tejun Heo 2023-04-12 815 ctx->bdev = bdev;
faffaab2895914 Tejun Heo 2023-04-12 816 return 0;
015d254cb02b6d Tejun Heo 2019-08-28 817 }
9730763f4756e3 Nilay Shroff 2025-03-19 818 /*
9730763f4756e3 Nilay Shroff 2025-03-19 819 * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
9730763f4756e3 Nilay Shroff 2025-03-19 820 * acquires q->elevator_lock, and ensures the correct locking order
9730763f4756e3 Nilay Shroff 2025-03-19 821 * between q->elevator_lock and q->rq_qos_mutex.
9730763f4756e3 Nilay Shroff 2025-03-19 822 *
9730763f4756e3 Nilay Shroff 2025-03-19 823 * This function returns negative error on failure. On success it returns
9730763f4756e3 Nilay Shroff 2025-03-19 824 * memflags which must be saved and later passed to blkg_conf_exit_frozen
9730763f4756e3 Nilay Shroff 2025-03-19 825 * for restoring the memalloc scope.
9730763f4756e3 Nilay Shroff 2025-03-19 826 */
9730763f4756e3 Nilay Shroff 2025-03-19 827 unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
9730763f4756e3 Nilay Shroff 2025-03-19 828 {
9730763f4756e3 Nilay Shroff 2025-03-19 829 int ret;
9730763f4756e3 Nilay Shroff 2025-03-19 830 unsigned long memflags;
9730763f4756e3 Nilay Shroff 2025-03-19 831
9730763f4756e3 Nilay Shroff 2025-03-19 @832 if (ctx->bdev)
9730763f4756e3 Nilay Shroff 2025-03-19 833 return -EINVAL;
9730763f4756e3 Nilay Shroff 2025-03-19 834
9730763f4756e3 Nilay Shroff 2025-03-19 835 ret = blkg_conf_open_bdev(ctx);
9730763f4756e3 Nilay Shroff 2025-03-19 836 if (ret < 0)
9730763f4756e3 Nilay Shroff 2025-03-19 837 return ret;
9730763f4756e3 Nilay Shroff 2025-03-19 838 /*
9730763f4756e3 Nilay Shroff 2025-03-19 839 * At this point, we haven’t started protecting anything related to QoS,
9730763f4756e3 Nilay Shroff 2025-03-19 840 * so we release q->rq_qos_mutex here, which was first acquired in blkg_
9730763f4756e3 Nilay Shroff 2025-03-19 841 * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
9730763f4756e3 Nilay Shroff 2025-03-19 842 * the queue and acquiring q->elevator_lock to maintain the correct
9730763f4756e3 Nilay Shroff 2025-03-19 843 * locking order.
9730763f4756e3 Nilay Shroff 2025-03-19 844 */
9730763f4756e3 Nilay Shroff 2025-03-19 @845 mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e3 Nilay Shroff 2025-03-19 846
9730763f4756e3 Nilay Shroff 2025-03-19 847 memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
9730763f4756e3 Nilay Shroff 2025-03-19 848 mutex_lock(&ctx->bdev->bd_queue->elevator_lock);
9730763f4756e3 Nilay Shroff 2025-03-19 849 mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e3 Nilay Shroff 2025-03-19 850
9730763f4756e3 Nilay Shroff 2025-03-19 851 return memflags;
9730763f4756e3 Nilay Shroff 2025-03-19 852 }
015d254cb02b6d Tejun Heo 2019-08-28 853
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
@ 2025-10-16 19:07 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-10-16 19:07 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Nilay Shroff <nilay@linux.ibm.com>
CC: Jens Axboe <axboe@kernel.dk>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7ea30958b3054f5e488fa0b33c352723f7ab3a2a
commit: 9730763f4756e32520cb86778331465e8d063a8f block: correct locking order for protecting blk-wbt parameters
date: 7 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-161-20251016 (https://download.01.org/0day-ci/archive/20251017/202510170324.JVGAvxHk-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202510170324.JVGAvxHk-lkp@intel.com/
smatch warnings:
block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
vim +845 block/blk-cgroup.c
faffaab2895914a Tejun Heo 2023-04-12 767
faffaab2895914a Tejun Heo 2023-04-12 768 /**
faffaab2895914a Tejun Heo 2023-04-12 769 * blkg_conf_open_bdev - parse and open bdev for per-blkg config update
faffaab2895914a Tejun Heo 2023-04-12 770 * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
015d254cb02b6d8 Tejun Heo 2019-08-28 771 *
faffaab2895914a Tejun Heo 2023-04-12 772 * Parse the device node prefix part, MAJ:MIN, of per-blkg config update from
faffaab2895914a Tejun Heo 2023-04-12 773 * @ctx->input and get and store the matching bdev in @ctx->bdev. @ctx->body is
faffaab2895914a Tejun Heo 2023-04-12 774 * set to point past the device node prefix.
015d254cb02b6d8 Tejun Heo 2019-08-28 775 *
faffaab2895914a Tejun Heo 2023-04-12 776 * This function may be called multiple times on @ctx and the extra calls become
faffaab2895914a Tejun Heo 2023-04-12 777 * NOOPs. blkg_conf_prep() implicitly calls this function. Use this function
faffaab2895914a Tejun Heo 2023-04-12 778 * explicitly if bdev access is needed without resolving the blkcg / policy part
faffaab2895914a Tejun Heo 2023-04-12 779 * of @ctx->input. Returns -errno on error.
015d254cb02b6d8 Tejun Heo 2019-08-28 780 */
faffaab2895914a Tejun Heo 2023-04-12 781 int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
015d254cb02b6d8 Tejun Heo 2019-08-28 782 {
faffaab2895914a Tejun Heo 2023-04-12 783 char *input = ctx->input;
015d254cb02b6d8 Tejun Heo 2019-08-28 784 unsigned int major, minor;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 785 struct block_device *bdev;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 786 int key_len;
015d254cb02b6d8 Tejun Heo 2019-08-28 787
faffaab2895914a Tejun Heo 2023-04-12 788 if (ctx->bdev)
faffaab2895914a Tejun Heo 2023-04-12 789 return 0;
faffaab2895914a Tejun Heo 2023-04-12 790
015d254cb02b6d8 Tejun Heo 2019-08-28 791 if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
faffaab2895914a Tejun Heo 2023-04-12 792 return -EINVAL;
015d254cb02b6d8 Tejun Heo 2019-08-28 793
015d254cb02b6d8 Tejun Heo 2019-08-28 794 input += key_len;
015d254cb02b6d8 Tejun Heo 2019-08-28 795 if (!isspace(*input))
faffaab2895914a Tejun Heo 2023-04-12 796 return -EINVAL;
015d254cb02b6d8 Tejun Heo 2019-08-28 797 input = skip_spaces(input);
015d254cb02b6d8 Tejun Heo 2019-08-28 798
22ae8ce8b89241c Christoph Hellwig 2020-11-26 799 bdev = blkdev_get_no_open(MKDEV(major, minor));
22ae8ce8b89241c Christoph Hellwig 2020-11-26 800 if (!bdev)
faffaab2895914a Tejun Heo 2023-04-12 801 return -ENODEV;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 802 if (bdev_is_partition(bdev)) {
22ae8ce8b89241c Christoph Hellwig 2020-11-26 803 blkdev_put_no_open(bdev);
faffaab2895914a Tejun Heo 2023-04-12 804 return -ENODEV;
015d254cb02b6d8 Tejun Heo 2019-08-28 805 }
015d254cb02b6d8 Tejun Heo 2019-08-28 806
a13bd91be223187 Yu Kuai 2023-04-14 807 mutex_lock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be223187 Yu Kuai 2023-04-14 808 if (!disk_live(bdev->bd_disk)) {
a13bd91be223187 Yu Kuai 2023-04-14 809 blkdev_put_no_open(bdev);
a13bd91be223187 Yu Kuai 2023-04-14 810 mutex_unlock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be223187 Yu Kuai 2023-04-14 811 return -ENODEV;
a13bd91be223187 Yu Kuai 2023-04-14 812 }
a13bd91be223187 Yu Kuai 2023-04-14 813
faffaab2895914a Tejun Heo 2023-04-12 814 ctx->body = input;
faffaab2895914a Tejun Heo 2023-04-12 815 ctx->bdev = bdev;
faffaab2895914a Tejun Heo 2023-04-12 816 return 0;
015d254cb02b6d8 Tejun Heo 2019-08-28 817 }
9730763f4756e32 Nilay Shroff 2025-03-19 818 /*
9730763f4756e32 Nilay Shroff 2025-03-19 819 * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
9730763f4756e32 Nilay Shroff 2025-03-19 820 * acquires q->elevator_lock, and ensures the correct locking order
9730763f4756e32 Nilay Shroff 2025-03-19 821 * between q->elevator_lock and q->rq_qos_mutex.
9730763f4756e32 Nilay Shroff 2025-03-19 822 *
9730763f4756e32 Nilay Shroff 2025-03-19 823 * This function returns negative error on failure. On success it returns
9730763f4756e32 Nilay Shroff 2025-03-19 824 * memflags which must be saved and later passed to blkg_conf_exit_frozen
9730763f4756e32 Nilay Shroff 2025-03-19 825 * for restoring the memalloc scope.
9730763f4756e32 Nilay Shroff 2025-03-19 826 */
9730763f4756e32 Nilay Shroff 2025-03-19 827 unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
9730763f4756e32 Nilay Shroff 2025-03-19 828 {
9730763f4756e32 Nilay Shroff 2025-03-19 829 int ret;
9730763f4756e32 Nilay Shroff 2025-03-19 830 unsigned long memflags;
9730763f4756e32 Nilay Shroff 2025-03-19 831
9730763f4756e32 Nilay Shroff 2025-03-19 @832 if (ctx->bdev)
9730763f4756e32 Nilay Shroff 2025-03-19 833 return -EINVAL;
9730763f4756e32 Nilay Shroff 2025-03-19 834
9730763f4756e32 Nilay Shroff 2025-03-19 835 ret = blkg_conf_open_bdev(ctx);
9730763f4756e32 Nilay Shroff 2025-03-19 836 if (ret < 0)
9730763f4756e32 Nilay Shroff 2025-03-19 837 return ret;
9730763f4756e32 Nilay Shroff 2025-03-19 838 /*
9730763f4756e32 Nilay Shroff 2025-03-19 839 * At this point, we haven’t started protecting anything related to QoS,
9730763f4756e32 Nilay Shroff 2025-03-19 840 * so we release q->rq_qos_mutex here, which was first acquired in blkg_
9730763f4756e32 Nilay Shroff 2025-03-19 841 * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
9730763f4756e32 Nilay Shroff 2025-03-19 842 * the queue and acquiring q->elevator_lock to maintain the correct
9730763f4756e32 Nilay Shroff 2025-03-19 843 * locking order.
9730763f4756e32 Nilay Shroff 2025-03-19 844 */
9730763f4756e32 Nilay Shroff 2025-03-19 @845 mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e32 Nilay Shroff 2025-03-19 846
9730763f4756e32 Nilay Shroff 2025-03-19 847 memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
9730763f4756e32 Nilay Shroff 2025-03-19 848 mutex_lock(&ctx->bdev->bd_queue->elevator_lock);
9730763f4756e32 Nilay Shroff 2025-03-19 849 mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e32 Nilay Shroff 2025-03-19 850
9730763f4756e32 Nilay Shroff 2025-03-19 851 return memflags;
9730763f4756e32 Nilay Shroff 2025-03-19 852 }
015d254cb02b6d8 Tejun Heo 2019-08-28 853
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
@ 2026-01-26 1:14 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-01-26 1:14 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Nilay Shroff <nilay@linux.ibm.com>
CC: Jens Axboe <axboe@kernel.dk>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 63804fed149a6750ffd28610c5c1c98cce6bd377
commit: 9730763f4756e32520cb86778331465e8d063a8f block: correct locking order for protecting blk-wbt parameters
date: 10 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 10 months ago
config: powerpc64-randconfig-r073-20260125 (https://download.01.org/0day-ci/archive/20260126/202601260947.zRboWPyP-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 12.5.0
smatch version: v0.5.0-8994-gd50c5a4c
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202601260947.zRboWPyP-lkp@intel.com/
smatch warnings:
block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
vim +845 block/blk-cgroup.c
faffaab2895914 Tejun Heo 2023-04-12 767
faffaab2895914 Tejun Heo 2023-04-12 768 /**
faffaab2895914 Tejun Heo 2023-04-12 769 * blkg_conf_open_bdev - parse and open bdev for per-blkg config update
faffaab2895914 Tejun Heo 2023-04-12 770 * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
015d254cb02b6d Tejun Heo 2019-08-28 771 *
faffaab2895914 Tejun Heo 2023-04-12 772 * Parse the device node prefix part, MAJ:MIN, of per-blkg config update from
faffaab2895914 Tejun Heo 2023-04-12 773 * @ctx->input and get and store the matching bdev in @ctx->bdev. @ctx->body is
faffaab2895914 Tejun Heo 2023-04-12 774 * set to point past the device node prefix.
015d254cb02b6d Tejun Heo 2019-08-28 775 *
faffaab2895914 Tejun Heo 2023-04-12 776 * This function may be called multiple times on @ctx and the extra calls become
faffaab2895914 Tejun Heo 2023-04-12 777 * NOOPs. blkg_conf_prep() implicitly calls this function. Use this function
faffaab2895914 Tejun Heo 2023-04-12 778 * explicitly if bdev access is needed without resolving the blkcg / policy part
faffaab2895914 Tejun Heo 2023-04-12 779 * of @ctx->input. Returns -errno on error.
015d254cb02b6d Tejun Heo 2019-08-28 780 */
faffaab2895914 Tejun Heo 2023-04-12 781 int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
015d254cb02b6d Tejun Heo 2019-08-28 782 {
faffaab2895914 Tejun Heo 2023-04-12 783 char *input = ctx->input;
015d254cb02b6d Tejun Heo 2019-08-28 784 unsigned int major, minor;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 785 struct block_device *bdev;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 786 int key_len;
015d254cb02b6d Tejun Heo 2019-08-28 787
faffaab2895914 Tejun Heo 2023-04-12 788 if (ctx->bdev)
faffaab2895914 Tejun Heo 2023-04-12 789 return 0;
faffaab2895914 Tejun Heo 2023-04-12 790
015d254cb02b6d Tejun Heo 2019-08-28 791 if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
faffaab2895914 Tejun Heo 2023-04-12 792 return -EINVAL;
015d254cb02b6d Tejun Heo 2019-08-28 793
015d254cb02b6d Tejun Heo 2019-08-28 794 input += key_len;
015d254cb02b6d Tejun Heo 2019-08-28 795 if (!isspace(*input))
faffaab2895914 Tejun Heo 2023-04-12 796 return -EINVAL;
015d254cb02b6d Tejun Heo 2019-08-28 797 input = skip_spaces(input);
015d254cb02b6d Tejun Heo 2019-08-28 798
22ae8ce8b89241 Christoph Hellwig 2020-11-26 799 bdev = blkdev_get_no_open(MKDEV(major, minor));
22ae8ce8b89241 Christoph Hellwig 2020-11-26 800 if (!bdev)
faffaab2895914 Tejun Heo 2023-04-12 801 return -ENODEV;
22ae8ce8b89241 Christoph Hellwig 2020-11-26 802 if (bdev_is_partition(bdev)) {
22ae8ce8b89241 Christoph Hellwig 2020-11-26 803 blkdev_put_no_open(bdev);
faffaab2895914 Tejun Heo 2023-04-12 804 return -ENODEV;
015d254cb02b6d Tejun Heo 2019-08-28 805 }
015d254cb02b6d Tejun Heo 2019-08-28 806
a13bd91be22318 Yu Kuai 2023-04-14 807 mutex_lock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be22318 Yu Kuai 2023-04-14 808 if (!disk_live(bdev->bd_disk)) {
a13bd91be22318 Yu Kuai 2023-04-14 809 blkdev_put_no_open(bdev);
a13bd91be22318 Yu Kuai 2023-04-14 810 mutex_unlock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be22318 Yu Kuai 2023-04-14 811 return -ENODEV;
a13bd91be22318 Yu Kuai 2023-04-14 812 }
a13bd91be22318 Yu Kuai 2023-04-14 813
faffaab2895914 Tejun Heo 2023-04-12 814 ctx->body = input;
faffaab2895914 Tejun Heo 2023-04-12 815 ctx->bdev = bdev;
faffaab2895914 Tejun Heo 2023-04-12 816 return 0;
015d254cb02b6d Tejun Heo 2019-08-28 817 }
9730763f4756e3 Nilay Shroff 2025-03-19 818 /*
9730763f4756e3 Nilay Shroff 2025-03-19 819 * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
9730763f4756e3 Nilay Shroff 2025-03-19 820 * acquires q->elevator_lock, and ensures the correct locking order
9730763f4756e3 Nilay Shroff 2025-03-19 821 * between q->elevator_lock and q->rq_qos_mutex.
9730763f4756e3 Nilay Shroff 2025-03-19 822 *
9730763f4756e3 Nilay Shroff 2025-03-19 823 * This function returns negative error on failure. On success it returns
9730763f4756e3 Nilay Shroff 2025-03-19 824 * memflags which must be saved and later passed to blkg_conf_exit_frozen
9730763f4756e3 Nilay Shroff 2025-03-19 825 * for restoring the memalloc scope.
9730763f4756e3 Nilay Shroff 2025-03-19 826 */
9730763f4756e3 Nilay Shroff 2025-03-19 827 unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
9730763f4756e3 Nilay Shroff 2025-03-19 828 {
9730763f4756e3 Nilay Shroff 2025-03-19 829 int ret;
9730763f4756e3 Nilay Shroff 2025-03-19 830 unsigned long memflags;
9730763f4756e3 Nilay Shroff 2025-03-19 831
9730763f4756e3 Nilay Shroff 2025-03-19 @832 if (ctx->bdev)
9730763f4756e3 Nilay Shroff 2025-03-19 833 return -EINVAL;
9730763f4756e3 Nilay Shroff 2025-03-19 834
9730763f4756e3 Nilay Shroff 2025-03-19 835 ret = blkg_conf_open_bdev(ctx);
9730763f4756e3 Nilay Shroff 2025-03-19 836 if (ret < 0)
9730763f4756e3 Nilay Shroff 2025-03-19 837 return ret;
9730763f4756e3 Nilay Shroff 2025-03-19 838 /*
9730763f4756e3 Nilay Shroff 2025-03-19 839 * At this point, we haven’t started protecting anything related to QoS,
9730763f4756e3 Nilay Shroff 2025-03-19 840 * so we release q->rq_qos_mutex here, which was first acquired in blkg_
9730763f4756e3 Nilay Shroff 2025-03-19 841 * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
9730763f4756e3 Nilay Shroff 2025-03-19 842 * the queue and acquiring q->elevator_lock to maintain the correct
9730763f4756e3 Nilay Shroff 2025-03-19 843 * locking order.
9730763f4756e3 Nilay Shroff 2025-03-19 844 */
9730763f4756e3 Nilay Shroff 2025-03-19 @845 mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e3 Nilay Shroff 2025-03-19 846
9730763f4756e3 Nilay Shroff 2025-03-19 847 memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
9730763f4756e3 Nilay Shroff 2025-03-19 848 mutex_lock(&ctx->bdev->bd_queue->elevator_lock);
9730763f4756e3 Nilay Shroff 2025-03-19 849 mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e3 Nilay Shroff 2025-03-19 850
9730763f4756e3 Nilay Shroff 2025-03-19 851 return memflags;
9730763f4756e3 Nilay Shroff 2025-03-19 852 }
015d254cb02b6d Tejun Heo 2019-08-28 853
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-26 1:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-26 1:14 block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832) kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-10-16 19:07 kernel test robot
2025-07-03 3:33 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.