From b2e65d7d3d9f590f3f1d9d7851cbc1109e80220f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0afr=C3=A1nek?= Date: Thu, 19 Aug 2021 11:23:24 +0200 Subject: [PATCH] UPSTREAM: 1988374: Disable uuid checks on XFS (#1614) Add 'nouuid' mount option to all XFS mounts to be able to mount a volume and its restored snapshot on the same node. Without the option, such a mount fails, because XFS detects that two different volumes with the same filesystem UUID are being mounted. --- pkg/csi/cinder/nodeserver.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/csi/cinder/nodeserver.go b/pkg/csi/cinder/nodeserver.go index 525114264b..278eedcfec 100644 --- a/pkg/csi/cinder/nodeserver.go +++ b/pkg/csi/cinder/nodeserver.go @@ -213,7 +213,7 @@ func nodePublishEphemeral(req *csi.NodePublishVolumeRequest, ns *nodeServer) (*c fsType = mnt.FsType } mountFlags := mnt.GetMountFlags() - options = append(options, mountFlags...) + options = append(options, collectMountOptions(fsType, mountFlags)...) } // Mount err = m.Mounter().FormatAndMount(devicePath, targetPath, fsType, nil) @@ -402,7 +402,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol fsType = mnt.FsType } mountFlags := mnt.GetMountFlags() - options = append(options, mountFlags...) + options = append(options, collectMountOptions(fsType, mountFlags)...) } // Mount err = m.Mounter().FormatAndMount(devicePath, stagingTarget, fsType, options) @@ -601,3 +601,15 @@ func getDevicePath(volumeID string, m mount.IMount) (string, error) { return devicePath, nil } + +func collectMountOptions(fsType string, mntFlags []string) []string { + var options []string + options = append(options, mntFlags...) + + // By default, xfs does not allow mounting of two volumes with the same filesystem uuid. + // Force ignore this uuid to be able to mount volume + its clone / restored snapshot on the same node. + if fsType == "xfs" { + options = append(options, "nouuid") + } + return options +}