Skip to content

Commit

Permalink
Linux 4.11 compat: statx support
Browse files Browse the repository at this point in the history
Linux 4.11 added a new statx system call that allows us to expose crtime
as btime. We do this by caching crtime in the znode to match how atime,
ctime and mtime are cached in the inode.

statx also introduced a new way of reporting whether the immutable,
append and nodump bits have been set. It adds support for reporting
compression and encryption, but the semantics on other filesystems is
not just to report compression/encryption, but to allow it to be turned
on/off at the file level. We do not support that.

We could implement semantics where we refuse to allow user modification
of the bit, but we would need to do a dnode_hold() in zfs_znode_alloc()
to find out encryption/compression information. That would introduce
locking that will have a minor (although unmeasured) performance cost.
It also would be inferior to zdb, which reports far more detailed
information. We therefore omit reporting of encryption/compression
through statx in favor of recommending that users interested in such
information use zdb.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Closes #8507
  • Loading branch information
ryao committed Mar 17, 2019
1 parent ca6c7a9 commit dd93db6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sys/zfs_znode.h
Expand Up @@ -216,6 +216,7 @@ typedef struct znode {
boolean_t z_is_mapped; /* are we mmap'ed */
boolean_t z_is_ctldir; /* are we .zfs entry */
boolean_t z_is_stale; /* are we stale due to rollback? */
uint64_t z_crtime[2]; /* creation/birth time (cached) */
struct inode z_inode; /* generic vfs inode */
} znode_t;

Expand Down
2 changes: 2 additions & 0 deletions module/zfs/zfs_znode.c
Expand Up @@ -582,6 +582,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL, &atime, 16);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16);
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL,
&zp->z_crtime[0], 16);

if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count) != 0 || tmp_gen == 0 ||
(dmu_objset_projectquota_enabled(zfsvfs->z_os) &&
Expand Down
21 changes: 21 additions & 0 deletions module/zfs/zpl_inode.c
Expand Up @@ -353,6 +353,27 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
*/

error = -zfs_getattr_fast(path->dentry->d_inode, stat);

#ifdef STATX_BTIME
ZFS_TIME_DECODE(zp->z_crtime, btime);
stat->result_mask |= STATX_BTIME;
#endif

#ifdef STATX_ATTR_IMMUTABLE
if (zfs_flags & ZFS_IMMUTABLE)
stat->attributes |= STATX_ATTR_IMMUTABLE;
#endif

#ifdef STATX_ATTR_APPEND
if (zfs_flags & ZFS_APPENDONLY)
stat->attributes |= STATX_ATTR_APPEND;
#endif

#ifdef STATX_ATTR_NODUMP
if (zfs_flags & ZFS_NODUMP)
stat->attributes |= STATX_ATTR_NODUMP;
#ifdef

spl_fstrans_unmark(cookie);
ASSERT3S(error, <=, 0);

Expand Down

0 comments on commit dd93db6

Please sign in to comment.