mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virfile: Detect ceph as shared FS
https://bugzilla.redhat.com/show_bug.cgi?id=1665553 Ceph can be mounted just like any other filesystem and in fact is a shared and cluster filesystem. The filesystem magic constant was taken from kernel sources as it is not in magic.h yet. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
@@ -3465,6 +3465,9 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
|
|||||||
# ifndef FUSE_SUPER_MAGIC
|
# ifndef FUSE_SUPER_MAGIC
|
||||||
# define FUSE_SUPER_MAGIC 0x65735546
|
# define FUSE_SUPER_MAGIC 0x65735546
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef CEPH_SUPER_MAGIC
|
||||||
|
# define CEPH_SUPER_MAGIC 0x00C36400
|
||||||
|
# endif
|
||||||
|
|
||||||
# define PROC_MOUNTS "/proc/mounts"
|
# define PROC_MOUNTS "/proc/mounts"
|
||||||
|
|
||||||
@@ -3607,6 +3610,9 @@ virFileIsSharedFSType(const char *path,
|
|||||||
if ((fstypes & VIR_FILE_SHFS_CIFS) &&
|
if ((fstypes & VIR_FILE_SHFS_CIFS) &&
|
||||||
(f_type == CIFS_SUPER_MAGIC))
|
(f_type == CIFS_SUPER_MAGIC))
|
||||||
return 1;
|
return 1;
|
||||||
|
if ((fstypes & VIR_FILE_SHFS_CEPH) &&
|
||||||
|
(f_type == CEPH_SUPER_MAGIC))
|
||||||
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3769,7 +3775,8 @@ int virFileIsSharedFS(const char *path)
|
|||||||
VIR_FILE_SHFS_OCFS |
|
VIR_FILE_SHFS_OCFS |
|
||||||
VIR_FILE_SHFS_AFS |
|
VIR_FILE_SHFS_AFS |
|
||||||
VIR_FILE_SHFS_SMB |
|
VIR_FILE_SHFS_SMB |
|
||||||
VIR_FILE_SHFS_CIFS);
|
VIR_FILE_SHFS_CIFS |
|
||||||
|
VIR_FILE_SHFS_CEPH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ enum {
|
|||||||
VIR_FILE_SHFS_AFS = (1 << 3),
|
VIR_FILE_SHFS_AFS = (1 << 3),
|
||||||
VIR_FILE_SHFS_SMB = (1 << 4),
|
VIR_FILE_SHFS_SMB = (1 << 4),
|
||||||
VIR_FILE_SHFS_CIFS = (1 << 5),
|
VIR_FILE_SHFS_CIFS = (1 << 5),
|
||||||
|
VIR_FILE_SHFS_CEPH = (1 << 6),
|
||||||
};
|
};
|
||||||
|
|
||||||
int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL(1);
|
int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL(1);
|
||||||
|
|||||||
@@ -1357,7 +1357,8 @@ int virStorageFileIsClusterFS(const char *path)
|
|||||||
*/
|
*/
|
||||||
return virFileIsSharedFSType(path,
|
return virFileIsSharedFSType(path,
|
||||||
VIR_FILE_SHFS_GFS2 |
|
VIR_FILE_SHFS_GFS2 |
|
||||||
VIR_FILE_SHFS_OCFS);
|
VIR_FILE_SHFS_OCFS |
|
||||||
|
VIR_FILE_SHFS_CEPH);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LVS
|
#ifdef LVS
|
||||||
|
|||||||
@@ -33,3 +33,5 @@ host:/nfs /nfs nfs4 rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,
|
|||||||
dev /nfs/blah devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=4093060,mode=755 0 0
|
dev /nfs/blah devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=4093060,mode=755 0 0
|
||||||
host:/gv0 /gluster fuse.glusterfs rw 0 0
|
host:/gv0 /gluster fuse.glusterfs rw 0 0
|
||||||
root@host:/tmp/mkdir /gluster/sshfs fuse.sshfs rw 0 0
|
root@host:/tmp/mkdir /gluster/sshfs fuse.sshfs rw 0 0
|
||||||
|
192.168.0.1:/ceph/data /ceph ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
|
||||||
|
192.168.0.1,192.168.0.2,192.168.0.3:/ceph/data2 /ceph/multi ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ setmntent(const char *filename, const char *type)
|
|||||||
#ifndef FUSE_SUPER_MAGIC
|
#ifndef FUSE_SUPER_MAGIC
|
||||||
# define FUSE_SUPER_MAGIC 0x65735546
|
# define FUSE_SUPER_MAGIC 0x65735546
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef CEPH_SUPER_MAGIC
|
||||||
|
# define CEPH_SUPER_MAGIC 0x00c36400
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -132,6 +135,8 @@ statfs_mock(const char *mtab,
|
|||||||
ftype = CIFS_SUPER_MAGIC;
|
ftype = CIFS_SUPER_MAGIC;
|
||||||
} else if (STRPREFIX(mb.mnt_type, "fuse")) {
|
} else if (STRPREFIX(mb.mnt_type, "fuse")) {
|
||||||
ftype = FUSE_SUPER_MAGIC;
|
ftype = FUSE_SUPER_MAGIC;
|
||||||
|
} else if (STRPREFIX(mb.mnt_type, "ceph")) {
|
||||||
|
ftype = CEPH_SUPER_MAGIC;
|
||||||
} else {
|
} else {
|
||||||
/* Everything else is EXT4. We don't care really for other paths. */
|
/* Everything else is EXT4. We don't care really for other paths. */
|
||||||
ftype = EXT4_SUPER_MAGIC;
|
ftype = EXT4_SUPER_MAGIC;
|
||||||
|
|||||||
@@ -455,6 +455,8 @@ mymain(void)
|
|||||||
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/file", true);
|
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/file", true);
|
||||||
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/sshfs/file", false);
|
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/sshfs/file", false);
|
||||||
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", true);
|
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", true);
|
||||||
|
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/file", true);
|
||||||
|
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/multi/file", true);
|
||||||
|
|
||||||
return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user