snpashots issues with other processes accessing the mounted brick snapshots
Hi,
By default, GlusterFS does mount even deactivated snapshot(s) under /run/gluster/snaps. Since we do have a mount, there is a possibility that some process may access the mount, causing issues when trying to umount the volume for instance when deleting the snapshot.
One of the workaround possible is to automatically umount all deactivated snapshot(s). But now the problem arises when trying to activate a snapshot(s). If the mount under /run/gluster/snaps is missing, activating the snapshot(s) will fail. Even the force option won't solve it.
We run into problems when deleting snapshot(s) if they are mounted (and some other process is accessing the snapshot brick), even if they are deactivated. On the other hand, if we umount the snapshot to resolve the first issue we run into an issue that the snapshot(s) can not be activated again.
Regards, Raghavendra
I looked at the code. Currently, we mount the snapshots in /run/gluster/snaps during snap creation and unmount them during deletion.
And yes, the current way can create problems, if some other process starts accessing those mounted brick snapshots. And as it was mentioned in the issue description, manually unmounting those brick snapshots can create problems while activating those snapshots (as currently activating the snapshots expect those brick snapshots to be mounted in /run/gluster/snaps)
I am thinking of the below solutions.
- Add umount of those brick snapshots in the snapshot deactivation code. And Add mounting of that snapshots during the activation (i.e. just add the umount and mount logic from snapshot delete and snapshot create sections)
"With the above method, the immediate question that came to me is what if someone accesses that mounted brick snapshots directly even when they are activated"? But I think if someone does that, we can give a warning (saying possible direct access to the brick snapshots) and fail the deactivate operation.
AND/OR
- have some kind of restriction for accessing those brick snapshots. Make sure that only glusterd (which acts only upon getting CLI requests) and brick processes (brick snapshot processes to be precise) can access those mounted brick snapshots. And any others trying to access that mounted brick snapshots should get error.
AND/OR
- Without making any of the above 2 changes, can we just do a lsof (or its equivalent) of the brick snapshot in snapshot_delete_prevalidate code and fail the delete snapshot if there are any active references. Same goes to activation also.
NOTE: Note that, with the options 1) and 3) we are still prone to some kind of problems when someone directly unmounts the brick snapshots (though we dont recommend it)
Please provide feedback.
Regards, Raghavendra
Option 1 above is faster to implement and makes some sense to me.
Option 2 is harder within filesystem. You can't implement restriction to applications. But one can do a chdir() and unmount the snap mount to prevent unwanted access (at least Quotad does it last I knew).
Option 3 is also fine, and will be better to let user know about having outside processes having access, and log it. So, as we don't support it, we will also get to know such things happened over the mount point. Btw, this with option 1 will be more complete solution (even though we can't restrict access).
Option 1 seems to me the most suitable available. As we don't expect a deactivated snapshot(s) to be available/mounted there should not be any problem. Once we active and thus mount it, we expect it to be accessed. Since an activated snapshot(s) can not be deleted, this should not cause any harm.
Certainly you will always have the issue, when umounting the share and something is accessing it, that it will fail. But here it's rather something that can be expected and thus resolved. But I still think we should warn the user and stop the deactivating process to allow stopping the processes and do a clean deactivation of the processes. To me, the biggest challenge here is the coordination of the task, check and deactivate activity across the different nodes in the gluster cluster. Since we need to maintain the same state on all systems, we need to check first if umount is working, and only if this works, proceed with the operation. But also for the following operation, we need to check if that works on all node and then proceed accordingly. Otherwise we might end-up with different states on different nodes, which can cause problems.
Option 2 is certainly also a way to go. But even when restricting permissions, you always have processes running as root and therefore can access the mount. I guess the question on whether this would be a suitable option or not depends on whether a snapshot(s) that is deactivated shall be mounted in general or not. Depending on that we should be able to design suitable solution.
Option 3 is certainly also possible. But here, you need to make sure that lsof is run correctly on every node in the gluster cluster and then return back the result to the user. Tricky part is to coordinate the effort on each node, have lsof made available via dependency and actually run the correct query to understand if something is accessing a snapshot(s) or not.
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: unmounting bricks during snap deactivation
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: unmounting bricks during snap deactivation
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: unmount bricks during snap deactivation
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: snpashots issues with other processes
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: snpashot issues with other processes access the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
One point to not here is, once a snapshot is restored to the parent volume, then the volume brick will be swapped with snapshot bricks. which means it will be mounted even if the volume is stopped. It is fine because even in case of volume delete we are not umounting the mount point via gluster code. The admin has to do it manually
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick
A patch https://review.gluster.org/18047 has been posted that references this issue. Commit message: snapshot: Issues with other processes accessing the mounted brick