mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
Provide macros for setting and getting blkptr birth times
There exist a couple of macros that are used to update the blkptr birth times but they can often be confusing. For example, the BP_PHYSICAL_BIRTH() macro will provide either the physical birth time if it is set or else return back the logical birth time. The complement to this macro is BP_SET_BIRTH() which will set the logical birth time and set the physical birth time if they are not the same. Consumers may get confused when they are trying to get the physical birth time and use the BP_PHYSICAL_BIRTH() macro only to find out that the logical birth time is what is actually returned. This change cleans up these macros and makes them symmetrical. The same functionally is preserved but the name is changed. Instead of calling BP_PHYSICAL_BIRTH(), consumer can now call BP_GET_BIRTH(). In additional to cleaning up this naming conventions, two new sets of macros are introduced -- BP_[SET|GET]_LOGICAL_BIRTH() and BP_[SET|GET]_PHYSICAL_BIRTH. These new macros allow the consumer to get and set the specific birth time. As part of the cleanup, the unused GRID macros have been removed and that portion of the blkptr are currently unused. Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Mark Maybee <mark.maybee@delphix.com> Signed-off-by: George Wilson <gwilson@delphix.com> Closes #15962
This commit is contained in:
+7
-7
@@ -557,7 +557,7 @@ zil_clear_log_block(zilog_t *zilog, const blkptr_t *bp, void *tx,
|
||||
* that we rewind to is invalid. Thus, we return -1 so
|
||||
* zil_parse() doesn't attempt to read it.
|
||||
*/
|
||||
if (bp->blk_birth >= first_txg)
|
||||
if (BP_GET_LOGICAL_BIRTH(bp) >= first_txg)
|
||||
return (-1);
|
||||
|
||||
if (zil_bp_tree_add(zilog, bp) != 0)
|
||||
@@ -583,7 +583,7 @@ zil_claim_log_block(zilog_t *zilog, const blkptr_t *bp, void *tx,
|
||||
* Claim log block if not already committed and not already claimed.
|
||||
* If tx == NULL, just verify that the block is claimable.
|
||||
*/
|
||||
if (BP_IS_HOLE(bp) || bp->blk_birth < first_txg ||
|
||||
if (BP_IS_HOLE(bp) || BP_GET_LOGICAL_BIRTH(bp) < first_txg ||
|
||||
zil_bp_tree_add(zilog, bp) != 0)
|
||||
return (0);
|
||||
|
||||
@@ -608,7 +608,7 @@ zil_claim_write(zilog_t *zilog, const lr_t *lrc, void *tx, uint64_t first_txg)
|
||||
* waited for all writes to be stable first), so it is semantically
|
||||
* correct to declare this the end of the log.
|
||||
*/
|
||||
if (lr->lr_blkptr.blk_birth >= first_txg) {
|
||||
if (BP_GET_LOGICAL_BIRTH(&lr->lr_blkptr) >= first_txg) {
|
||||
error = zil_read_log_data(zilog, lr, NULL);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
@@ -655,7 +655,7 @@ zil_claim_clone_range(zilog_t *zilog, const lr_t *lrc, void *tx,
|
||||
* just in case lets be safe and just stop here now instead of
|
||||
* corrupting the pool.
|
||||
*/
|
||||
if (BP_PHYSICAL_BIRTH(bp) >= first_txg)
|
||||
if (BP_GET_BIRTH(bp) >= first_txg)
|
||||
return (SET_ERROR(ENOENT));
|
||||
|
||||
/*
|
||||
@@ -710,8 +710,8 @@ zil_free_write(zilog_t *zilog, const lr_t *lrc, void *tx, uint64_t claim_txg)
|
||||
/*
|
||||
* If we previously claimed it, we need to free it.
|
||||
*/
|
||||
if (bp->blk_birth >= claim_txg && zil_bp_tree_add(zilog, bp) == 0 &&
|
||||
!BP_IS_HOLE(bp)) {
|
||||
if (BP_GET_LOGICAL_BIRTH(bp) >= claim_txg &&
|
||||
zil_bp_tree_add(zilog, bp) == 0 && !BP_IS_HOLE(bp)) {
|
||||
zio_free(zilog->zl_spa, dmu_tx_get_txg(tx), bp);
|
||||
}
|
||||
|
||||
@@ -1965,7 +1965,7 @@ next_lwb:
|
||||
&slog);
|
||||
}
|
||||
if (error == 0) {
|
||||
ASSERT3U(bp->blk_birth, ==, txg);
|
||||
ASSERT3U(BP_GET_LOGICAL_BIRTH(bp), ==, txg);
|
||||
BP_SET_CHECKSUM(bp, nlwb->lwb_slim ? ZIO_CHECKSUM_ZILOG2 :
|
||||
ZIO_CHECKSUM_ZILOG);
|
||||
bp->blk_cksum = lwb->lwb_blk.blk_cksum;
|
||||
|
||||
Reference in New Issue
Block a user