mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
493fcce9be
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
103 lines
2.5 KiB
C
103 lines
2.5 KiB
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <getopt.h>
|
|
#include <openssl/evp.h>
|
|
#include <sys/zfs_context.h>
|
|
#include <sys/spa.h>
|
|
#include <sys/spa_impl.h>
|
|
#include <sys/dmu.h>
|
|
#include <sys/zap.h>
|
|
#include <sys/fs/zfs.h>
|
|
#include <sys/zfs_znode.h>
|
|
#include <sys/zfs_sa.h>
|
|
#include <sys/sa.h>
|
|
#include <sys/sa_impl.h>
|
|
#include <sys/vdev.h>
|
|
#include <sys/vdev_impl.h>
|
|
#include <sys/metaslab_impl.h>
|
|
#include <sys/dmu_objset.h>
|
|
#include <sys/dsl_dir.h>
|
|
#include <sys/dsl_dataset.h>
|
|
#include <sys/dsl_pool.h>
|
|
#include <sys/dsl_bookmark.h>
|
|
#include <sys/dbuf.h>
|
|
#include <sys/zil.h>
|
|
#include <sys/zil_impl.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/resource.h>
|
|
#include <sys/dmu_send.h>
|
|
#include <sys/dmu_traverse.h>
|
|
#include <sys/zio_checksum.h>
|
|
#include <sys/zio_compress.h>
|
|
#include <sys/zfs_fuid.h>
|
|
#include <sys/arc.h>
|
|
#include <sys/arc_impl.h>
|
|
#include <sys/ddt.h>
|
|
#include <sys/zfeature.h>
|
|
#include <sys/abd.h>
|
|
#include <sys/blkptr.h>
|
|
#include <sys/dsl_crypt.h>
|
|
#include <sys/dsl_scan.h>
|
|
#include <sys/btree.h>
|
|
#include <sys/brt.h>
|
|
#include <sys/brt_impl.h>
|
|
#include <zfs_comutil.h>
|
|
#include <sys/zstd/zstd.h>
|
|
|
|
#include <libnvpair.h>
|
|
#include <libzutil.h>
|
|
|
|
#include <libzdb.h>
|
|
|
|
const char *
|
|
zdb_ot_name(dmu_object_type_t type)
|
|
{
|
|
if (type < DMU_OT_NUMTYPES)
|
|
return (dmu_ot[type].ot_name);
|
|
else if ((type & DMU_OT_NEWTYPE) &&
|
|
((type & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS))
|
|
return (dmu_ot_byteswap[type & DMU_OT_BYTESWAP_MASK].ob_name);
|
|
else
|
|
return ("UNKNOWN");
|
|
}
|
|
|
|
int
|
|
livelist_compare(const void *larg, const void *rarg)
|
|
{
|
|
const blkptr_t *l = larg;
|
|
const blkptr_t *r = rarg;
|
|
|
|
/* Sort them according to dva[0] */
|
|
uint64_t l_dva0_vdev, r_dva0_vdev;
|
|
l_dva0_vdev = DVA_GET_VDEV(&l->blk_dva[0]);
|
|
r_dva0_vdev = DVA_GET_VDEV(&r->blk_dva[0]);
|
|
if (l_dva0_vdev < r_dva0_vdev)
|
|
return (-1);
|
|
else if (l_dva0_vdev > r_dva0_vdev)
|
|
return (+1);
|
|
|
|
/* if vdevs are equal, sort by offsets. */
|
|
uint64_t l_dva0_offset;
|
|
uint64_t r_dva0_offset;
|
|
l_dva0_offset = DVA_GET_OFFSET(&l->blk_dva[0]);
|
|
r_dva0_offset = DVA_GET_OFFSET(&r->blk_dva[0]);
|
|
if (l_dva0_offset < r_dva0_offset) {
|
|
return (-1);
|
|
} else if (l_dva0_offset > r_dva0_offset) {
|
|
return (+1);
|
|
}
|
|
|
|
/*
|
|
* Since we're storing blkptrs without cancelling FREE/ALLOC pairs,
|
|
* it's possible the offsets are equal. In that case, sort by txg
|
|
*/
|
|
if (BP_GET_LOGICAL_BIRTH(l) < BP_GET_LOGICAL_BIRTH(r)) {
|
|
return (-1);
|
|
} else if (BP_GET_LOGICAL_BIRTH(l) > BP_GET_LOGICAL_BIRTH(r)) {
|
|
return (+1);
|
|
}
|
|
return (0);
|
|
}
|