Nir Soffer has uploaded a new change for review.
Change subject: mount: Support NFS4 mounts with double slash
......................................................................
mount: Support NFS4 mounts with double slash
With NFS4, the kernel may present fs_spec using double slashes [1]:
noveria.wodel.wd://vmengine
Instead of the original (normalized) mount path:
noveria.wodel.wd:/vmengine
According to [2], this is unlikely to be fixed in the near future.
This patch normalizes fs_spec read from /proc/mounts, restoring
Mount.isMounted() with NFS4.
[1]
http://lists.ovirt.org/pipermail/users/2016-July/041519.html
[2]
http://www.spinics.net/lists/util-linux-ng/msg13079.html
Change-Id: Iee85efb6aaff5d3fe887d11d7c4a5045ae72ea57
Reported-By: wodel youchi <wodel.youchi(a)gmail.com>
Bug-Url: XXX
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/storage/mount.py
M tests/mountTests.py
2 files changed, 21 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/61579/1
diff --git a/lib/vdsm/storage/mount.py b/lib/vdsm/storage/mount.py
index da1179e..dd54225 100644
--- a/lib/vdsm/storage/mount.py
+++ b/lib/vdsm/storage/mount.py
@@ -35,6 +35,8 @@
from vdsm import supervdsm
from vdsm import utils
+from vdsm.storage import fileUtils
+
# Common vfs types
VFS_NFS = "nfs"
@@ -58,9 +60,11 @@
fs_freq = int(fs_freq)
fs_passno = int(fs_passno)
- # We expect normalized inputs for
- # fs_spec and fs_file from the kernel.
- fs_spec = _parseFstabPath(fs_spec)
+ # Using NFS4 the kernel shows the mount path with double slashes,
+ # regarless of the original (normalized) mount path.
+ fs_spec = fileUtils.normalize_path(_parseFstabPath(fs_spec))
+
+ # We expect normalized fs_file from the kernel.
fs_file = _parseFstabPath(fs_file)
for suffix in (" (deleted)", ):
if not fs_file.endswith(suffix):
diff --git a/tests/mountTests.py b/tests/mountTests.py
index 0133a3f..3b49b84 100644
--- a/tests/mountTests.py
+++ b/tests/mountTests.py
@@ -184,6 +184,20 @@
mnt = mount.Mount(fs_spec, fs_file)
self.assertEqual(mnt.isMounted(), equality)
+ @permutations([
+ # NFS4 using fsid=0 - kernel display mount as server://path instead of
+ # normalized server:/path
+ (b"server://a/b /mnt/server:_a_b nfs defaults 0 0",),
+
+ # Not seen yet, but it should work now
+ (b"server:/a//b /mnt/server:_a_b nfs defaults 0 0",),
+ (b"server:/a/b// /mnt/server:_a_b nfs defaults 0 0",),
+ ])
+ def test_is_mounted_normalize_kernel_mounts(self, mount_line):
+ with fake_mounts([mount_line]):
+ mnt = mount.Mount("server:/a/b", "/mnt/server:_a_b")
+ self.assertTrue(mnt.isMounted())
+
def test_is_mounted_with_symlink(self):
with namedTemporaryDir() as dir:
file = os.path.join(dir, "file")
--
To view, visit
https://gerrit.ovirt.org/61579
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee85efb6aaff5d3fe887d11d7c4a5045ae72ea57
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>