fs/btrfs/volumes.c:888:50: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Mon Oct 19 2020 - 00:28:42 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7cf726a59435301046250c42131554d9ccc566b8
commit: 8d1a7aae89dc0c41ffb76fe1007dbba59d13881b btrfs: annotate device name rcu_string with __rcu
date: 12 days ago
config: s390-randconfig-s032-20201019 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-rc1-2-g368fd9ce-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8d1a7aae89dc0c41ffb76fe1007dbba59d13881b
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 8d1a7aae89dc0c41ffb76fe1007dbba59d13881b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=s390

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


"sparse warnings: (new ones prefixed by >>)"
fs/btrfs/volumes.c:374:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct rcu_string *str @@ got struct rcu_string [noderef] __rcu *name @@
fs/btrfs/volumes.c:374:31: sparse: expected struct rcu_string *str
fs/btrfs/volumes.c:374:31: sparse: got struct rcu_string [noderef] __rcu *name
fs/btrfs/volumes.c:631:43: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:631:43: sparse: expected char const *device_path
fs/btrfs/volumes.c:631:43: sparse: got char [noderef] __rcu *
>> fs/btrfs/volumes.c:888:50: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *s1 @@ got char [noderef] __rcu * @@
>> fs/btrfs/volumes.c:888:50: sparse: expected char const *s1
fs/btrfs/volumes.c:888:50: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:963:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct rcu_string *str @@ got struct rcu_string [noderef] __rcu *name @@
fs/btrfs/volumes.c:963:39: sparse: expected struct rcu_string *str
fs/btrfs/volumes.c:963:39: sparse: got struct rcu_string [noderef] __rcu *name
fs/btrfs/volumes.c:1018:58: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *src @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:1018:58: sparse: expected char const *src
fs/btrfs/volumes.c:1018:58: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:2165:49: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:2165:49: sparse: expected char const *device_path
fs/btrfs/volumes.c:2165:49: sparse: got char [noderef] __rcu *
fs/btrfs/volumes.c:2273:41: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected char const *device_path @@ got char [noderef] __rcu * @@
fs/btrfs/volumes.c:2273:41: sparse: expected char const *device_path
fs/btrfs/volumes.c:2273:41: sparse: got char [noderef] __rcu *

vim +888 fs/btrfs/volumes.c

1362089d2ad7e20 Nikolay Borisov 2020-01-10 745
1362089d2ad7e20 Nikolay Borisov 2020-01-10 746 static struct btrfs_fs_devices *find_fsid_reverted_metadata(
1362089d2ad7e20 Nikolay Borisov 2020-01-10 747 struct btrfs_super_block *disk_super)
1362089d2ad7e20 Nikolay Borisov 2020-01-10 748 {
1362089d2ad7e20 Nikolay Borisov 2020-01-10 749 struct btrfs_fs_devices *fs_devices;
1362089d2ad7e20 Nikolay Borisov 2020-01-10 750
1362089d2ad7e20 Nikolay Borisov 2020-01-10 751 /*
1362089d2ad7e20 Nikolay Borisov 2020-01-10 752 * Handle the case where the scanned device is part of an fs whose last
1362089d2ad7e20 Nikolay Borisov 2020-01-10 753 * metadata UUID change reverted it to the original FSID. At the same
1362089d2ad7e20 Nikolay Borisov 2020-01-10 754 * time * fs_devices was first created by another constitutent device
1362089d2ad7e20 Nikolay Borisov 2020-01-10 755 * which didn't fully observe the operation. This results in an
1362089d2ad7e20 Nikolay Borisov 2020-01-10 756 * btrfs_fs_devices created with metadata/fsid different AND
1362089d2ad7e20 Nikolay Borisov 2020-01-10 757 * btrfs_fs_devices::fsid_change set AND the metadata_uuid of the
1362089d2ad7e20 Nikolay Borisov 2020-01-10 758 * fs_devices equal to the FSID of the disk.
1362089d2ad7e20 Nikolay Borisov 2020-01-10 759 */
1362089d2ad7e20 Nikolay Borisov 2020-01-10 760 list_for_each_entry(fs_devices, &fs_uuids, fs_list) {
1362089d2ad7e20 Nikolay Borisov 2020-01-10 761 if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid,
1362089d2ad7e20 Nikolay Borisov 2020-01-10 762 BTRFS_FSID_SIZE) != 0 &&
1362089d2ad7e20 Nikolay Borisov 2020-01-10 763 memcmp(fs_devices->metadata_uuid, disk_super->fsid,
1362089d2ad7e20 Nikolay Borisov 2020-01-10 764 BTRFS_FSID_SIZE) == 0 &&
1362089d2ad7e20 Nikolay Borisov 2020-01-10 765 fs_devices->fsid_change)
1362089d2ad7e20 Nikolay Borisov 2020-01-10 766 return fs_devices;
1362089d2ad7e20 Nikolay Borisov 2020-01-10 767 }
1362089d2ad7e20 Nikolay Borisov 2020-01-10 768
1362089d2ad7e20 Nikolay Borisov 2020-01-10 769 return NULL;
1362089d2ad7e20 Nikolay Borisov 2020-01-10 770 }
60999ca4b4033ee David Sterba 2014-03-26 771 /*
60999ca4b4033ee David Sterba 2014-03-26 772 * Add new device to list of registered devices
60999ca4b4033ee David Sterba 2014-03-26 773 *
60999ca4b4033ee David Sterba 2014-03-26 774 * Returns:
e124ece53edf3a8 Anand Jain 2018-01-18 775 * device pointer which was just added or updated when successful
e124ece53edf3a8 Anand Jain 2018-01-18 776 * error pointer when failed
60999ca4b4033ee David Sterba 2014-03-26 777 */
e124ece53edf3a8 Anand Jain 2018-01-18 778 static noinline struct btrfs_device *device_list_add(const char *path,
4306a97449f9a0f Anand Jain 2018-05-29 779 struct btrfs_super_block *disk_super,
4306a97449f9a0f Anand Jain 2018-05-29 780 bool *new_device_added)
8a4b83cc8bd75fc Chris Mason 2008-03-24 781 {
8a4b83cc8bd75fc Chris Mason 2008-03-24 782 struct btrfs_device *device;
7a62d0f07377b51 Nikolay Borisov 2018-10-30 783 struct btrfs_fs_devices *fs_devices = NULL;
606686eeac4550d Josef Bacik 2012-06-04 784 struct rcu_string *name;
8a4b83cc8bd75fc Chris Mason 2008-03-24 785 u64 found_transid = btrfs_super_generation(disk_super);
3acbcbfc8f06d4a Anand Jain 2018-01-18 786 u64 devid = btrfs_stack_device_id(&disk_super->dev_item);
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 787 bool has_metadata_uuid = (btrfs_super_incompat_flags(disk_super) &
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 788 BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
d1a63002829a4d8 Nikolay Borisov 2018-10-30 789 bool fsid_change_in_progress = (btrfs_super_flags(disk_super) &
d1a63002829a4d8 Nikolay Borisov 2018-10-30 790 BTRFS_SUPER_FLAG_CHANGING_FSID_V2);
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 791
cc5de4e70256cbf Nikolay Borisov 2018-10-30 792 if (fsid_change_in_progress) {
c0d81c7cb236782 Su Yue 2020-01-10 793 if (!has_metadata_uuid)
7a62d0f07377b51 Nikolay Borisov 2018-10-30 794 fs_devices = find_fsid_inprogress(disk_super);
c0d81c7cb236782 Su Yue 2020-01-10 795 else
cc5de4e70256cbf Nikolay Borisov 2018-10-30 796 fs_devices = find_fsid_changed(disk_super);
7a62d0f07377b51 Nikolay Borisov 2018-10-30 797 } else if (has_metadata_uuid) {
c6730a0e5778bf2 Su Yue 2020-01-10 798 fs_devices = find_fsid_with_metadata_uuid(disk_super);
7a62d0f07377b51 Nikolay Borisov 2018-10-30 799 } else {
1362089d2ad7e20 Nikolay Borisov 2020-01-10 800 fs_devices = find_fsid_reverted_metadata(disk_super);
1362089d2ad7e20 Nikolay Borisov 2020-01-10 801 if (!fs_devices)
7a62d0f07377b51 Nikolay Borisov 2018-10-30 802 fs_devices = find_fsid(disk_super->fsid, NULL);
7a62d0f07377b51 Nikolay Borisov 2018-10-30 803 }
7a62d0f07377b51 Nikolay Borisov 2018-10-30 804
7a62d0f07377b51 Nikolay Borisov 2018-10-30 805
8a4b83cc8bd75fc Chris Mason 2008-03-24 806 if (!fs_devices) {
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 807 if (has_metadata_uuid)
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 808 fs_devices = alloc_fs_devices(disk_super->fsid,
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 809 disk_super->metadata_uuid);
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 810 else
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 811 fs_devices = alloc_fs_devices(disk_super->fsid, NULL);
7239ff4b2be8ec0 Nikolay Borisov 2018-10-30 812
2208a378f35fea7 Ilya Dryomov 2013-08-12 813 if (IS_ERR(fs_devices))
e124ece53edf3a8 Anand Jain 2018-01-18 814 return ERR_CAST(fs_devices);
2208a378f35fea7 Ilya Dryomov 2013-08-12 815
92900e5160a5444 Al Viro 2019-01-27 816 fs_devices->fsid_change = fsid_change_in_progress;
92900e5160a5444 Al Viro 2019-01-27 817
9c6d173ea6e4c8c Anand Jain 2018-05-29 818 mutex_lock(&fs_devices->device_list_mutex);
c4babc5e38e94e7 Anand Jain 2018-04-12 819 list_add(&fs_devices->fs_list, &fs_uuids);
2208a378f35fea7 Ilya Dryomov 2013-08-12 820
8a4b83cc8bd75fc Chris Mason 2008-03-24 821 device = NULL;
8a4b83cc8bd75fc Chris Mason 2008-03-24 822 } else {
9c6d173ea6e4c8c Anand Jain 2018-05-29 823 mutex_lock(&fs_devices->device_list_mutex);
09ba3bc9dd15045 Anand Jain 2019-01-19 824 device = btrfs_find_device(fs_devices, devid,
09ba3bc9dd15045 Anand Jain 2019-01-19 825 disk_super->dev_item.uuid, NULL, false);
7a62d0f07377b51 Nikolay Borisov 2018-10-30 826
7a62d0f07377b51 Nikolay Borisov 2018-10-30 827 /*
7a62d0f07377b51 Nikolay Borisov 2018-10-30 828 * If this disk has been pulled into an fs devices created by
7a62d0f07377b51 Nikolay Borisov 2018-10-30 829 * a device which had the CHANGING_FSID_V2 flag then replace the
7a62d0f07377b51 Nikolay Borisov 2018-10-30 830 * metadata_uuid/fsid values of the fs_devices.
7a62d0f07377b51 Nikolay Borisov 2018-10-30 831 */
1362089d2ad7e20 Nikolay Borisov 2020-01-10 832 if (fs_devices->fsid_change &&
7a62d0f07377b51 Nikolay Borisov 2018-10-30 833 found_transid > fs_devices->latest_generation) {
7a62d0f07377b51 Nikolay Borisov 2018-10-30 834 memcpy(fs_devices->fsid, disk_super->fsid,
7a62d0f07377b51 Nikolay Borisov 2018-10-30 835 BTRFS_FSID_SIZE);
1362089d2ad7e20 Nikolay Borisov 2020-01-10 836
1362089d2ad7e20 Nikolay Borisov 2020-01-10 837 if (has_metadata_uuid)
1362089d2ad7e20 Nikolay Borisov 2020-01-10 838 memcpy(fs_devices->metadata_uuid,
1362089d2ad7e20 Nikolay Borisov 2020-01-10 839 disk_super->metadata_uuid,
1362089d2ad7e20 Nikolay Borisov 2020-01-10 840 BTRFS_FSID_SIZE);
1362089d2ad7e20 Nikolay Borisov 2020-01-10 841 else
7a62d0f07377b51 Nikolay Borisov 2018-10-30 842 memcpy(fs_devices->metadata_uuid,
1362089d2ad7e20 Nikolay Borisov 2020-01-10 843 disk_super->fsid, BTRFS_FSID_SIZE);
7a62d0f07377b51 Nikolay Borisov 2018-10-30 844
7a62d0f07377b51 Nikolay Borisov 2018-10-30 845 fs_devices->fsid_change = false;
7a62d0f07377b51 Nikolay Borisov 2018-10-30 846 }
8a4b83cc8bd75fc Chris Mason 2008-03-24 847 }
443f24fee731703 Miao Xie 2014-07-24 848
8a4b83cc8bd75fc Chris Mason 2008-03-24 849 if (!device) {
9c6d173ea6e4c8c Anand Jain 2018-05-29 850 if (fs_devices->opened) {
9c6d173ea6e4c8c Anand Jain 2018-05-29 851 mutex_unlock(&fs_devices->device_list_mutex);
e124ece53edf3a8 Anand Jain 2018-01-18 852 return ERR_PTR(-EBUSY);
9c6d173ea6e4c8c Anand Jain 2018-05-29 853 }
2b82032c34ec405 Yan Zheng 2008-11-17 854
12bd2fc0d2f589f Ilya Dryomov 2013-08-23 855 device = btrfs_alloc_device(NULL, &devid,
12bd2fc0d2f589f Ilya Dryomov 2013-08-23 856 disk_super->dev_item.uuid);
12bd2fc0d2f589f Ilya Dryomov 2013-08-23 857 if (IS_ERR(device)) {
9c6d173ea6e4c8c Anand Jain 2018-05-29 858 mutex_unlock(&fs_devices->device_list_mutex);
8a4b83cc8bd75fc Chris Mason 2008-03-24 859 /* we can safely leave the fs_devices entry around */
e124ece53edf3a8 Anand Jain 2018-01-18 860 return device;
8a4b83cc8bd75fc Chris Mason 2008-03-24 861 }
606686eeac4550d Josef Bacik 2012-06-04 862
606686eeac4550d Josef Bacik 2012-06-04 863 name = rcu_string_strdup(path, GFP_NOFS);
606686eeac4550d Josef Bacik 2012-06-04 864 if (!name) {
a425f9d4755a14f David Sterba 2018-03-20 865 btrfs_free_device(device);
9c6d173ea6e4c8c Anand Jain 2018-05-29 866 mutex_unlock(&fs_devices->device_list_mutex);
e124ece53edf3a8 Anand Jain 2018-01-18 867 return ERR_PTR(-ENOMEM);
8a4b83cc8bd75fc Chris Mason 2008-03-24 868 }
606686eeac4550d Josef Bacik 2012-06-04 869 rcu_assign_pointer(device->name, name);
90519d66abbccc2 Arne Jansen 2011-05-23 870
1f78160ce1b1b8e Xiao Guangrong 2011-04-20 871 list_add_rcu(&device->dev_list, &fs_devices->devices);
f71717502460c5c Filipe David Borba Manana 2013-08-12 872 fs_devices->num_devices++;
e5e9a5206a171b2 Chris Mason 2009-06-10 873
2b82032c34ec405 Yan Zheng 2008-11-17 874 device->fs_devices = fs_devices;
4306a97449f9a0f Anand Jain 2018-05-29 875 *new_device_added = true;
327f18cc7f44bc0 Anand Jain 2018-01-18 876
327f18cc7f44bc0 Anand Jain 2018-01-18 877 if (disk_super->label[0])
aa6c0df73e3b3fc Anand Jain 2019-10-02 878 pr_info(
aa6c0df73e3b3fc Anand Jain 2019-10-02 879 "BTRFS: device label %s devid %llu transid %llu %s scanned by %s (%d)\n",
aa6c0df73e3b3fc Anand Jain 2019-10-02 880 disk_super->label, devid, found_transid, path,
aa6c0df73e3b3fc Anand Jain 2019-10-02 881 current->comm, task_pid_nr(current));
327f18cc7f44bc0 Anand Jain 2018-01-18 882 else
aa6c0df73e3b3fc Anand Jain 2019-10-02 883 pr_info(
aa6c0df73e3b3fc Anand Jain 2019-10-02 884 "BTRFS: device fsid %pU devid %llu transid %llu %s scanned by %s (%d)\n",
aa6c0df73e3b3fc Anand Jain 2019-10-02 885 disk_super->fsid, devid, found_transid, path,
aa6c0df73e3b3fc Anand Jain 2019-10-02 886 current->comm, task_pid_nr(current));
327f18cc7f44bc0 Anand Jain 2018-01-18 887
606686eeac4550d Josef Bacik 2012-06-04 @888 } else if (!device->name || strcmp(device->name->str, path)) {
b96de000bc8bc96 Anand Jain 2014-07-03 889 /*
b96de000bc8bc96 Anand Jain 2014-07-03 890 * When FS is already mounted.
b96de000bc8bc96 Anand Jain 2014-07-03 891 * 1. If you are here and if the device->name is NULL that
b96de000bc8bc96 Anand Jain 2014-07-03 892 * means this device was missing at time of FS mount.
b96de000bc8bc96 Anand Jain 2014-07-03 893 * 2. If you are here and if the device->name is different
b96de000bc8bc96 Anand Jain 2014-07-03 894 * from 'path' that means either
b96de000bc8bc96 Anand Jain 2014-07-03 895 * a. The same device disappeared and reappeared with
b96de000bc8bc96 Anand Jain 2014-07-03 896 * different name. or
b96de000bc8bc96 Anand Jain 2014-07-03 897 * b. The missing-disk-which-was-replaced, has
b96de000bc8bc96 Anand Jain 2014-07-03 898 * reappeared now.
b96de000bc8bc96 Anand Jain 2014-07-03 899 *
b96de000bc8bc96 Anand Jain 2014-07-03 900 * We must allow 1 and 2a above. But 2b would be a spurious
b96de000bc8bc96 Anand Jain 2014-07-03 901 * and unintentional.
b96de000bc8bc96 Anand Jain 2014-07-03 902 *
b96de000bc8bc96 Anand Jain 2014-07-03 903 * Further in case of 1 and 2a above, the disk at 'path'
b96de000bc8bc96 Anand Jain 2014-07-03 904 * would have missed some transaction when it was away and
b96de000bc8bc96 Anand Jain 2014-07-03 905 * in case of 2a the stale bdev has to be updated as well.
b96de000bc8bc96 Anand Jain 2014-07-03 906 * 2b must not be allowed at all time.
b96de000bc8bc96 Anand Jain 2014-07-03 907 */
b96de000bc8bc96 Anand Jain 2014-07-03 908
b96de000bc8bc96 Anand Jain 2014-07-03 909 /*
0f23ae74f589304 Chris Mason 2014-09-18 910 * For now, we do allow update to btrfs_fs_device through the
0f23ae74f589304 Chris Mason 2014-09-18 911 * btrfs dev scan cli after FS has been mounted. We're still
0f23ae74f589304 Chris Mason 2014-09-18 912 * tracking a problem where systems fail mount by subvolume id
0f23ae74f589304 Chris Mason 2014-09-18 913 * when we reject replacement on a mounted FS.
b96de000bc8bc96 Anand Jain 2014-07-03 914 */
0f23ae74f589304 Chris Mason 2014-09-18 915 if (!fs_devices->opened && found_transid < device->generation) {
77bdae4d136e167 Anand Jain 2014-07-03 916 /*
77bdae4d136e167 Anand Jain 2014-07-03 917 * That is if the FS is _not_ mounted and if you
77bdae4d136e167 Anand Jain 2014-07-03 918 * are here, that means there is more than one
77bdae4d136e167 Anand Jain 2014-07-03 919 * disk with same uuid and devid.We keep the one
77bdae4d136e167 Anand Jain 2014-07-03 920 * with larger generation number or the last-in if
77bdae4d136e167 Anand Jain 2014-07-03 921 * generation are equal.
77bdae4d136e167 Anand Jain 2014-07-03 922 */
9c6d173ea6e4c8c Anand Jain 2018-05-29 923 mutex_unlock(&fs_devices->device_list_mutex);
e124ece53edf3a8 Anand Jain 2018-01-18 924 return ERR_PTR(-EEXIST);
77bdae4d136e167 Anand Jain 2014-07-03 925 }
b96de000bc8bc96 Anand Jain 2014-07-03 926
a9261d4125c97ce Anand Jain 2018-10-15 927 /*
a9261d4125c97ce Anand Jain 2018-10-15 928 * We are going to replace the device path for a given devid,
a9261d4125c97ce Anand Jain 2018-10-15 929 * make sure it's the same device if the device is mounted
a9261d4125c97ce Anand Jain 2018-10-15 930 */
a9261d4125c97ce Anand Jain 2018-10-15 931 if (device->bdev) {
a9261d4125c97ce Anand Jain 2018-10-15 932 struct block_device *path_bdev;
a9261d4125c97ce Anand Jain 2018-10-15 933
a9261d4125c97ce Anand Jain 2018-10-15 934 path_bdev = lookup_bdev(path);
a9261d4125c97ce Anand Jain 2018-10-15 935 if (IS_ERR(path_bdev)) {
a9261d4125c97ce Anand Jain 2018-10-15 936 mutex_unlock(&fs_devices->device_list_mutex);
a9261d4125c97ce Anand Jain 2018-10-15 937 return ERR_CAST(path_bdev);
a9261d4125c97ce Anand Jain 2018-10-15 938 }
a9261d4125c97ce Anand Jain 2018-10-15 939
a9261d4125c97ce Anand Jain 2018-10-15 940 if (device->bdev != path_bdev) {
a9261d4125c97ce Anand Jain 2018-10-15 941 bdput(path_bdev);
a9261d4125c97ce Anand Jain 2018-10-15 942 mutex_unlock(&fs_devices->device_list_mutex);
a9261d4125c97ce Anand Jain 2018-10-15 943 btrfs_warn_in_rcu(device->fs_info,
79dae17d8d44b2d Anand Jain 2020-09-03 944 "duplicate device %s devid %llu generation %llu scanned by %s (%d)",
79dae17d8d44b2d Anand Jain 2020-09-03 945 path, devid, found_transid,
79dae17d8d44b2d Anand Jain 2020-09-03 946 current->comm,
79dae17d8d44b2d Anand Jain 2020-09-03 947 task_pid_nr(current));
a9261d4125c97ce Anand Jain 2018-10-15 948 return ERR_PTR(-EEXIST);
a9261d4125c97ce Anand Jain 2018-10-15 949 }
a9261d4125c97ce Anand Jain 2018-10-15 950 bdput(path_bdev);
a9261d4125c97ce Anand Jain 2018-10-15 951 btrfs_info_in_rcu(device->fs_info,
79dae17d8d44b2d Anand Jain 2020-09-03 952 "devid %llu device path %s changed to %s scanned by %s (%d)",
79dae17d8d44b2d Anand Jain 2020-09-03 953 devid, rcu_str_deref(device->name),
79dae17d8d44b2d Anand Jain 2020-09-03 954 path, current->comm,
79dae17d8d44b2d Anand Jain 2020-09-03 955 task_pid_nr(current));
a9261d4125c97ce Anand Jain 2018-10-15 956 }
a9261d4125c97ce Anand Jain 2018-10-15 957
606686eeac4550d Josef Bacik 2012-06-04 958 name = rcu_string_strdup(path, GFP_NOFS);
9c6d173ea6e4c8c Anand Jain 2018-05-29 959 if (!name) {
9c6d173ea6e4c8c Anand Jain 2018-05-29 960 mutex_unlock(&fs_devices->device_list_mutex);
e124ece53edf3a8 Anand Jain 2018-01-18 961 return ERR_PTR(-ENOMEM);
9c6d173ea6e4c8c Anand Jain 2018-05-29 962 }
606686eeac4550d Josef Bacik 2012-06-04 963 rcu_string_free(device->name);
606686eeac4550d Josef Bacik 2012-06-04 964 rcu_assign_pointer(device->name, name);
e6e674bd4d54fe8 Anand Jain 2017-12-04 965 if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) {
cd02dca56442e15 Chris Mason 2010-12-13 966 fs_devices->missing_devices--;
e6e674bd4d54fe8 Anand Jain 2017-12-04 967 clear_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);
cd02dca56442e15 Chris Mason 2010-12-13 968 }
8a4b83cc8bd75fc Chris Mason 2008-03-24 969 }
8a4b83cc8bd75fc Chris Mason 2008-03-24 970
77bdae4d136e167 Anand Jain 2014-07-03 971 /*
77bdae4d136e167 Anand Jain 2014-07-03 972 * Unmount does not free the btrfs_device struct but would zero
77bdae4d136e167 Anand Jain 2014-07-03 973 * generation along with most of the other members. So just update
77bdae4d136e167 Anand Jain 2014-07-03 974 * it back. We need it to pick the disk with largest generation
77bdae4d136e167 Anand Jain 2014-07-03 975 * (as above).
77bdae4d136e167 Anand Jain 2014-07-03 976 */
d1a63002829a4d8 Nikolay Borisov 2018-10-30 977 if (!fs_devices->opened) {
77bdae4d136e167 Anand Jain 2014-07-03 978 device->generation = found_transid;
d1a63002829a4d8 Nikolay Borisov 2018-10-30 979 fs_devices->latest_generation = max_t(u64, found_transid,
d1a63002829a4d8 Nikolay Borisov 2018-10-30 980 fs_devices->latest_generation);
d1a63002829a4d8 Nikolay Borisov 2018-10-30 981 }
77bdae4d136e167 Anand Jain 2014-07-03 982
f2788d2f76cafef Anand Jain 2018-01-18 983 fs_devices->total_devices = btrfs_super_num_devices(disk_super);
f2788d2f76cafef Anand Jain 2018-01-18 984
9c6d173ea6e4c8c Anand Jain 2018-05-29 985 mutex_unlock(&fs_devices->device_list_mutex);
e124ece53edf3a8 Anand Jain 2018-01-18 986 return device;
8a4b83cc8bd75fc Chris Mason 2008-03-24 987 }
8a4b83cc8bd75fc Chris Mason 2008-03-24 988

:::::: The code at line 888 was first introduced by commit
:::::: 606686eeac4550d2212bf3d621a810407ef5e9bf Btrfs: use rcu to protect device->name

:::::: TO: Josef Bacik <josef@xxxxxxxxxx>
:::::: CC: Chris Mason <chris.mason@xxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip