> 2023年1月25日 18:07,Andrea Tomassetti <andrea.tomassetti-opensource@xxxxxxxx> 写道: > > On Tue, Jan 17, 2023 at 5:18 PM Coly Li <colyli@xxxxxxx> wrote: >>> >>>> >>>>> struct async_reg_args { >>>>> struct delayed_work reg_work; >>>>> char *path; >>>>> @@ -2569,7 +2639,10 @@ static ssize_t register_bcache(struct kobject >>>>> *k, struct kobj_attribute *attr, >>>>> mutex_lock(&bch_register_lock); >>>>> if (lookup_bdev(strim(path), &dev) == 0 && >>>>> bch_is_open(dev)) >>>>> - err = "device already registered"; >>>>> + if (bch_update_capacity(dev)) >>>>> + err = "capacity changed"; >>>>> + else >>>>> + err = "device already registered"; >>>> >>>> >>>> As I said, it should be a separated write-only sysfile under the cache >>>> device's directory. >>> Can I ask why you don't like the automatic resize way? Why should the >>> resize be manual? >> >> Most of system administrators don’t like such silently automatic things. They want to extend the size explicitly, especially when there is other dependences in their configurations. >> > What I was trying to say is that, in order to resize a block device, a > manual command should be executed. So, this is already a "non-silent" > automatic thing. > Moreover, if the block device has a FS on it, the FS needs to be > manually grown with some special utilities, e.g. xfs_growfs. So, > again, another non-silent automatic step. Don't you agree? > For example, to resize a qcow device attached to a VM I'm manually > doing a `virsh blockresize`. As soon as I issue that command, the > virtio_blk driver inside the VM detects the disk size change and calls > the `set_capacity_and_notify` function. Why then should bcache behave > differently? The above VM example makes sense, I am almost convinced. > > If you're concerned that this can somehow break the > behaviour-compatibility with older versions of the driver, can we > protect this automatic discovery with an optional parameter? Will this > be an option you will take into account? Then let’s forget the option sysfs at this moment. Once you feel the patch is ready for me to testing, please notice me with detailed steps to redo your testing. At that time during my testing, let’s discuss whether an extra option is necesssary, for now just keep your idea as automatically resize the cached device. Thanks for your detailed explanation. Coly Li