mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
linux/vfsops: remove zfs_mnt_t, pass directly
A cleanup of opportunity. Since we already are modifying the contents of zfs_mnt_t, we've broken any API guarantee, so we might as well go the rest of the way and get rid of it, and just pass the osname and/or the vfs_t directly. It seems like zfs_mnt_t was never really needed anyway; it was added in1c2555ef92(March 2017) to minimise the difference to illumos, but zfs_vfsops was made platform-specific anyway in7b4e27232d. We also remove setting SB_RDONLY on the caller's flags when failing a read-write remount on a read-only snapshot or pool. Since0f608aa6cathe caller's flags have been a pointer back to fc->sb_flags, which are discarded without further ceremony when the operation fails, so the change is unnecessary and we can simplify the call further. Sponsored-by: TrueNAS Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@truenas.com> Closes #18377
This commit is contained in:
@@ -74,11 +74,6 @@ typedef struct vfs {
|
|||||||
kmutex_t vfs_mntpt_lock;
|
kmutex_t vfs_mntpt_lock;
|
||||||
} vfs_t;
|
} vfs_t;
|
||||||
|
|
||||||
typedef struct zfs_mnt {
|
|
||||||
const char *mnt_osname; /* Objset name */
|
|
||||||
vfs_t *mnt_opts; /* Parsed options */
|
|
||||||
} zfs_mnt_t;
|
|
||||||
|
|
||||||
struct zfsvfs {
|
struct zfsvfs {
|
||||||
vfs_t *z_vfs; /* generic fs struct */
|
vfs_t *z_vfs; /* generic fs struct */
|
||||||
struct super_block *z_sb; /* generic super_block */
|
struct super_block *z_sb; /* generic super_block */
|
||||||
@@ -250,10 +245,11 @@ extern vfs_t *zfsvfs_vfs_alloc(void);
|
|||||||
extern void zfsvfs_vfs_free(vfs_t *vfsp);
|
extern void zfsvfs_vfs_free(vfs_t *vfsp);
|
||||||
|
|
||||||
extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
|
extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
|
||||||
extern int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent);
|
extern int zfs_domount(struct super_block *sb, const char *osname,
|
||||||
|
vfs_t *mntopts, int silent);
|
||||||
extern void zfs_preumount(struct super_block *sb);
|
extern void zfs_preumount(struct super_block *sb);
|
||||||
extern int zfs_umount(struct super_block *sb);
|
extern int zfs_umount(struct super_block *sb);
|
||||||
extern int zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm);
|
extern int zfs_remount(struct super_block *sb, vfs_t *mntopts, int flags);
|
||||||
extern int zfs_statvfs(struct inode *ip, struct kstatfs *statp);
|
extern int zfs_statvfs(struct inode *ip, struct kstatfs *statp);
|
||||||
extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
|
extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
|
||||||
extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
|
extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
|
||||||
|
|||||||
@@ -1316,20 +1316,16 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
|
|||||||
static atomic_long_t zfs_bdi_seq = ATOMIC_LONG_INIT(0);
|
static atomic_long_t zfs_bdi_seq = ATOMIC_LONG_INIT(0);
|
||||||
|
|
||||||
int
|
int
|
||||||
zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent)
|
zfs_domount(struct super_block *sb, const char *osname,
|
||||||
|
vfs_t *vfs, int silent)
|
||||||
{
|
{
|
||||||
const char *osname = zm->mnt_osname;
|
|
||||||
struct inode *root_inode = NULL;
|
struct inode *root_inode = NULL;
|
||||||
uint64_t recordsize;
|
uint64_t recordsize;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
zfsvfs_t *zfsvfs = NULL;
|
zfsvfs_t *zfsvfs = NULL;
|
||||||
vfs_t *vfs = zm->mnt_opts;
|
|
||||||
int canwrite;
|
int canwrite;
|
||||||
int dataset_visible_zone;
|
int dataset_visible_zone;
|
||||||
|
|
||||||
ASSERT(zm);
|
|
||||||
ASSERT(osname);
|
|
||||||
|
|
||||||
dataset_visible_zone = zone_dataset_visible(osname, &canwrite);
|
dataset_visible_zone = zone_dataset_visible(osname, &canwrite);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1533,19 +1529,16 @@ zfs_umount(struct super_block *sb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm)
|
zfs_remount(struct super_block *sb, vfs_t *vfsp, int flags)
|
||||||
{
|
{
|
||||||
zfsvfs_t *zfsvfs = sb->s_fs_info;
|
zfsvfs_t *zfsvfs = sb->s_fs_info;
|
||||||
vfs_t *vfsp = zm->mnt_opts;
|
|
||||||
boolean_t issnap = dmu_objset_is_snapshot(zfsvfs->z_os);
|
boolean_t issnap = dmu_objset_is_snapshot(zfsvfs->z_os);
|
||||||
|
|
||||||
if ((issnap || !spa_writeable(dmu_objset_spa(zfsvfs->z_os))) &&
|
if ((issnap || !spa_writeable(dmu_objset_spa(zfsvfs->z_os))) &&
|
||||||
!(*flags & SB_RDONLY)) {
|
!(flags & SB_RDONLY))
|
||||||
*flags |= SB_RDONLY;
|
|
||||||
return (EROFS);
|
return (EROFS);
|
||||||
}
|
|
||||||
|
|
||||||
if (!zfs_is_readonly(zfsvfs) && (*flags & SB_RDONLY))
|
if (!zfs_is_readonly(zfsvfs) && (flags & SB_RDONLY))
|
||||||
txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
|
txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
|
||||||
|
|
||||||
zfs_unregister_callbacks(zfsvfs);
|
zfs_unregister_callbacks(zfsvfs);
|
||||||
|
|||||||
@@ -880,13 +880,9 @@ zpl_get_tree(struct fs_context *fc)
|
|||||||
vfs->vfs_do_readonly = B_TRUE;
|
vfs->vfs_do_readonly = B_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
zfs_mnt_t zm = {
|
|
||||||
.mnt_osname = fc->source,
|
|
||||||
.mnt_opts = vfs,
|
|
||||||
};
|
|
||||||
|
|
||||||
fstrans_cookie_t cookie = spl_fstrans_mark();
|
fstrans_cookie_t cookie = spl_fstrans_mark();
|
||||||
err = zfs_domount(sb, &zm, fc->sb_flags & SB_SILENT ? 1 : 0);
|
err = zfs_domount(sb, fc->source, vfs,
|
||||||
|
fc->sb_flags & SB_SILENT ? 1 : 0);
|
||||||
spl_fstrans_unmark(cookie);
|
spl_fstrans_unmark(cookie);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -921,12 +917,11 @@ zpl_get_tree(struct fs_context *fc)
|
|||||||
static int
|
static int
|
||||||
zpl_reconfigure(struct fs_context *fc)
|
zpl_reconfigure(struct fs_context *fc)
|
||||||
{
|
{
|
||||||
zfs_mnt_t zm = { .mnt_osname = NULL, .mnt_opts = fc->fs_private };
|
|
||||||
fstrans_cookie_t cookie;
|
fstrans_cookie_t cookie;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
cookie = spl_fstrans_mark();
|
cookie = spl_fstrans_mark();
|
||||||
error = -zfs_remount(fc->root->d_sb, &fc->sb_flags, &zm);
|
error = -zfs_remount(fc->root->d_sb, fc->fs_private, fc->sb_flags);
|
||||||
spl_fstrans_unmark(cookie);
|
spl_fstrans_unmark(cookie);
|
||||||
ASSERT3S(error, <=, 0);
|
ASSERT3S(error, <=, 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user