Skip to content
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

Longname: files/directories name upto 1023 bytes #15921

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 71 additions & 59 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,61 +1117,62 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
{
(void) data, (void) size;
zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp = zap_attribute_long_alloc();
void *prop;
unsigned i;

dump_zap_stats(os, object);
(void) printf("\n");

for (zap_cursor_init(&zc, os, object);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
zap_cursor_advance(&zc)) {
boolean_t key64 =
!!(zap_getflags(zc.zc_zap) & ZAP_FLAG_UINT64_KEY);

if (key64)
(void) printf("\t\t0x%010lx = ",
*(uint64_t *)attr.za_name);
*(uint64_t *)attrp->za_name);
else
(void) printf("\t\t%s = ", attr.za_name);
(void) printf("\t\t%s = ", attrp->za_name);

if (attr.za_num_integers == 0) {
if (attrp->za_num_integers == 0) {
(void) printf("\n");
continue;
}
prop = umem_zalloc(attr.za_num_integers *
attr.za_integer_length, UMEM_NOFAIL);
prop = umem_zalloc(attrp->za_num_integers *
attrp->za_integer_length, UMEM_NOFAIL);

if (key64)
(void) zap_lookup_uint64(os, object,
(const uint64_t *)attr.za_name, 1,
attr.za_integer_length, attr.za_num_integers,
(const uint64_t *)attrp->za_name, 1,
attrp->za_integer_length, attrp->za_num_integers,
prop);
else
(void) zap_lookup(os, object, attr.za_name,
attr.za_integer_length, attr.za_num_integers,
(void) zap_lookup(os, object, attrp->za_name,
attrp->za_integer_length, attrp->za_num_integers,
prop);

if (attr.za_integer_length == 1 && !key64) {
if (strcmp(attr.za_name,
if (attrp->za_integer_length == 1 && !key64) {
if (strcmp(attrp->za_name,
DSL_CRYPTO_KEY_MASTER_KEY) == 0 ||
strcmp(attr.za_name,
strcmp(attrp->za_name,
DSL_CRYPTO_KEY_HMAC_KEY) == 0 ||
strcmp(attr.za_name, DSL_CRYPTO_KEY_IV) == 0 ||
strcmp(attr.za_name, DSL_CRYPTO_KEY_MAC) == 0 ||
strcmp(attr.za_name, DMU_POOL_CHECKSUM_SALT) == 0) {
strcmp(attrp->za_name, DSL_CRYPTO_KEY_IV) == 0 ||
strcmp(attrp->za_name, DSL_CRYPTO_KEY_MAC) == 0 ||
strcmp(attrp->za_name,
DMU_POOL_CHECKSUM_SALT) == 0) {
uint8_t *u8 = prop;

for (i = 0; i < attr.za_num_integers; i++) {
for (i = 0; i < attrp->za_num_integers; i++) {
(void) printf("%02x", u8[i]);
}
} else {
(void) printf("%s", (char *)prop);
}
} else {
for (i = 0; i < attr.za_num_integers; i++) {
switch (attr.za_integer_length) {
for (i = 0; i < attrp->za_num_integers; i++) {
switch (attrp->za_integer_length) {
case 1:
(void) printf("%u ",
((uint8_t *)prop)[i]);
Expand All @@ -1192,9 +1193,11 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
}
}
(void) printf("\n");
umem_free(prop, attr.za_num_integers * attr.za_integer_length);
umem_free(prop,
attrp->za_num_integers * attrp->za_integer_length);
}
zap_cursor_fini(&zc);
zap_attribute_free(attrp);
}

static void
Expand Down Expand Up @@ -1295,72 +1298,74 @@ dump_sa_attrs(objset_t *os, uint64_t object, void *data, size_t size)
{
(void) data, (void) size;
zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp = zap_attribute_alloc();

dump_zap_stats(os, object);
(void) printf("\n");

for (zap_cursor_init(&zc, os, object);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
zap_cursor_advance(&zc)) {
(void) printf("\t\t%s = ", attr.za_name);
if (attr.za_num_integers == 0) {
(void) printf("\t\t%s = ", attrp->za_name);
if (attrp->za_num_integers == 0) {
(void) printf("\n");
continue;
}
(void) printf(" %llx : [%d:%d:%d]\n",
(u_longlong_t)attr.za_first_integer,
(int)ATTR_LENGTH(attr.za_first_integer),
(int)ATTR_BSWAP(attr.za_first_integer),
(int)ATTR_NUM(attr.za_first_integer));
(u_longlong_t)attrp->za_first_integer,
(int)ATTR_LENGTH(attrp->za_first_integer),
(int)ATTR_BSWAP(attrp->za_first_integer),
(int)ATTR_NUM(attrp->za_first_integer));
}
zap_cursor_fini(&zc);
zap_attribute_free(attrp);
}

static void
dump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size)
{
(void) data, (void) size;
zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp = zap_attribute_alloc();
uint16_t *layout_attrs;
unsigned i;

dump_zap_stats(os, object);
(void) printf("\n");

for (zap_cursor_init(&zc, os, object);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
zap_cursor_advance(&zc)) {
(void) printf("\t\t%s = [", attr.za_name);
if (attr.za_num_integers == 0) {
(void) printf("\t\t%s = [", attrp->za_name);
if (attrp->za_num_integers == 0) {
(void) printf("\n");
continue;
}

VERIFY(attr.za_integer_length == 2);
layout_attrs = umem_zalloc(attr.za_num_integers *
attr.za_integer_length, UMEM_NOFAIL);
VERIFY(attrp->za_integer_length == 2);
layout_attrs = umem_zalloc(attrp->za_num_integers *
attrp->za_integer_length, UMEM_NOFAIL);

VERIFY(zap_lookup(os, object, attr.za_name,
attr.za_integer_length,
attr.za_num_integers, layout_attrs) == 0);
VERIFY(zap_lookup(os, object, attrp->za_name,
attrp->za_integer_length,
attrp->za_num_integers, layout_attrs) == 0);

for (i = 0; i != attr.za_num_integers; i++)
for (i = 0; i != attrp->za_num_integers; i++)
(void) printf(" %d ", (int)layout_attrs[i]);
(void) printf("]\n");
umem_free(layout_attrs,
attr.za_num_integers * attr.za_integer_length);
attrp->za_num_integers * attrp->za_integer_length);
}
zap_cursor_fini(&zc);
zap_attribute_free(attrp);
}

static void
dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
{
(void) data, (void) size;
zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp = zap_attribute_long_alloc();
const char *typenames[] = {
/* 0 */ "not specified",
/* 1 */ "FIFO",
Expand All @@ -1384,13 +1389,14 @@ dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
(void) printf("\n");

for (zap_cursor_init(&zc, os, object);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
zap_cursor_advance(&zc)) {
(void) printf("\t\t%s = %lld (type: %s)\n",
attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer),
typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]);
attrp->za_name, ZFS_DIRENT_OBJ(attrp->za_first_integer),
typenames[ZFS_DIRENT_TYPE(attrp->za_first_integer)]);
}
zap_cursor_fini(&zc);
zap_attribute_free(attrp);
}

static int
Expand Down Expand Up @@ -2155,23 +2161,25 @@ dump_brt(spa_t *spa)
continue;

zap_cursor_t zc;
zap_attribute_t za;
zap_attribute_t *za = zap_attribute_alloc();
for (zap_cursor_init(&zc, brt->brt_mos, brtvd->bv_mos_entries);
zap_cursor_retrieve(&zc, &za) == 0;
zap_cursor_retrieve(&zc, za) == 0;
zap_cursor_advance(&zc)) {
uint64_t refcnt;
VERIFY0(zap_lookup_uint64(brt->brt_mos,
brtvd->bv_mos_entries,
(const uint64_t *)za.za_name, 1,
za.za_integer_length, za.za_num_integers, &refcnt));
(const uint64_t *)za->za_name, 1,
za->za_integer_length, za->za_num_integers,
&refcnt));

uint64_t offset = *(const uint64_t *)za.za_name;
uint64_t offset = *(const uint64_t *)za->za_name;

snprintf(dva, sizeof (dva), "%" PRIu64 ":%llx", vdevid,
(u_longlong_t)offset);
printf("%-16s %-10llu\n", dva, (u_longlong_t)refcnt);
}
zap_cursor_fini(&zc);
zap_attribute_free(za);
}
}

Expand Down Expand Up @@ -2953,28 +2961,30 @@ static void
dump_bookmarks(objset_t *os, int verbosity)
{
zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp;
dsl_dataset_t *ds = dmu_objset_ds(os);
dsl_pool_t *dp = spa_get_dsl(os->os_spa);
objset_t *mos = os->os_spa->spa_meta_objset;
if (verbosity < 4)
return;
attrp = zap_attribute_alloc();
dsl_pool_config_enter(dp, FTAG);

for (zap_cursor_init(&zc, mos, ds->ds_bookmarks_obj);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
zap_cursor_advance(&zc)) {
char osname[ZFS_MAX_DATASET_NAME_LEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
int len;
dmu_objset_name(os, osname);
len = snprintf(buf, sizeof (buf), "%s#%s", osname,
attr.za_name);
attrp->za_name);
VERIFY3S(len, <, ZFS_MAX_DATASET_NAME_LEN);
(void) dump_bookmark(dp, buf, verbosity >= 5, verbosity >= 6);
}
zap_cursor_fini(&zc);
dsl_pool_config_exit(dp, FTAG);
zap_attribute_free(attrp);
}

static void
Expand Down Expand Up @@ -6857,18 +6867,19 @@ iterate_deleted_livelists(spa_t *spa, ll_iter_t func, void *arg)
ASSERT0(err);

zap_cursor_t zc;
zap_attribute_t attr;
zap_attribute_t *attrp = zap_attribute_alloc();
dsl_deadlist_t ll;
/* NULL out os prior to dsl_deadlist_open in case it's garbage */
ll.dl_os = NULL;
for (zap_cursor_init(&zc, mos, zap_obj);
zap_cursor_retrieve(&zc, &attr) == 0;
zap_cursor_retrieve(&zc, attrp) == 0;
(void) zap_cursor_advance(&zc)) {
dsl_deadlist_open(&ll, mos, attr.za_first_integer);
dsl_deadlist_open(&ll, mos, attrp->za_first_integer);
func(&ll, arg);
dsl_deadlist_close(&ll);
}
zap_cursor_fini(&zc);
zap_attribute_free(attrp);
}

static int
Expand Down Expand Up @@ -8082,13 +8093,14 @@ static void
errorlog_count_refd(objset_t *mos, uint64_t errlog)
{
zap_cursor_t zc;
zap_attribute_t za;
zap_attribute_t *za = zap_attribute_alloc();
for (zap_cursor_init(&zc, mos, errlog);
zap_cursor_retrieve(&zc, &za) == 0;
zap_cursor_retrieve(&zc, za) == 0;
zap_cursor_advance(&zc)) {
mos_obj_refd(za.za_first_integer);
mos_obj_refd(za->za_first_integer);
}
zap_cursor_fini(&zc);
zap_attribute_free(za);
}

static int
Expand Down
17 changes: 9 additions & 8 deletions cmd/zhack.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,26 +203,27 @@ static void
dump_obj(objset_t *os, uint64_t obj, const char *name)
{
zap_cursor_t zc;
zap_attribute_t za;
zap_attribute_t *za = zap_attribute_long_alloc();

(void) printf("%s_obj:\n", name);

for (zap_cursor_init(&zc, os, obj);
zap_cursor_retrieve(&zc, &za) == 0;
zap_cursor_retrieve(&zc, za) == 0;
zap_cursor_advance(&zc)) {
if (za.za_integer_length == 8) {
ASSERT(za.za_num_integers == 1);
if (za->za_integer_length == 8) {
ASSERT(za->za_num_integers == 1);
(void) printf("\t%s = %llu\n",
za.za_name, (u_longlong_t)za.za_first_integer);
za->za_name, (u_longlong_t)za->za_first_integer);
} else {
ASSERT(za.za_integer_length == 1);
ASSERT(za->za_integer_length == 1);
char val[1024];
VERIFY(zap_lookup(os, obj, za.za_name,
VERIFY(zap_lookup(os, obj, za->za_name,
1, sizeof (val), val) == 0);
(void) printf("\t%s = %s\n", za.za_name, val);
(void) printf("\t%s = %s\n", za->za_name, val);
}
}
zap_cursor_fini(&zc);
zap_attribute_free(za);
}

static void
Expand Down
1 change: 1 addition & 0 deletions include/os/freebsd/zfs/sys/zfs_vfsops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct zfsvfs {
boolean_t z_use_sa; /* version allow system attributes */
boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
boolean_t z_use_namecache; /* make use of FreeBSD name cache */
boolean_t z_longname; /* Dataset supports long names */
uint8_t z_xattr; /* xattr type in use */
uint64_t z_version; /* ZPL version */
uint64_t z_shares_dir; /* hidden shares dir */
Expand Down
2 changes: 1 addition & 1 deletion include/os/freebsd/zfs/sys/zfs_znode_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extern void zfs_znode_free(struct znode *);
extern zil_replay_func_t *const zfs_replay_vector[TX_MAX_TYPE];

extern int zfs_znode_parent_and_name(struct znode *zp, struct znode **dzpp,
char *buf);
char *buf, uint64_t buflen);

extern int zfs_rlimit_fsize(off_t fsize);
#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions include/os/linux/zfs/sys/zfs_vfsops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct zfsvfs {
boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
boolean_t z_draining; /* is true when drain is active */
boolean_t z_drain_cancel; /* signal the unlinked drain to stop */
boolean_t z_longname; /* Dataset supports long names */
uint64_t z_version; /* ZPL version */
uint64_t z_shares_dir; /* hidden shares dir */
dataset_kstats_t z_kstat; /* fs kstats */
Expand Down
1 change: 1 addition & 0 deletions include/os/linux/zfs/sys/zfs_vnops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern int zfs_write_simple(znode_t *zp, const void *data, size_t len,
loff_t pos, size_t *resid);
extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp, int flags,
cred_t *cr, int *direntflags, pathname_t *realpnp);
extern int zfs_get_name(znode_t *dzp, char *name, znode_t *zp);
extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp,
zidmap_t *mnt_ns);
Expand Down
Loading
Loading