-
Notifications
You must be signed in to change notification settings - Fork 2k
Persist z_seq across znode eviction #18573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ixhamza
wants to merge
1
commit into
openzfs:master
Choose a base branch
from
truenas:persist_znode_across_eviction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+209
−68
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,7 @@ typedef enum zpl_attr { | |
| ZPL_DACL_ACES, | ||
| ZPL_DXATTR, | ||
| ZPL_PROJID, | ||
| ZPL_SEQ, | ||
| ZPL_END | ||
| } zpl_attr_t; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,7 @@ zfs_znode_cache_constructor(void *buf, void *arg, int kmflags) | |
| zp->z_xattr_cached = NULL; | ||
| zp->z_xattr_parent = 0; | ||
| zp->z_vnode = NULL; | ||
| zp->z_has_seq = B_FALSE; | ||
|
|
||
| return (0); | ||
| } | ||
|
|
@@ -490,6 +491,21 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, | |
| return (NULL); | ||
| } | ||
|
|
||
| /* | ||
| * Restore z_seq from SA_ZPL_SEQ when present, marking the file migrated | ||
| * via the in-core z_has_seq (never persisted). Absence keeps the | ||
| * default z_seq; FreeBSD's va_filerev never folded ctime in, so no | ||
| * seed is needed across the upgrade. | ||
| * | ||
| * Note: after 'zfs rollback' this path restores the snapshot's | ||
| * SA_ZPL_SEQ; va_filerev advances again from there on the next modify. | ||
| */ | ||
| if (zp->z_is_sa && sa_lookup(zp->z_sa_hdl, SA_ZPL_SEQ(zfsvfs), | ||
| &zp->z_seq, sizeof (zp->z_seq)) == 0) | ||
| zp->z_has_seq = B_TRUE; | ||
| else | ||
| zp->z_has_seq = B_FALSE; | ||
|
|
||
| zp->z_projid = projid; | ||
| zp->z_mode = mode; | ||
|
|
||
|
|
@@ -1187,6 +1203,26 @@ zfs_rezget(znode_t *zp) | |
| } | ||
|
|
||
| zp->z_projid = projid; | ||
|
|
||
| /* | ||
| * Recompute the in-core z_has_seq marker from disk. rezget reloads a | ||
| * znode in place (rollback, recv); a stale TRUE marker must not survive | ||
| * or ZFS_SEQ_MAY_GROW() would skip the grow reservation while | ||
| * SA_ZPL_SEQ is gone on disk. | ||
| * | ||
| * Advance z_seq to signal that content may have changed | ||
| * (rollback, recv). After recv the on-disk SA_ZPL_SEQ may be the | ||
| * sender's higher value, so take MAX(in-core, on-disk) + 1 to | ||
| * stay above anything an NFS client could have observed via the | ||
| * cold-load path, preserving change-cookie monotonicity. The new | ||
| * value persists on the next modify. | ||
| */ | ||
| uint64_t tmp_seq = 0; | ||
| zp->z_has_seq = (zp->z_is_sa && | ||
| sa_lookup(zp->z_sa_hdl, SA_ZPL_SEQ(zfsvfs), | ||
| &tmp_seq, sizeof (tmp_seq)) == 0); | ||
| zp->z_seq = MAX(zp->z_seq, tmp_seq) + 1; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many/most of dnodes on the dataset may not have the znodes allocated, so they won't get the bump. With all good intention, I am not sure this is not consistent/predictable enough. Same is on Linux. |
||
|
|
||
| zp->z_mode = mode; | ||
|
|
||
| if (gen != zp->z_gen) { | ||
|
|
@@ -1668,7 +1704,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) | |
| zilog_t *zilog = zfsvfs->z_log; | ||
| uint64_t mode; | ||
| uint64_t mtime[2], ctime[2]; | ||
| sa_bulk_attr_t bulk[3]; | ||
| sa_bulk_attr_t bulk[4]; | ||
| int count = 0; | ||
| int error; | ||
|
|
||
|
|
@@ -1695,7 +1731,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) | |
| return (error); | ||
| log: | ||
| tx = dmu_tx_create(zfsvfs->z_os); | ||
| dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); | ||
| dmu_tx_hold_sa(tx, zp->z_sa_hdl, ZFS_SEQ_MAY_GROW(zp)); | ||
| zfs_sa_upgrade_txholds(tx, zp); | ||
| error = dmu_tx_assign(tx, DMU_TX_WAIT); | ||
| if (error) { | ||
|
|
@@ -1708,6 +1744,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) | |
| SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), | ||
| NULL, &zp->z_pflags, 8); | ||
| zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); | ||
| ZFS_PERSIST_SEQ(zp, bulk, count); | ||
| error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx); | ||
| ASSERT0(error); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about it, but my feeling is this would probably be more readable without the macro. I also wonder if the
if ((zp)->z_is_sa)check is really needed. While I didn't audit every call site in general it looks like it would be straight forward to add this only to the SA code paths.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the guard,
sa_bulk_updatepanics on non-SA znodes.SA_ZPL_PROJIDhas the same constraint but is gated viaif (projid != ZFS_INVALID_PROJID).z_seqis always set, so we checkz_is_sadirectly.