Skip to content

Commit ef65950

Browse files
committed
Expose whether snapdir is enabled
Include information about whether the ZFS snapdir is enabled in the mount superblock information. This allows userspace applications to use mountinfo to determine whether snapshots will be accessible. The ability to specify snapdir or nosnapdir as mount options is also added as a convenience feature so that an admin may choose to temporarily override the dataset property. Signed-off-by: Andrew Walker <[email protected]>
1 parent a0fd93a commit ef65950

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

include/os/linux/zfs/sys/zfs_vfsops_os.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ typedef struct vfs {
6969
boolean_t vfs_do_relatime;
7070
boolean_t vfs_nbmand;
7171
boolean_t vfs_do_nbmand;
72+
boolean_t vfs_snapdir;
73+
boolean_t vfs_do_snapdir;
7274
kmutex_t vfs_mntpt_lock;
7375
} vfs_t;
7476

include/sys/mntent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,7 @@
111111
#define MNTOPT_CASESENSITIVE "casesensitive" /* case sensitivity */
112112
#define MNTOPT_CASEINSENSITIVE "caseinsensitive" /* case insensitivity */
113113
#define MNTOPT_CASEMIXED "casemixed" /* case mixed */
114+
#define MNTOPT_SNAPDIR "snapdir" /* hidden snapdir */
115+
#define MNTOPT_NOSNAPDIR "nosnapdir" /* disabled snapdir */
114116

115117
#endif /* _SYS_MNTENT_H */

lib/libzfs/os/linux/libzfs_mount_os.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const option_map_t option_map[] = {
9191
{ MNTOPT_CASESENSITIVE, MS_COMMENT, ZS_COMMENT },
9292
{ MNTOPT_CASEINSENSITIVE, MS_COMMENT, ZS_COMMENT },
9393
{ MNTOPT_CASEMIXED, MS_COMMENT, ZS_COMMENT },
94+
/* Snapdir options: snapdir == hidden, nosnapdir == disabled */
95+
{ MNTOPT_SNAPDIR, MS_COMMENT, ZS_COMMENT },
96+
{ MNTOPT_NOSNAPDIR, MS_COMMENT, ZS_COMMENT },
9497
#ifdef MS_NOATIME
9598
{ MNTOPT_NOATIME, MS_NOATIME, ZS_COMMENT },
9699
{ MNTOPT_ATIME, MS_COMMENT, ZS_COMMENT },

module/os/linux/zfs/zfs_vfsops.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ enum {
8383
TOKEN_NBMAND,
8484
TOKEN_NONBMAND,
8585
TOKEN_MNTPOINT,
86+
TOKEN_SNAPDIR,
87+
TOKEN_NOSNAPDIR,
8688
TOKEN_LAST,
8789
};
8890

@@ -105,6 +107,8 @@ static const match_table_t zpl_tokens = {
105107
{ TOKEN_NORELATIME, MNTOPT_NORELATIME },
106108
{ TOKEN_NBMAND, MNTOPT_NBMAND },
107109
{ TOKEN_NONBMAND, MNTOPT_NONBMAND },
110+
{ TOKEN_SNAPDIR, MNTOPT_SNAPDIR },
111+
{ TOKEN_NOSNAPDIR, MNTOPT_NOSNAPDIR },
108112
{ TOKEN_MNTPOINT, MNTOPT_MNTPOINT "=%s" },
109113
{ TOKEN_LAST, NULL },
110114
};
@@ -196,6 +200,14 @@ zfsvfs_parse_option(char *option, int token, substring_t *args, vfs_t *vfsp)
196200
vfsp->vfs_nbmand = B_FALSE;
197201
vfsp->vfs_do_nbmand = B_TRUE;
198202
break;
203+
case TOKEN_SNAPDIR:
204+
vfsp->vfs_snapdir = B_TRUE;
205+
vfsp->vfs_do_snapdir = B_TRUE;
206+
break;
207+
case TOKEN_NOSNAPDIR:
208+
vfsp->vfs_snapdir = B_FALSE;
209+
vfsp->vfs_do_snapdir = B_TRUE;
210+
break;
199211
case TOKEN_MNTPOINT:
200212
if (vfsp->vfs_mntpoint != NULL)
201213
kmem_strfree(vfsp->vfs_mntpoint);
@@ -561,6 +573,9 @@ zfs_register_callbacks(vfs_t *vfsp)
561573
relatime_changed_cb(zfsvfs, vfsp->vfs_relatime);
562574
if (vfsp->vfs_do_nbmand)
563575
nbmand_changed_cb(zfsvfs, vfsp->vfs_nbmand);
576+
if (vfsp->vfs_do_snapdir)
577+
snapdir_changed_cb(zfsvfs, vfsp->vfs_snapdir ?
578+
ZFS_SNAPDIR_HIDDEN : ZFS_SNAPDIR_DISABLED);
564579

565580
return (0);
566581

@@ -633,6 +648,10 @@ zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, uint64_t *val,
633648
if (vfsp->vfs_do_nbmand)
634649
tmp = vfsp->vfs_nbmand;
635650
break;
651+
case ZFS_PROP_SNAPDIR:
652+
if (vfsp->vfs_do_snapdir)
653+
tmp = vfsp->vfs_snapdir;
654+
break;
636655
default:
637656
return (ENOENT);
638657
}

module/os/linux/zfs/zpl_super.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ __zpl_show_options(struct seq_file *seq, zfsvfs_t *zfsvfs)
240240
break;
241241
}
242242

243+
seq_printf(seq, ",%s",
244+
zfsvfs->z_show_ctldir == ZFS_SNAPDIR_DISABLED ?
245+
"nosnapdir" : "snapdir");
246+
243247
return (0);
244248
}
245249

0 commit comments

Comments
 (0)