* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-01 6:52 ` [PATCH 3/3] bcache: support overlay bcache mingzhe.zou
@ 2023-02-01 17:31 ` kernel test robot
2023-02-01 18:02 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-02-01 17:31 UTC (permalink / raw)
To: mingzhe.zou, colyli, andrea.tomassetti-opensource, bcache
Cc: oe-kbuild-all, kent.overstreet, linux-bcache, zoumingzhe,
Dongsheng Yang, mingzhe
Hi,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc6 next-20230201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
patch link: https://lore.kernel.org/r/20230201065202.17610-3-mingzhe.zou%40easystack.cn
patch subject: [PATCH 3/3] bcache: support overlay bcache
config: alpha-randconfig-r026-20230129 (https://download.01.org/0day-ci/archive/20230202/202302020120.FNJ9XwCm-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/785b6ea709e3008e2df009d5555c80db709e6d5f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
git checkout 785b6ea709e3008e2df009d5555c80db709e6d5f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/md/bcache/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/md/bcache/super.c: In function 'register_bdev':
>> drivers/md/bcache/super.c:1475:41: error: implicit declaration of function 'part_to_dev'; did you mean 'part_devt'? [-Werror=implicit-function-declaration]
1475 | ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
| ^~~~~~~~~~~
| part_devt
>> drivers/md/bcache/super.c:1475:59: error: 'struct block_device' has no member named 'bd_part'; did you mean 'bd_partno'?
1475 | ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
| ^~~~~~~
| bd_partno
drivers/md/bcache/super.c: In function 'register_cache':
drivers/md/bcache/super.c:2403:59: error: 'struct block_device' has no member named 'bd_part'; did you mean 'bd_partno'?
2403 | ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
| ^~~~~~~
| bd_partno
cc1: some warnings being treated as errors
vim +1475 drivers/md/bcache/super.c
1453
1454 static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
1455 struct block_device *bdev,
1456 struct cached_dev *dc)
1457 {
1458 const char *err = "cannot allocate memory";
1459 struct cache_set *c;
1460 int ret = -ENOMEM;
1461
1462 memcpy(&dc->sb, sb, sizeof(struct cache_sb));
1463 dc->bdev = bdev;
1464 dc->bdev->bd_holder = dc;
1465 dc->sb_disk = sb_disk;
1466
1467 if (cached_dev_init(dc, sb->block_size << 9))
1468 goto err;
1469
1470 err = "error creating kobject";
1471 if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache_bdev"))
1472 goto err;
1473
1474 err = "error creating lagacy sysfs link";
> 1475 ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
1476 &dc->disk.kobj, "bcache");
1477 if (ret && ret != -EEXIST) {
1478 pr_err("Couldn't create lagacy disk sysfs ->bcache");
1479 goto err;
1480 }
1481
1482 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
1483 goto err;
1484
1485 pr_info("registered backing device %pg\n", dc->bdev);
1486
1487 list_add(&dc->list, &uncached_devices);
1488 /* attach to a matched cache set if it exists */
1489 list_for_each_entry(c, &bch_cache_sets, list)
1490 bch_cached_dev_attach(dc, c, NULL);
1491
1492 if (BDEV_STATE(&dc->sb) == BDEV_STATE_NONE ||
1493 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE) {
1494 err = "failed to run cached device";
1495 ret = bch_cached_dev_run(dc);
1496 if (ret)
1497 goto err;
1498 }
1499
1500 return 0;
1501 err:
1502 pr_notice("error %pg: %s\n", dc->bdev, err);
1503 bcache_device_stop(&dc->disk);
1504 return ret;
1505 }
1506
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-01 6:52 ` [PATCH 3/3] bcache: support overlay bcache mingzhe.zou
2023-02-01 17:31 ` kernel test robot
@ 2023-02-01 18:02 ` kernel test robot
2023-02-01 18:13 ` Eric Wheeler
2023-02-01 21:39 ` kernel test robot
3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-02-01 18:02 UTC (permalink / raw)
To: mingzhe.zou, colyli, andrea.tomassetti-opensource, bcache
Cc: llvm, oe-kbuild-all, kent.overstreet, linux-bcache, zoumingzhe,
Dongsheng Yang, mingzhe
Hi,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc6 next-20230201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
patch link: https://lore.kernel.org/r/20230201065202.17610-3-mingzhe.zou%40easystack.cn
patch subject: [PATCH 3/3] bcache: support overlay bcache
config: x86_64-randconfig-a014-20230130 (https://download.01.org/0day-ci/archive/20230202/202302020147.4HT8cQF3-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/785b6ea709e3008e2df009d5555c80db709e6d5f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
git checkout 785b6ea709e3008e2df009d5555c80db709e6d5f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/md/bcache/super.c:1475:34: error: implicit declaration of function 'part_to_dev' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
^
>> drivers/md/bcache/super.c:1475:62: error: member reference type 'int' is not a pointer
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
>> drivers/md/bcache/super.c:1475:52: error: no member named 'bd_part' in 'struct block_device'
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~ ^
drivers/md/bcache/super.c:2403:34: error: implicit declaration of function 'part_to_dev' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
^
drivers/md/bcache/super.c:2403:62: error: member reference type 'int' is not a pointer
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
drivers/md/bcache/super.c:2403:52: error: no member named 'bd_part' in 'struct block_device'
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~ ^
6 errors generated.
vim +/part_to_dev +1475 drivers/md/bcache/super.c
1453
1454 static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
1455 struct block_device *bdev,
1456 struct cached_dev *dc)
1457 {
1458 const char *err = "cannot allocate memory";
1459 struct cache_set *c;
1460 int ret = -ENOMEM;
1461
1462 memcpy(&dc->sb, sb, sizeof(struct cache_sb));
1463 dc->bdev = bdev;
1464 dc->bdev->bd_holder = dc;
1465 dc->sb_disk = sb_disk;
1466
1467 if (cached_dev_init(dc, sb->block_size << 9))
1468 goto err;
1469
1470 err = "error creating kobject";
1471 if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache_bdev"))
1472 goto err;
1473
1474 err = "error creating lagacy sysfs link";
> 1475 ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
1476 &dc->disk.kobj, "bcache");
1477 if (ret && ret != -EEXIST) {
1478 pr_err("Couldn't create lagacy disk sysfs ->bcache");
1479 goto err;
1480 }
1481
1482 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
1483 goto err;
1484
1485 pr_info("registered backing device %pg\n", dc->bdev);
1486
1487 list_add(&dc->list, &uncached_devices);
1488 /* attach to a matched cache set if it exists */
1489 list_for_each_entry(c, &bch_cache_sets, list)
1490 bch_cached_dev_attach(dc, c, NULL);
1491
1492 if (BDEV_STATE(&dc->sb) == BDEV_STATE_NONE ||
1493 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE) {
1494 err = "failed to run cached device";
1495 ret = bch_cached_dev_run(dc);
1496 if (ret)
1497 goto err;
1498 }
1499
1500 return 0;
1501 err:
1502 pr_notice("error %pg: %s\n", dc->bdev, err);
1503 bcache_device_stop(&dc->disk);
1504 return ret;
1505 }
1506
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-01 6:52 ` [PATCH 3/3] bcache: support overlay bcache mingzhe.zou
2023-02-01 17:31 ` kernel test robot
2023-02-01 18:02 ` kernel test robot
@ 2023-02-01 18:13 ` Eric Wheeler
2023-02-02 5:48 ` mingzhe
2023-02-01 21:39 ` kernel test robot
3 siblings, 1 reply; 10+ messages in thread
From: Eric Wheeler @ 2023-02-01 18:13 UTC (permalink / raw)
To: mingzhe
Cc: colyli, andrea.tomassetti-opensource, kent.overstreet,
linux-bcache, zoumingzhe, Dongsheng Yang
[-- Attachment #1: Type: text/plain, Size: 7151 bytes --]
On Wed, 1 Feb 2023, mingzhe.zou@easystack.cn wrote:
> From: Dongsheng Yang <dongsheng.yang@easystack.cn>
>
> If we want to build a bcache device with backing device of a bcache flash device,
> we will fail with creating a duplicated sysfs filename.
>
> E.g:
> (1) we create bcache0 with vdc, then there is "/sys/block/bcache0/bcache" as a link to "/sys/block/vdc/bcache"
> $ readlink /sys/block/bcache0/bcache
> ../../../pci0000:00/0000:00:0b.0/virtio4/block/vdc/bcache
>
> (2) if we continue to create bcache1 with bcache0:
> $ make-bcache -B /dev/bcache0
>
> We will fail to register bdev with "sysfs: cannot create duplicate
> filename '/devices/virtual/block/bcache0/bcache'"
>
> How this commit solving this problem?
> E.g:
> we have vdf as cache disk, vdc as backing disk.
>
> $ make-bcache -C /dev/vdf -B /dev/vdc --wipe-bcache
> $ echo 100G > /sys/block/vdf/bcache_cache/set/flash_vol_create
> $ lsblk
> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
> vdf 252:80 0 50G 0 disk
> ├─bcache0 251:0 0 100G 0 disk
> └─bcache1 251:128 0 100G 0 disk
> vdc 252:32 0 100G 0 disk
> └─bcache0 251:0 0 100G 0 disk
>
> (a) rename sysfs file to more meaningful name:
> (a.2) bcahce_cache -> sysfs filename under cache disk (/sys/block/vdf/bcache_cache)
> (a.1) bcache_fdev -> flash bcache device (/sys/block/bcache1/bcache_fdev)
> (a.4) bcache_bdev -> sysfs filename for backing disk (/sys/block/vdc/bcache_bdev)
> (a.3) bcache_cdev -> link to /sys/block/vdc/bcache_bdev (/sys/block/bcache0/bcache_cdev)
Good idea.
> (b) create ->bcache lagacy link file for backward compatability
> $ ll /sys/block/vdc/bcache
> lrwxrwxrwx 1 root root 0 Oct 26 11:21 /sys/block/vdc/bcache -> bcache_bdev
> $ ll /sys/block/bcache0/bcache
> lrwxrwxrwx 1 root root 0 Oct 26 11:21 /sys/block/bcache0/bcache -> ../../../pci0000:00/0000:00:0b.0/virtio4/block/vdc/bcache_bdev
> $ ll /sys/block/bcache1/bcache
> lrwxrwxrwx 1 root root 0 Oct 26 11:19 /sys/block/bcache1/bcache -> bcache_fdev
> $ ll /sys/block/vdf/bcache
> lrwxrwxrwx 1 root root 0 Oct 26 11:17 /sys/block/vdf/bcache -> bcache_cache
>
> These link are created with sysfs_create_link_nowarn(), that means, we dont
> care about the failure when creating if these links are already created.
> Because these lagacy sysfile are only for backwards compatability in no-overlay usecase
> of bcache, in the no-overlay use, bcache will never create duplicated link.
awesome.
> In overlay usecase after this commit, please dont use bcache link any more, instead
> use bcache_cdev, bcache_fdev, bcache_bdev or bcache_cache.
>
> Then we can create a cached_dev with bcache1 (flash dev) as backing dev.
> $ make-bcache -B /dev/bcache1
> $ lsblk
> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
> vdf 252:80 0 50G 0 disk
> ├─bcache0 251:0 0 100G 0 disk
> └─bcache1 251:128 0 100G 0 disk
> └─bcache2 251:256 0 100G 0 disk
>
> As a result there is a cached device bcache2 with backing device of a flash device bcache1.
> ----------------------------
> | bcache2 (cached_dev) |
> | ------------------------ |
> | | sdb (cache_dev) | |
> | ------------------------ |
> | ------------------------ |
> | | bcache1 (flash_dev)| |
> | ------------------------ |
> ----------------------------
Does this allow an arbitrary depth of bcache stacking?
-Eric
>
> Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
> Signed-off-by: mingzhe <mingzhe.zou@easystack.cn>
> ---
> drivers/md/bcache/super.c | 40 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index ba3909bb6bea..0ca8c05831c9 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1087,12 +1087,19 @@ int bch_cached_dev_run(struct cached_dev *dc)
>
> if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
> sysfs_create_link(&disk_to_dev(d->disk)->kobj,
> - &d->kobj, "bcache")) {
> + &d->kobj, "bcache_cdev")) {
> pr_err("Couldn't create bcache dev <-> disk sysfs symlinks\n");
> ret = -ENOMEM;
> goto out;
> }
>
> + ret = sysfs_create_link_nowarn(&disk_to_dev(d->disk)->kobj,
> + &d->kobj, "bcache");
> + if (ret && ret != -EEXIST) {
> + pr_err("Couldn't create lagacy disk sysfs ->bcache symlinks\n");
> + goto out;
> + }
> +
> dc->status_update_thread = kthread_run(cached_dev_status_update,
> dc, "bcache_status_update");
> if (IS_ERR(dc->status_update_thread)) {
> @@ -1461,8 +1468,17 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> goto err;
>
> err = "error creating kobject";
> - if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache"))
> + if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache_bdev"))
> goto err;
> +
> + err = "error creating lagacy sysfs link";
> + ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
> + &dc->disk.kobj, "bcache");
> + if (ret && ret != -EEXIST) {
> + pr_err("Couldn't create lagacy disk sysfs ->bcache");
> + goto err;
> + }
> +
> if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
> goto err;
>
> @@ -1524,6 +1540,7 @@ static void flash_dev_flush(struct closure *cl)
>
> static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
> {
> + int ret;
> int err = -ENOMEM;
> struct bcache_device *d = kzalloc(sizeof(struct bcache_device),
> GFP_KERNEL);
> @@ -1546,10 +1563,17 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
> if (err)
> goto err;
>
> - err = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache");
> + err = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache_fdev");
> if (err)
> goto err;
>
> + ret = sysfs_create_link_nowarn(&disk_to_dev(d->disk)->kobj,
> + &d->kobj, "bcache");
> + if (ret && ret != -EEXIST) {
> + pr_err("Couldn't create lagacy flash dev ->bcache");
> + goto err;
> + }
> +
> bcache_device_link(d, c, "volume");
>
> if (bch_has_feature_obso_large_bucket(&c->cache->sb)) {
> @@ -2370,12 +2394,20 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> goto err;
> }
>
> - if (kobject_add(&ca->kobj, bdev_kobj(bdev), "bcache")) {
> + if (kobject_add(&ca->kobj, bdev_kobj(bdev), "bcache_cache")) {
> err = "error calling kobject_add";
> ret = -ENOMEM;
> goto out;
> }
>
> + ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
> + &ca->kobj, "bcache");
> + if (ret && ret != -EEXIST) {
> + pr_err("Couldn't create lagacy disk sysfs ->cache symlinks\n");
> + goto out;
> + } else
> + ret = 0;
> +
> mutex_lock(&bch_register_lock);
> err = register_cache_set(ca);
> mutex_unlock(&bch_register_lock);
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-01 18:13 ` Eric Wheeler
@ 2023-02-02 5:48 ` mingzhe
2023-05-30 9:12 ` Cedric de Wijs
0 siblings, 1 reply; 10+ messages in thread
From: mingzhe @ 2023-02-02 5:48 UTC (permalink / raw)
To: Eric Wheeler
Cc: colyli, andrea.tomassetti-opensource, kent.overstreet,
linux-bcache, zoumingzhe, Dongsheng Yang
在 2023/2/2 02:13, Eric Wheeler 写道:
> On Wed, 1 Feb 2023, mingzhe.zou@easystack.cn wrote:
>> From: Dongsheng Yang <dongsheng.yang@easystack.cn>
>>
>> If we want to build a bcache device with backing device of a bcache flash device,
>> we will fail with creating a duplicated sysfs filename.
>>
>> E.g:
>> (1) we create bcache0 with vdc, then there is "/sys/block/bcache0/bcache" as a link to "/sys/block/vdc/bcache"
>> $ readlink /sys/block/bcache0/bcache
>> ../../../pci0000:00/0000:00:0b.0/virtio4/block/vdc/bcache
>>
>> (2) if we continue to create bcache1 with bcache0:
>> $ make-bcache -B /dev/bcache0
>>
>> We will fail to register bdev with "sysfs: cannot create duplicate
>> filename '/devices/virtual/block/bcache0/bcache'"
>>
>> How this commit solving this problem?
>> E.g:
>> we have vdf as cache disk, vdc as backing disk.
>>
>> $ make-bcache -C /dev/vdf -B /dev/vdc --wipe-bcache
>> $ echo 100G > /sys/block/vdf/bcache_cache/set/flash_vol_create
>> $ lsblk
>> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
>> vdf 252:80 0 50G 0 disk
>> ├─bcache0 251:0 0 100G 0 disk
>> └─bcache1 251:128 0 100G 0 disk
>> vdc 252:32 0 100G 0 disk
>> └─bcache0 251:0 0 100G 0 disk
>>
>> (a) rename sysfs file to more meaningful name:
>> (a.2) bcahce_cache -> sysfs filename under cache disk (/sys/block/vdf/bcache_cache)
>> (a.1) bcache_fdev -> flash bcache device (/sys/block/bcache1/bcache_fdev)
>> (a.4) bcache_bdev -> sysfs filename for backing disk (/sys/block/vdc/bcache_bdev)
>> (a.3) bcache_cdev -> link to /sys/block/vdc/bcache_bdev (/sys/block/bcache0/bcache_cdev)
>
> Good idea.
>
>> (b) create ->bcache lagacy link file for backward compatability
>> $ ll /sys/block/vdc/bcache
>> lrwxrwxrwx 1 root root 0 Oct 26 11:21 /sys/block/vdc/bcache -> bcache_bdev
>> $ ll /sys/block/bcache0/bcache
>> lrwxrwxrwx 1 root root 0 Oct 26 11:21 /sys/block/bcache0/bcache -> ../../../pci0000:00/0000:00:0b.0/virtio4/block/vdc/bcache_bdev
>> $ ll /sys/block/bcache1/bcache
>> lrwxrwxrwx 1 root root 0 Oct 26 11:19 /sys/block/bcache1/bcache -> bcache_fdev
>> $ ll /sys/block/vdf/bcache
>> lrwxrwxrwx 1 root root 0 Oct 26 11:17 /sys/block/vdf/bcache -> bcache_cache
>>
>> These link are created with sysfs_create_link_nowarn(), that means, we dont
>> care about the failure when creating if these links are already created.
>> Because these lagacy sysfile are only for backwards compatability in no-overlay usecase
>> of bcache, in the no-overlay use, bcache will never create duplicated link.
>
> awesome.
>
>> In overlay usecase after this commit, please dont use bcache link any more, instead
>> use bcache_cdev, bcache_fdev, bcache_bdev or bcache_cache.
>>
>> Then we can create a cached_dev with bcache1 (flash dev) as backing dev.
>> $ make-bcache -B /dev/bcache1
>> $ lsblk
>> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
>> vdf 252:80 0 50G 0 disk
>> ├─bcache0 251:0 0 100G 0 disk
>> └─bcache1 251:128 0 100G 0 disk
>> └─bcache2 251:256 0 100G 0 disk
>>
>> As a result there is a cached device bcache2 with backing device of a flash device bcache1.
>> ----------------------------
>> | bcache2 (cached_dev) |
>> | ------------------------ |
>> | | sdb (cache_dev) | |
>> | ------------------------ |
>> | ------------------------ |
>> | | bcache1 (flash_dev)| |
>> | ------------------------ |
>> ----------------------------
>
> Does this allow an arbitrary depth of bcache stacking?
>
> -Eric
>
More than 2 layers we did not test, but should be allowed.
mingzhe
>>
>> Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
>> Signed-off-by: mingzhe <mingzhe.zou@easystack.cn>
>> ---
>> drivers/md/bcache/super.c | 40 +++++++++++++++++++++++++++++++++++----
>> 1 file changed, 36 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>> index ba3909bb6bea..0ca8c05831c9 100644
>> --- a/drivers/md/bcache/super.c
>> +++ b/drivers/md/bcache/super.c
>> @@ -1087,12 +1087,19 @@ int bch_cached_dev_run(struct cached_dev *dc)
>>
>> if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
>> sysfs_create_link(&disk_to_dev(d->disk)->kobj,
>> - &d->kobj, "bcache")) {
>> + &d->kobj, "bcache_cdev")) {
>> pr_err("Couldn't create bcache dev <-> disk sysfs symlinks\n");
>> ret = -ENOMEM;
>> goto out;
>> }
>>
>> + ret = sysfs_create_link_nowarn(&disk_to_dev(d->disk)->kobj,
>> + &d->kobj, "bcache");
>> + if (ret && ret != -EEXIST) {
>> + pr_err("Couldn't create lagacy disk sysfs ->bcache symlinks\n");
>> + goto out;
>> + }
>> +
>> dc->status_update_thread = kthread_run(cached_dev_status_update,
>> dc, "bcache_status_update");
>> if (IS_ERR(dc->status_update_thread)) {
>> @@ -1461,8 +1468,17 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
>> goto err;
>>
>> err = "error creating kobject";
>> - if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache"))
>> + if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache_bdev"))
>> goto err;
>> +
>> + err = "error creating lagacy sysfs link";
>> + ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
>> + &dc->disk.kobj, "bcache");
>> + if (ret && ret != -EEXIST) {
>> + pr_err("Couldn't create lagacy disk sysfs ->bcache");
>> + goto err;
>> + }
>> +
>> if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
>> goto err;
>>
>> @@ -1524,6 +1540,7 @@ static void flash_dev_flush(struct closure *cl)
>>
>> static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
>> {
>> + int ret;
>> int err = -ENOMEM;
>> struct bcache_device *d = kzalloc(sizeof(struct bcache_device),
>> GFP_KERNEL);
>> @@ -1546,10 +1563,17 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
>> if (err)
>> goto err;
>>
>> - err = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache");
>> + err = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache_fdev");
>> if (err)
>> goto err;
>>
>> + ret = sysfs_create_link_nowarn(&disk_to_dev(d->disk)->kobj,
>> + &d->kobj, "bcache");
>> + if (ret && ret != -EEXIST) {
>> + pr_err("Couldn't create lagacy flash dev ->bcache");
>> + goto err;
>> + }
>> +
>> bcache_device_link(d, c, "volume");
>>
>> if (bch_has_feature_obso_large_bucket(&c->cache->sb)) {
>> @@ -2370,12 +2394,20 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
>> goto err;
>> }
>>
>> - if (kobject_add(&ca->kobj, bdev_kobj(bdev), "bcache")) {
>> + if (kobject_add(&ca->kobj, bdev_kobj(bdev), "bcache_cache")) {
>> err = "error calling kobject_add";
>> ret = -ENOMEM;
>> goto out;
>> }
>>
>> + ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
>> + &ca->kobj, "bcache");
>> + if (ret && ret != -EEXIST) {
>> + pr_err("Couldn't create lagacy disk sysfs ->cache symlinks\n");
>> + goto out;
>> + } else
>> + ret = 0;
>> +
>> mutex_lock(&bch_register_lock);
>> err = register_cache_set(ca);
>> mutex_unlock(&bch_register_lock);
>> --
>> 2.17.1
>>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-02 5:48 ` mingzhe
@ 2023-05-30 9:12 ` Cedric de Wijs
2023-05-30 10:32 ` Coly Li
0 siblings, 1 reply; 10+ messages in thread
From: Cedric de Wijs @ 2023-05-30 9:12 UTC (permalink / raw)
To: mingzhe, Eric Wheeler
Cc: cedric.dewijs, colyli, andrea.tomassetti-opensource,
kent.overstreet, linux-bcache, zoumingzhe, Dongsheng Yang
<snip>
>>>
>>> Then we can create a cached_dev with bcache1 (flash dev) as backing dev.
>>> $ make-bcache -B /dev/bcache1
>>> $ lsblk
>>> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
>>> vdf 252:80 0 50G 0 disk
>>> ├─bcache0 251:0 0 100G 0 disk
>>> └─bcache1 251:128 0 100G 0 disk
>>> └─bcache2 251:256 0 100G 0 disk
>>>
>>> As a result there is a cached device bcache2 with backing device of a
>>> flash device bcache1.
>>> ----------------------------
>>> | bcache2 (cached_dev) |
>>> | ------------------------ |
>>> | | sdb (cache_dev) | |
>>> | ------------------------ |
>>> | ------------------------ |
>>> | | bcache1 (flash_dev)| |
>>> | ------------------------ |
>>> ----------------------------
>>
>> Does this allow an arbitrary depth of bcache stacking?
>>
>> -Eric
>>
> More than 2 layers we did not test, but should be allowed.
>
> mingzhe
>>>
>>> Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
>>> Signed-off-by: mingzhe <mingzhe.zou@easystack.cn>
>>> ---
>>> drivers/md/bcache/super.c | 40 +++++++++++++++++++++++++++++++++++----
>>> 1 file changed, 36 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>>> index ba3909bb6bea..0ca8c05831c9 100644
>>> --- a/drivers/md/bcache/super.c
>>> +++ b/drivers/md/bcache/super.c
<snip>
Hi All,
I've not seen this commit appear in the mainline kernel yet. In 2023,
only this commit changed super.c in 2023:
2023-04-25 block/drivers: remove dead clear of random flag
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/drivers/md/bcache/super.c?h=v6.4-rc4
What's preventing this patch from going into the mainline kernel?
Cheers,
Cedric
_________________________________________________________________
________________________________________________________
Your E-Mail. Your Cloud. Your Office. eclipso Mail & Cloud. https://www.eclipso.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] bcache: support overlay bcache
2023-05-30 9:12 ` Cedric de Wijs
@ 2023-05-30 10:32 ` Coly Li
0 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2023-05-30 10:32 UTC (permalink / raw)
To: Cedric de Wijs
Cc: mingzhe, Eric Wheeler, Andrea Tomassetti, Kent Overstreet,
Bcache Linux, zoumingzhe, Dongsheng Yang
> 2023年5月30日 17:12,Cedric de Wijs <cedric.dewijs@eclipso.eu> 写道:
>
> <snip>
>>>>
>>>> Then we can create a cached_dev with bcache1 (flash dev) as backing dev.
>>>> $ make-bcache -B /dev/bcache1
>>>> $ lsblk
>>>> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
>>>> vdf 252:80 0 50G 0 disk
>>>> ├─bcache0 251:0 0 100G 0 disk
>>>> └─bcache1 251:128 0 100G 0 disk
>>>> └─bcache2 251:256 0 100G 0 disk
>>>>
>>>> As a result there is a cached device bcache2 with backing device of a flash device bcache1.
>>>> ----------------------------
>>>> | bcache2 (cached_dev) |
>>>> | ------------------------ |
>>>> | | sdb (cache_dev) | |
>>>> | ------------------------ |
>>>> | ------------------------ |
>>>> | | bcache1 (flash_dev)| |
>>>> | ------------------------ |
>>>> ----------------------------
>>>
>>> Does this allow an arbitrary depth of bcache stacking?
>>>
>>> -Eric
>>>
>> More than 2 layers we did not test, but should be allowed.
>> mingzhe
>>>>
>>>> Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
>>>> Signed-off-by: mingzhe <mingzhe.zou@easystack.cn>
>>>> ---
>>>> drivers/md/bcache/super.c | 40 +++++++++++++++++++++++++++++++++++----
>>>> 1 file changed, 36 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>>>> index ba3909bb6bea..0ca8c05831c9 100644
>>>> --- a/drivers/md/bcache/super.c
>>>> +++ b/drivers/md/bcache/super.c
> <snip>
>
> Hi All,
>
> I've not seen this commit appear in the mainline kernel yet. In 2023, only this commit changed super.c in 2023:
> 2023-04-25 block/drivers: remove dead clear of random flag
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/drivers/md/bcache/super.c?h=v6.4-rc4
>
> What's preventing this patch from going into the mainline kernel?
Code reviewer is the bottleneck. This series is in my todo list, but not on it yet. If Junhui Tang, or Guoju Fang may help to review the code, it can be a bit faster.
Of course if Kent reviews the code and supportive, I will take it immediately.
Thanks.
Coly Li
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] bcache: support overlay bcache
2023-02-01 6:52 ` [PATCH 3/3] bcache: support overlay bcache mingzhe.zou
` (2 preceding siblings ...)
2023-02-01 18:13 ` Eric Wheeler
@ 2023-02-01 21:39 ` kernel test robot
3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-02-01 21:39 UTC (permalink / raw)
To: mingzhe.zou, colyli, andrea.tomassetti-opensource, bcache
Cc: llvm, oe-kbuild-all, kent.overstreet, linux-bcache, zoumingzhe,
Dongsheng Yang, mingzhe
Hi,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc6 next-20230201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
patch link: https://lore.kernel.org/r/20230201065202.17610-3-mingzhe.zou%40easystack.cn
patch subject: [PATCH 3/3] bcache: support overlay bcache
config: riscv-randconfig-r042-20230130 (https://download.01.org/0day-ci/archive/20230202/202302020507.y0NPeWHf-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 4196ca3278f78c6e19246e54ab0ecb364e37d66a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/785b6ea709e3008e2df009d5555c80db709e6d5f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review mingzhe-zou-easystack-cn/bcache-submit-writeback-inflight-dirty-writes-in-batch/20230201-145421
git checkout 785b6ea709e3008e2df009d5555c80db709e6d5f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/md/bcache/super.c:1475:34: error: call to undeclared function 'part_to_dev'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
^
drivers/md/bcache/super.c:1475:62: error: member reference type 'int' is not a pointer
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
drivers/md/bcache/super.c:1475:52: error: no member named 'bd_part' in 'struct block_device'
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~ ^
drivers/md/bcache/super.c:2403:34: error: call to undeclared function 'part_to_dev'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
^
drivers/md/bcache/super.c:2403:62: error: member reference type 'int' is not a pointer
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
drivers/md/bcache/super.c:2403:52: error: no member named 'bd_part' in 'struct block_device'
ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
~~~~ ^
6 errors generated.
vim +/part_to_dev +1475 drivers/md/bcache/super.c
1453
1454 static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
1455 struct block_device *bdev,
1456 struct cached_dev *dc)
1457 {
1458 const char *err = "cannot allocate memory";
1459 struct cache_set *c;
1460 int ret = -ENOMEM;
1461
1462 memcpy(&dc->sb, sb, sizeof(struct cache_sb));
1463 dc->bdev = bdev;
1464 dc->bdev->bd_holder = dc;
1465 dc->sb_disk = sb_disk;
1466
1467 if (cached_dev_init(dc, sb->block_size << 9))
1468 goto err;
1469
1470 err = "error creating kobject";
1471 if (kobject_add(&dc->disk.kobj, bdev_kobj(bdev), "bcache_bdev"))
1472 goto err;
1473
1474 err = "error creating lagacy sysfs link";
> 1475 ret = sysfs_create_link_nowarn(&part_to_dev(bdev->bd_part)->kobj,
1476 &dc->disk.kobj, "bcache");
1477 if (ret && ret != -EEXIST) {
1478 pr_err("Couldn't create lagacy disk sysfs ->bcache");
1479 goto err;
1480 }
1481
1482 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
1483 goto err;
1484
1485 pr_info("registered backing device %pg\n", dc->bdev);
1486
1487 list_add(&dc->list, &uncached_devices);
1488 /* attach to a matched cache set if it exists */
1489 list_for_each_entry(c, &bch_cache_sets, list)
1490 bch_cached_dev_attach(dc, c, NULL);
1491
1492 if (BDEV_STATE(&dc->sb) == BDEV_STATE_NONE ||
1493 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE) {
1494 err = "failed to run cached device";
1495 ret = bch_cached_dev_run(dc);
1496 if (ret)
1497 goto err;
1498 }
1499
1500 return 0;
1501 err:
1502 pr_notice("error %pg: %s\n", dc->bdev, err);
1503 bcache_device_stop(&dc->disk);
1504 return ret;
1505 }
1506
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread