Skip to content

Commit c98dabf

Browse files
committed
Linux 4.11 compat: statx support
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 <[email protected]> Closes #8507
1 parent ca6c7a9 commit c98dabf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

include/sys/zfs_znode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ typedef struct znode {
216216
boolean_t z_is_mapped; /* are we mmap'ed */
217217
boolean_t z_is_ctldir; /* are we .zfs entry */
218218
boolean_t z_is_stale; /* are we stale due to rollback? */
219+
uint64_t z_crtime[2]; /* creation/birth time (cached) */
219220
struct inode z_inode; /* generic vfs inode */
220221
} znode_t;
221222

module/zfs/zfs_znode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
582582
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL, &atime, 16);
583583
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16);
584584
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16);
585+
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL, zp->z_crtime, 16);
585586

586587
if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count) != 0 || tmp_gen == 0 ||
587588
(dmu_objset_projectquota_enabled(zfsvfs->z_os) &&

module/zfs/zpl_inode.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,27 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
353353
*/
354354

355355
error = -zfs_getattr_fast(path->dentry->d_inode, stat);
356+
357+
#ifdef STATX_BTIME
358+
ZFS_TIME_DECODE(zp->z_crtime, btime);
359+
stat->result_mask |= STATX_BTIME;
360+
#endif
361+
362+
#ifdef STATX_ATTR_IMMUTABLE
363+
if (zfs_flags & ZFS_IMMUTABLE)
364+
stat->attributes |= STATX_ATTR_IMMUTABLE;
365+
#endif
366+
367+
#ifdef STATX_ATTR_APPEND
368+
if (zfs_flags & ZFS_APPENDONLY)
369+
stat->attributes |= STATX_ATTR_APPEND;
370+
#endif
371+
372+
#ifdef STATX_ATTR_NODUMP
373+
if (zfs_flags & ZFS_NODUMP)
374+
stat->attributes |= STATX_ATTR_NODUMP;
375+
#ifdef
376+
356377
spl_fstrans_unmark(cookie);
357378
ASSERT3S(error, <=, 0);
358379

0 commit comments

Comments
 (0)