Not allowing the deletion of snapshots if its in use
Currently, the gluster volume snapshots can be accessed via 2 methods
-
Mounting of the gluster snapshot (gluster snapshot is logically a gluster volume itself with the lvm snapshots of the original bricks considered as the bricks for the snapshot)
-
User Serviceable Snapshots (Where all the active snapshots of a volume can be accessed via the mount point)
-
We have issues where, if a snapshot is being accessed (say a file is opened) via either of the above methods, is to be deleted. The glusterd which mainly controls the creation, maintenance and deletion of the snapshots will try to unmount the snapshot volume's brick and remove the logical volume associated with the snapshot. But a reference to a file in the snapshot can lead to umount of the snapshot brick being failed (Please correct me if I am wrong). This might lead to snapshot not being completely deleted.
-
Another issue is when a file in a snapshot is opened via user serviceable snapshots and later, the snapshot is deleted. But, with this the data structures associated with that snapshot for USS will be freed (things such as fds, inodes, glfs structures etc). Later a access to such a open file via the mount point will create problems when such requests come to the snap daemon.
The proposal here is to maintain some kind of refcount or reference to the snapshot data structure in the glusterd code. A reference will be held on such snapshot structures whenever they are either mounted via fuse OR made available via USS. This will prevent deletion of the snapshots in such incidents and prevent later problems. We can have a force option if someone wants to delete the snapshot despite being either mounted or accessed via USS.
Might need some more thoughts. This is just a idea to check if something like this can be done or not
Thank you for your contributions. Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity. It will be closed in 2 weeks if no one responds with a comment here.
Closing this issue as there was no update since my last update on issue. If this is an issue which is still valid, feel free to open it.