diff options
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/zfs_acl.c | 2 | ||||
-rw-r--r-- | module/zfs/zfs_ctldir.c | 2 | ||||
-rw-r--r-- | module/zfs/zfs_dir.c | 10 | ||||
-rw-r--r-- | module/zfs/zfs_sa.c | 5 | ||||
-rw-r--r-- | module/zfs/zfs_vnops.c | 38 | ||||
-rw-r--r-- | module/zfs/zfs_znode.c | 72 | ||||
-rw-r--r-- | module/zfs/zpl_file.c | 2 |
7 files changed, 34 insertions, 97 deletions
diff --git a/module/zfs/zfs_acl.c b/module/zfs/zfs_acl.c index a208dea15..47cfd464b 100644 --- a/module/zfs/zfs_acl.c +++ b/module/zfs/zfs_acl.c @@ -1457,7 +1457,7 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx) if (ace_trivial_common(aclp, 0, zfs_ace_walk) == 0) zp->z_pflags |= ZFS_ACL_TRIVIAL; - zfs_tstamp_update_setup(zp, STATE_CHANGED, NULL, ctime, B_TRUE); + zfs_tstamp_update_setup(zp, STATE_CHANGED, NULL, ctime); return (sa_bulk_update(zp->z_sa_hdl, bulk, count, tx)); } diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index fc46a7307..937feac23 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -478,8 +478,6 @@ zfsctl_inode_alloc(zfs_sb_t *zsb, uint64_t id, zp->z_mapcnt = 0; zp->z_gen = 0; zp->z_size = 0; - zp->z_atime[0] = 0; - zp->z_atime[1] = 0; zp->z_links = 0; zp->z_pflags = 0; zp->z_uid = 0; diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c index 951acb0d6..bdcb87b94 100644 --- a/module/zfs/zfs_dir.c +++ b/module/zfs/zfs_dir.c @@ -760,7 +760,7 @@ zfs_link_create(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag) SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, ctime, sizeof (ctime)); zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, - ctime, B_TRUE); + ctime); } error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx); ASSERT(error == 0); @@ -781,7 +781,7 @@ zfs_link_create(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag) ctime, sizeof (ctime)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL, &dzp->z_pflags, sizeof (dzp->z_pflags)); - zfs_tstamp_update_setup(dzp, CONTENT_MODIFIED, mtime, ctime, B_TRUE); + zfs_tstamp_update_setup(dzp, CONTENT_MODIFIED, mtime, ctime); error = sa_bulk_update(dzp->z_sa_hdl, bulk, count, tx); ASSERT(error == 0); mutex_exit(&dzp->z_lock); @@ -876,8 +876,8 @@ zfs_link_destroy(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag, NULL, &ctime, sizeof (ctime)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL, &zp->z_pflags, sizeof (zp->z_pflags)); - zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, ctime, - B_TRUE); + zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, + ctime); } SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_LINKS(zsb), NULL, &zp->z_links, sizeof (zp->z_links)); @@ -904,7 +904,7 @@ zfs_link_destroy(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag, NULL, mtime, sizeof (mtime)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL, &dzp->z_pflags, sizeof (dzp->z_pflags)); - zfs_tstamp_update_setup(dzp, CONTENT_MODIFIED, mtime, ctime, B_TRUE); + zfs_tstamp_update_setup(dzp, CONTENT_MODIFIED, mtime, ctime); error = sa_bulk_update(dzp->z_sa_hdl, bulk, count, tx); ASSERT(error == 0); mutex_exit(&dzp->z_lock); diff --git a/module/zfs/zfs_sa.c b/module/zfs/zfs_sa.c index fa1a679e1..98e6185cf 100644 --- a/module/zfs/zfs_sa.c +++ b/module/zfs/zfs_sa.c @@ -277,7 +277,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) sa_bulk_attr_t *bulk, *sa_attrs; zfs_acl_locator_cb_t locate = { 0 }; uint64_t uid, gid, mode, rdev, xattr, parent; - uint64_t crtime[2], mtime[2], ctime[2]; + uint64_t crtime[2], mtime[2], ctime[2], atime[2]; zfs_acl_phys_t znode_acl; char scanstamp[AV_SCANSTAMP_SZ]; boolean_t drop_lock = B_FALSE; @@ -309,6 +309,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) /* First do a bulk query of the attributes that aren't cached */ bulk = kmem_alloc(sizeof (sa_bulk_attr_t) * 20, KM_SLEEP); + SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zsb), NULL, &atime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zsb), NULL, &mtime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, &ctime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zsb), NULL, &crtime, 16); @@ -344,7 +345,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_FLAGS(zsb), NULL, &zp->z_pflags, 8); SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_ATIME(zsb), NULL, - zp->z_atime, 16); + &atime, 16); SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_MTIME(zsb), NULL, &mtime, 16); SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_CTIME(zsb), NULL, diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 4fa4fe074..b4ffd8d2a 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -551,7 +551,6 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) out: zfs_range_unlock(rl); - ZFS_ACCESSTIME_STAMP(zsb, zp); ZFS_EXIT(zsb); return (error); } @@ -875,8 +874,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) } mutex_exit(&zp->z_acl_lock); - zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, - B_TRUE); + zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); /* * Update the file size (zp_size) if it has changed; @@ -2211,9 +2209,6 @@ update: zap_cursor_fini(&zc); if (error == ENOENT) error = 0; - - ZFS_ACCESSTIME_STAMP(zsb, zp); - out: ZFS_EXIT(zsb); @@ -2266,11 +2261,11 @@ zfs_getattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) zfs_sb_t *zsb = ITOZSB(ip); int error = 0; uint64_t links; - uint64_t mtime[2], ctime[2]; + uint64_t atime[2], mtime[2], ctime[2]; xvattr_t *xvap = (xvattr_t *)vap; /* vap may be an xvattr_t * */ xoptattr_t *xoap = NULL; boolean_t skipaclchk = (flags & ATTR_NOACLCHECK) ? B_TRUE : B_FALSE; - sa_bulk_attr_t bulk[2]; + sa_bulk_attr_t bulk[3]; int count = 0; ZFS_ENTER(zsb); @@ -2278,6 +2273,7 @@ zfs_getattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) zfs_fuid_map_ids(zp, cr, &vap->va_uid, &vap->va_gid); + SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zsb), NULL, &atime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zsb), NULL, &mtime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, &ctime, 16); @@ -2426,7 +2422,7 @@ zfs_getattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) } } - ZFS_TIME_DECODE(&vap->va_atime, zp->z_atime); + ZFS_TIME_DECODE(&vap->va_atime, atime); ZFS_TIME_DECODE(&vap->va_mtime, mtime); ZFS_TIME_DECODE(&vap->va_ctime, ctime); @@ -2473,7 +2469,6 @@ zfs_getattr_fast(struct inode *ip, struct kstat *sp) mutex_enter(&zp->z_lock); generic_fillattr(ip, sp); - ZFS_TIME_DECODE(&sp->atime, zp->z_atime); sa_object_size(zp->z_sa_hdl, &blksize, &nblocks); sp->blksize = blksize; @@ -2537,7 +2532,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) uint64_t new_mode; uint64_t new_uid, new_gid; uint64_t xattr_obj; - uint64_t mtime[2], ctime[2]; + uint64_t mtime[2], ctime[2], atime[2]; znode_t *attrzp; int need_policy = FALSE; int err, err2; @@ -3011,9 +3006,9 @@ top: if (mask & ATTR_ATIME) { - ZFS_TIME_ENCODE(&vap->va_atime, zp->z_atime); + ZFS_TIME_ENCODE(&vap->va_atime, atime); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zsb), NULL, - &zp->z_atime, sizeof (zp->z_atime)); + &atime, sizeof (atime)); } if (mask & ATTR_MTIME) { @@ -3028,19 +3023,17 @@ top: NULL, mtime, sizeof (mtime)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, &ctime, sizeof (ctime)); - zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, - B_TRUE); + zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); } else if (mask != 0) { SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, &ctime, sizeof (ctime)); - zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, ctime, - B_TRUE); + zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, ctime); if (attrzp) { SA_ADD_BULK_ATTR(xattr_bulk, xattr_count, SA_ZPL_CTIME(zsb), NULL, &ctime, sizeof (ctime)); zfs_tstamp_update_setup(attrzp, STATE_CHANGED, - mtime, ctime, B_TRUE); + mtime, ctime); } } /* @@ -3766,7 +3759,6 @@ zfs_readlink(struct inode *ip, uio_t *uio, cred_t *cr) error = zfs_sa_readlink(zp, uio); mutex_exit(&zp->z_lock); - ZFS_ACCESSTIME_STAMP(zsb, zp); ZFS_EXIT(zsb); return (error); } @@ -4169,7 +4161,6 @@ zfs_dirty_inode(struct inode *ip, int flags) mode = ip->i_mode; zp->z_mode = mode; - zp->z_atime_dirty = 0; error = sa_bulk_update(zp->z_sa_hdl, bulk, cnt, tx); mutex_exit(&zp->z_lock); @@ -4187,6 +4178,7 @@ zfs_inactive(struct inode *ip) { znode_t *zp = ITOZ(ip); zfs_sb_t *zsb = ITOZSB(ip); + uint64_t atime[2]; int error; int need_unlock = 0; @@ -4210,9 +4202,10 @@ zfs_inactive(struct inode *ip) if (error) { dmu_tx_abort(tx); } else { + ZFS_TIME_ENCODE(&ip->i_atime, atime); mutex_enter(&zp->z_lock); (void) sa_update(zp->z_sa_hdl, SA_ZPL_ATIME(zsb), - (void *)&zp->z_atime, sizeof (zp->z_atime), tx); + (void *)&atime, sizeof (atime), tx); zp->z_atime_dirty = 0; mutex_exit(&zp->z_lock); dmu_tx_commit(tx); @@ -4322,9 +4315,6 @@ zfs_getpage(struct inode *ip, struct page *pl[], int nr_pages) err = zfs_fillpage(ip, pl, nr_pages); - if (!err) - ZFS_ACCESSTIME_STAMP(zsb, zp); - ZFS_EXIT(zsb); return (err); } diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index f32482247..f3662e272 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -508,7 +508,7 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz, struct inode *ip; uint64_t mode; uint64_t parent; - sa_bulk_attr_t bulk[9]; + sa_bulk_attr_t bulk[8]; int count = 0; ASSERT(zsb != NULL); @@ -546,8 +546,6 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz, &zp->z_pflags, 8); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_PARENT(zsb), NULL, &parent, 8); - SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zsb), NULL, - &zp->z_atime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zsb), NULL, &zp->z_uid, 8); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zsb), NULL, &zp->z_gid, 8); @@ -1144,7 +1142,7 @@ zfs_rezget(znode_t *zp) dmu_buf_t *db; uint64_t obj_num = zp->z_id; uint64_t mode; - sa_bulk_attr_t bulk[8]; + sa_bulk_attr_t bulk[7]; int err; int count = 0; uint64_t gen; @@ -1199,8 +1197,6 @@ zfs_rezget(znode_t *zp) &zp->z_links, sizeof (zp->z_links)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL, &zp->z_pflags, sizeof (zp->z_pflags)); - SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zsb), NULL, - &zp->z_atime, sizeof (zp->z_atime)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zsb), NULL, &zp->z_uid, sizeof (zp->z_uid)); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zsb), NULL, @@ -1296,77 +1292,27 @@ zfs_compare_timespec(struct timespec *t1, struct timespec *t2) } /* - * Determine whether the znode's atime must be updated. The logic mostly - * duplicates the Linux kernel's relatime_need_update() functionality. - * This function is only called if the underlying filesystem actually has - * atime updates enabled. - */ -static inline boolean_t -zfs_atime_need_update(znode_t *zp, timestruc_t *now) -{ - if (!ZTOZSB(zp)->z_relatime) - return (B_TRUE); - - /* - * In relatime mode, only update the atime if the previous atime - * is earlier than either the ctime or mtime or if at least a day - * has passed since the last update of atime. - */ - if (zfs_compare_timespec(&ZTOI(zp)->i_mtime, &ZTOI(zp)->i_atime) >= 0) - return (B_TRUE); - - if (zfs_compare_timespec(&ZTOI(zp)->i_ctime, &ZTOI(zp)->i_atime) >= 0) - return (B_TRUE); - - if ((long)now->tv_sec - ZTOI(zp)->i_atime.tv_sec >= 24*60*60) - return (B_TRUE); - - return (B_FALSE); -} - -/* * Prepare to update znode time stamps. * * IN: zp - znode requiring timestamp update - * flag - ATTR_MTIME, ATTR_CTIME, ATTR_ATIME flags - * have_tx - true of caller is creating a new txg + * flag - ATTR_MTIME, ATTR_CTIME flags * - * OUT: zp - new atime (via underlying inode's i_atime) + * OUT: zp - z_seq * mtime - new mtime * ctime - new ctime * - * NOTE: The arguments are somewhat redundant. The following condition - * is always true: - * - * have_tx == !(flag & ATTR_ATIME) + * Note: We don't update atime here, because we rely on Linux VFS to do + * atime updating. */ void zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2], - uint64_t ctime[2], boolean_t have_tx) + uint64_t ctime[2]) { timestruc_t now; - ASSERT(have_tx == !(flag & ATTR_ATIME)); gethrestime(&now); - /* - * NOTE: The following test intentionally does not update z_atime_dirty - * in the case where an ATIME update has been requested but for which - * the update is omitted due to relatime logic. The rationale being - * that if the flag was set somewhere else, we should leave it alone - * here. - */ - if (flag & ATTR_ATIME) { - if (zfs_atime_need_update(zp, &now)) { - ZFS_TIME_ENCODE(&now, zp->z_atime); - ZTOI(zp)->i_atime.tv_sec = zp->z_atime[0]; - ZTOI(zp)->i_atime.tv_nsec = zp->z_atime[1]; - zp->z_atime_dirty = 1; - } - } else { - zp->z_atime_dirty = 0; - zp->z_seq++; - } + zp->z_seq++; if (flag & ATTR_MTIME) { ZFS_TIME_ENCODE(&now, mtime); @@ -1739,7 +1685,7 @@ log: SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, ctime, 16); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL, &zp->z_pflags, 8); - zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, B_TRUE); + zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx); ASSERT(error == 0); diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c index 5c430c7ca..36153cb90 100644 --- a/module/zfs/zpl_file.c +++ b/module/zfs/zpl_file.c @@ -261,6 +261,7 @@ zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) UIO_USERSPACE, filp->f_flags, cr); crfree(cr); + file_accessed(filp); return (read); } @@ -277,6 +278,7 @@ zpl_iter_read_common(struct kiocb *kiocb, const struct iovec *iovp, nr_segs, &kiocb->ki_pos, seg, filp->f_flags, cr, skip); crfree(cr); + file_accessed(filp); return (read); } |