datto / dattobd

kernel module for taking block-level snapshots and incremental backups of Linux block devices
GNU General Public License v2.0
576 stars 122 forks source link

External device cannot be resumed #195

Open pomipomi opened 5 years ago

pomipomi commented 5 years ago

I'm using Ubuntu 16.04 and tried to backup for my external device. However, after setup-snapshot, the block device cannot be resumed if I plugged it out and plugin again.

Here is the following step:

  1. Plug in an external device (usb) as "/dev/sdc"
  2. mount "/dev/sdc", setup snapshot
  3. unmount "/dev/sdc"
  4. Plug out the external device and plug in again
  5. The device returned as block device "/dev/sdd"

It seems that the external device cannot go back to "/dev/sdc" because of datto is still using the resource or some other reason.

Is that possible to let the external drive back to "/dev/sdc" again with some other operation?

adnanshaheen commented 5 years ago

I think the device re-plug moving from sdc to sdd happens usually, and dattobd has nothing to do with it.

nixomose commented 5 years ago

yeah I don't think dattobd was designed to have its underlying device ripped out from under it. the snapshot device relies on the existence of the device it is snapshotting for non-cow reads. So likely if you tried to eject it, it would fail, because there's probably a reference count on that device that's not zero because dattobd has it. If you physically rip the usb device out, well, then you get what you have there, the virtual device still has references to it in dattobd. that's my guess anyway, tom can probably fill in more gruesome details.

pomipomi commented 5 years ago

I think the device re-plug moving from sdc to sdd happens usually, and dattobd has nothing to do with it.

However, the device cannot go back to "/dev/sdc" until I use datto destroy snapshot command to remove the original "/dev/sdc" snapshot and re-plug my removable device. That's why I guess that datto might still using "/dev/sdc".

And thanks for nixomose's reply.

tcaputi commented 5 years ago

Yeah, @nixomose is right. We could probably make this work with a bit of effort. I would think we would just need to call one of the bdev_put() functions on umount and then get it again on mount. It is a bit outside the original design spec, but we should try it at some point.