diff --git a/kmod/src/ioctl.c b/kmod/src/ioctl.c index 47082869..a4fbd013 100644 --- a/kmod/src/ioctl.c +++ b/kmod/src/ioctl.c @@ -24,6 +24,7 @@ #include "name.h" #include "ioctl.h" #include "super.h" +#include "inode.h" /* * Find all the inodes that have had keys of a given type modified since @@ -274,6 +275,21 @@ out: return copied ?: ret; } +/* + * Sample the inode's data_version. It is not strictly serialized with + * writes that are in flight. + */ +static long scoutfs_ioc_data_version(struct file *file, unsigned long arg) +{ + u64 __user *uvers = (void __user *)arg; + u64 vers = scoutfs_inode_get_data_version(file_inode(file)); + + if (put_user(vers, uvers)) + return -EFAULT; + + return 0; +} + long scoutfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { @@ -287,6 +303,8 @@ long scoutfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return scoutfs_ioc_find_xattr(file, arg, false); case SCOUTFS_IOC_INODE_DATA_SINCE: return scoutfs_ioc_inodes_since(file, arg, SCOUTFS_EXTENT_KEY); + case SCOUTFS_IOC_DATA_VERSION: + return scoutfs_ioc_data_version(file, arg); } return -ENOTTY; diff --git a/kmod/src/ioctl.h b/kmod/src/ioctl.h index d0592d2f..964ccd92 100644 --- a/kmod/src/ioctl.h +++ b/kmod/src/ioctl.h @@ -55,4 +55,7 @@ struct scoutfs_ioctl_find_xattr { #define SCOUTFS_IOC_INODE_DATA_SINCE _IOW(SCOUTFS_IOCTL_MAGIC, 5, \ struct scoutfs_ioctl_inodes_since) + +#define SCOUTFS_IOC_DATA_VERSION _IOW(SCOUTFS_IOCTL_MAGIC, 6, u64) + #endif