@@ -732,7 +732,8 @@ zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
732732 if (fuid_dirtied )
733733 zfs_fuid_txhold (zfsvfs , tx );
734734 dmu_tx_hold_zap (tx , dzp -> z_id , TRUE, name );
735- dmu_tx_hold_sa (tx , dzp -> z_sa_hdl , B_FALSE );
735+ dmu_tx_hold_sa (tx , dzp -> z_sa_hdl ,
736+ (dzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
736737 if (!zfsvfs -> z_use_sa &&
737738 acl_ids .z_aclp -> z_acl_bytes > ZFS_ACE_SPACE ) {
738739 dmu_tx_hold_write (tx , DMU_NEW_OBJECT ,
@@ -1063,7 +1064,10 @@ zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
10631064 obj = zp -> z_id ;
10641065 tx = dmu_tx_create (zfsvfs -> z_os );
10651066 dmu_tx_hold_zap (tx , dzp -> z_id , FALSE, name );
1066- dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_FALSE );
1067+ dmu_tx_hold_sa (tx , zp -> z_sa_hdl ,
1068+ (zp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
1069+ dmu_tx_hold_sa (tx , dzp -> z_sa_hdl ,
1070+ (dzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
10671071 zfs_sa_upgrade_txholds (tx , zp );
10681072 zfs_sa_upgrade_txholds (tx , dzp );
10691073 if (may_delete_now ) {
@@ -1080,7 +1084,8 @@ zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
10801084 error = zfs_zget (zfsvfs , xattr_obj , & xzp );
10811085 ASSERT0 (error );
10821086 dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_TRUE );
1083- dmu_tx_hold_sa (tx , xzp -> z_sa_hdl , B_FALSE );
1087+ dmu_tx_hold_sa (tx , xzp -> z_sa_hdl ,
1088+ (xzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
10841089 }
10851090
10861091 mutex_enter (& zp -> z_lock );
@@ -1332,6 +1337,8 @@ zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp,
13321337 tx = dmu_tx_create (zfsvfs -> z_os );
13331338 dmu_tx_hold_zap (tx , dzp -> z_id , TRUE, dirname );
13341339 dmu_tx_hold_zap (tx , DMU_NEW_OBJECT , FALSE, NULL );
1340+ dmu_tx_hold_sa (tx , dzp -> z_sa_hdl ,
1341+ (dzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
13351342 fuid_dirtied = zfsvfs -> z_fuid_dirty ;
13361343 if (fuid_dirtied )
13371344 zfs_fuid_txhold (zfsvfs , tx );
@@ -1484,7 +1491,10 @@ zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr,
14841491
14851492 tx = dmu_tx_create (zfsvfs -> z_os );
14861493 dmu_tx_hold_zap (tx , dzp -> z_id , FALSE, name );
1487- dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_FALSE );
1494+ dmu_tx_hold_sa (tx , zp -> z_sa_hdl ,
1495+ (zp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
1496+ dmu_tx_hold_sa (tx , dzp -> z_sa_hdl ,
1497+ (dzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
14881498 dmu_tx_hold_zap (tx , zfsvfs -> z_unlinkedobj , FALSE, NULL );
14891499 zfs_sa_upgrade_txholds (tx , zp );
14901500 zfs_sa_upgrade_txholds (tx , dzp );
@@ -1947,7 +1957,8 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
19471957 boolean_t fuid_dirtied = B_FALSE ;
19481958 boolean_t handle_eadir = B_FALSE ;
19491959 sa_bulk_attr_t * bulk , * xattr_bulk ;
1950- int count = 0 , xattr_count = 0 , bulks = 8 ;
1960+ int count = 0 , xattr_count = 0 , bulks = 9 ;
1961+ uint64_t change_seq ;
19511962
19521963 if (mask == 0 )
19531964 return (0 );
@@ -2376,7 +2387,8 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
23762387 if (((mask & ATTR_XVATTR ) &&
23772388 XVA_ISSET_REQ (xvap , XAT_AV_SCANSTAMP )) ||
23782389 (projid != ZFS_INVALID_PROJID &&
2379- !(zp -> z_pflags & ZFS_PROJID )))
2390+ !(zp -> z_pflags & ZFS_PROJID )) ||
2391+ !(zp -> z_pflags & ZFS_HAS_SEQ ))
23802392 dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_TRUE );
23812393 else
23822394 dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_FALSE );
@@ -2598,6 +2610,7 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
25982610 */
25992611 if (!(mask & (ATTR_MODE | ATTR_SIZE )))
26002612 zp -> z_seq ++ ;
2613+ ZFS_PERSIST_SEQ (zp , bulk , count , & change_seq );
26012614 }
26022615
26032616 mutex_exit (& zp -> z_lock );
@@ -3061,25 +3074,30 @@ zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp, char *tnm,
30613074 }
30623075
30633076 tx = dmu_tx_create (zfsvfs -> z_os );
3064- dmu_tx_hold_sa (tx , szp -> z_sa_hdl , B_FALSE );
3065- dmu_tx_hold_sa (tx , sdzp -> z_sa_hdl , B_FALSE );
3077+ dmu_tx_hold_sa (tx , szp -> z_sa_hdl ,
3078+ (szp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
3079+ dmu_tx_hold_sa (tx , sdzp -> z_sa_hdl ,
3080+ (sdzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
30663081 dmu_tx_hold_zap (tx , sdzp -> z_id ,
30673082 (rflags & RENAME_EXCHANGE ) ? TRUE : FALSE, snm );
30683083 dmu_tx_hold_zap (tx , tdzp -> z_id , TRUE, tnm );
30693084 if (sdzp != tdzp ) {
3070- dmu_tx_hold_sa (tx , tdzp -> z_sa_hdl , B_FALSE );
3085+ dmu_tx_hold_sa (tx , tdzp -> z_sa_hdl ,
3086+ (tdzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
30713087 zfs_sa_upgrade_txholds (tx , tdzp );
30723088 }
30733089 if (tzp ) {
3074- dmu_tx_hold_sa (tx , tzp -> z_sa_hdl , B_FALSE );
3090+ dmu_tx_hold_sa (tx , tzp -> z_sa_hdl ,
3091+ (tzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
30753092 zfs_sa_upgrade_txholds (tx , tzp );
30763093 }
30773094 if (rflags & RENAME_WHITEOUT ) {
30783095 dmu_tx_hold_sa_create (tx , acl_ids .z_aclp -> z_acl_bytes +
30793096 ZFS_SA_BASE_ATTR_SIZE );
30803097
30813098 dmu_tx_hold_zap (tx , sdzp -> z_id , TRUE, snm );
3082- dmu_tx_hold_sa (tx , sdzp -> z_sa_hdl , B_FALSE );
3099+ dmu_tx_hold_sa (tx , sdzp -> z_sa_hdl ,
3100+ (sdzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
30833101 if (!zfsvfs -> z_use_sa &&
30843102 acl_ids .z_aclp -> z_acl_bytes > ZFS_ACE_SPACE ) {
30853103 dmu_tx_hold_write (tx , DMU_NEW_OBJECT ,
@@ -3380,7 +3398,8 @@ zfs_symlink(znode_t *dzp, char *name, vattr_t *vap, char *link,
33803398 dmu_tx_hold_zap (tx , dzp -> z_id , TRUE, name );
33813399 dmu_tx_hold_sa_create (tx , acl_ids .z_aclp -> z_acl_bytes +
33823400 ZFS_SA_BASE_ATTR_SIZE + len );
3383- dmu_tx_hold_sa (tx , dzp -> z_sa_hdl , B_FALSE );
3401+ dmu_tx_hold_sa (tx , dzp -> z_sa_hdl ,
3402+ (dzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
33843403 if (!zfsvfs -> z_use_sa && acl_ids .z_aclp -> z_acl_bytes > ZFS_ACE_SPACE ) {
33853404 dmu_tx_hold_write (tx , DMU_NEW_OBJECT , 0 ,
33863405 acl_ids .z_aclp -> z_acl_bytes );
@@ -3632,7 +3651,10 @@ zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr,
36323651 }
36333652
36343653 tx = dmu_tx_create (zfsvfs -> z_os );
3635- dmu_tx_hold_sa (tx , szp -> z_sa_hdl , B_FALSE );
3654+ dmu_tx_hold_sa (tx , szp -> z_sa_hdl ,
3655+ (szp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
3656+ dmu_tx_hold_sa (tx , tdzp -> z_sa_hdl ,
3657+ (tdzp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
36363658 dmu_tx_hold_zap (tx , tdzp -> z_id , TRUE, name );
36373659 if (is_tmpfile )
36383660 dmu_tx_hold_zap (tx , zfsvfs -> z_unlinkedobj , FALSE, NULL );
@@ -3771,8 +3793,9 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
37713793 caddr_t va ;
37723794 int err = 0 ;
37733795 uint64_t mtime [2 ], ctime [2 ];
3796+ uint64_t change_seq ;
37743797 inode_timespec_t tmp_ts ;
3775- sa_bulk_attr_t bulk [3 ];
3798+ sa_bulk_attr_t bulk [4 ];
37763799 int cnt = 0 ;
37773800 struct address_space * mapping ;
37783801
@@ -3889,7 +3912,8 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
38893912
38903913 tx = dmu_tx_create (zfsvfs -> z_os );
38913914 dmu_tx_hold_write (tx , zp -> z_id , pgoff , pglen );
3892- dmu_tx_hold_sa (tx , zp -> z_sa_hdl , B_FALSE );
3915+ dmu_tx_hold_sa (tx , zp -> z_sa_hdl ,
3916+ (zp -> z_pflags & ZFS_HAS_SEQ ) ? B_FALSE : B_TRUE );
38933917 zfs_sa_upgrade_txholds (tx , zp );
38943918
38953919 err = dmu_tx_assign (tx , DMU_TX_WAIT );
@@ -3924,6 +3948,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
39243948 ZFS_TIME_ENCODE (& tmp_ts , ctime );
39253949 zp -> z_atime_dirty = B_FALSE ;
39263950 zp -> z_seq ++ ;
3951+ ZFS_PERSIST_SEQ (zp , bulk , cnt , & change_seq );
39273952
39283953 err = sa_bulk_update (zp -> z_sa_hdl , bulk , cnt , tx );
39293954
0 commit comments