From b0f58de8246bd514650e7d4e4d6bdcc51e815b45 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 16 Jun 2015 22:24:24 -0700 Subject: [PATCH] hammer2 - Refactor frontend part 3/many * Compartmentalize the inode mostly node-independent meta-data portion of the inode on-disk data structure. * The filename and directdata/block-table part of the inode data structure is left out. --- sbin/hammer2/cmd_debug.c | 80 ++++----- sbin/hammer2/cmd_setcheck.c | 2 +- sbin/hammer2/cmd_setcomp.c | 2 +- sbin/hammer2/cmd_stat.c | 15 +- sbin/hammer2/print_inode.c | 34 ++-- sbin/newfs_hammer2/newfs_hammer2.c | 93 +++++----- sys/vfs/hammer2/hammer2.h | 21 ++- sys/vfs/hammer2/hammer2_chain.c | 15 +- sys/vfs/hammer2/hammer2_cluster.c | 18 +- sys/vfs/hammer2/hammer2_disk.h | 28 +-- sys/vfs/hammer2/hammer2_flush.c | 6 +- sys/vfs/hammer2/hammer2_inode.c | 262 +++++++++++++++-------------- sys/vfs/hammer2/hammer2_iocom.c | 10 +- sys/vfs/hammer2/hammer2_ioctl.c | 60 +++---- sys/vfs/hammer2/hammer2_subr.c | 12 +- sys/vfs/hammer2/hammer2_syncthr.c | 6 +- sys/vfs/hammer2/hammer2_vfsops.c | 64 ++++--- sys/vfs/hammer2/hammer2_vnops.c | 112 ++++++------ 18 files changed, 449 insertions(+), 391 deletions(-) diff --git a/sbin/hammer2/cmd_debug.c b/sbin/hammer2/cmd_debug.c index a05bd4dee5..aa4f9139be 100644 --- a/sbin/hammer2/cmd_debug.c +++ b/sbin/hammer2/cmd_debug.c @@ -564,95 +564,95 @@ show_bref(int fd, int tab, int bi, hammer2_blockref_t *bref, int dofreemap) break; case HAMMER2_BREF_TYPE_INODE: printf("{\n"); - if (media.ipdata.op_flags & HAMMER2_OPFLAG_DIRECTDATA) { + if (media.ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) { /* no blockrefs */ } else { bscan = &media.ipdata.u.blockset.blockref[0]; bcount = HAMMER2_SET_COUNT; } - namelen = media.ipdata.name_len; + namelen = media.ipdata.meta.name_len; if (namelen > HAMMER2_INODE_MAXNAME) namelen = 0; tabprintf(tab, "filename \"%*.*s\"\n", namelen, namelen, media.ipdata.filename); - tabprintf(tab, "version %d\n", media.ipdata.version); + tabprintf(tab, "version %d\n", media.ipdata.meta.version); tabprintf(tab, "uflags 0x%08x\n", - media.ipdata.uflags); - if (media.ipdata.rmajor || media.ipdata.rminor) { + media.ipdata.meta.uflags); + if (media.ipdata.meta.rmajor || media.ipdata.meta.rminor) { tabprintf(tab, "rmajor %d\n", - media.ipdata.rmajor); + media.ipdata.meta.rmajor); tabprintf(tab, "rminor %d\n", - media.ipdata.rminor); + media.ipdata.meta.rminor); } tabprintf(tab, "ctime %s\n", - hammer2_time64_to_str(media.ipdata.ctime, &str)); + hammer2_time64_to_str(media.ipdata.meta.ctime, &str)); tabprintf(tab, "mtime %s\n", - hammer2_time64_to_str(media.ipdata.mtime, &str)); + hammer2_time64_to_str(media.ipdata.meta.mtime, &str)); tabprintf(tab, "atime %s\n", - hammer2_time64_to_str(media.ipdata.atime, &str)); + hammer2_time64_to_str(media.ipdata.meta.atime, &str)); tabprintf(tab, "btime %s\n", - hammer2_time64_to_str(media.ipdata.btime, &str)); + hammer2_time64_to_str(media.ipdata.meta.btime, &str)); tabprintf(tab, "uid %s\n", - hammer2_uuid_to_str(&media.ipdata.uid, &str)); + hammer2_uuid_to_str(&media.ipdata.meta.uid, &str)); tabprintf(tab, "gid %s\n", - hammer2_uuid_to_str(&media.ipdata.gid, &str)); - if (media.ipdata.type == HAMMER2_OBJTYPE_HARDLINK) + hammer2_uuid_to_str(&media.ipdata.meta.gid, &str)); + if (media.ipdata.meta.type == HAMMER2_OBJTYPE_HARDLINK) tabprintf(tab, "type %s (%s)\n", - hammer2_iptype_to_str(media.ipdata.type), - hammer2_iptype_to_str(media.ipdata.target_type)); + hammer2_iptype_to_str(media.ipdata.meta.type), + hammer2_iptype_to_str(media.ipdata.meta.target_type)); else tabprintf(tab, "type %s\n", - hammer2_iptype_to_str(media.ipdata.type)); + hammer2_iptype_to_str(media.ipdata.meta.type)); tabprintf(tab, "opflgs 0x%02x\n", - media.ipdata.op_flags); + media.ipdata.meta.op_flags); tabprintf(tab, "capflgs 0x%04x\n", - media.ipdata.cap_flags); + media.ipdata.meta.cap_flags); tabprintf(tab, "mode %-7o\n", - media.ipdata.mode); + media.ipdata.meta.mode); tabprintf(tab, "inum 0x%016jx\n", - media.ipdata.inum); + media.ipdata.meta.inum); tabprintf(tab, "size %ju\n", - (uintmax_t)media.ipdata.size); + (uintmax_t)media.ipdata.meta.size); tabprintf(tab, "nlinks %ju\n", - (uintmax_t)media.ipdata.nlinks); + (uintmax_t)media.ipdata.meta.nlinks); tabprintf(tab, "iparent 0x%016jx\n", - (uintmax_t)media.ipdata.iparent); + (uintmax_t)media.ipdata.meta.iparent); tabprintf(tab, "name_key 0x%016jx\n", - (uintmax_t)media.ipdata.name_key); + (uintmax_t)media.ipdata.meta.name_key); tabprintf(tab, "name_len %u\n", - media.ipdata.name_len); + media.ipdata.meta.name_len); tabprintf(tab, "ncopies %u\n", - media.ipdata.ncopies); + media.ipdata.meta.ncopies); tabprintf(tab, "compalg %u\n", - media.ipdata.comp_algo); + media.ipdata.meta.comp_algo); tabprintf(tab, "checkalg %u\n", - media.ipdata.check_algo); - if (media.ipdata.op_flags & HAMMER2_OPFLAG_PFSROOT) { + media.ipdata.meta.check_algo); + if (media.ipdata.meta.op_flags & HAMMER2_OPFLAG_PFSROOT) { tabprintf(tab, "pfs_type %u (%s)\n", - media.ipdata.pfs_type, - hammer2_pfstype_to_str(media.ipdata.pfs_type)); + media.ipdata.meta.pfs_type, + hammer2_pfstype_to_str(media.ipdata.meta.pfs_type)); tabprintf(tab, "pfs_inum 0x%016jx\n", - (uintmax_t)media.ipdata.pfs_inum); + (uintmax_t)media.ipdata.meta.pfs_inum); tabprintf(tab, "pfs_clid %s\n", - hammer2_uuid_to_str(&media.ipdata.pfs_clid, + hammer2_uuid_to_str(&media.ipdata.meta.pfs_clid, &str)); tabprintf(tab, "pfs_fsid %s\n", - hammer2_uuid_to_str(&media.ipdata.pfs_fsid, + hammer2_uuid_to_str(&media.ipdata.meta.pfs_fsid, &str)); } tabprintf(tab, "data_quota %ju\n", - (uintmax_t)media.ipdata.data_quota); + (uintmax_t)media.ipdata.meta.data_quota); tabprintf(tab, "data_count %ju\n", (uintmax_t)bref->data_count); tabprintf(tab, "inode_quota %ju\n", - (uintmax_t)media.ipdata.inode_quota); + (uintmax_t)media.ipdata.meta.inode_quota); tabprintf(tab, "inode_count %ju\n", (uintmax_t)bref->inode_count); tabprintf(tab, "attr_tid 0x%016jx\n", - (uintmax_t)media.ipdata.attr_tid); - if (media.ipdata.type == HAMMER2_OBJTYPE_DIRECTORY) { + (uintmax_t)media.ipdata.meta.attr_tid); + if (media.ipdata.meta.type == HAMMER2_OBJTYPE_DIRECTORY) { tabprintf(tab, "dirent_tid %016jx\n", - (uintmax_t)media.ipdata.dirent_tid); + (uintmax_t)media.ipdata.meta.dirent_tid); } break; case HAMMER2_BREF_TYPE_INDIRECT: diff --git a/sbin/hammer2/cmd_setcheck.c b/sbin/hammer2/cmd_setcheck.c index f5bd9a0ce7..76c71efe1c 100644 --- a/sbin/hammer2/cmd_setcheck.c +++ b/sbin/hammer2/cmd_setcheck.c @@ -113,7 +113,7 @@ cmd_setcheck_core(uint8_t check_algo, const char *path_str, struct stat *st) goto failed; } printf("%s\tcheck_algo=0x%02x\n", path_str, check_algo); - inode.ip_data.check_algo = check_algo; + inode.ip_data.meta.check_algo = check_algo; res = ioctl(fd, HAMMER2IOC_INODE_SET, &inode); if (res < 0) { fprintf(stderr, diff --git a/sbin/hammer2/cmd_setcomp.c b/sbin/hammer2/cmd_setcomp.c index 593f635ab7..13b6bcd552 100644 --- a/sbin/hammer2/cmd_setcomp.c +++ b/sbin/hammer2/cmd_setcomp.c @@ -149,7 +149,7 @@ cmd_setcomp_core(uint8_t comp_algo, const char *path_str, struct stat *st) goto failed; } printf("%s\tcomp_algo=0x%02x\n", path_str, comp_algo); - inode.ip_data.comp_algo = comp_algo; + inode.ip_data.meta.comp_algo = comp_algo; res = ioctl(fd, HAMMER2IOC_INODE_SET, &inode); if (res < 0) { fprintf(stderr, diff --git a/sbin/hammer2/cmd_stat.c b/sbin/hammer2/cmd_stat.c index adf5598e08..58bd99572d 100644 --- a/sbin/hammer2/cmd_stat.c +++ b/sbin/hammer2/cmd_stat.c @@ -74,16 +74,19 @@ cmd_stat(int ac, const char **av) continue; } printf("%-*.*s ", w, w, av[i]); - printf("%3d ", ino.ip_data.ncopies); + printf("%3d ", ino.ip_data.meta.ncopies); printf("%9s ", sizetostr(ino.data_count)); printf("%9s ", counttostr(ino.inode_count)); /*printf("%p ", ino.kdata); debugging */ - printf("comp=%s ", compmodestr(ino.ip_data.comp_algo)); - printf("check=%s ", checkmodestr(ino.ip_data.check_algo)); - if (ino.ip_data.data_quota || ino.ip_data.inode_quota) { + printf("comp=%s ", compmodestr(ino.ip_data.meta.comp_algo)); + printf("check=%s ", checkmodestr(ino.ip_data.meta.check_algo)); + if (ino.ip_data.meta.data_quota || + ino.ip_data.meta.inode_quota) { printf(" quota "); - printf("%12s", sizetostr(ino.ip_data.data_quota)); - printf("/%-12s", counttostr(ino.ip_data.inode_quota)); + printf("%12s", + sizetostr(ino.ip_data.meta.data_quota)); + printf("/%-12s", + counttostr(ino.ip_data.meta.inode_quota)); } printf("\n"); } diff --git a/sbin/hammer2/print_inode.c b/sbin/hammer2/print_inode.c index c82b9e0838..571c479837 100644 --- a/sbin/hammer2/print_inode.c +++ b/sbin/hammer2/print_inode.c @@ -46,23 +46,23 @@ print_inode(char* inode_string) inode_data = inode.ip_data; printf("Got res = %d\n", res); printf("Printing inode data.\n"); - /*printf("version = %d\n", inode_data.version); - printf("uflags = %d\n", inode_data.uflags); - printf("rmajor = %d\n", inode_data.rmajor); - printf("rminor = %d\n", inode_data.rminor); - printf("ctime = %u !\n", (unsigned int)inode_data.ctime); - printf("mtime = %u !\n", (unsigned int)inode_data.mtime);*/ - printf("type = %d\n", inode_data.type); - printf("op_flags = %d\n", inode_data.op_flags); - /*printf("cap_flags = %d\n", inode_data.cap_flags); - printf("mode = %d\n", inode_data.mode); - printf("inum = %u !\n", (unsigned int)inode_data.inum); - printf("size = %u !\n", (unsigned int)inode_data.size),*/ - printf("name_key = %u !\n", (unsigned int)inode_data.name_key); - /*printf("name_len = %d\n", inode_data.name_len); - printf("ncopies = %d\n", inode_data.ncopies);*/ - printf("comp_algo = %d\n", inode_data.comp_algo); - if (inode_data.op_flags != HAMMER2_OPFLAG_DIRECTDATA) { + /*printf("version = %d\n", inode_data.meta.version); + printf("uflags = %d\n", inode_data.meta.uflags); + printf("rmajor = %d\n", inode_data.meta.rmajor); + printf("rminor = %d\n", inode_data.meta.rminor); + printf("ctime = %u !\n", (unsigned int)inode_data.meta.ctime); + printf("mtime = %u !\n", (unsigned int)inode_data.meta.mtime);*/ + printf("type = %d\n", inode_data.meta.type); + printf("op_flags = %d\n", inode_data.meta.op_flags); + /*printf("cap_flags = %d\n", inode_data.meta.cap_flags); + printf("mode = %d\n", inode_data.meta.mode); + printf("inum = %u !\n", (unsigned int)inode_data.meta.inum); + printf("size = %u !\n", (unsigned int)inode_data.meta.size),*/ + printf("name_key = %u !\n", (unsigned int)inode_data.meta.name_key); + /*printf("name_len = %d\n", inode_data.meta.name_len); + printf("ncopies = %d\n", inode_data.meta.ncopies);*/ + printf("comp_algo = %d\n", inode_data.meta.comp_algo); + if (inode_data.meta.op_flags != HAMMER2_OPFLAG_DIRECTDATA) { int i; for (i = 0; i < HAMMER2_SET_COUNT; ++i) { if (inode_data.u.blockset.blockref[i].type != HAMMER2_BREF_TYPE_EMPTY) { diff --git a/sbin/newfs_hammer2/newfs_hammer2.c b/sbin/newfs_hammer2/newfs_hammer2.c index bb397bbbbd..50b83bfa0f 100644 --- a/sbin/newfs_hammer2/newfs_hammer2.c +++ b/sbin/newfs_hammer2/newfs_hammer2.c @@ -552,19 +552,20 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) */ rawip = (void *)(buf + (HAMMER2_OFF_MASK_LO & root_blockref[i].data_off)); - rawip->version = HAMMER2_INODE_VERSION_ONE; - rawip->ctime = now; - rawip->mtime = now; + rawip->meta.version = HAMMER2_INODE_VERSION_ONE; + rawip->meta.ctime = now; + rawip->meta.mtime = now; /* rawip->atime = now; NOT IMPL MUST BE ZERO */ - rawip->btime = now; - rawip->type = HAMMER2_OBJTYPE_DIRECTORY; - rawip->mode = 0755; - rawip->inum = 1; /* root inode, inumber 1 */ - rawip->nlinks = 1; /* directory link count compat */ + rawip->meta.btime = now; + rawip->meta.type = HAMMER2_OBJTYPE_DIRECTORY; + rawip->meta.mode = 0755; + rawip->meta.inum = 1; /* root inode, inumber 1 */ + rawip->meta.nlinks = 1; /* directory link count compat */ - rawip->name_len = strlen(Label[i]); - bcopy(Label[i], rawip->filename, rawip->name_len); - rawip->name_key = dirhash(rawip->filename, rawip->name_len); + rawip->meta.name_len = strlen(Label[i]); + bcopy(Label[i], rawip->filename, rawip->meta.name_len); + rawip->meta.name_key = + dirhash(rawip->filename, rawip->meta.name_len); /* * Compression mode and supported copyids. @@ -573,15 +574,15 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) * (pfs-create also does the same if the pfs is named "BOOT") */ if (strcasecmp(Label[i], "BOOT") == 0) { - rawip->comp_algo = HAMMER2_ENC_ALGO( - HAMMER2_COMP_AUTOZERO); - rawip->check_algo = HAMMER2_ENC_ALGO( - HAMMER2_CHECK_ISCSI32); + rawip->meta.comp_algo = HAMMER2_ENC_ALGO( + HAMMER2_COMP_AUTOZERO); + rawip->meta.check_algo = HAMMER2_ENC_ALGO( + HAMMER2_CHECK_ISCSI32); } else { - rawip->comp_algo = HAMMER2_ENC_ALGO( - HAMMER2_COMP_NEWFS_DEFAULT); - rawip->check_algo = HAMMER2_ENC_ALGO( - HAMMER2_CHECK_ISCSI32); + rawip->meta.comp_algo = HAMMER2_ENC_ALGO( + HAMMER2_COMP_NEWFS_DEFAULT); + rawip->meta.check_algo = HAMMER2_ENC_ALGO( + HAMMER2_CHECK_ISCSI32); } /* @@ -589,11 +590,13 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) * don't know how many masters there are. The quorum * calculation will effectively be 1 ( 0 / 2 + 1 ). */ - rawip->pfs_clid = Hammer2_PfsCLID[i]; - rawip->pfs_fsid = Hammer2_PfsFSID[i]; - rawip->pfs_type = HAMMER2_PFSTYPE_MASTER; - rawip->op_flags |= HAMMER2_OPFLAG_PFSROOT; - rawip->pfs_inum = 16; /* first allocatable inode number */ + rawip->meta.pfs_clid = Hammer2_PfsCLID[i]; + rawip->meta.pfs_fsid = Hammer2_PfsFSID[i]; + rawip->meta.pfs_type = HAMMER2_PFSTYPE_MASTER; + rawip->meta.op_flags |= HAMMER2_OPFLAG_PFSROOT; + + /* first allocatable inode number */ + rawip->meta.pfs_inum = 16; /* rawip->u.blockset is left empty */ @@ -605,7 +608,7 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) * The key field for a directory entry's blockref is * essentially the name key for the entry. */ - root_blockref[i].key = rawip->name_key; + root_blockref[i].key = rawip->meta.name_key; root_blockref[i].copyid = HAMMER2_COPYID_LOCAL; root_blockref[i].keybits = 0; root_blockref[i].check.iscsi32.value = @@ -628,21 +631,21 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) * having to worry about the hash. Use index 0. */ rawip = (void *)(buf + (HAMMER2_OFF_MASK_LO & sroot_blockref.data_off)); - rawip->version = HAMMER2_INODE_VERSION_ONE; - rawip->ctime = now; - rawip->mtime = now; - /* rawip->atime = now; NOT IMPL MUST BE ZERO */ - rawip->btime = now; - rawip->type = HAMMER2_OBJTYPE_DIRECTORY; - rawip->mode = 0700; /* super-root - root only */ - rawip->inum = 0; /* super root inode, inumber 0 */ - rawip->nlinks = 2; /* directory link count compat */ - - rawip->name_len = 0; /* super-root is unnamed */ - rawip->name_key = 0; - - rawip->comp_algo = HAMMER2_ENC_ALGO(HAMMER2_COMP_AUTOZERO); - rawip->check_algo = HAMMER2_ENC_ALGO(HAMMER2_CHECK_ISCSI32); + rawip->meta.version = HAMMER2_INODE_VERSION_ONE; + rawip->meta.ctime = now; + rawip->meta.mtime = now; + /* rawip->meta.atime = now; NOT IMPL MUST BE ZERO */ + rawip->meta.btime = now; + rawip->meta.type = HAMMER2_OBJTYPE_DIRECTORY; + rawip->meta.mode = 0700; /* super-root - root only */ + rawip->meta.inum = 0; /* super root inode, inumber 0 */ + rawip->meta.nlinks = 2; /* directory link count compat */ + + rawip->meta.name_len = 0; /* super-root is unnamed */ + rawip->meta.name_key = 0; + + rawip->meta.comp_algo = HAMMER2_ENC_ALGO(HAMMER2_COMP_AUTOZERO); + rawip->meta.check_algo = HAMMER2_ENC_ALGO(HAMMER2_CHECK_ISCSI32); /* * The super-root is flagged as a PFS and typically given its own @@ -655,10 +658,12 @@ format_hammer2(int fd, hammer2_off_t total_space, hammer2_off_t free_space) * transaction id domain, so normal mechanics cannot cross a PFS * boundary). */ - rawip->pfs_clid = Hammer2_SupCLID; - rawip->pfs_fsid = Hammer2_SupFSID; - rawip->pfs_type = HAMMER2_PFSTYPE_SUPROOT; - rawip->pfs_inum = 16; /* first allocatable inode number */ + rawip->meta.pfs_clid = Hammer2_SupCLID; + rawip->meta.pfs_fsid = Hammer2_SupFSID; + rawip->meta.pfs_type = HAMMER2_PFSTYPE_SUPROOT; + + /* first allocatable inode number */ + rawip->meta.pfs_inum = 16; /* * Currently newfs_hammer2 just throws the PFS inodes into the diff --git a/sys/vfs/hammer2/hammer2.h b/sys/vfs/hammer2/hammer2.h index c69a63a4d0..0173a78cf8 100644 --- a/sys/vfs/hammer2/hammer2.h +++ b/sys/vfs/hammer2/hammer2.h @@ -104,6 +104,8 @@ struct hammer2_pfs; struct hammer2_span; struct hammer2_state; struct hammer2_msg; +struct hammer2_syncthr; +struct hammer2_vop_info; /* * Mutex and lock shims. Hammer2 requires support for asynchronous and @@ -690,6 +692,7 @@ typedef struct hammer2_inode hammer2_inode_t; #define HAMMER2_INODE_RESIZED 0x0010 #define HAMMER2_INODE_MTIME 0x0020 #define HAMMER2_INODE_ISUNLINKED 0x0040 +#define HAMMER2_INODE_DATAGOOD 0x0080 /* inode meta-data */ int hammer2_inode_cmp(hammer2_inode_t *ip1, hammer2_inode_t *ip2); RB_PROTOTYPE2(hammer2_inode_tree, hammer2_inode, rbnode, hammer2_inode_cmp, @@ -757,18 +760,26 @@ struct hammer2_trans_manage { typedef struct hammer2_trans_manage hammer2_trans_manage_t; /* - * Collection point for distributed frontend operation. Uses a managed - * objcache. + * hammer2_vop_info - container for VOP operation. + * + * This structure is used to distribute a VOP operation across multiple + * nodes. It provides a rendezvous for concurrent node execution and + * can be detached from the frontend operation to allow the frontend to + * return early. */ struct hammer2_vop_info { hammer2_inode_t *dip; hammer2_inode_t *ip; struct uio *uio; + int clidx; + void (*xio_func)(struct hammer2_syncthr *thr, + struct hammer2_vop_info *info); }; +typedef struct hammer2_vop_info hammer2_vop_info_t; /* - * Cluster node synchronization thread element. + * Cluster node synchronization and operation thread element. * * Multiple syncthr's can hang off of a hammer2_pfs structure, typically one * for each block device that is part of the PFS. Synchronization threads @@ -782,7 +793,6 @@ struct hammer2_vop_info { */ struct hammer2_syncthr { struct hammer2_pfs *pmp; - kdmsg_state_t *span; thread_t td; uint32_t flags; int depth; @@ -795,7 +805,7 @@ typedef struct hammer2_syncthr hammer2_syncthr_t; #define HAMMER2_SYNCTHR_UNMOUNTING 0x0001 /* unmount request */ #define HAMMER2_SYNCTHR_DEV 0x0002 /* related to dev, not pfs */ -#define HAMMER2_SYNCTHR_SPANNED 0x0004 /* LNK_SPAN active */ +#define HAMMER2_SYNCTHR_UNUSED04 0x0004 #define HAMMER2_SYNCTHR_REMASTER 0x0008 /* remaster request */ #define HAMMER2_SYNCTHR_STOP 0x0010 /* exit request */ #define HAMMER2_SYNCTHR_FREEZE 0x0020 /* force idle */ @@ -1041,6 +1051,7 @@ extern long hammer2_ioa_volu_write; extern struct objcache *cache_buffer_read; extern struct objcache *cache_buffer_write; +extern struct objcache *cache_vop_info; extern int destroy; extern int write_thread_wakeup; diff --git a/sys/vfs/hammer2/hammer2_chain.c b/sys/vfs/hammer2/hammer2_chain.c index f6357a5013..533a29d599 100644 --- a/sys/vfs/hammer2/hammer2_chain.c +++ b/sys/vfs/hammer2/hammer2_chain.c @@ -1670,7 +1670,8 @@ again: * * This is only applicable to regular files and softlinks. */ - if (parent->data->ipdata.op_flags & HAMMER2_OPFLAG_DIRECTDATA) { + if (parent->data->ipdata.meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA) { if (flags & HAMMER2_LOOKUP_NODIRECT) { chain = NULL; *key_nextp = key_end + 1; @@ -2041,8 +2042,10 @@ again: /* * An inode with embedded data has no sub-chains. */ - if (parent->data->ipdata.op_flags & HAMMER2_OPFLAG_DIRECTDATA) + if (parent->data->ipdata.meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA) { goto done; + } base = &parent->data->ipdata.u.blockset.blockref[0]; count = HAMMER2_SET_COUNT; break; @@ -2315,7 +2318,7 @@ again: switch(parent->bref.type) { case HAMMER2_BREF_TYPE_INODE: - KKASSERT((parent->data->ipdata.op_flags & + KKASSERT((parent->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0); KKASSERT(parent->data != NULL); base = &parent->data->ipdata.u.blockset.blockref[0]; @@ -2599,7 +2602,7 @@ _hammer2_chain_delete_helper(hammer2_trans_t *trans, * an OBJTYPE_HARDLINK placeholding inode. */ if (parent->data && - (parent->data->ipdata.op_flags & + (parent->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0) { base = &parent->data->ipdata.u.blockset.blockref[0]; @@ -3840,8 +3843,10 @@ hammer2_base_sort(hammer2_chain_t *chain) * * This is only applicable to regular files and softlinks. */ - if (chain->data->ipdata.op_flags & HAMMER2_OPFLAG_DIRECTDATA) + if (chain->data->ipdata.meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA) { return; + } base = &chain->data->ipdata.u.blockset.blockref[0]; count = HAMMER2_SET_COUNT; break; diff --git a/sys/vfs/hammer2/hammer2_cluster.c b/sys/vfs/hammer2/hammer2_cluster.c index 3e4cf34f74..05bebd2f53 100644 --- a/sys/vfs/hammer2/hammer2_cluster.c +++ b/sys/vfs/hammer2/hammer2_cluster.c @@ -990,7 +990,7 @@ hammer2_cluster_modsync(hammer2_cluster_t *cluster) case HAMMER2_BREF_TYPE_INODE: ripdata = &focus->data->ipdata; wipdata = &scan->data->ipdata; - if ((ripdata->op_flags & + if ((ripdata->meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0) { bcopy(ripdata, wipdata, offsetof(hammer2_inode_data_t, u)); @@ -1556,7 +1556,7 @@ hammer2_cluster_snapshot(hammer2_trans_t *trans, hammer2_cluster_t *ocluster, */ ripdata = &hammer2_cluster_rdata(ocluster)->ipdata; #if 0 - opfs_clid = ripdata->pfs_clid; + opfs_clid = ripdata->meta.pfs_clid; #endif hmp = ocluster->focus->hmp; /* XXX find synchronized local disk */ @@ -1583,10 +1583,10 @@ hammer2_cluster_snapshot(hammer2_trans_t *trans, hammer2_cluster_t *ocluster, if (nip) { wipdata = hammer2_cluster_modify_ip(trans, nip, ncluster, 0); - wipdata->pfs_type = HAMMER2_PFSTYPE_MASTER; - wipdata->pfs_subtype = HAMMER2_PFSSUBTYPE_SNAPSHOT; - wipdata->op_flags |= HAMMER2_OPFLAG_PFSROOT; - kern_uuidgen(&wipdata->pfs_fsid, 1); + wipdata->meta.pfs_type = HAMMER2_PFSTYPE_MASTER; + wipdata->meta.pfs_subtype = HAMMER2_PFSSUBTYPE_SNAPSHOT; + wipdata->meta.op_flags |= HAMMER2_OPFLAG_PFSROOT; + kern_uuidgen(&wipdata->meta.pfs_fsid, 1); /* * Give the snapshot its own private cluster. As a snapshot @@ -1595,11 +1595,11 @@ hammer2_cluster_snapshot(hammer2_trans_t *trans, hammer2_cluster_t *ocluster, */ #if 0 if (ocluster->focus->flags & HAMMER2_CHAIN_PFSBOUNDARY) - wipdata->pfs_clid = opfs_clid; + wipdata->meta.pfs_clid = opfs_clid; else - kern_uuidgen(&wipdata->pfs_clid, 1); + kern_uuidgen(&wipdata->meta.pfs_clid, 1); #endif - kern_uuidgen(&wipdata->pfs_clid, 1); + kern_uuidgen(&wipdata->meta.pfs_clid, 1); for (i = 0; i < ncluster->nchains; ++i) { if ((ncluster->array[i].flags & diff --git a/sys/vfs/hammer2/hammer2_disk.h b/sys/vfs/hammer2/hammer2_disk.h index 010cba5a1f..e750df604f 100644 --- a/sys/vfs/hammer2/hammer2_disk.h +++ b/sys/vfs/hammer2/hammer2_disk.h @@ -494,7 +494,7 @@ struct hammer2_volconf { uuid_t pfs_clid; /* 20-2F copy target must match this uuid */ uint8_t label[16]; /* 30-3F import/export label */ uint8_t path[64]; /* 40-7F target specification string or key */ -}; +} __packed; typedef struct hammer2_volconf hammer2_volconf_t; @@ -511,7 +511,7 @@ struct dmsg_lnk_hammer2_volconf { int32_t unused01; uuid_t mediaid; int64_t reserved02[32]; -}; +} __packed; typedef struct dmsg_lnk_hammer2_volconf dmsg_lnk_hammer2_volconf_t; @@ -620,7 +620,7 @@ struct hammer2_blockref { /* MUST BE EXACTLY 64 BYTES */ char reserved[48]; } freemap; } check; -}; +} __packed; typedef struct hammer2_blockref hammer2_blockref_t; @@ -668,7 +668,7 @@ typedef struct hammer2_blockref hammer2_blockref_t; /* * Encode/decode check or compression algorithm request in - * ipdata->check_algo and ipdata->comp_algo. + * ipdata->meta.check_algo and ipdata->meta.comp_algo. */ #define HAMMER2_ENC_ALGO(n) (n) #define HAMMER2_DEC_ALGO(n) ((n) & 15) @@ -786,7 +786,7 @@ struct hammer2_bmap_data { uint32_t reserved20[8]; /* 20-3F 256 bits manages 128K/1KB/2-bits */ /* 40-7F 512 bits manages 4MB of storage */ hammer2_bitmap_t bitmapq[HAMMER2_BMAP_ELEMENTS]; -}; +} __packed; typedef struct hammer2_bmap_data hammer2_bmap_data_t; @@ -798,7 +798,10 @@ typedef struct hammer2_bmap_data hammer2_bmap_data_t; * * The inode is 1024 bytes, made up of 256 bytes of meta-data, 256 bytes * for the filename, and 512 bytes worth of direct file data OR an embedded - * blockset. + * blockset. The in-memory hammer2_inode structure contains only the mostly- + * node-independent meta-data portion (some flags are node-specific and will + * not be synchronized). The rest of the inode is node-specific and chain I/O + * is required to obtain it. * * Directories represent one inode per blockref. Inodes are not laid out * as a file but instead are represented by the related blockrefs. The @@ -844,7 +847,7 @@ typedef struct hammer2_bmap_data hammer2_bmap_data_t; #define HAMMER2_INODE_HIDDENDIR 16 /* special inode */ #define HAMMER2_INODE_START 1024 /* dynamically allocated */ -struct hammer2_inode_data { +struct hammer2_inode_meta { uint16_t version; /* 0000 inode data version */ uint8_t reserved02; /* 0002 */ uint8_t pfs_subtype; /* 0003 pfs sub-type */ @@ -918,14 +921,19 @@ struct hammer2_inode_data { */ uint64_t decrypt_check; /* 00E0 decryption validator */ hammer2_off_t reservedE0[3]; /* 00E8/F0/F8 */ +} __packed; +typedef struct hammer2_inode_meta hammer2_inode_meta_t; + +struct hammer2_inode_data { + hammer2_inode_meta_t meta; /* 0000-00FF */ unsigned char filename[HAMMER2_INODE_MAXNAME]; /* 0100-01FF (256 char, unterminated) */ union { /* 0200-03FF (64x8 = 512 bytes) */ struct hammer2_blockset blockset; char data[HAMMER2_EMBEDDED_BYTES]; } u; -}; +} __packed; typedef struct hammer2_inode_data hammer2_inode_data_t; @@ -1201,7 +1209,7 @@ struct hammer2_volume_data { * icrc on entire volume header */ hammer2_crc32_t icrc_volheader; /* FFFC-FFFF full volume icrc*/ -}; +} __packed; typedef struct hammer2_volume_data hammer2_volume_data_t; @@ -1243,7 +1251,7 @@ union hammer2_media_data { hammer2_blockref_t npdata[HAMMER2_IND_COUNT_MAX]; hammer2_bmap_data_t bmdata[HAMMER2_FREEMAP_COUNT]; char buf[HAMMER2_PBUFSIZE]; -}; +} __packed; typedef union hammer2_media_data hammer2_media_data_t; diff --git a/sys/vfs/hammer2/hammer2_flush.c b/sys/vfs/hammer2/hammer2_flush.c index 6de7163874..6ddbc4a296 100644 --- a/sys/vfs/hammer2/hammer2_flush.c +++ b/sys/vfs/hammer2/hammer2_flush.c @@ -808,7 +808,7 @@ again: * changes to the inode data, the system might * have already flushed the buffer. */ - if (chain->data->ipdata.op_flags & + if (chain->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_PFSROOT) { /* * non-NULL pmp if mounted as a PFS. We must @@ -819,7 +819,7 @@ again: hammer2_io_setdirty(chain->dio); ipdata = &chain->data->ipdata; if (chain->pmp) { - ipdata->pfs_inum = + ipdata->meta.pfs_inum = chain->pmp->inode_tid; } } else { @@ -946,7 +946,7 @@ again: * no block array if the inode is flagged DIRECTDATA. */ if (parent->data && - (parent->data->ipdata.op_flags & + (parent->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0) { base = &parent->data-> ipdata.u.blockset.blockref[0]; diff --git a/sys/vfs/hammer2/hammer2_inode.c b/sys/vfs/hammer2/hammer2_inode.c index 5483334984..bc85bcb40d 100644 --- a/sys/vfs/hammer2/hammer2_inode.c +++ b/sys/vfs/hammer2/hammer2_inode.c @@ -151,7 +151,7 @@ hammer2_inode_lock(hammer2_inode_t *ip, int how) ripdata = &hammer2_cluster_rdata(cluster)->ipdata; hammer2_cluster_bref(cluster, &bref); - pmp->inode_tid = ripdata->pfs_inum + 1; + pmp->inode_tid = ripdata->meta.pfs_inum + 1; pmp->modify_tid = bref.modify_tid; kprintf("PMP focus good set nextino=%ld mod=%016jx\n", pmp->inode_tid, pmp->modify_tid); @@ -414,15 +414,15 @@ hammer2_igetv(hammer2_inode_t *ip, hammer2_cluster_t *cparent, int *errorp) continue; } - switch (ripdata->type) { + switch (ripdata->meta.type) { case HAMMER2_OBJTYPE_DIRECTORY: vp->v_type = VDIR; break; case HAMMER2_OBJTYPE_REGFILE: vp->v_type = VREG; - vinitvmio(vp, ripdata->size, + vinitvmio(vp, ripdata->meta.size, HAMMER2_LBUFSIZE, - (int)ripdata->size & HAMMER2_LBUFMASK); + (int)ripdata->meta.size & HAMMER2_LBUFMASK); break; case HAMMER2_OBJTYPE_SOFTLINK: /* @@ -431,25 +431,28 @@ hammer2_igetv(hammer2_inode_t *ip, hammer2_cluster_t *cparent, int *errorp) * association. */ vp->v_type = VLNK; - vinitvmio(vp, ripdata->size, + vinitvmio(vp, ripdata->meta.size, HAMMER2_LBUFSIZE, - (int)ripdata->size & HAMMER2_LBUFMASK); + (int)ripdata->meta.size & HAMMER2_LBUFMASK); break; case HAMMER2_OBJTYPE_CDEV: vp->v_type = VCHR; /* fall through */ case HAMMER2_OBJTYPE_BDEV: vp->v_ops = &pmp->mp->mnt_vn_spec_ops; - if (ripdata->type != HAMMER2_OBJTYPE_CDEV) + if (ripdata->meta.type != HAMMER2_OBJTYPE_CDEV) vp->v_type = VBLK; - addaliasu(vp, ripdata->rmajor, ripdata->rminor); + addaliasu(vp, + ripdata->meta.rmajor, + ripdata->meta.rminor); break; case HAMMER2_OBJTYPE_FIFO: vp->v_type = VFIFO; vp->v_ops = &pmp->mp->mnt_vn_fifo_ops; break; default: - panic("hammer2: unhandled objtype %d", ripdata->type); + panic("hammer2: unhandled objtype %d", + ripdata->meta.type); break; } @@ -509,7 +512,7 @@ hammer2_inode_get(hammer2_pfs_t *pmp, hammer2_inode_t *dip, again: while (cluster) { iptmp = &hammer2_cluster_rdata(cluster)->ipdata; - nip = hammer2_inode_lookup(pmp, iptmp->inum); + nip = hammer2_inode_lookup(pmp, iptmp->meta.inum); if (nip == NULL) break; @@ -550,9 +553,9 @@ again: nip->cluster.flags |= HAMMER2_CLUSTER_INODE; if (cluster) { nipdata = &hammer2_cluster_rdata(cluster)->ipdata; - nip->inum = nipdata->inum; - nip->size = nipdata->size; - nip->mtime = nipdata->mtime; + nip->inum = nipdata->meta.inum; + nip->size = nipdata->meta.size; + nip->mtime = nipdata->meta.mtime; hammer2_inode_repoint(nip, NULL, cluster); } else { nip->inum = 1; /* PFS inum is always 1 XXX */ @@ -644,11 +647,11 @@ hammer2_inode_create(hammer2_trans_t *trans, hammer2_inode_t *dip, retry: cparent = hammer2_inode_lock(dip, HAMMER2_RESOLVE_ALWAYS); dipdata = &hammer2_cluster_rdata(cparent)->ipdata; - dip_uid = dipdata->uid; - dip_gid = dipdata->gid; - dip_mode = dipdata->mode; - dip_comp_algo = dipdata->comp_algo; - dip_check_algo = dipdata->check_algo; + dip_uid = dipdata->meta.uid; + dip_gid = dipdata->meta.gid; + dip_mode = dipdata->meta.mode; + dip_comp_algo = dipdata->meta.comp_algo; + dip_check_algo = dipdata->meta.check_algo; error = 0; while (error == 0) { @@ -711,41 +714,41 @@ retry: */ KKASSERT(cluster->focus->flags & HAMMER2_CHAIN_MODIFIED); nipdata = &hammer2_cluster_wdata(cluster)->ipdata; - nipdata->inum = trans->inode_tid; + nipdata->meta.inum = trans->inode_tid; hammer2_cluster_modsync(cluster); nip = hammer2_inode_get(dip->pmp, dip, cluster); nipdata = &hammer2_cluster_wdata(cluster)->ipdata; if (vap) { KKASSERT(trans->inodes_created == 0); - nipdata->type = hammer2_get_obj_type(vap->va_type); - nipdata->inum = trans->inode_tid; + nipdata->meta.type = hammer2_get_obj_type(vap->va_type); + nipdata->meta.inum = trans->inode_tid; ++trans->inodes_created; - switch (nipdata->type) { + switch (nipdata->meta.type) { case HAMMER2_OBJTYPE_CDEV: case HAMMER2_OBJTYPE_BDEV: - nipdata->rmajor = vap->va_rmajor; - nipdata->rminor = vap->va_rminor; + nipdata->meta.rmajor = vap->va_rmajor; + nipdata->meta.rminor = vap->va_rminor; break; default: break; } } else { - nipdata->type = HAMMER2_OBJTYPE_DIRECTORY; - nipdata->inum = 1; + nipdata->meta.type = HAMMER2_OBJTYPE_DIRECTORY; + nipdata->meta.inum = 1; } /* Inherit parent's inode compression mode. */ nip->comp_heuristic = 0; - nipdata->comp_algo = dip_comp_algo; - nipdata->check_algo = dip_check_algo; - nipdata->version = HAMMER2_INODE_VERSION_ONE; - hammer2_update_time(&nipdata->ctime); - nipdata->mtime = nipdata->ctime; + nipdata->meta.comp_algo = dip_comp_algo; + nipdata->meta.check_algo = dip_check_algo; + nipdata->meta.version = HAMMER2_INODE_VERSION_ONE; + hammer2_update_time(&nipdata->meta.ctime); + nipdata->meta.mtime = nipdata->meta.ctime; if (vap) - nipdata->mode = vap->va_mode; - nipdata->nlinks = 1; + nipdata->meta.mode = vap->va_mode; + nipdata->meta.nlinks = 1; if (vap) { if (dip && dip->pmp) { xuid = hammer2_to_unix_xid(&dip_uid); @@ -759,18 +762,18 @@ retry: xuid = 0; } if (vap->va_vaflags & VA_UID_UUID_VALID) - nipdata->uid = vap->va_uid_uuid; + nipdata->meta.uid = vap->va_uid_uuid; else if (vap->va_uid != (uid_t)VNOVAL) - hammer2_guid_to_uuid(&nipdata->uid, vap->va_uid); + hammer2_guid_to_uuid(&nipdata->meta.uid, vap->va_uid); else - hammer2_guid_to_uuid(&nipdata->uid, xuid); + hammer2_guid_to_uuid(&nipdata->meta.uid, xuid); if (vap->va_vaflags & VA_GID_UUID_VALID) - nipdata->gid = vap->va_gid_uuid; + nipdata->meta.gid = vap->va_gid_uuid; else if (vap->va_gid != (gid_t)VNOVAL) - hammer2_guid_to_uuid(&nipdata->gid, vap->va_gid); + hammer2_guid_to_uuid(&nipdata->meta.gid, vap->va_gid); else if (dip) - nipdata->gid = dip_gid; + nipdata->meta.gid = dip_gid; } /* @@ -778,15 +781,15 @@ retry: * directly embedded in the inode. This flag will be cleared if * the size is extended past the embedded limit. */ - if (nipdata->type == HAMMER2_OBJTYPE_REGFILE || - nipdata->type == HAMMER2_OBJTYPE_SOFTLINK) { - nipdata->op_flags |= HAMMER2_OPFLAG_DIRECTDATA; + if (nipdata->meta.type == HAMMER2_OBJTYPE_REGFILE || + nipdata->meta.type == HAMMER2_OBJTYPE_SOFTLINK) { + nipdata->meta.op_flags |= HAMMER2_OPFLAG_DIRECTDATA; } KKASSERT(name_len < HAMMER2_INODE_MAXNAME); bcopy(name, nipdata->filename, name_len); - nipdata->name_key = lhc; - nipdata->name_len = name_len; + nipdata->meta.name_key = lhc; + nipdata->meta.name_len = name_len; hammer2_cluster_modsync(cluster); *clusterp = cluster; @@ -815,7 +818,7 @@ hammer2_hardlink_shiftup(hammer2_trans_t *trans, hammer2_cluster_t *cluster, hammer2_blockref_t bref; iptmp = &hammer2_cluster_rdata(cluster)->ipdata; - lhc = iptmp->inum; + lhc = iptmp->meta.inum; KKASSERT((lhc & HAMMER2_DIRHASH_VISIBLE) == 0); /* @@ -879,10 +882,10 @@ hammer2_hardlink_shiftup(hammer2_trans_t *trans, hammer2_cluster_t *cluster, hammer2_cluster_modify(trans, cluster, 0); nipdata = &hammer2_cluster_wdata(cluster)->ipdata; ksnprintf(nipdata->filename, sizeof(nipdata->filename), - "0x%016jx", (intmax_t)nipdata->inum); - nipdata->name_len = strlen(nipdata->filename); - nipdata->name_key = lhc; - nipdata->nlinks += nlinks; + "0x%016jx", (intmax_t)nipdata->meta.inum); + nipdata->meta.name_len = strlen(nipdata->filename); + nipdata->meta.name_key = lhc; + nipdata->meta.nlinks += nlinks; hammer2_cluster_modsync(cluster); } @@ -1031,15 +1034,16 @@ hammer2_inode_connect(hammer2_trans_t *trans, KKASSERT(name_len < HAMMER2_INODE_MAXNAME); wipdata = &hammer2_cluster_wdata(ncluster)->ipdata; bcopy(name, wipdata->filename, name_len); - wipdata->name_key = lhc; - wipdata->name_len = name_len; - wipdata->target_type = - hammer2_cluster_rdata(ocluster)->ipdata.type; - wipdata->type = HAMMER2_OBJTYPE_HARDLINK; - wipdata->inum = hammer2_cluster_rdata(ocluster)->ipdata.inum; - wipdata->version = HAMMER2_INODE_VERSION_ONE; - wipdata->nlinks = 1; - wipdata->op_flags = HAMMER2_OPFLAG_DIRECTDATA; + wipdata->meta.name_key = lhc; + wipdata->meta.name_len = name_len; + wipdata->meta.target_type = + hammer2_cluster_rdata(ocluster)->ipdata.meta.type; + wipdata->meta.type = HAMMER2_OBJTYPE_HARDLINK; + wipdata->meta.inum = + hammer2_cluster_rdata(ocluster)->ipdata.meta.inum; + wipdata->meta.version = HAMMER2_INODE_VERSION_ONE; + wipdata->meta.nlinks = 1; + wipdata->meta.op_flags = HAMMER2_OPFLAG_DIRECTDATA; hammer2_cluster_modsync(ncluster); hammer2_cluster_unlock(ncluster); hammer2_cluster_drop(ncluster); @@ -1056,9 +1060,9 @@ hammer2_inode_connect(hammer2_trans_t *trans, KKASSERT(name_len < HAMMER2_INODE_MAXNAME); bcopy(name, wipdata->filename, name_len); - wipdata->name_key = lhc; - wipdata->name_len = name_len; - wipdata->nlinks = 1; + wipdata->meta.name_key = lhc; + wipdata->meta.name_len = name_len; + wipdata->meta.nlinks = 1; hammer2_cluster_modsync(ncluster); } @@ -1297,7 +1301,7 @@ again: while (cluster) { if (hammer2_cluster_type(cluster) == HAMMER2_BREF_TYPE_INODE) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - if (ripdata->name_len == name_len && + if (ripdata->meta.name_len == name_len && bcmp(ripdata->filename, name, name_len) == 0) { break; } @@ -1318,10 +1322,10 @@ again: goto done; } ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - type = ripdata->type; + type = ripdata->meta.type; if (type == HAMMER2_OBJTYPE_HARDLINK) { hlink = 1; - type = ripdata->target_type; + type = ripdata->meta.target_type; } if (type == HAMMER2_OBJTYPE_DIRECTORY && isdir == 0) { @@ -1343,7 +1347,7 @@ again: * NOTE: hammer2_hardlink_find() will locate the hardlink target, * returning a modified hparent and hcluster. */ - if (ripdata->type == HAMMER2_OBJTYPE_HARDLINK) { + if (ripdata->meta.type == HAMMER2_OBJTYPE_HARDLINK) { if (hcluster == NULL) { hcluster = cluster; cluster = NULL; /* safety */ @@ -1443,7 +1447,7 @@ again: * incrementing. */ ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - last_link = (ripdata->nlinks + nlinks == 0); + last_link = (ripdata->meta.nlinks + nlinks == 0); if (last_link) { /* @@ -1456,7 +1460,8 @@ again: hammer2_inode_t *ip; if (nlinks == -1) { - ip = hammer2_inode_lookup(trans->pmp, ripdata->inum); + ip = hammer2_inode_lookup(trans->pmp, + ripdata->meta.inum); if (ip) { atomic_set_int(&ip->flags, HAMMER2_INODE_ISUNLINKED); @@ -1472,14 +1477,14 @@ again: hammer2_cluster_modify(trans, cluster, 0); wipdata = &hammer2_cluster_wdata(cluster)->ipdata; ripdata = wipdata; - wipdata->nlinks += nlinks; + wipdata->meta.nlinks += nlinks; /* XXX debugging */ - if ((int64_t)wipdata->nlinks < 0) { - wipdata->nlinks = 0; + if ((int64_t)wipdata->meta.nlinks < 0) { + wipdata->meta.nlinks = 0; } hammer2_cluster_modsync(cluster); hammer2_inode_move_to_hidden(trans, &cparent, &cluster, - wipdata->inum); + wipdata->meta.inum); } else { /* * This won't get everything if a vnode is still @@ -1510,9 +1515,10 @@ again: hammer2_cluster_modify(trans, cluster, 0); wipdata = &hammer2_cluster_wdata(cluster)->ipdata; ripdata = wipdata; - wipdata->nlinks += nlinks; - if ((int64_t)wipdata->nlinks < 0) { /* XXX debugging */ - wipdata->nlinks = 0; + wipdata->meta.nlinks += nlinks; + /* XXX debugging */ + if ((int64_t)wipdata->meta.nlinks < 0) { + wipdata->meta.nlinks = 0; } hammer2_cluster_modsync(cluster); } @@ -1581,8 +1587,8 @@ hammer2_inode_install_hidden(hammer2_pfs_t *pmp) */ cparent = hammer2_inode_lock(pmp->iroot, HAMMER2_RESOLVE_ALWAYS); ripdata = &hammer2_cluster_rdata(cparent)->ipdata; - dip_check_algo = ripdata->check_algo; - dip_comp_algo = ripdata->comp_algo; + dip_check_algo = ripdata->meta.check_algo; + dip_comp_algo = ripdata->meta.comp_algo; ripdata = NULL; cluster = hammer2_cluster_lookup(cparent, &key_dummy, @@ -1634,11 +1640,11 @@ hammer2_inode_install_hidden(hammer2_pfs_t *pmp) hammer2_cluster_modify(&trans, cluster, 0); wipdata = &hammer2_cluster_wdata(cluster)->ipdata; - wipdata->type = HAMMER2_OBJTYPE_DIRECTORY; - wipdata->inum = HAMMER2_INODE_HIDDENDIR; - wipdata->nlinks = 1; - wipdata->comp_algo = dip_comp_algo; - wipdata->check_algo = dip_check_algo; + wipdata->meta.type = HAMMER2_OBJTYPE_DIRECTORY; + wipdata->meta.inum = HAMMER2_INODE_HIDDENDIR; + wipdata->meta.nlinks = 1; + wipdata->meta.comp_algo = dip_comp_algo; + wipdata->meta.check_algo = dip_check_algo; hammer2_cluster_modsync(cluster); kprintf("hammer2: PFS root missing hidden directory, creating\n"); @@ -1709,7 +1715,7 @@ hammer2_hardlink_consolidate(hammer2_trans_t *trans, cluster = *clusterp; ripdata = &hammer2_cluster_rdata(cluster)->ipdata; if (nlinks == 0 && /* no hardlink needed */ - (ripdata->name_key & HAMMER2_DIRHASH_VISIBLE)) { + (ripdata->meta.name_key & HAMMER2_DIRHASH_VISIBLE)) { return (0); } @@ -1729,11 +1735,11 @@ hammer2_hardlink_consolidate(hammer2_trans_t *trans, */ ripdata = &hammer2_cluster_rdata(cluster)->ipdata; if (cdip == ip->pip && - (ripdata->name_key & HAMMER2_DIRHASH_VISIBLE) == 0) { + (ripdata->meta.name_key & HAMMER2_DIRHASH_VISIBLE) == 0) { if (nlinks) { hammer2_cluster_modify(trans, cluster, 0); wipdata = &hammer2_cluster_wdata(cluster)->ipdata; - wipdata->nlinks += nlinks; + wipdata->meta.nlinks += nlinks; hammer2_cluster_modsync(cluster); ripdata = wipdata; } @@ -1763,8 +1769,8 @@ hammer2_hardlink_consolidate(hammer2_trans_t *trans, hammer2_cluster_delete(trans, cparent, cluster, 0); ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - KKASSERT(ripdata->type != HAMMER2_OBJTYPE_HARDLINK); - if (ripdata->name_key & HAMMER2_DIRHASH_VISIBLE) { + KKASSERT(ripdata->meta.type != HAMMER2_OBJTYPE_HARDLINK); + if (ripdata->meta.name_key & HAMMER2_DIRHASH_VISIBLE) { hammer2_cluster_t *ncluster; hammer2_key_t lhc; @@ -1779,41 +1785,42 @@ hammer2_hardlink_consolidate(hammer2_trans_t *trans, wipdata = &hammer2_cluster_wdata(ncluster)->ipdata; /* wipdata->comp_algo = ripdata->comp_algo; */ - wipdata->comp_algo = 0; - wipdata->check_algo = 0; - wipdata->version = HAMMER2_INODE_VERSION_ONE; - wipdata->inum = ripdata->inum; - wipdata->target_type = ripdata->type; - wipdata->type = HAMMER2_OBJTYPE_HARDLINK; - wipdata->uflags = 0; - wipdata->rmajor = 0; - wipdata->rminor = 0; - wipdata->ctime = 0; - wipdata->mtime = 0; - wipdata->atime = 0; - wipdata->btime = 0; - bzero(&wipdata->uid, sizeof(wipdata->uid)); - bzero(&wipdata->gid, sizeof(wipdata->gid)); - wipdata->op_flags = HAMMER2_OPFLAG_DIRECTDATA; - wipdata->cap_flags = 0; - wipdata->mode = 0; - wipdata->size = 0; - wipdata->nlinks = 1; - wipdata->iparent = 0; /* XXX */ - wipdata->pfs_type = 0; - wipdata->pfs_inum = 0; - bzero(&wipdata->pfs_clid, sizeof(wipdata->pfs_clid)); - bzero(&wipdata->pfs_fsid, sizeof(wipdata->pfs_fsid)); - wipdata->data_quota = 0; + wipdata->meta.comp_algo = 0; + wipdata->meta.check_algo = 0; + wipdata->meta.version = HAMMER2_INODE_VERSION_ONE; + wipdata->meta.inum = ripdata->meta.inum; + wipdata->meta.target_type = ripdata->meta.type; + wipdata->meta.type = HAMMER2_OBJTYPE_HARDLINK; + wipdata->meta.uflags = 0; + wipdata->meta.rmajor = 0; + wipdata->meta.rminor = 0; + wipdata->meta.ctime = 0; + wipdata->meta.mtime = 0; + wipdata->meta.atime = 0; + wipdata->meta.btime = 0; + bzero(&wipdata->meta.uid, sizeof(wipdata->meta.uid)); + bzero(&wipdata->meta.gid, sizeof(wipdata->meta.gid)); + wipdata->meta.op_flags = HAMMER2_OPFLAG_DIRECTDATA; + wipdata->meta.cap_flags = 0; + wipdata->meta.mode = 0; + wipdata->meta.size = 0; + wipdata->meta.nlinks = 1; + wipdata->meta.iparent = 0; /* XXX */ + wipdata->meta.pfs_type = 0; + wipdata->meta.pfs_inum = 0; + bzero(&wipdata->meta.pfs_clid, sizeof(wipdata->meta.pfs_clid)); + bzero(&wipdata->meta.pfs_fsid, sizeof(wipdata->meta.pfs_fsid)); + wipdata->meta.data_quota = 0; /* wipdata->data_count = 0; */ - wipdata->inode_quota = 0; + wipdata->meta.inode_quota = 0; /* wipdata->inode_count = 0; */ - wipdata->attr_tid = 0; - wipdata->dirent_tid = 0; + wipdata->meta.attr_tid = 0; + wipdata->meta.dirent_tid = 0; bzero(&wipdata->u, sizeof(wipdata->u)); - bcopy(ripdata->filename, wipdata->filename, ripdata->name_len); - wipdata->name_key = ncluster->focus->bref.key; - wipdata->name_len = ripdata->name_len; + bcopy(ripdata->filename, wipdata->filename, + ripdata->meta.name_len); + wipdata->meta.name_key = ncluster->focus->bref.key; + wipdata->meta.name_len = ripdata->meta.name_len; /* XXX transaction ids */ hammer2_cluster_modsync(ncluster); hammer2_cluster_unlock(ncluster); @@ -1909,7 +1916,7 @@ hammer2_hardlink_find(hammer2_inode_t *dip, * data. */ ipdata = &hammer2_cluster_rdata(cluster)->ipdata; - lhc = ipdata->inum; + lhc = ipdata->meta.inum; ipdata = NULL; /* safety */ hammer2_cluster_unlock(cluster); hammer2_cluster_drop(cluster); @@ -2031,13 +2038,13 @@ hammer2_inode_fsync(hammer2_trans_t *trans, hammer2_inode_t *ip, if (ip->flags & HAMMER2_INODE_MTIME) { wipdata = hammer2_cluster_modify_ip(trans, ip, cparent, 0); atomic_clear_int(&ip->flags, HAMMER2_INODE_MTIME); - wipdata->mtime = ip->mtime; + wipdata->meta.mtime = ip->mtime; dosync = 1; ripdata = wipdata; } - if ((ip->flags & HAMMER2_INODE_RESIZED) && ip->size < ripdata->size) { + if ((ip->flags & HAMMER2_INODE_RESIZED) && ip->size < ripdata->meta.size) { wipdata = hammer2_cluster_modify_ip(trans, ip, cparent, 0); - wipdata->size = ip->size; + wipdata->meta.size = ip->size; dosync = 1; ripdata = wipdata; atomic_clear_int(&ip->flags, HAMMER2_INODE_RESIZED); @@ -2046,7 +2053,7 @@ hammer2_inode_fsync(hammer2_trans_t *trans, hammer2_inode_t *ip, * We must delete any chains beyond the EOF. The chain * straddling the EOF will be pending in the bioq. */ - lbase = (ripdata->size + HAMMER2_PBUFMASK64) & + lbase = (ripdata->meta.size + HAMMER2_PBUFMASK64) & ~HAMMER2_PBUFMASK64; dparent = hammer2_cluster_lookup_init(&ip->cluster, 0); cluster = hammer2_cluster_lookup(dparent, &key_next, @@ -2076,18 +2083,19 @@ hammer2_inode_fsync(hammer2_trans_t *trans, hammer2_inode_t *ip, } hammer2_cluster_lookup_done(dparent); } else - if ((ip->flags & HAMMER2_INODE_RESIZED) && ip->size > ripdata->size) { + if ((ip->flags & HAMMER2_INODE_RESIZED) && + ip->size > ripdata->meta.size) { wipdata = hammer2_cluster_modify_ip(trans, ip, cparent, 0); - wipdata->size = ip->size; + wipdata->meta.size = ip->size; atomic_clear_int(&ip->flags, HAMMER2_INODE_RESIZED); /* * When resizing larger we may not have any direct-data * available. */ - if ((wipdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA) && + if ((wipdata->meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) && ip->size > HAMMER2_EMBEDDED_BYTES) { - wipdata->op_flags &= ~HAMMER2_OPFLAG_DIRECTDATA; + wipdata->meta.op_flags &= ~HAMMER2_OPFLAG_DIRECTDATA; bzero(&wipdata->u.blockset, sizeof(wipdata->u.blockset)); } diff --git a/sys/vfs/hammer2/hammer2_iocom.c b/sys/vfs/hammer2/hammer2_iocom.c index ca4e170fa8..9d8963db86 100644 --- a/sys/vfs/hammer2/hammer2_iocom.c +++ b/sys/vfs/hammer2/hammer2_iocom.c @@ -126,7 +126,7 @@ hammer2_cluster_reconnect(hammer2_dev_t *hmp, struct file *fp) hmp->iocom.auto_lnk_conn.peer_mask = 1LLU << DMSG_PEER_HAMMER2; #if 0 - switch (ipdata->pfs_type) { + switch (ipdata->meta.pfs_type) { case DMSG_PFSTYPE_CLIENT: hmp->iocom.auto_lnk_conn.peer_mask &= ~(1LLU << DMSG_PFSTYPE_CLIENT); @@ -312,12 +312,12 @@ hammer2_update_spans(hammer2_dev_t *hmp, kdmsg_state_t *state) rmsg = kdmsg_msg_alloc(&hmp->iocom.state0, DMSG_LNK_SPAN | DMSGF_CREATE, hammer2_lnk_span_reply, NULL); - rmsg->any.lnk_span.peer_id = ripdata->pfs_clid; - rmsg->any.lnk_span.pfs_id = ripdata->pfs_fsid; - rmsg->any.lnk_span.pfs_type = ripdata->pfs_type; + rmsg->any.lnk_span.peer_id = ripdata->meta.pfs_clid; + rmsg->any.lnk_span.pfs_id = ripdata->meta.pfs_fsid; + rmsg->any.lnk_span.pfs_type = ripdata->meta.pfs_type; rmsg->any.lnk_span.peer_type = DMSG_PEER_HAMMER2; rmsg->any.lnk_span.proto_version = DMSG_SPAN_PROTO_1; - name_len = ripdata->name_len; + name_len = ripdata->meta.name_len; if (name_len >= sizeof(rmsg->any.lnk_span.peer_label)) name_len = sizeof(rmsg->any.lnk_span.peer_label) - 1; bcopy(ripdata->filename, diff --git a/sys/vfs/hammer2/hammer2_ioctl.c b/sys/vfs/hammer2/hammer2_ioctl.c index ae41009502..c671cfbe5c 100644 --- a/sys/vfs/hammer2/hammer2_ioctl.c +++ b/sys/vfs/hammer2/hammer2_ioctl.c @@ -394,8 +394,8 @@ hammer2_ioctl_pfs_get(hammer2_inode_t *ip, void *data) } else if (pfs->name_key == (hammer2_key_t)-1) { ripdata = &hammer2_cluster_rdata(rcluster)->ipdata; cluster = hammer2_cluster_lookup(cparent, &key_next, - ripdata->name_key, - ripdata->name_key, + ripdata->meta.name_key, + ripdata->meta.name_key, 0); ripdata = NULL; /* safety */ } else { @@ -416,14 +416,14 @@ hammer2_ioctl_pfs_get(hammer2_inode_t *ip, void *data) * Load the data being returned by the ioctl. */ ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - pfs->name_key = ripdata->name_key; - pfs->pfs_type = ripdata->pfs_type; - pfs->pfs_subtype = ripdata->pfs_subtype; - pfs->pfs_clid = ripdata->pfs_clid; - pfs->pfs_fsid = ripdata->pfs_fsid; - KKASSERT(ripdata->name_len < sizeof(pfs->name)); - bcopy(ripdata->filename, pfs->name, ripdata->name_len); - pfs->name[ripdata->name_len] = 0; + pfs->name_key = ripdata->meta.name_key; + pfs->pfs_type = ripdata->meta.pfs_type; + pfs->pfs_subtype = ripdata->meta.pfs_subtype; + pfs->pfs_clid = ripdata->meta.pfs_clid; + pfs->pfs_fsid = ripdata->meta.pfs_fsid; + KKASSERT(ripdata->meta.name_len < sizeof(pfs->name)); + bcopy(ripdata->filename, pfs->name, ripdata->meta.name_len); + pfs->name[ripdata->meta.name_len] = 0; ripdata = NULL; /* safety */ /* @@ -439,7 +439,7 @@ hammer2_ioctl_pfs_get(hammer2_inode_t *ip, void *data) HAMMER2_BREF_TYPE_INODE); if (cluster) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - pfs->name_next = ripdata->name_key; + pfs->name_next = ripdata->meta.name_key; hammer2_cluster_unlock(cluster); hammer2_cluster_drop(cluster); } else { @@ -486,7 +486,7 @@ hammer2_ioctl_pfs_lookup(hammer2_inode_t *ip, void *data) while (cluster) { if (hammer2_cluster_type(cluster) == HAMMER2_BREF_TYPE_INODE) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - if (ripdata->name_len == len && + if (ripdata->meta.name_len == len && bcmp(ripdata->filename, pfs->name, len) == 0) { break; } @@ -503,11 +503,11 @@ hammer2_ioctl_pfs_lookup(hammer2_inode_t *ip, void *data) */ if (cluster) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - pfs->name_key = ripdata->name_key; - pfs->pfs_type = ripdata->pfs_type; - pfs->pfs_subtype = ripdata->pfs_subtype; - pfs->pfs_clid = ripdata->pfs_clid; - pfs->pfs_fsid = ripdata->pfs_fsid; + pfs->name_key = ripdata->meta.name_key; + pfs->pfs_type = ripdata->meta.pfs_type; + pfs->pfs_subtype = ripdata->meta.pfs_subtype; + pfs->pfs_clid = ripdata->meta.pfs_clid; + pfs->pfs_fsid = ripdata->meta.pfs_fsid; ripdata = NULL; hammer2_cluster_unlock(cluster); @@ -553,11 +553,11 @@ hammer2_ioctl_pfs_create(hammer2_inode_t *ip, void *data) HAMMER2_INSERT_PFSROOT, &error); if (error == 0) { nipdata = hammer2_cluster_modify_ip(&trans, nip, ncluster, 0); - nipdata->pfs_type = pfs->pfs_type; - nipdata->pfs_subtype = pfs->pfs_subtype; - nipdata->pfs_clid = pfs->pfs_clid; - nipdata->pfs_fsid = pfs->pfs_fsid; - nipdata->op_flags |= HAMMER2_OPFLAG_PFSROOT; + nipdata->meta.pfs_type = pfs->pfs_type; + nipdata->meta.pfs_subtype = pfs->pfs_subtype; + nipdata->meta.pfs_clid = pfs->pfs_clid; + nipdata->meta.pfs_fsid = pfs->pfs_fsid; + nipdata->meta.op_flags |= HAMMER2_OPFLAG_PFSROOT; /* * Set default compression and check algorithm. This @@ -566,13 +566,13 @@ hammer2_ioctl_pfs_create(hammer2_inode_t *ip, void *data) * Do not allow compression on PFS's with the special name * "boot", the boot loader can't decompress (yet). */ - nipdata->comp_algo = + nipdata->meta.comp_algo = HAMMER2_ENC_ALGO(HAMMER2_COMP_NEWFS_DEFAULT); - nipdata->check_algo = + nipdata->meta.check_algo = HAMMER2_ENC_ALGO( HAMMER2_CHECK_ISCSI32); if (strcasecmp(pfs->name, "boot") == 0) { - nipdata->comp_algo = + nipdata->meta.comp_algo = HAMMER2_ENC_ALGO(HAMMER2_COMP_AUTOZERO); } hammer2_cluster_modsync(ncluster); @@ -684,17 +684,17 @@ hammer2_ioctl_inode_set(hammer2_inode_t *ip, void *data) cparent = hammer2_inode_lock(ip, HAMMER2_RESOLVE_ALWAYS); ripdata = &hammer2_cluster_rdata(cparent)->ipdata; - if (ino->ip_data.check_algo != ripdata->check_algo) { + if (ino->ip_data.meta.check_algo != ripdata->meta.check_algo) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cparent, 0); - wipdata->check_algo = ino->ip_data.check_algo; + wipdata->meta.check_algo = ino->ip_data.meta.check_algo; ripdata = wipdata; /* safety */ hammer2_cluster_setmethod_check(&trans, cparent, - wipdata->check_algo); + wipdata->meta.check_algo); dosync = 1; } - if (ino->ip_data.comp_algo != ripdata->comp_algo) { + if (ino->ip_data.meta.comp_algo != ripdata->meta.comp_algo) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cparent, 0); - wipdata->comp_algo = ino->ip_data.comp_algo; + wipdata->meta.comp_algo = ino->ip_data.meta.comp_algo; ripdata = wipdata; /* safety */ dosync = 1; } diff --git a/sys/vfs/hammer2/hammer2_subr.c b/sys/vfs/hammer2/hammer2_subr.c index 212145cb83..53e3f2844e 100644 --- a/sys/vfs/hammer2/hammer2_subr.c +++ b/sys/vfs/hammer2/hammer2_subr.c @@ -73,8 +73,8 @@ hammer2_get_dtype(const hammer2_inode_data_t *ipdata) { uint8_t type; - if ((type = ipdata->type) == HAMMER2_OBJTYPE_HARDLINK) - type = ipdata->target_type; + if ((type = ipdata->meta.type) == HAMMER2_OBJTYPE_HARDLINK) + type = ipdata->meta.target_type; switch(type) { case HAMMER2_OBJTYPE_UNKNOWN: @@ -109,7 +109,7 @@ hammer2_get_dtype(const hammer2_inode_data_t *ipdata) int hammer2_get_vtype(const hammer2_inode_data_t *ipdata) { - switch(ipdata->type) { + switch(ipdata->meta.type) { case HAMMER2_OBJTYPE_UNKNOWN: return (VBAD); case HAMMER2_OBJTYPE_DIRECTORY: @@ -374,11 +374,11 @@ hammer2_calc_physical(hammer2_inode_t *ip, int eofbytes; lblksize = hammer2_calc_logical(ip, lbase, NULL, NULL); - if (lbase + lblksize <= ipdata->size) + if (lbase + lblksize <= ipdata->meta.size) return (lblksize); - if (lbase >= ipdata->size) + if (lbase >= ipdata->meta.size) return (0); - eofbytes = (int)(ipdata->size - lbase); + eofbytes = (int)(ipdata->meta.size - lbase); pblksize = lblksize; while (pblksize >= eofbytes && pblksize >= HAMMER2_ALLOC_MIN) pblksize >>= 1; diff --git a/sys/vfs/hammer2/hammer2_syncthr.c b/sys/vfs/hammer2/hammer2_syncthr.c index 655142e3ad..ffe1ca66c8 100644 --- a/sys/vfs/hammer2/hammer2_syncthr.c +++ b/sys/vfs/hammer2/hammer2_syncthr.c @@ -741,7 +741,7 @@ hammer2_sync_insert(hammer2_syncthr_t *thr, */ switch(chain->bref.type) { case HAMMER2_BREF_TYPE_INODE: - if ((focus->data->ipdata.op_flags & + if ((focus->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0) { bcopy(focus->data, chain->data, offsetof(hammer2_inode_data_t, u)); @@ -876,7 +876,7 @@ hammer2_sync_replace(hammer2_syncthr_t *thr, */ switch(chain->bref.type) { case HAMMER2_BREF_TYPE_INODE: - if ((focus->data->ipdata.op_flags & + if ((focus->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) == 0) { /* * If DIRECTDATA is transitioning to 0 or the old @@ -884,7 +884,7 @@ hammer2_sync_replace(hammer2_syncthr_t *thr, * the block table. */ if (otype != HAMMER2_BREF_TYPE_INODE || - (chain->data->ipdata.op_flags & + (chain->data->ipdata.meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA)) { kprintf("chain inode transiiton away from dd\n"); bzero(&chain->data->ipdata.u, diff --git a/sys/vfs/hammer2/hammer2_vfsops.c b/sys/vfs/hammer2/hammer2_vfsops.c index 661bc4fcca..64def26f81 100644 --- a/sys/vfs/hammer2/hammer2_vfsops.c +++ b/sys/vfs/hammer2/hammer2_vfsops.c @@ -106,11 +106,13 @@ long hammer2_ioa_meta_write; long hammer2_ioa_indr_write; long hammer2_ioa_volu_write; -MALLOC_DECLARE(C_BUFFER); -MALLOC_DEFINE(C_BUFFER, "compbuffer", "Buffer used for compression."); +MALLOC_DECLARE(M_HAMMER2_CBUFFER); +MALLOC_DEFINE(M_HAMMER2_CBUFFER, "HAMMER2-compbuffer", + "Buffer used for compression."); -MALLOC_DECLARE(D_BUFFER); -MALLOC_DEFINE(D_BUFFER, "decompbuffer", "Buffer used for decompression."); +MALLOC_DECLARE(M_HAMMER2_DEBUFFER); +MALLOC_DEFINE(M_HAMMER2_DEBUFFER, "HAMMER2-decompbuffer", + "Buffer used for decompression."); SYSCTL_NODE(_vfs, OID_AUTO, hammer2, CTLFLAG_RW, 0, "HAMMER2 filesystem"); @@ -268,6 +270,7 @@ hammer2_vfs_init(struct vfsconf *conf) { static struct objcache_malloc_args margs_read; static struct objcache_malloc_args margs_write; + static struct objcache_malloc_args margs_vop; int error; @@ -284,10 +287,13 @@ hammer2_vfs_init(struct vfsconf *conf) kprintf("HAMMER2 structure size mismatch; cannot continue.\n"); margs_read.objsize = 65536; - margs_read.mtype = D_BUFFER; + margs_read.mtype = M_HAMMER2_DEBUFFER; margs_write.objsize = 32768; - margs_write.mtype = C_BUFFER; + margs_write.mtype = M_HAMMER2_CBUFFER; + + margs_vop.objsize = sizeof(hammer2_vop_info_t); + margs_vop.mtype = M_HAMMER2; cache_buffer_read = objcache_create(margs_read.mtype->ks_shortdesc, 0, 1, NULL, NULL, NULL, objcache_malloc_alloc, @@ -295,6 +301,10 @@ hammer2_vfs_init(struct vfsconf *conf) cache_buffer_write = objcache_create(margs_write.mtype->ks_shortdesc, 0, 1, NULL, NULL, NULL, objcache_malloc_alloc, objcache_malloc_free, &margs_write); + cache_vop_info = objcache_create(margs_vop.mtype->ks_shortdesc, + 0, 1, NULL, NULL, NULL, objcache_malloc_alloc, + objcache_malloc_free, &margs_vop); + lockinit(&hammer2_mntlk, "mntlk", 0, 0); TAILQ_INIT(&hammer2_mntlist); @@ -311,6 +321,7 @@ hammer2_vfs_uninit(struct vfsconf *vfsp __unused) { objcache_destroy(cache_buffer_read); objcache_destroy(cache_buffer_write); + objcache_destroy(cache_vop_info); return 0; } @@ -343,7 +354,7 @@ hammer2_pfsalloc(hammer2_cluster_t *cluster, */ if (ripdata) { TAILQ_FOREACH(pmp, &hammer2_pfslist, mntentry) { - if (bcmp(&pmp->pfs_clid, &ripdata->pfs_clid, + if (bcmp(&pmp->pfs_clid, &ripdata->meta.pfs_clid, sizeof(pmp->pfs_clid)) == 0) { break; } @@ -368,7 +379,7 @@ hammer2_pfsalloc(hammer2_cluster_t *cluster, * initial */ if (ripdata) - pmp->pfs_clid = ripdata->pfs_clid; + pmp->pfs_clid = ripdata->meta.pfs_clid; hammer2_mtx_init(&pmp->wthread_mtx, "h2wthr"); bioq_init(&pmp->wthread_bioq); TAILQ_INSERT_TAIL(&hammer2_pfslist, pmp, mntentry); @@ -423,7 +434,7 @@ hammer2_pfsalloc(hammer2_cluster_t *cluster, rchain->pmp = pmp; hammer2_chain_ref(rchain); iroot->cluster.array[j].chain = rchain; - pmp->pfs_types[j] = ripdata->pfs_type; + pmp->pfs_types[j] = ripdata->meta.pfs_type; pmp->pfs_names[j] = kstrdup(ripdata->filename, M_HAMMER2); /* @@ -457,13 +468,13 @@ hammer2_pfsalloc(hammer2_cluster_t *cluster, * (This informs us of masters that might not currently be * discoverable by this mount). */ - if (ripdata && pmp->pfs_nmasters < ripdata->pfs_nmasters) { - pmp->pfs_nmasters = ripdata->pfs_nmasters; + if (ripdata && pmp->pfs_nmasters < ripdata->meta.pfs_nmasters) { + pmp->pfs_nmasters = ripdata->meta.pfs_nmasters; } /* * Count visible masters. Masters are usually added with - * ripdata->pfs_nmasters set to 1. This detects when there + * ripdata->meta.pfs_nmasters set to 1. This detects when there * are more (XXX and must update the master inodes). */ count = 0; @@ -973,7 +984,7 @@ hammer2_vfs_mount(struct mount *mp, char *path, caddr_t data, */ ripdata = &hammer2_chain_rdata(schain)->ipdata; KKASSERT(schain->pmp == NULL); - spmp->pfs_clid = ripdata->pfs_clid; + spmp->pfs_clid = ripdata->meta.pfs_clid; /* * Replace the dummy spmp->iroot with a real one. It's @@ -987,7 +998,7 @@ hammer2_vfs_mount(struct mount *mp, char *path, caddr_t data, spmp->iroot = NULL; spmp->iroot = hammer2_inode_get(spmp, NULL, cluster); spmp->spmp_hmp = hmp; - spmp->pfs_types[0] = ripdata->pfs_type; + spmp->pfs_types[0] = ripdata->meta.pfs_type; hammer2_inode_ref(spmp->iroot); hammer2_inode_unlock(spmp->iroot, cluster); schain = NULL; @@ -1429,7 +1440,7 @@ hammer2_write_file_core(struct buf *bp, hammer2_trans_t *trans, { hammer2_cluster_t *cluster; - switch(HAMMER2_DEC_ALGO(ripdata->comp_algo)) { + switch(HAMMER2_DEC_ALGO(ripdata->meta.comp_algo)) { case HAMMER2_COMP_NONE: /* * We have to assign physical storage to the buffer @@ -1447,14 +1458,15 @@ hammer2_write_file_core(struct buf *bp, hammer2_trans_t *trans, wipdata = hammer2_cluster_modify_ip(trans, ip, cluster, 0); - KKASSERT(wipdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA); + KKASSERT(wipdata->meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA); KKASSERT(bp->b_loffset == 0); bcopy(bp->b_data, wipdata->u.data, HAMMER2_EMBEDDED_BYTES); hammer2_cluster_modsync(cluster); } else { hammer2_write_bp(cluster, bp, ioflag, pblksize, - errorp, ripdata->check_algo); + errorp, ripdata->meta.check_algo); } /* ripdata can become invalid */ if (cluster) { @@ -1469,7 +1481,7 @@ hammer2_write_file_core(struct buf *bp, hammer2_trans_t *trans, hammer2_zero_check_and_write(bp, trans, ip, ripdata, cparent, lbase, ioflag, pblksize, errorp, - ripdata->check_algo); + ripdata->meta.check_algo); break; case HAMMER2_COMP_LZ4: case HAMMER2_COMP_ZLIB: @@ -1481,8 +1493,8 @@ hammer2_write_file_core(struct buf *bp, hammer2_trans_t *trans, ripdata, cparent, lbase, ioflag, pblksize, errorp, - ripdata->comp_algo, - ripdata->check_algo); + ripdata->meta.comp_algo, + ripdata->meta.check_algo); break; } } @@ -1624,7 +1636,7 @@ hammer2_compress_and_write(struct buf *bp, hammer2_trans_t *trans, hammer2_inode_data_t *wipdata; wipdata = &hammer2_cluster_wdata(cluster)->ipdata; - KKASSERT(wipdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA); + KKASSERT(wipdata->meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA); KKASSERT(bp->b_loffset == 0); bcopy(bp->b_data, wipdata->u.data, HAMMER2_EMBEDDED_BYTES); hammer2_cluster_modsync(cluster); @@ -1801,7 +1813,8 @@ zero_write(struct buf *bp, hammer2_trans_t *trans, wipdata = hammer2_cluster_modify_ip(trans, ip, cluster, 0); - KKASSERT(wipdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA); + KKASSERT(wipdata->meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA); KKASSERT(bp->b_loffset == 0); bzero(wipdata->u.data, HAMMER2_EMBEDDED_BYTES); hammer2_cluster_modsync(cluster); @@ -1845,7 +1858,8 @@ hammer2_write_bp(hammer2_cluster_t *cluster, struct buf *bp, int ioflag, switch(chain->bref.type) { case HAMMER2_BREF_TYPE_INODE: wipdata = &hammer2_chain_wdata(chain)->ipdata; - KKASSERT(wipdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA); + KKASSERT(wipdata->meta.op_flags & + HAMMER2_OPFLAG_DIRECTDATA); KKASSERT(bp->b_loffset == 0); bcopy(bp->b_data, wipdata->u.data, HAMMER2_EMBEDDED_BYTES); @@ -2235,7 +2249,7 @@ hammer2_vfs_root(struct mount *mp, struct vnode **vpp) /* * Filesystem status * - * XXX incorporate ipdata->inode_quota and data_quota + * XXX incorporate ipdata->meta.inode_quota and data_quota */ static int @@ -2409,7 +2423,7 @@ hammer2_recovery_scan(hammer2_trans_t *trans, hammer2_dev_t *hmp, */ hammer2_chain_lock(parent, HAMMER2_RESOLVE_ALWAYS); ripdata = &hammer2_chain_rdata(parent)->ipdata; - if (ripdata->op_flags & HAMMER2_OPFLAG_DIRECTDATA) { + if (ripdata->meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA) { /* not applicable to recovery scan */ hammer2_chain_unlock(parent); return 0; diff --git a/sys/vfs/hammer2/hammer2_vnops.c b/sys/vfs/hammer2/hammer2_vnops.c index f5cba6f429..6f45a00852 100644 --- a/sys/vfs/hammer2/hammer2_vnops.c +++ b/sys/vfs/hammer2/hammer2_vnops.c @@ -253,9 +253,10 @@ hammer2_vop_access(struct vop_access_args *ap) cluster = hammer2_inode_lock(ip, HAMMER2_RESOLVE_ALWAYS | HAMMER2_RESOLVE_SHARED); ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - uid = hammer2_to_unix_xid(&ripdata->uid); - gid = hammer2_to_unix_xid(&ripdata->gid); - error = vop_helper_access(ap, uid, gid, ripdata->mode, ripdata->uflags); + uid = hammer2_to_unix_xid(&ripdata->meta.uid); + gid = hammer2_to_unix_xid(&ripdata->meta.gid); + error = vop_helper_access(ap, uid, gid, + ripdata->meta.mode, ripdata->meta.uflags); hammer2_inode_unlock(ip, cluster); LOCKSTOP; @@ -288,25 +289,25 @@ hammer2_vop_getattr(struct vop_getattr_args *ap) hammer2_cluster_bref(cluster, &bref); vap->va_fsid = pmp->mp->mnt_stat.f_fsid.val[0]; - vap->va_fileid = ripdata->inum; - vap->va_mode = ripdata->mode; - vap->va_nlink = ripdata->nlinks; - vap->va_uid = hammer2_to_unix_xid(&ripdata->uid); - vap->va_gid = hammer2_to_unix_xid(&ripdata->gid); + vap->va_fileid = ripdata->meta.inum; + vap->va_mode = ripdata->meta.mode; + vap->va_nlink = ripdata->meta.nlinks; + vap->va_uid = hammer2_to_unix_xid(&ripdata->meta.uid); + vap->va_gid = hammer2_to_unix_xid(&ripdata->meta.gid); vap->va_rmajor = 0; vap->va_rminor = 0; vap->va_size = ip->size; /* protected by shared lock */ vap->va_blocksize = HAMMER2_PBUFSIZE; - vap->va_flags = ripdata->uflags; - hammer2_time_to_timespec(ripdata->ctime, &vap->va_ctime); - hammer2_time_to_timespec(ripdata->mtime, &vap->va_mtime); - hammer2_time_to_timespec(ripdata->mtime, &vap->va_atime); + vap->va_flags = ripdata->meta.uflags; + hammer2_time_to_timespec(ripdata->meta.ctime, &vap->va_ctime); + hammer2_time_to_timespec(ripdata->meta.mtime, &vap->va_mtime); + hammer2_time_to_timespec(ripdata->meta.mtime, &vap->va_atime); vap->va_gen = 1; vap->va_bytes = bref.data_count; vap->va_type = hammer2_get_vtype(ripdata); vap->va_filerev = 0; - vap->va_uid_uuid = ripdata->uid; - vap->va_gid_uuid = ripdata->gid; + vap->va_uid_uuid = ripdata->meta.uid; + vap->va_gid_uuid = ripdata->meta.gid; vap->va_vaflags = VA_UID_UUID_VALID | VA_GID_UUID_VALID | VA_FSID_UUID_VALID; @@ -354,35 +355,35 @@ hammer2_vop_setattr(struct vop_setattr_args *ap) if (vap->va_flags != VNOVAL) { u_int32_t flags; - flags = ripdata->uflags; + flags = ripdata->meta.uflags; error = vop_helper_setattr_flags(&flags, vap->va_flags, - hammer2_to_unix_xid(&ripdata->uid), - ap->a_cred); + hammer2_to_unix_xid(&ripdata->meta.uid), + ap->a_cred); if (error == 0) { - if (ripdata->uflags != flags) { + if (ripdata->meta.uflags != flags) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cluster, 0); - wipdata->uflags = flags; - wipdata->ctime = ctime; + wipdata->meta.uflags = flags; + wipdata->meta.ctime = ctime; kflags |= NOTE_ATTRIB; dosync = 1; ripdata = wipdata; } - if (ripdata->uflags & (IMMUTABLE | APPEND)) { + if (ripdata->meta.uflags & (IMMUTABLE | APPEND)) { error = 0; goto done; } } goto done; } - if (ripdata->uflags & (IMMUTABLE | APPEND)) { + if (ripdata->meta.uflags & (IMMUTABLE | APPEND)) { error = EPERM; goto done; } if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { - mode_t cur_mode = ripdata->mode; - uid_t cur_uid = hammer2_to_unix_xid(&ripdata->uid); - gid_t cur_gid = hammer2_to_unix_xid(&ripdata->gid); + mode_t cur_mode = ripdata->meta.mode; + uid_t cur_uid = hammer2_to_unix_xid(&ripdata->meta.uid); + gid_t cur_gid = hammer2_to_unix_xid(&ripdata->meta.gid); uuid_t uuid_uid; uuid_t uuid_gid; @@ -392,16 +393,18 @@ hammer2_vop_setattr(struct vop_setattr_args *ap) if (error == 0) { hammer2_guid_to_uuid(&uuid_uid, cur_uid); hammer2_guid_to_uuid(&uuid_gid, cur_gid); - if (bcmp(&uuid_uid, &ripdata->uid, sizeof(uuid_uid)) || - bcmp(&uuid_gid, &ripdata->gid, sizeof(uuid_gid)) || - ripdata->mode != cur_mode + if (bcmp(&uuid_uid, &ripdata->meta.uid, + sizeof(uuid_uid)) || + bcmp(&uuid_gid, &ripdata->meta.gid, + sizeof(uuid_gid)) || + ripdata->meta.mode != cur_mode ) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cluster, 0); - wipdata->uid = uuid_uid; - wipdata->gid = uuid_gid; - wipdata->mode = cur_mode; - wipdata->ctime = ctime; + wipdata->meta.uid = uuid_uid; + wipdata->meta.gid = uuid_gid; + wipdata->meta.mode = cur_mode; + wipdata->meta.ctime = ctime; dosync = 1; ripdata = wipdata; } @@ -438,7 +441,7 @@ hammer2_vop_setattr(struct vop_setattr_args *ap) /* atime not supported */ if (vap->va_atime.tv_sec != VNOVAL) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cluster, 0); - wipdata->atime = hammer2_timespec_to_time(&vap->va_atime); + wipdata->meta.atime = hammer2_timespec_to_time(&vap->va_atime); kflags |= NOTE_ATTRIB; dosync = 1; ripdata = wipdata; @@ -446,24 +449,24 @@ hammer2_vop_setattr(struct vop_setattr_args *ap) #endif if (vap->va_mtime.tv_sec != VNOVAL) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cluster, 0); - wipdata->mtime = hammer2_timespec_to_time(&vap->va_mtime); + wipdata->meta.mtime = hammer2_timespec_to_time(&vap->va_mtime); kflags |= NOTE_ATTRIB; domtime = 0; dosync = 1; ripdata = wipdata; } if (vap->va_mode != (mode_t)VNOVAL) { - mode_t cur_mode = ripdata->mode; - uid_t cur_uid = hammer2_to_unix_xid(&ripdata->uid); - gid_t cur_gid = hammer2_to_unix_xid(&ripdata->gid); + mode_t cur_mode = ripdata->meta.mode; + uid_t cur_uid = hammer2_to_unix_xid(&ripdata->meta.uid); + gid_t cur_gid = hammer2_to_unix_xid(&ripdata->meta.gid); error = vop_helper_chmod(ap->a_vp, vap->va_mode, ap->a_cred, cur_uid, cur_gid, &cur_mode); - if (error == 0 && ripdata->mode != cur_mode) { + if (error == 0 && ripdata->meta.mode != cur_mode) { wipdata = hammer2_cluster_modify_ip(&trans, ip, cluster, 0); - wipdata->mode = cur_mode; - wipdata->ctime = ctime; + wipdata->meta.mode = cur_mode; + wipdata->meta.ctime = ctime; kflags |= NOTE_ATTRIB; dosync = 1; ripdata = wipdata; @@ -562,7 +565,7 @@ hammer2_vop_readdir(struct vop_readdir_args *ap) cluster = (void *)(intptr_t)-1; /* non-NULL for early goto done case */ if (saveoff == 0) { - inum = ripdata->inum & HAMMER2_DIRHASH_USERMSK; + inum = ripdata->meta.inum & HAMMER2_DIRHASH_USERMSK; r = vop_write_dirent(&error, uio, inum, DT_DIR, 1, "."); if (r) goto done; @@ -580,7 +583,7 @@ hammer2_vop_readdir(struct vop_readdir_args *ap) * * (ip is the current dir. xip is the parent dir). */ - inum = ripdata->inum & HAMMER2_DIRHASH_USERMSK; + inum = ripdata->meta.inum & HAMMER2_DIRHASH_USERMSK; while (ip->pip != NULL && ip != ip->pmp->iroot) { xip = ip->pip; hammer2_inode_ref(xip); @@ -596,7 +599,8 @@ hammer2_vop_readdir(struct vop_readdir_args *ap) ripdata = &hammer2_cluster_rdata(cparent)->ipdata; if (xip == ip->pip) { inum = hammer2_cluster_rdata(xcluster)-> - ipdata.inum & HAMMER2_DIRHASH_USERMSK; + ipdata.meta.inum & + HAMMER2_DIRHASH_USERMSK; hammer2_inode_unlock(xip, xcluster); break; } @@ -644,10 +648,10 @@ hammer2_vop_readdir(struct vop_readdir_args *ap) dtype = hammer2_get_dtype(ripdata); saveoff = bref.key & HAMMER2_DIRHASH_USERMSK; r = vop_write_dirent(&error, uio, - ripdata->inum & + ripdata->meta.inum & HAMMER2_DIRHASH_USERMSK, dtype, - ripdata->name_len, + ripdata->meta.name_len, ripdata->filename); if (r) break; @@ -1157,7 +1161,7 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap) while (cluster) { if (hammer2_cluster_type(cluster) == HAMMER2_BREF_TYPE_INODE) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - if (ripdata->name_len == name_len && + if (ripdata->meta.name_len == name_len && bcmp(ripdata->filename, name, name_len) == 0) { break; } @@ -1174,8 +1178,8 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap) */ if (cluster) { ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - if (ripdata->type == HAMMER2_OBJTYPE_HARDLINK) { - hammer2_tid_t inum = ripdata->inum; + if (ripdata->meta.type == HAMMER2_OBJTYPE_HARDLINK) { + hammer2_tid_t inum = ripdata->meta.inum; error = hammer2_hardlink_find(dip, NULL, &cluster); if (error) { kprintf("hammer2: unable to find hardlink " @@ -1194,7 +1198,7 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap) if (cluster) { ip = hammer2_inode_get(dip->pmp, dip, cluster); ripdata = &hammer2_cluster_rdata(cluster)->ipdata; - if (ripdata->type == HAMMER2_OBJTYPE_HARDLINK) { + if (ripdata->meta.type == HAMMER2_OBJTYPE_HARDLINK) { kprintf("nresolve: fixup hardlink\n"); hammer2_inode_ref(ip); hammer2_inode_unlock(ip, NULL); @@ -1205,7 +1209,7 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap) ripdata = &hammer2_cluster_rdata(cluster)->ipdata; hammer2_inode_drop(ip); kprintf("nresolve: fixup to type %02x\n", - ripdata->type); + ripdata->meta.type); } } else { ip = NULL; @@ -1219,7 +1223,7 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap) * XXX upgrade shared lock? */ if (ochain && chain && - chain->data->ipdata.nlinks == 1 && !dip->pmp->ronly) { + chain->data->ipdata.meta.nlinks == 1 && !dip->pmp->ronly) { kprintf("hammer2: need to unconsolidate hardlink for %s\n", chain->data->ipdata.filename); /* XXX retain shared lock on dip? (currently not held) */ @@ -1367,7 +1371,7 @@ hammer2_vop_advlock(struct vop_advlock_args *ap) cparent = hammer2_inode_lock(ip, HAMMER2_RESOLVE_ALWAYS | HAMMER2_RESOLVE_SHARED); ripdata = &hammer2_cluster_rdata(cparent)->ipdata; - size = ripdata->size; + size = ripdata->meta.size; hammer2_inode_unlock(ip, cparent); return (lf_advlock(ap, &ip->advlock, size)); } @@ -1626,10 +1630,10 @@ hammer2_vop_nsymlink(struct vop_nsymlink_args *ap) bytes = strlen(ap->a_target); if (bytes <= HAMMER2_EMBEDDED_BYTES) { - KKASSERT(nipdata->op_flags & + KKASSERT(nipdata->meta.op_flags & HAMMER2_OPFLAG_DIRECTDATA); bcopy(ap->a_target, nipdata->u.data, bytes); - nipdata->size = bytes; + nipdata->meta.size = bytes; nip->size = bytes; hammer2_cluster_modsync(ncparent); hammer2_inode_unlock(nip, ncparent); -- 2.41.0