Remove zfs_parse_bootfs() support
[zfs.git] / module / zfs / zfs_vfsops.c
index f68dde8..ef43312 100644 (file)
@@ -65,6 +65,7 @@
 #include <sys/sa.h>
 #include "zfs_comutil.h"
 
+#ifdef HAVE_ZPL
 int zfsfstype;
 vfsops_t *zfs_vfsops = NULL;
 static major_t zfs_major;
@@ -74,11 +75,7 @@ static kmutex_t      zfs_dev_mtx;
 extern int sys_shutdown;
 
 static int zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr);
-static int zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr);
 static int zfs_mountroot(vfs_t *vfsp, enum whymountroot);
-static int zfs_root(vfs_t *vfsp, vnode_t **vpp);
-static int zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp);
-static int zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp);
 static void zfs_freevfs(vfs_t *vfsp);
 
 static const fs_operation_def_t zfs_vfsops_template[] = {
@@ -166,7 +163,7 @@ zfs_sync(vfs_t *vfsp, short flag, cred_t *cr)
                }
 
                if (zfsvfs->z_log != NULL)
-                       zil_commit(zfsvfs->z_log, UINT64_MAX, 0);
+                       zil_commit(zfsvfs->z_log, 0);
 
                ZFS_EXIT(zfsvfs);
        } else {
@@ -180,6 +177,7 @@ zfs_sync(vfs_t *vfsp, short flag, cred_t *cr)
 
        return (0);
 }
+EXPORT_SYMBOL(zfs_sync);
 
 static int
 zfs_create_unique_device(dev_t *dev)
@@ -391,7 +389,7 @@ acl_inherit_changed_cb(void *arg, uint64_t newval)
        zfsvfs->z_acl_inherit = newval;
 }
 
-static int
+int
 zfs_register_callbacks(vfs_t *vfsp)
 {
        struct dsl_dataset *ds = NULL;
@@ -417,7 +415,8 @@ zfs_register_callbacks(vfs_t *vfsp)
         * of mount options, we stash away the current values and
         * restore them after we register the callbacks.
         */
-       if (vfs_optionisset(vfsp, MNTOPT_RO, NULL)) {
+       if (vfs_optionisset(vfsp, MNTOPT_RO, NULL) ||
+           !spa_writeable(dmu_objset_spa(os))) {
                readonly = B_TRUE;
                do_readonly = B_TRUE;
        } else if (vfs_optionisset(vfsp, MNTOPT_RW, NULL)) {
@@ -483,8 +482,8 @@ zfs_register_callbacks(vfs_t *vfsp)
                char osname[MAXNAMELEN];
 
                dmu_objset_name(os, osname);
-               if (error = dsl_prop_get_integer(osname, "nbmand", &nbmand,
-                   NULL)) {
+               if ((error = dsl_prop_get_integer(osname, "nbmand", &nbmand,
+                   NULL))) {
                        return (error);
                }
        }
@@ -559,6 +558,8 @@ unregister:
        return (error);
 
 }
+EXPORT_SYMBOL(zfs_register_callbacks);
+#endif /* HAVE_ZPL */
 
 static int
 zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
@@ -609,6 +610,7 @@ zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
        return (error);
 }
 
+#ifdef HAVE_ZPL
 static void
 fuidstr_to_sid(zfsvfs_t *zfsvfs, const char *fuidstr,
     char *domainbuf, int buflen, uid_t *ridp)
@@ -638,6 +640,8 @@ zfs_userquota_prop_to_obj(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type)
                return (zfsvfs->z_userquota_obj);
        case ZFS_PROP_GROUPQUOTA:
                return (zfsvfs->z_groupquota_obj);
+       default:
+               return (ENOTSUP);
        }
        return (0);
 }
@@ -683,6 +687,7 @@ zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
        zap_cursor_fini(&zc);
        return (error);
 }
+EXPORT_SYMBOL(zfs_userspace_many);
 
 /*
  * buf must be big enough (eg, 32 bytes)
@@ -730,6 +735,7 @@ zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
                err = 0;
        return (err);
 }
+EXPORT_SYMBOL(zfs_userspace_one);
 
 int
 zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
@@ -791,6 +797,7 @@ zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
        dmu_tx_commit(tx);
        return (err);
 }
+EXPORT_SYMBOL(zfs_set_userquota);
 
 boolean_t
 zfs_fuid_overquota(zfsvfs_t *zfsvfs, boolean_t isgroup, uint64_t fuid)
@@ -815,31 +822,24 @@ zfs_fuid_overquota(zfsvfs_t *zfsvfs, boolean_t isgroup, uint64_t fuid)
                return (B_FALSE);
        return (used >= quota);
 }
+EXPORT_SYMBOL(zfs_fuid_overquota);
 
 boolean_t
 zfs_owner_overquota(zfsvfs_t *zfsvfs, znode_t *zp, boolean_t isgroup)
 {
        uint64_t fuid;
        uint64_t quotaobj;
-       uid_t id;
 
        quotaobj = isgroup ? zfsvfs->z_groupquota_obj : zfsvfs->z_userquota_obj;
 
-       id = isgroup ? zp->z_gid : zp->z_uid;
+       fuid = isgroup ? zp->z_gid : zp->z_uid;
 
        if (quotaobj == 0 || zfsvfs->z_replay)
                return (B_FALSE);
 
-       if (IS_EPHEMERAL(id)) {
-               VERIFY(0 == sa_lookup(zp->z_sa_hdl,
-                   isgroup ? SA_ZPL_GID(zfsvfs) : SA_ZPL_UID(zfsvfs),
-                   &fuid, sizeof (fuid)));
-       } else {
-               fuid = (uint64_t)id;
-       }
-
        return (zfs_fuid_overquota(zfsvfs, isgroup, fuid));
 }
+EXPORT_SYMBOL(zfs_owner_overquota);
 
 int
 zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
@@ -878,7 +878,7 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
                goto out;
        } else if (zfsvfs->z_version >
            zfs_zpl_version_map(spa_version(dmu_objset_spa(os)))) {
-               (void) printf("Can't mount a version %lld file system "
+               (void) printk("Can't mount a version %lld file system "
                    "on a version %lld pool\n. Pool must be upgraded to mount "
                    "this file system.", (u_longlong_t)zfsvfs->z_version,
                    (u_longlong_t)spa_version(dmu_objset_spa(os)));
@@ -922,7 +922,10 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
                sa_obj = 0;
        }
 
-       zfsvfs->z_attr_table = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END);
+       error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
+           &zfsvfs->z_attr_table);
+       if (error)
+               goto out;
 
        if (zfsvfs->z_version >= ZPL_VERSION_SA)
                sa_register_update_callback(os, zfs_sa_upgrade);
@@ -1043,12 +1046,15 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
                 * allocated and in the unlinked set, and there is an
                 * intent log record saying to allocate it.
                 */
-               if (zil_replay_disable) {
-                       zil_destroy(zfsvfs->z_log, B_FALSE);
-               } else {
-                       zfsvfs->z_replay = B_TRUE;
-                       zil_replay(zfsvfs->z_os, zfsvfs, zfs_replay_vector);
-                       zfsvfs->z_replay = B_FALSE;
+               if (spa_writeable(dmu_objset_spa(zfsvfs->z_os))) {
+                       if (zil_replay_disable) {
+                               zil_destroy(zfsvfs->z_log, B_FALSE);
+                       } else {
+                               zfsvfs->z_replay = B_TRUE;
+                               zil_replay(zfsvfs->z_os, zfsvfs,
+                                   zfs_replay_vector);
+                               zfsvfs->z_replay = B_FALSE;
+                       }
                }
                zfsvfs->z_vfs->vfs_flag |= readonly; /* restore readonly bit */
        }
@@ -1099,7 +1105,7 @@ zfs_set_fuid_feature(zfsvfs_t *zfsvfs)
        zfsvfs->z_use_sa = USE_SA(zfsvfs->z_version, zfsvfs->z_os);
 }
 
-static int
+int
 zfs_domount(vfs_t *vfsp, char *osname)
 {
        dev_t mount_dev;
@@ -1125,8 +1131,8 @@ zfs_domount(vfs_t *vfsp, char *osname)
        }
        ASSERT(vfs_devismounted(mount_dev) == 0);
 
-       if (error = dsl_prop_get_integer(osname, "recordsize", &recordsize,
-           NULL))
+       if ((error = dsl_prop_get_integer(osname, "recordsize",
+           &recordsize, NULL)))
                goto out;
 
        vfsp->vfs_dev = mount_dev;
@@ -1168,10 +1174,11 @@ zfs_domount(vfs_t *vfsp, char *osname)
 
                atime_changed_cb(zfsvfs, B_FALSE);
                readonly_changed_cb(zfsvfs, B_TRUE);
-               if (error = dsl_prop_get_integer(osname, "xattr", &pval, NULL))
+               if ((error = dsl_prop_get_integer(osname,"xattr",&pval,NULL)))
                        goto out;
                xattr_changed_cb(zfsvfs, pval);
                zfsvfs->z_issnap = B_TRUE;
+               zfsvfs->z_os->os_sync = ZFS_SYNC_DISABLED;
 
                mutex_enter(&zfsvfs->z_os->os_user_ptr_lock);
                dmu_objset_set_user(zfsvfs->z_os, zfsvfs);
@@ -1192,6 +1199,7 @@ out:
 
        return (error);
 }
+EXPORT_SYMBOL(zfs_domount);
 
 void
 zfs_unregister_callbacks(zfsvfs_t *zfsvfs)
@@ -1235,62 +1243,9 @@ zfs_unregister_callbacks(zfsvfs_t *zfsvfs)
                    vscan_changed_cb, zfsvfs) == 0);
        }
 }
+EXPORT_SYMBOL(zfs_unregister_callbacks);
 
-/*
- * Convert a decimal digit string to a uint64_t integer.
- */
-static int
-str_to_uint64(char *str, uint64_t *objnum)
-{
-       uint64_t num = 0;
-
-       while (*str) {
-               if (*str < '0' || *str > '9')
-                       return (EINVAL);
-
-               num = num*10 + *str++ - '0';
-       }
-
-       *objnum = num;
-       return (0);
-}
-
-/*
- * The boot path passed from the boot loader is in the form of
- * "rootpool-name/root-filesystem-object-number'. Convert this
- * string to a dataset name: "rootpool-name/root-filesystem-name".
- */
-static int
-zfs_parse_bootfs(char *bpath, char *outpath)
-{
-       char *slashp;
-       uint64_t objnum;
-       int error;
-
-       if (*bpath == 0 || *bpath == '/')
-               return (EINVAL);
-
-       (void) strcpy(outpath, bpath);
-
-       slashp = strchr(bpath, '/');
-
-       /* if no '/', just return the pool name */
-       if (slashp == NULL) {
-               return (0);
-       }
-
-       /* if not a number, just return the root dataset name */
-       if (str_to_uint64(slashp+1, &objnum)) {
-               return (0);
-       }
-
-       *slashp = '\0';
-       error = dsl_dsobj_to_dsname(bpath, objnum, outpath);
-       *slashp = '/';
-
-       return (error);
-}
-
+#ifdef HAVE_MLSLABEL
 /*
  * zfs_check_global_label:
  *     Check that the hex label string is appropriate for the dataset
@@ -1318,6 +1273,7 @@ zfs_check_global_label(const char *dsname, const char *hexsl)
        }
        return (EACCES);
 }
+#endif /* HAVE_MLSLABEL */
 
 /*
  * zfs_mount_label_policy:
@@ -1563,7 +1519,7 @@ zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
        /*
         * Get the objset name (the "special" mount argument).
         */
-       if (error = pn_get(uap->spec, fromspace, &spn))
+       if ((error = pn_get(uap->spec, fromspace, &spn)))
                return (error);
 
        osname = spn.pn_path;
@@ -1639,7 +1595,7 @@ out:
        return (error);
 }
 
-static int
+int
 zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp)
 {
        zfsvfs_t *zfsvfs = vfsp->vfs_data;
@@ -1702,8 +1658,9 @@ zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp)
        ZFS_EXIT(zfsvfs);
        return (0);
 }
+EXPORT_SYMBOL(zfs_statvfs);
 
-static int
+int
 zfs_root(vfs_t *vfsp, vnode_t **vpp)
 {
        zfsvfs_t *zfsvfs = vfsp->vfs_data;
@@ -1719,6 +1676,7 @@ zfs_root(vfs_t *vfsp, vnode_t **vpp)
        ZFS_EXIT(zfsvfs);
        return (error);
 }
+EXPORT_SYMBOL(zfs_root);
 
 /*
  * Teardown the zfsvfs::z_os.
@@ -1808,16 +1766,16 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
        /*
         * Evict cached data
         */
-       if (dmu_objset_evict_dbufs(zfsvfs->z_os)) {
-               txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
-               (void) dmu_objset_evict_dbufs(zfsvfs->z_os);
-       }
+       if (dmu_objset_is_dirty_anywhere(zfsvfs->z_os))
+               if (!(zfsvfs->z_vfs->vfs_flag & VFS_RDONLY))
+                       txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
+       (void) dmu_objset_evict_dbufs(zfsvfs->z_os);
 
        return (0);
 }
 
 /*ARGSUSED*/
-static int
+int
 zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr)
 {
        zfsvfs_t *zfsvfs = vfsp->vfs_data;
@@ -1900,8 +1858,9 @@ zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr)
 
        return (0);
 }
+EXPORT_SYMBOL(zfs_umount);
 
-static int
+int
 zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
 {
        zfsvfs_t        *zfsvfs = vfsp->vfs_data;
@@ -1966,7 +1925,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
        gen_mask = -1ULL >> (64 - 8 * i);
 
        dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask);
-       if (err = zfs_zget(zfsvfs, object, &zp)) {
+       if ((err = zfs_zget(zfsvfs, object, &zp))) {
                ZFS_EXIT(zfsvfs);
                return (err);
        }
@@ -1986,6 +1945,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
        ZFS_EXIT(zfsvfs);
        return (0);
 }
+EXPORT_SYMBOL(zfs_vget);
 
 /*
  * Block out VOPs and close zfsvfs_t::z_os
@@ -2004,6 +1964,7 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
 
        return (0);
 }
+EXPORT_SYMBOL(zfs_suspend_fs);
 
 /*
  * Reopen zfsvfs_t::z_os and release VOPs.
@@ -2031,8 +1992,9 @@ zfs_resume_fs(zfsvfs_t *zfsvfs, const char *osname)
                        goto bail;
 
 
-               zfsvfs->z_attr_table = sa_setup(zfsvfs->z_os, sa_obj,
-                   zfs_attr_table,  ZPL_END);
+               if ((err = sa_setup(zfsvfs->z_os, sa_obj,
+                   zfs_attr_table,  ZPL_END, &zfsvfs->z_attr_table)) != 0)
+                       goto bail;
 
                VERIFY(zfsvfs_setup(zfsvfs, B_FALSE) == 0);
 
@@ -2066,6 +2028,7 @@ bail:
        }
        return (err);
 }
+EXPORT_SYMBOL(zfs_resume_fs);
 
 static void
 zfs_freevfs(vfs_t *vfsp)
@@ -2127,10 +2090,12 @@ zfs_vfsinit(int fstype, char *name)
 
        return (0);
 }
+#endif /* HAVE_ZPL */
 
 void
 zfs_init(void)
 {
+#ifdef HAVE_ZPL
        /*
         * Initialize .zfs directory structures
         */
@@ -2140,6 +2105,7 @@ zfs_init(void)
         * Initialize znode cache, vnode ops, etc...
         */
        zfs_znode_init();
+#endif /* HAVE_ZPL */
 
        dmu_objset_register_type(DMU_OST_ZFS, zfs_space_delta_cb);
 }
@@ -2147,16 +2113,13 @@ zfs_init(void)
 void
 zfs_fini(void)
 {
+#ifdef HAVE_ZPL
        zfsctl_fini();
        zfs_znode_fini();
+#endif /* HAVE_ZPL */
 }
 
-int
-zfs_busy(void)
-{
-       return (zfs_active_fs_count != 0);
-}
-
+#ifdef HAVE_ZPL
 int
 zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
 {
@@ -2224,6 +2187,8 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
 
        return (0);
 }
+EXPORT_SYMBOL(zfs_set_version);
+#endif /* HAVE_ZPL */
 
 /*
  * Read a property stored within the master node.
@@ -2267,15 +2232,17 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
        return (error);
 }
 
+#ifdef HAVE_ZPL
 static vfsdef_t vfw = {
        VFSDEF_VERSION,
        MNTTYPE_ZFS,
        zfs_vfsinit,
        VSW_HASPROTO|VSW_CANRWRO|VSW_CANREMOUNT|VSW_VOLATILEDEV|VSW_STATS|
-           VSW_XID,
+           VSW_XID|VSW_ZMOUNT,
        &zfs_mntopts
 };
 
 struct modlfs zfs_modlfs = {
        &mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw
 };
+#endif /* HAVE_ZPL */