[mcgrof-next:20210910-sysfs-generic-deadlock-fix 3/10] lib/test_sysfs.c:839: undefined reference to `del_gendisk'

From: kernel test robot
Date: Sat Sep 11 2021 - 16:34:31 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 20210910-sysfs-generic-deadlock-fix
head: 13abd44a9d3bec85045cb6410d2bb1c56d169c5c
commit: ef91c4485e77ae1fdb9dcadfbd2be17c80407ec3 [3/10] selftests: add tests_sysfs module
config: x86_64-randconfig-c003-20210911 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/commit/?id=ef91c4485e77ae1fdb9dcadfbd2be17c80407ec3
git remote add mcgrof-next https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git
git fetch --no-tags mcgrof-next 20210910-sysfs-generic-deadlock-fix
git checkout ef91c4485e77ae1fdb9dcadfbd2be17c80407ec3
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

ld: lib/test_sysfs.o: in function `unregister_test_dev_sysfs_block':
>> lib/test_sysfs.c:839: undefined reference to `del_gendisk'
>> ld: lib/test_sysfs.c:840: undefined reference to `blk_cleanup_disk'
ld: lib/test_sysfs.o: in function `sysfs_test_dev_alloc_blockdev':
>> lib/test_sysfs.c:688: undefined reference to `__blk_alloc_disk'
>> ld: lib/test_sysfs.c:701: undefined reference to `set_capacity'
>> ld: lib/test_sysfs.c:702: undefined reference to `blk_queue_flag_set'
>> ld: lib/test_sysfs.c:703: undefined reference to `blk_queue_flag_clear'
>> ld: lib/test_sysfs.c:704: undefined reference to `blk_queue_physical_block_size'
>> ld: lib/test_sysfs.c:705: undefined reference to `blk_queue_max_discard_sectors'
ld: lib/test_sysfs.c:706: undefined reference to `blk_queue_flag_set'
ld: lib/test_sysfs.o: in function `register_test_dev_sysfs_block':
>> lib/test_sysfs.c:768: undefined reference to `device_add_disk'


vim +839 lib/test_sysfs.c

683
684 static int sysfs_test_dev_alloc_blockdev(struct sysfs_test_device *test_dev)
685 {
686 int ret = -ENOMEM;
687
> 688 test_dev->disk = blk_alloc_disk(NUMA_NO_NODE);
689 if (!test_dev->disk) {
690 pr_err("Error allocating disk structure for device %d\n",
691 test_dev->dev_idx);
692 goto out;
693 }
694
695 test_dev->disk->major = sysfs_test_major;
696 test_dev->disk->first_minor = test_dev->dev_idx + 1;
697 test_dev->disk->fops = &sysfs_testdev_ops;
698 test_dev->disk->private_data = test_dev;
699 snprintf(test_dev->disk->disk_name, 16, "test_sysfs%d",
700 test_dev->dev_idx);
> 701 set_capacity(test_dev->disk, 0);
> 702 blk_queue_flag_set(QUEUE_FLAG_NONROT, test_dev->disk->queue);
> 703 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, test_dev->disk->queue);
> 704 blk_queue_physical_block_size(test_dev->disk->queue, PAGE_SIZE);
> 705 blk_queue_max_discard_sectors(test_dev->disk->queue, UINT_MAX);
706 blk_queue_flag_set(QUEUE_FLAG_DISCARD, test_dev->disk->queue);
707
708 return 0;
709 out:
710 return ret;
711 }
712
713 static struct sysfs_test_device *alloc_test_dev_sysfs(int idx)
714 {
715 struct sysfs_test_device *test_dev;
716 int ret;
717
718 switch (test_devtype) {
719 case TESTDEV_TYPE_MISC:
720 fallthrough;
721 case TESTDEV_TYPE_BLOCK:
722 break;
723 default:
724 return NULL;
725 }
726
727 test_dev = kzalloc(sizeof(struct sysfs_test_device), GFP_KERNEL);
728 if (!test_dev)
729 goto err_out;
730
731 mutex_init(&test_dev->config_mutex);
732 test_dev->dev_idx = idx;
733 test_dev->devtype = test_devtype;
734
735 if (test_dev->devtype == TESTDEV_TYPE_MISC) {
736 ret = sysfs_test_dev_alloc_miscdev(test_dev);
737 if (ret)
738 goto err_out_free;
739 } else if (test_dev->devtype == TESTDEV_TYPE_BLOCK) {
740 ret = sysfs_test_dev_alloc_blockdev(test_dev);
741 if (ret)
742 goto err_out_free;
743 }
744 return test_dev;
745
746 err_out_free:
747 kfree(test_dev);
748 test_dev = NULL;
749 err_out:
750 return NULL;
751 }
752
753 static int register_test_dev_sysfs_misc(struct sysfs_test_device *test_dev)
754 {
755 int ret;
756
757 ret = misc_register(&test_dev->misc_dev);
758 if (ret)
759 return ret;
760
761 test_dev->dev = test_dev->misc_dev.this_device;
762
763 return 0;
764 }
765
766 static int register_test_dev_sysfs_block(struct sysfs_test_device *test_dev)
767 {
> 768 device_add_disk(NULL, test_dev->disk, test_dev_groups);
769 test_dev->dev = disk_to_dev(test_dev->disk);
770
771 return 0;
772 }
773
774 static struct sysfs_test_device *register_test_dev_sysfs(void)
775 {
776 struct sysfs_test_device *test_dev = NULL;
777 int ret;
778
779 test_dev = alloc_test_dev_sysfs(0);
780 if (!test_dev)
781 goto out;
782
783 if (test_dev->devtype == TESTDEV_TYPE_MISC) {
784 ret = register_test_dev_sysfs_misc(test_dev);
785 if (ret) {
786 pr_err("could not register misc device: %d\n", ret);
787 goto out_free_dev;
788 }
789 } else if (test_dev->devtype == TESTDEV_TYPE_BLOCK) {
790 ret = register_test_dev_sysfs_block(test_dev);
791 if (ret) {
792 pr_err("could not register block device: %d\n", ret);
793 goto out_free_dev;
794 }
795 }
796
797 dev_info(test_dev->dev, "interface ready\n");
798
799 out:
800 return test_dev;
801 out_free_dev:
802 free_test_dev_sysfs(test_dev);
803 return NULL;
804 }
805
806 static struct sysfs_test_device *register_test_dev_set_config(void)
807 {
808 struct sysfs_test_device *test_dev;
809 struct test_config *config;
810
811 test_dev = register_test_dev_sysfs();
812 if (!test_dev)
813 return NULL;
814
815 config = &test_dev->config;
816
817 if (enable_lock)
818 config->enable_lock = true;
819 if (enable_lock_on_rmmod)
820 config->enable_lock_on_rmmod = true;
821 if (use_rtnl_lock)
822 config->use_rtnl_lock = true;
823 if (enable_busy_alloc)
824 config->enable_busy_alloc = true;
825
826 config->write_delay_msec_y = write_delay_msec_y;
827 test_sysfs_reset_vals(test_dev);
828
829 return test_dev;
830 }
831
832 static void unregister_test_dev_sysfs_misc(struct sysfs_test_device *test_dev)
833 {
834 misc_deregister(&test_dev->misc_dev);
835 }
836
837 static void unregister_test_dev_sysfs_block(struct sysfs_test_device *test_dev)
838 {
> 839 del_gendisk(test_dev->disk);
> 840 blk_cleanup_disk(test_dev->disk);
841 }
842

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip