This patch adds new field m_fsid to filesystem configuration structure
to identify which filesystem (zfs, rofs, etc) given vnode belongs to.
This becomes necessary to properly refactor logic in pagecache.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
---
 .../opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 10 ++++++----
 fs/vfs/vfs.h                                   |  9 +++++++++
 fs/vfs/vfs_conf.cc                             | 18 +++++++++---------
 fs/vfs/vfs_mount.cc                            |  1 +
 include/osv/mount.h                            |  1 +
 5 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c 
b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
index cd08ff4f..d79e0360 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
@@ -1005,11 +1005,13 @@ zfs_domount(vfs_t *vfsp, const char *osname)
         * The 8-bit fs type must be put in the low bits of fsid[1]
         * because that's where other Solaris filesystems put it.
         */
-       fsid_guid = dmu_objset_fsid_guid(zfsvfs->z_os);
-       ASSERT((fsid_guid & ~((1ULL<<56)-1)) == 0);
-       vfsp->vfs_fsid.__val[0] = fsid_guid;
+       //DISABLE the logic below to make sure that vfs_fsid
+       //is static and stays the same as it is set in config
+       //fsid_guid = dmu_objset_fsid_guid(zfsvfs->z_os);
+       //ASSERT((fsid_guid & ~((1ULL<<56)-1)) == 0);
+       //vfsp->vfs_fsid.__val[0] = fsid_guid;
        /* fsid type not included */
-       vfsp->vfs_fsid.__val[1] = fsid_guid >> 32;
+       //vfsp->vfs_fsid.__val[1] = fsid_guid >> 32;
 
        /*
         * Set features for file system.
diff --git a/fs/vfs/vfs.h b/fs/vfs/vfs.h
index d86ef957..ef165a62 100644
--- a/fs/vfs/vfs.h
+++ b/fs/vfs/vfs.h
@@ -76,6 +76,15 @@ extern int vfs_debug;
 
 #define OPEN_MAX       256
 
+#define RAMFS_ID    1
+#define DEVFS_ID    2
+#define NFS_ID      3
+#define PROCFS_ID   4
+#define SYSFS_ID    5
+#define ZFS_ID      6
+#define ROFS_ID     7
+#define VIRTIOFS_ID 8
+
 /*
  * per task data
  */
diff --git a/fs/vfs/vfs_conf.cc b/fs/vfs/vfs_conf.cc
index 4a54cb97..1976092b 100644
--- a/fs/vfs/vfs_conf.cc
+++ b/fs/vfs/vfs_conf.cc
@@ -67,13 +67,13 @@ extern "C" int zfs_init(void);
  * VFS switch table
  */
 const struct vfssw vfssw[] = {
-       {"ramfs",       ramfs_init,     &ramfs_vfsops},
-       {"devfs",       devfs_init,     &devfs_vfsops},
-       {"nfs",         nfs_init,       &nfs_vfsops},
-       {"procfs",      procfs_init,    &procfs_vfsops},
-       {"sysfs",       sysfs_init,     &sysfs_vfsops},
-       {"zfs",         zfs_init,       &zfs_vfsops},
-       {"rofs",        rofs_init,      &rofs_vfsops},
-       {"virtiofs",    virtiofs_init,  &virtiofs_vfsops},
-       {nullptr,       fs_noop,        nullptr},
+       {{0, RAMFS_ID}, "ramfs",        ramfs_init,     &ramfs_vfsops},
+       {{0, DEVFS_ID}, "devfs",        devfs_init,     &devfs_vfsops},
+       {{0, NFS_ID}, "nfs",            nfs_init,       &nfs_vfsops},
+       {{0, PROCFS_ID}, "procfs",      procfs_init,    &procfs_vfsops},
+       {{0, SYSFS_ID}, "sysfs",        sysfs_init,     &sysfs_vfsops},
+       {{0, ZFS_ID}, "zfs",            zfs_init,       &zfs_vfsops},
+       {{0, ROFS_ID}, "rofs",  rofs_init,      &rofs_vfsops},
+       {{0, VIRTIOFS_ID}, "virtiofs",  virtiofs_init,  &virtiofs_vfsops},
+       {{0, 0}, nullptr,       fs_noop,        nullptr},
 };
diff --git a/fs/vfs/vfs_mount.cc b/fs/vfs/vfs_mount.cc
index dac4d09c..bcc9568a 100644
--- a/fs/vfs/vfs_mount.cc
+++ b/fs/vfs/vfs_mount.cc
@@ -147,6 +147,7 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
     mp->m_flags = flags;
     mp->m_dev = device;
     mp->m_data = nullptr;
+    mp->m_fsid = fs->m_fsid;
     strlcpy(mp->m_path, dir, sizeof(mp->m_path));
     strlcpy(mp->m_special, dev, sizeof(mp->m_special));
 
diff --git a/include/osv/mount.h b/include/osv/mount.h
index 7268d8ce..99eb8766 100755
--- a/include/osv/mount.h
+++ b/include/osv/mount.h
@@ -102,6 +102,7 @@ struct mount {
  * Filesystem type switch table.
  */
 struct vfssw {
+       fsid_t          m_fsid; /* filesystem id */
        const char      *vs_name;       /* name of file system */
        int             (*vs_init)(void); /* initialize routine */
        struct vfsops   *vs_op;         /* pointer to vfs operation */
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20200404045846.27854-1-jwkozaczuk%40gmail.com.

Reply via email to