diff options
40 files changed, 808 insertions, 715 deletions
@@ -9747,10 +9747,7 @@ d usr/lib/raidcfg/amd64 0755 root bin f usr/lib/raidcfg/amd64/mpt.so.1 0755 root bin f usr/lib/raidcfg/mpt.so.1 0755 root bin d usr/lib/rcap 0755 root bin -d usr/lib/rcap/amd64 0755 root bin -f usr/lib/rcap/amd64/rcapd 0555 root bin -d usr/lib/rcap/i86 0755 root bin -h usr/lib/rcap/rcapd=usr/lib/isaexec +f usr/lib/rcap/rcapd 0555 root bin d usr/lib/rcm 0755 root bin d usr/lib/rcm/modules 0755 root bin f usr/lib/rcm/modules/SUNW_aggr_rcm.so 0555 root bin diff --git a/usr/src/boot/sys/boot/efi/libefi/Makefile b/usr/src/boot/sys/boot/efi/libefi/Makefile index e987cbc9d6..b8b4c5e6d6 100644 --- a/usr/src/boot/sys/boot/efi/libefi/Makefile +++ b/usr/src/boot/sys/boot/efi/libefi/Makefile @@ -24,9 +24,21 @@ all: lib$(LIB).a install: -SRCS= delay.c devicename.c devpath.c efi_console.c efi_driver_utils.c \ - efichar.c efinet.c efipart.c efizfs.c env.c errno.c handles.c \ - libefi.c time.c wchar.c +SRCS= delay.c \ + devicename.c \ + devpath.c \ + efi_console.c \ + efi_driver_utils.c \ + efichar.c \ + efinet.c \ + efipart.c \ + efizfs.c \ + env.c \ + errno.c \ + handles.c \ + libefi.c \ + time.c \ + wchar.c #.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" #SRCS += time.c diff --git a/usr/src/boot/sys/boot/i386/Makefile b/usr/src/boot/sys/boot/i386/Makefile index 46db89b56e..55e7d5ca62 100644 --- a/usr/src/boot/sys/boot/i386/Makefile +++ b/usr/src/boot/sys/boot/i386/Makefile @@ -17,7 +17,7 @@ include $(SRC)/Makefile.master # likely targets for removal, keeping around just in case... -# SUBDIRS= boot0 boot0sio kgzldr libfirewire +# SUBDIRS= boot0 boot0sio kgzldr libfirewire # current targets SUBDIRS= pmbr btx cdboot gptzfsboot libi386 loader pxeldr INSTDIRS= pmbr cdboot gptzfsboot loader pxeldr @@ -29,12 +29,12 @@ clobber:= TARGET= clobber .KEEP_STATE: -pxeldr: loader - all clean clobber: $(SUBDIRS) install: all .WAIT $(INSTDIRS) +pxeldr: loader + FRC: $(SUBDIRS): FRC diff --git a/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c b/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c index 7cf5e1c5a0..6b5439d47c 100644 --- a/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c +++ b/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c @@ -24,7 +24,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -64,7 +64,7 @@ * bsize - block size * fragsize - fragment size * cgsize - The number of disk cylinders per cylinder group. - * free - minimum free space + * free - minimum free space * rps - rotational speed (rev/sec). * nbpi - number of data bytes per allocated inode * opt - optimization (space, time) @@ -248,7 +248,7 @@ #include <sys/statvfs.h> #include <locale.h> #include <fcntl.h> -#include <sys/isa_defs.h> /* for ENDIAN defines */ +#include <sys/isa_defs.h> /* for ENDIAN defines */ #include <sys/vtoc.h> #include <sys/dkio.h> @@ -508,9 +508,9 @@ long ntrack = DFLNTRAK; /* tracks per cylinder group */ int ntrack_flag = RC_DEFAULT; long bsize = DESBLKSIZE; /* filesystem block size */ int bsize_flag = RC_DEFAULT; -long fragsize = DESFRAGSIZE; /* filesystem fragment size */ +long fragsize = DESFRAGSIZE; /* filesystem fragment size */ int fragsize_flag = RC_DEFAULT; -long minfree = MINFREE; /* fs_minfree */ +long minfree = MINFREE; /* fs_minfree */ int minfree_flag = RC_DEFAULT; long rps = DEFHZ; /* revolutions/second of drive */ int rps_flag = RC_DEFAULT; @@ -611,8 +611,8 @@ void wlockfs(void); void clockfs(void); void wtsb(void); static int64_t checkfragallocated(daddr32_t); -static struct csum *read_summaryinfo(struct fs *); -static diskaddr_t probe_summaryinfo(); +static struct csum *read_summaryinfo(struct fs *); +static diskaddr_t probe_summaryinfo(); int main(int argc, char *argv[]) @@ -765,7 +765,7 @@ main(int argc, char *argv[]) case 'G': /* grow the file system */ grow = 1; break; - case 'P': /* probe the file system growing size */ + case 'P': /* probe the file system growing size */ Pflag = 1; grow = 1; /* probe mode implies fs growing */ break; @@ -2379,6 +2379,17 @@ grow50: return (0); } +static diskaddr_t +get_device_size(int fd) +{ + struct dk_minfo disk_info; + + if ((ioctl(fd, DKIOCGMEDIAINFO, (caddr_t)&disk_info)) == -1) + return (0); + + return (disk_info.dki_capacity); +} + /* * Figure out how big the partition we're dealing with is. * The value returned is in disk blocks (sectors); @@ -2403,23 +2414,32 @@ get_max_size(int fd) } if (index < 0) { - switch (index) { - case VT_ERROR: - break; - case VT_EIO: - errno = EIO; - break; - case VT_EINVAL: - errno = EINVAL; + /* + * Since both attempts to read the label failed, we're + * going to use DKIOCGMEDIAINFO to get device size. + */ + + label_type = LABEL_TYPE_OTHER; + slicesize = get_device_size(fd); + if (slicesize == 0) { + switch (index) { + case VT_ERROR: + break; + case VT_EIO: + errno = EIO; + break; + case VT_EINVAL: + errno = EINVAL; + } + perror(gettext("Can not determine partition size")); + lockexit(32); } - perror(gettext("Can not determine partition size")); - lockexit(32); } if (label_type == LABEL_TYPE_EFI) { slicesize = efi_vtoc->efi_parts[index].p_size; efi_free(efi_vtoc); - } else { + } else if (label_type == LABEL_TYPE_VTOC) { /* * In the vtoc struct, p_size is a 32-bit signed quantity. * In the dk_gpt struct (efi's version of the vtoc), p_size @@ -3265,8 +3285,8 @@ static void awtfs(diskaddr_t bno, int size, char *bf, int release) { int n; - aio_trans *transp; - sigset_t old_mask; + aio_trans *transp; + sigset_t old_mask; if (fso == -1) return; @@ -4452,9 +4472,9 @@ findcsfragino() dp = gdinode((ino_t)i); switch (dp->di_mode & IFMT) { case IFSHAD : - case IFLNK : - case IFDIR : - case IFREG : break; + case IFLNK : + case IFDIR : + case IFREG : break; default : continue; } @@ -4537,7 +4557,7 @@ fixcsfragino() static struct csum * read_summaryinfo(struct fs *fsp) { - struct csum *csp; + struct csum *csp; int i; if ((csp = malloc((size_t)fsp->fs_cssize)) == NULL) { @@ -4565,7 +4585,7 @@ read_summaryinfo(struct fs *fsp) int64_t checkfragallocated(daddr32_t frag) { - struct csfrag *cfp; + struct csfrag *cfp; /* * Since the lists are sorted we can break the search if the asked * frag is smaller then the one in the list. @@ -4601,12 +4621,12 @@ diskaddr_t probe_summaryinfo() { /* fragments by which the csum block can be extended. */ - int64_t growth_csum_frags = 0; + int64_t growth_csum_frags = 0; /* fragments by which the filesystem can be extended. */ int64_t growth_fs_frags = 0; int64_t new_fs_cssize; /* size of csum blk in the new FS */ int64_t new_fs_ncg; /* number of cg in the new FS */ - int64_t spare_csum; + int64_t spare_csum; daddr32_t oldfrag_daddr; daddr32_t newfrag_daddr; daddr32_t daddr; @@ -5690,7 +5710,7 @@ in_64bit_mode(void) static int validate_size(int fd, diskaddr_t size) { - char buf[DEV_BSIZE]; + char buf[DEV_BSIZE]; int rc; if ((llseek(fd, (offset_t)((size - 1) * DEV_BSIZE), SEEK_SET) == -1) || diff --git a/usr/src/cmd/grep/grep.c b/usr/src/cmd/grep/grep.c index eabd465cca..7054d1f602 100644 --- a/usr/src/cmd/grep/grep.c +++ b/usr/src/cmd/grep/grep.c @@ -35,6 +35,7 @@ */ /* + * Copyright 2018 RackTop Systems. * Copyright 2018 Nexenta Systems, Inc. * Copyright 2013 Damian Bogel. All rights reserved. */ @@ -1277,8 +1278,8 @@ L_start_process: goto L_next_line; /* Do we have room to add this line to the context buffer? */ - if ((line_len + 1) > (conbuflen - - (conptrend >= conptr) ? conptrend - conbuf : 0)) { + while ((line_len + 1) > (conbuflen - + ((conptrend >= conptr) ? conptrend - conbuf : 0))) { char *oldconbuf = conbuf; char *oldconptr = conptr; long tmp = matchptr - conptr; diff --git a/usr/src/cmd/rcap/rcapd/Makefile b/usr/src/cmd/rcap/rcapd/Makefile index 62112abd00..77f4d6812e 100644 --- a/usr/src/cmd/rcap/rcapd/Makefile +++ b/usr/src/cmd/rcap/rcapd/Makefile @@ -19,41 +19,88 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -MANIFEST = rcap.xml +include ../../Makefile.cmd +include ../../Makefile.cmd.64 -include ../../Makefile.cmd +.KEEP_STATE: + +PROG = rcapd +ROOTUSRLIBRCAP = $(ROOT)/usr/lib/rcap +ROOTUSRLIBRCAPPROG = $(ROOTUSRLIBRCAP)/$(PROG) -ROOTMANIFESTDIR = $(ROOTSVCSYSTEM) +COMMON_DIR= ../common +MANIFEST = rcap.xml +ROOTMANIFESTDIR = $(ROOTSVCSYSTEM) $(ROOTSVCSYSTEM)/rcap.xml := FILEMODE = 0444 -.KEEP_STATE: -SUBDIRS = $(MACH) -$(BUILD64)SUBDIRS += $(MACH64) +SRCS = rcapd_main.c \ + rcapd_collection.c \ + rcapd_collection_project.c \ + rcapd_collection_zone.c \ + rcapd_mapping.c \ + rcapd_rfd.c \ + rcapd_scanner.c \ + rcapd_stat.c \ + utils.c + +LINTSRCS = rcapd_main.c \ + rcapd_collection.c \ + rcapd_collection_project.c \ + rcapd_collection_zone.c \ + rcapd_mapping.c \ + rcapd_rfd.c \ + rcapd_scanner.c \ + $(COMMON_DIR)/rcapd_stat.c \ + $(COMMON_DIR)/utils.c + +$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG +CPPFLAGS += -DDEBUG_MSG +CPPFLAGS += -I$(COMMON_DIR) +LDLIBS += -lkstat -lproc -lproject -lzonecfg -lumem -lscf +LDLIBS += $(EXTRA_LDLIBS) + +LINTFLAGS64 += -u + +OBJS = $(SRCS:%.c=%.o) rcapd_conf.o + +POFILES = $(OBJS:%.o=%.po) +POFILE = $(PROG).po + +CLOBBERFILES += $(POFILES) $(POFILE) + +include ../Makefile.com + +.NO_PARALLEL: +.PARALLEL: $(OBJS) + +all: $(PROG) -MSGSUBDIRS= $(MACH) +install: all $(ROOTUSRLIBRCAPPROG) $(ROOTUSRLIBRCAP) $(ROOTMANIFEST) -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint -_msg := TARGET = _msg +$(PROG): $(OBJS) + $(LINK.c) $(OBJS) -o $@ $(LDLIBS) + $(POST_PROCESS) -all clean clobber lint: $(SUBDIRS) +check: $(CHKMANIFEST) -install: all $(SUBDIRS) $(ROOTMANIFEST) +clean: + $(RM) $(OBJS) + $(RM) rcapd_conf.c -check: $(CHKMANIFEST) +lint: + $(LINT.c) $(LINTSRCS) $(LDLIBS) -_msg: $(MSGSUBDIRS) +$(POFILE): $(POFILES) + $(RM) $@ + $(CAT) $(POFILES) > $@ -$(SUBDIRS): FRC - @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET) +$(ROOTUSRLIBRCAP)/%: $(ROOTUSRLIBRCAP) % + $(INS.file) -FRC: +include ../../Makefile.targ diff --git a/usr/src/cmd/rcap/rcapd/Makefile.rcapd b/usr/src/cmd/rcap/rcapd/Makefile.rcapd deleted file mode 100644 index f0ff0e0669..0000000000 --- a/usr/src/cmd/rcap/rcapd/Makefile.rcapd +++ /dev/null @@ -1,113 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -.KEEP_STATE: -.SUFFIXES: - -# -# subdirs must define COMMON_DIR and include Makefile.com -# - -SRCS = rcapd_main.c \ - rcapd_collection.c \ - rcapd_collection_project.c \ - rcapd_collection_zone.c \ - rcapd_mapping.c \ - rcapd_rfd.c \ - rcapd_scanner.c \ - rcapd_stat.c \ - utils.c - -LINTSRCS = ../rcapd_main.c \ - ../rcapd_collection.c \ - ../rcapd_collection_project.c \ - ../rcapd_collection_zone.c \ - ../rcapd_mapping.c \ - ../rcapd_rfd.c \ - ../rcapd_scanner.c \ - $(COMMON_DIR)/rcapd_stat.c \ - $(COMMON_DIR)/utils.c - -$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG -CPPFLAGS += -DDEBUG_MSG -CPPFLAGS += -I$(COMMON_DIR) -LDLIBS += -lkstat -lproc -lproject -lzonecfg -lumem -lscf -LDLIBS += $(EXTRA_LDLIBS) - -LINTFLAGS += -u -LINTFLAGS64 += -u - -PROG = rcapd -OBJS = $(SRCS:%.c=%.o) rcapd_conf.o - -POFILES = $(OBJS:%.o=%.po) -POFILE = $(PROG).po - -CLOBBERFILES += $(POFILES) $(POFILE) - -.NO_PARALLEL: -.PARALLEL: $(OBJS) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -%.o: ../%.c - $(COMPILE.c) $< -%.po: ../%.c - $(COMPILE.cpp) $< > $<.i - $(BUILD.po) - - -clean: - $(RM) $(OBJS) - $(RM) rcapd_conf.c - -lint: - $(LINT.c) $(LINTSRCS) $(LDLIBS) - -$(POFILE): $(POFILES) - $(RM) $@ - $(CAT) $(POFILES) > $@ - - -ROOTUSRLIBRCAP = $(ROOT)/usr/lib/rcap -ROOTUSRLIBRCAP32 = $(ROOTUSRLIBRCAP)/$(MACH32) -ROOTUSRLIBRCAP64 = $(ROOTUSRLIBRCAP)/$(MACH64) -ROOTUSRLIBRCAPPROG = $(ROOTUSRLIBRCAP)/$(PROG) -ROOTUSRLIBRCAPPROG32 = $(ROOTUSRLIBRCAP32)/$(PROG) -ROOTUSRLIBRCAPPROG64 = $(ROOTUSRLIBRCAP64)/$(PROG) -$(ROOTUSRLIBRCAP)/%: $(ROOTUSRLIBRCAP) % - $(INS.file) -$(ROOTUSRLIBRCAP32)/%: $(ROOTUSRLIBRCAP32) % - $(INS.file) -$(ROOTUSRLIBRCAP64)/%: $(ROOTUSRLIBRCAP64) % - $(INS.file) - -include ../../../Makefile.targ diff --git a/usr/src/cmd/rcap/rcapd/amd64/Makefile b/usr/src/cmd/rcap/rcapd/amd64/Makefile deleted file mode 100644 index 489c7f4148..0000000000 --- a/usr/src/cmd/rcap/rcapd/amd64/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../../../Makefile.cmd -include ../../../Makefile.cmd.64 -COMMON_DIR= ../../common # for Makefile.com -include ../Makefile.rcapd -include ../../Makefile.com - -ROOTUSRLIBRCAPLINK=$(ROOTUSRLIBRCAPPROG) -$(ROOTUSRLIBRCAPLINK): $(ISAEXEC) $(ROOTUSRLIBRCAP) $(ROOTUSRLIBRCAPPROG64) - -$(RM) $(ROOTUSRLIBRCAPPROG) - $(LN) $(ISAEXEC) $(ROOTUSRLIBRCAPPROG) - -install: all $(ROOTUSRLIBRCAPPROG64) $(ROOTUSRLIBRCAPLINK) diff --git a/usr/src/cmd/rcap/rcapd/i386/Makefile b/usr/src/cmd/rcap/rcapd/i386/Makefile deleted file mode 100644 index 22f6ebe30c..0000000000 --- a/usr/src/cmd/rcap/rcapd/i386/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -include ../../../Makefile.cmd -COMMON_DIR= ../../common # for Makefile.com -include ../Makefile.rcapd -include ../../Makefile.com - -ROOTUSRLIBRCAPLINK=$(ROOTUSRLIBRCAPPROG) -$(ROOTUSRLIBRCAPLINK): $(ISAEXEC) $(ROOTUSRLIBRCAP) $(ROOTUSRLIBRCAPPROG32) - -$(RM) $(ROOTUSRLIBRCAPPROG) - $(LN) $(ISAEXEC) $(ROOTUSRLIBRCAPPROG) - -install: all $(ROOTUSRLIBRCAPPROG32) $(ROOTUSRLIBRCAPLINK) diff --git a/usr/src/cmd/rcap/rcapd/sparc/Makefile b/usr/src/cmd/rcap/rcapd/sparc/Makefile deleted file mode 100644 index 54841664c5..0000000000 --- a/usr/src/cmd/rcap/rcapd/sparc/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -include ../../../Makefile.cmd -COMMON_DIR= ../../common # for Makefile.com -include ../Makefile.rcapd -include ../../Makefile.com - -ROOTUSRLIBRCAPLINK=$(ROOTUSRLIBRCAPPROG) -$(ROOTUSRLIBRCAPLINK): $(ISAEXEC) $(ROOTUSRLIBRCAPPROG32) - -$(RM) $(ROOTUSRLIBRCAPPROG) - $(LN) $(ISAEXEC) $(ROOTUSRLIBRCAPPROG) - -install: all $(ROOTUSRLIBRCAPPROG32) $(ROOTUSRLIBRCAPLINK) diff --git a/usr/src/cmd/rcap/rcapd/sparcv9/Makefile b/usr/src/cmd/rcap/rcapd/sparcv9/Makefile deleted file mode 100644 index 322d709cd6..0000000000 --- a/usr/src/cmd/rcap/rcapd/sparcv9/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -include ../../../Makefile.cmd -include ../../../Makefile.cmd.64 -COMMON_DIR= ../../common # for Makefile.com -include ../Makefile.rcapd -include ../../Makefile.com - -ROOTUSRLIBRCAPLINK=$(ROOTUSRLIBRCAPPROG) -$(ROOTUSRLIBRCAPLINK): $(ISAEXEC) $(ROOTUSRLIBRCAP) $(ROOTUSRLIBRCAPPROG64) - -$(RM) $(ROOTUSRLIBRCAPPROG) - $(LN) $(ISAEXEC) $(ROOTUSRLIBRCAPPROG) - -install: all $(ROOTUSRLIBRCAPPROG64) $(ROOTUSRLIBRCAPLINK) diff --git a/usr/src/cmd/sasinfo/printAttrs.c b/usr/src/cmd/sasinfo/printAttrs.c index ae66526d59..2c0d71743f 100644 --- a/usr/src/cmd/sasinfo/printAttrs.c +++ b/usr/src/cmd/sasinfo/printAttrs.c @@ -99,6 +99,7 @@ static SAS_STATE phystate_string[] = { HBA_SASSPEED_1_5GBIT, "1.5Gbit", HBA_SASSPEED_3GBIT, "3Gbit", HBA_SASSPEED_6GBIT, "6Gbit", + HBA_SASSPEED_12GBIT, "12Gbit", -1, NULL, }; @@ -165,7 +166,8 @@ getPhyStateString(HBA_UINT32 key, phystat_type phyt) HBA_UINT32 physpeed[] = { HBA_SASSPEED_1_5GBIT, HBA_SASSPEED_3GBIT, - HBA_SASSPEED_6GBIT + HBA_SASSPEED_6GBIT, + HBA_SASSPEED_12GBIT }; len = sizeof (physpeed) / sizeof (HBA_UINT32); diff --git a/usr/src/lib/libdiskmgt/common/slice.c b/usr/src/lib/libdiskmgt/common/slice.c index 311b8285e6..979145f9eb 100644 --- a/usr/src/lib/libdiskmgt/common/slice.c +++ b/usr/src/lib/libdiskmgt/common/slice.c @@ -83,15 +83,15 @@ slice_get_assoc_descriptors(descriptor_t *desc, dm_desc_type_t type, int *errp) { if (!desc_ok(desc)) { - *errp = ENODEV; - return (NULL); + *errp = ENODEV; + return (NULL); } switch (type) { case DM_MEDIA: - return (media_get_assocs(desc, errp)); + return (media_get_assocs(desc, errp)); case DM_PARTITION: - return (partition_get_assocs(desc, errp)); + return (partition_get_assocs(desc, errp)); } *errp = EINVAL; @@ -109,8 +109,8 @@ slice_get_assocs(descriptor_t *desc, int *errp) { /* Just check the first drive name. */ if (desc->p.disk->aliases == NULL) { - *errp = 0; - return (libdiskmgt_empty_desc_array(errp)); + *errp = 0; + return (libdiskmgt_empty_desc_array(errp)); } return (get_fixed_assocs(desc, errp)); @@ -124,13 +124,13 @@ slice_get_attributes(descriptor_t *dp, int *errp) char devpath[MAXPATHLEN]; if (!desc_ok(dp)) { - *errp = ENODEV; - return (NULL); + *errp = ENODEV; + return (NULL); } if (nvlist_alloc(&attrs, NVATTRS, 0) != 0) { - *errp = ENOMEM; - return (NULL); + *errp = ENOMEM; + return (NULL); } /* dp->name is /dev/dsk, need to convert back to /dev/rdsk */ @@ -138,12 +138,12 @@ slice_get_attributes(descriptor_t *dp, int *errp) fd = open(devpath, O_RDONLY|O_NDELAY); if ((*errp = get_attrs(dp, fd, attrs)) != 0) { - nvlist_free(attrs); - attrs = NULL; + nvlist_free(attrs); + attrs = NULL; } if (fd >= 0) { - (void) close(fd); + (void) close(fd); } return (attrs); @@ -165,7 +165,7 @@ slice_get_descriptor_by_name(char *name, int *errp) char mname[MAXPATHLEN]; if (*errp != 0) { - return (NULL); + return (NULL); } mname[0] = 0; @@ -199,15 +199,15 @@ slice_get_stats(descriptor_t *dp, int stat_type, int *errp) nvlist_t *stats; if (stat_type != DM_SLICE_STAT_USE) { - *errp = EINVAL; - return (NULL); + *errp = EINVAL; + return (NULL); } *errp = 0; if (nvlist_alloc(&stats, NVATTRS_STAT, 0) != 0) { - *errp = ENOMEM; - return (NULL); + *errp = ENOMEM; + return (NULL); } if ((*errp = add_inuse(dp->name, stats)) != 0) { @@ -229,14 +229,14 @@ slice_make_descriptors() dp = cache_get_disklist(); while (dp != NULL) { - int error; + int error; - error = make_fixed_descriptors(dp); - if (error != 0) { - return (error); - } + error = make_fixed_descriptors(dp); + if (error != 0) { + return (error); + } - dp = dp->next; + dp = dp->next; } return (0); @@ -251,18 +251,18 @@ slice_rdsk2dsk(char *rdsk, char *dsk, int size) (void) strlcpy(dsk, rdsk, size); if ((strp = strstr(dsk, "/rdsk/")) == NULL) { - /* not rdsk, check for floppy */ - strp = strstr(dsk, "/rdiskette"); + /* not rdsk, check for floppy */ + strp = strstr(dsk, "/rdiskette"); } if (strp != NULL) { - strp++; /* move ptr to the r in rdsk or rdiskette */ + strp++; /* move ptr to the r in rdsk or rdiskette */ - /* move the succeeding chars over by one */ - do { - *strp = *(strp + 1); - strp++; - } while (*strp); + /* move the succeeding chars over by one */ + do { + *strp = *(strp + 1); + strp++; + } while (*strp); } } @@ -276,12 +276,12 @@ add_inuse(char *name, nvlist_t *attrs) int error; for (i = 0; detectors[i] != NULL; i ++) { - if (detectors[i](name, attrs, &error) || error != 0) { - if (error != 0) { - return (error); + if (detectors[i](name, attrs, &error) || error != 0) { + if (error != 0) { + return (error); + } + break; } - break; - } } return (0); @@ -293,17 +293,17 @@ desc_ok(descriptor_t *dp) { /* First verify the media name for removable media */ if (dp->p.disk->removable) { - char mname[MAXPATHLEN]; + char mname[MAXPATHLEN]; - if (!media_read_name(dp->p.disk, mname, sizeof (mname))) { - return (0); - } + if (!media_read_name(dp->p.disk, mname, sizeof (mname))) { + return (0); + } - if (mname[0] == 0) { - return (libdiskmgt_str_eq(dp->secondary_name, NULL)); - } else { - return (libdiskmgt_str_eq(dp->secondary_name, mname)); - } + if (mname[0] == 0) { + return (libdiskmgt_str_eq(dp->secondary_name, NULL)); + } else { + return (libdiskmgt_str_eq(dp->secondary_name, mname)); + } } /* @@ -326,25 +326,25 @@ dsk2rdsk(char *dsk, char *rdsk, int size) /* make sure there is enough room to add the r to dsk */ len = strlen(dsk); if (len + 2 > size) { - return; + return; } if ((slashp = strstr(rdsk, "/dsk/")) == NULL) { - /* not dsk, check for floppy */ - slashp = strstr(rdsk, "/diskette"); + /* not dsk, check for floppy */ + slashp = strstr(rdsk, "/diskette"); } if (slashp != NULL) { - char *endp; + char *endp; - endp = rdsk + len; /* point to terminating 0 */ - /* move the succeeding chars over by one */ - do { - *(endp + 1) = *endp; - endp--; - } while (endp != slashp); + endp = rdsk + len; /* point to terminating 0 */ + /* move the succeeding chars over by one */ + do { + *(endp + 1) = *endp; + endp--; + } while (endp != slashp); - *(endp + 1) = 'r'; + *(endp + 1) = 'r'; } } @@ -363,114 +363,113 @@ get_attrs(descriptor_t *dp, int fd, nvlist_t *attrs) struct stat buf; if (fd < 0) { - return (ENODEV); + return (ENODEV); } /* First make sure media is inserted and spun up. */ if (!media_read_info(fd, &minfo)) { - return (ENODEV); + return (ENODEV); } if ((status = read_extvtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; + data_format = FMT_VTOC; } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; - if (nvlist_add_boolean(attrs, DM_EFI) != 0) { - efi_free(efip); - return (ENOMEM); - } + data_format = FMT_EFI; + if (nvlist_add_boolean(attrs, DM_EFI) != 0) { + efi_free(efip); + return (ENOMEM); + } } if (data_format == FMT_UNKNOWN) { - return (ENODEV); + return (ENODEV); } if (ioctl(fd, DKIOCINFO, &dkinfo) >= 0) { - snum = dkinfo.dki_partition; + snum = dkinfo.dki_partition; } /* check the slice */ if (data_format == FMT_VTOC) { - if (snum < 0 || snum >= vtoc.v_nparts || - vtoc.v_part[snum].p_size == 0) { - return (ENODEV); - } + if (snum < 0 || snum >= vtoc.v_nparts || + vtoc.v_part[snum].p_size == 0) { + return (ENODEV); + } } else { /* data_format == FMT_EFI */ - if (snum < 0 || snum >= efip->efi_nparts || - efip->efi_parts[snum].p_size == 0) { - efi_free(efip); - return (ENODEV); - } + if (snum < 0 || snum >= efip->efi_nparts || + efip->efi_parts[snum].p_size == 0) { + efi_free(efip); + return (ENODEV); + } } /* the slice exists */ if (nvlist_add_uint32(attrs, DM_INDEX, snum) != 0) { - if (data_format == FMT_EFI) { - efi_free(efip); - } - return (ENOMEM); + if (data_format == FMT_EFI) { + efi_free(efip); + } + return (ENOMEM); } if (data_format == FMT_VTOC) { - if (nvlist_add_uint64(attrs, DM_START, vtoc.v_part[snum].p_start) - != 0) { - return (ENOMEM); - } - - if (nvlist_add_uint64(attrs, DM_SIZE, vtoc.v_part[snum].p_size) - != 0) { - return (ENOMEM); - } + if (nvlist_add_uint64(attrs, DM_START, + vtoc.v_part[snum].p_start) != 0) { + return (ENOMEM); + } - if (nvlist_add_uint32(attrs, DM_TAG, vtoc.v_part[snum].p_tag) - != 0) { - return (ENOMEM); - } + if (nvlist_add_uint64(attrs, DM_SIZE, + vtoc.v_part[snum].p_size) != 0) { + return (ENOMEM); + } - if (nvlist_add_uint32(attrs, DM_FLAG, vtoc.v_part[snum].p_flag) - != 0) { - return (ENOMEM); - } + if (nvlist_add_uint32(attrs, DM_TAG, + vtoc.v_part[snum].p_tag) != 0) { + return (ENOMEM); + } + if (nvlist_add_uint32(attrs, DM_FLAG, + vtoc.v_part[snum].p_flag) != 0) { + return (ENOMEM); + } } else { /* data_format == FMT_EFI */ - if (nvlist_add_uint64(attrs, DM_START, - efip->efi_parts[snum].p_start) != 0) { - efi_free(efip); - return (ENOMEM); - } + if (nvlist_add_uint64(attrs, DM_START, + efip->efi_parts[snum].p_start) != 0) { + efi_free(efip); + return (ENOMEM); + } - if (nvlist_add_uint64(attrs, DM_SIZE, efip->efi_parts[snum].p_size) - != 0) { - efi_free(efip); - return (ENOMEM); - } + if (nvlist_add_uint64(attrs, DM_SIZE, + efip->efi_parts[snum].p_size) != 0) { + efi_free(efip); + return (ENOMEM); + } - if (efip->efi_parts[snum].p_name[0] != 0) { - char label[EFI_PART_NAME_LEN + 1]; + if (efip->efi_parts[snum].p_name[0] != 0) { + char label[EFI_PART_NAME_LEN + 1]; - (void) snprintf(label, sizeof (label), "%.*s", - EFI_PART_NAME_LEN, efip->efi_parts[snum].p_name); - if (nvlist_add_string(attrs, DM_EFI_NAME, label) != 0) { - efi_free(efip); - return (ENOMEM); + (void) snprintf(label, sizeof (label), "%.*s", + EFI_PART_NAME_LEN, efip->efi_parts[snum].p_name); + if (nvlist_add_string(attrs, DM_EFI_NAME, label) != 0) { + efi_free(efip); + return (ENOMEM); + } } - } } if (data_format == FMT_EFI) { - efi_free(efip); + efi_free(efip); } if (inuse_mnt(dp->name, attrs, &error)) { - if (error != 0) - return (error); + if (error != 0) + return (error); } if (fstat(fd, &buf) != -1) { - if (nvlist_add_uint64(attrs, DM_DEVT, buf.st_rdev) != 0) { - return (ENOMEM); - } + if (nvlist_add_uint64(attrs, DM_DEVT, buf.st_rdev) != 0) { + return (ENOMEM); + } } /* @@ -480,33 +479,34 @@ get_attrs(descriptor_t *dp, int fd, nvlist_t *attrs) cooked_fd = open(dp->name, O_RDONLY|O_NDELAY); if (cooked_fd >= 0) { - int no_mem = 0; - ddi_devid_t devid; + int no_mem = 0; + ddi_devid_t devid; - if (devid_get(cooked_fd, &devid) == 0) { - char *minor; + if (devid_get(cooked_fd, &devid) == 0) { + char *minor; - if (devid_get_minor_name(cooked_fd, &minor) == 0) { - char *devidstr; + if (devid_get_minor_name(cooked_fd, &minor) == 0) { + char *devidstr; - if ((devidstr = devid_str_encode(devid, minor)) != 0) { + devidstr = devid_str_encode(devid, minor); + if (devidstr != NULL) { - if (nvlist_add_string(attrs, DM_DEVICEID, devidstr) - != 0) { - no_mem = 1; - } + if (nvlist_add_string(attrs, + DM_DEVICEID, devidstr) != 0) { + no_mem = 1; + } - devid_str_free(devidstr); - } - devid_str_free(minor); + devid_str_free(devidstr); + } + devid_str_free(minor); + } + devid_free(devid); } - devid_free(devid); - } - (void) close(cooked_fd); + (void) close(cooked_fd); - if (no_mem) { - return (ENOMEM); - } + if (no_mem) { + return (ENOMEM); + } } return (0); @@ -527,84 +527,85 @@ get_fixed_assocs(descriptor_t *desc, int *errp) descriptor_t **slices; if ((fd = drive_open_disk(desc->p.disk, NULL, 0)) < 0) { - *errp = ENODEV; - return (NULL); + *errp = ENODEV; + return (NULL); } if ((status = read_extvtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; + data_format = FMT_VTOC; } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; + data_format = FMT_EFI; } else { - (void) close(fd); - *errp = 0; - return (libdiskmgt_empty_desc_array(errp)); + (void) close(fd); + *errp = 0; + return (libdiskmgt_empty_desc_array(errp)); } (void) close(fd); /* count the number of slices */ - for (cnt = 0, devp = desc->p.disk->aliases->devpaths; devp != NULL; - devp = devp->next, cnt++); + devp = desc->p.disk->aliases->devpaths; + for (cnt = 0; devp != NULL; devp = devp->next) + cnt++; /* allocate the array for the descriptors */ slices = (descriptor_t **)calloc(cnt + 1, sizeof (descriptor_t *)); if (slices == NULL) { - if (data_format == FMT_EFI) { - efi_free(efip); - } - *errp = ENOMEM; - return (NULL); + if (data_format == FMT_EFI) { + efi_free(efip); + } + *errp = ENOMEM; + return (NULL); } /* get the media name from the descriptor */ if (desc->type == DM_MEDIA) { - media_name = desc->name; + media_name = desc->name; } else { - /* must be a DM_PARTITION */ - media_name = desc->secondary_name; + /* must be a DM_PARTITION */ + media_name = desc->secondary_name; } pos = 0; for (devp = desc->p.disk->aliases->devpaths; devp != NULL; devp = devp->next) { - int slice_num; - char devpath[MAXPATHLEN]; - - slice_num = get_slice_num(devp); - /* can't get slicenum, so no need to keep trying the drive */ - if (slice_num == -1) { - break; - } + int slice_num; + char devpath[MAXPATHLEN]; - if (data_format == FMT_VTOC) { - if (slice_num >= vtoc.v_nparts || - vtoc.v_part[slice_num].p_size == 0) { - continue; + slice_num = get_slice_num(devp); + /* can't get slicenum, so no need to keep trying the drive */ + if (slice_num == -1) { + break; } - } else { /* data_format == FMT_EFI */ - if (slice_num >= efip->efi_nparts || - efip->efi_parts[slice_num].p_size == 0) { - continue; + + if (data_format == FMT_VTOC) { + if (slice_num >= vtoc.v_nparts || + vtoc.v_part[slice_num].p_size == 0) { + continue; + } + } else { /* data_format == FMT_EFI */ + if (slice_num >= efip->efi_nparts || + efip->efi_parts[slice_num].p_size == 0) { + continue; + } } - } - slice_rdsk2dsk(devp->devpath, devpath, sizeof (devpath)); - slices[pos] = cache_get_desc(DM_SLICE, desc->p.disk, devpath, - media_name, errp); - if (*errp != 0) { - cache_free_descriptors(slices); - if (data_format == FMT_EFI) { - efi_free(efip); + slice_rdsk2dsk(devp->devpath, devpath, sizeof (devpath)); + slices[pos] = cache_get_desc(DM_SLICE, desc->p.disk, devpath, + media_name, errp); + if (*errp != 0) { + cache_free_descriptors(slices); + if (data_format == FMT_EFI) { + efi_free(efip); + } + return (NULL); } - return (NULL); - } - pos++; + pos++; } slices[pos] = NULL; if (data_format == FMT_EFI) { - efi_free(efip); + efi_free(efip); } *errp = 0; @@ -616,15 +617,15 @@ get_slice_num(slice_t *devp) { /* check if we already determined the devpath slice number */ if (devp->slice_num == -1) { - int fd; + int fd; - if ((fd = open(devp->devpath, O_RDONLY|O_NDELAY)) >= 0) { - struct dk_cinfo dkinfo; - if (ioctl(fd, DKIOCINFO, &dkinfo) >= 0) { - devp->slice_num = dkinfo.dki_partition; + if ((fd = open(devp->devpath, O_RDONLY|O_NDELAY)) >= 0) { + struct dk_cinfo dkinfo; + if (ioctl(fd, DKIOCINFO, &dkinfo) >= 0) { + devp->slice_num = dkinfo.dki_partition; + } + (void) close(fd); } - (void) close(fd); - } } return (devp->slice_num); @@ -643,63 +644,63 @@ make_fixed_descriptors(disk_t *dp) /* Just check the first drive name. */ if ((ap = dp->aliases) == NULL) { - return (0); + return (0); } mname[0] = 0; (void) media_read_name(dp, mname, sizeof (mname)); for (devp = ap->devpaths; devp != NULL; devp = devp->next) { - int slice_num; - char devpath[MAXPATHLEN]; - - slice_num = get_slice_num(devp); - /* can't get slicenum, so no need to keep trying the drive */ - if (slice_num == -1) { - break; - } - - if (data_format == FMT_UNKNOWN) { - int fd; - int status; - - if ((fd = drive_open_disk(dp, NULL, 0)) >= 0) { - if ((status = read_extvtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; - } else if (status == VT_ENOTSUP && - efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; - } - (void) close(fd); + int slice_num; + char devpath[MAXPATHLEN]; + + slice_num = get_slice_num(devp); + /* can't get slicenum, so no need to keep trying the drive */ + if (slice_num == -1) { + break; } - } - /* can't get slice data, so no need to keep trying the drive */ - if (data_format == FMT_UNKNOWN) { - break; - } + if (data_format == FMT_UNKNOWN) { + int fd; + int status; + + if ((fd = drive_open_disk(dp, NULL, 0)) >= 0) { + if ((status = read_extvtoc(fd, &vtoc)) >= 0) { + data_format = FMT_VTOC; + } else if (status == VT_ENOTSUP && + efi_alloc_and_read(fd, &efip) >= 0) { + data_format = FMT_EFI; + } + (void) close(fd); + } + } - if (data_format == FMT_VTOC) { - if (slice_num >= vtoc.v_nparts || - vtoc.v_part[slice_num].p_size == 0) { - continue; + /* can't get slice data, so no need to keep trying the drive */ + if (data_format == FMT_UNKNOWN) { + break; } - } else { /* data_format == FMT_EFI */ - if (slice_num >= efip->efi_nparts || - efip->efi_parts[slice_num].p_size == 0) { - continue; + + if (data_format == FMT_VTOC) { + if (slice_num >= vtoc.v_nparts || + vtoc.v_part[slice_num].p_size == 0) { + continue; + } + } else { /* data_format == FMT_EFI */ + if (slice_num >= efip->efi_nparts || + efip->efi_parts[slice_num].p_size == 0) { + continue; + } } - } - slice_rdsk2dsk(devp->devpath, devpath, sizeof (devpath)); - cache_load_desc(DM_SLICE, dp, devpath, mname, &error); - if (error != 0) { - break; - } + slice_rdsk2dsk(devp->devpath, devpath, sizeof (devpath)); + cache_load_desc(DM_SLICE, dp, devpath, mname, &error); + if (error != 0) { + break; + } } if (data_format == FMT_EFI) { - efi_free(efip); + efi_free(efip); } return (error); @@ -723,32 +724,32 @@ match_fixed_name(disk_t *diskp, char *name, int *errp) ap = diskp->aliases; while (ap != NULL) { - slice_t *devp; + slice_t *devp; - devp = ap->devpaths; - while (devp != NULL) { - char path[MAXPATHLEN]; + devp = ap->devpaths; + while (devp != NULL) { + char path[MAXPATHLEN]; - slice_rdsk2dsk(devp->devpath, path, sizeof (path)); - if (libdiskmgt_str_eq(path, name)) { - /* found it */ - dp = devp; - break; - } + slice_rdsk2dsk(devp->devpath, path, sizeof (path)); + if (libdiskmgt_str_eq(path, name)) { + /* found it */ + dp = devp; + break; + } - devp = devp->next; - } + devp = devp->next; + } - if (dp != NULL) { - break; - } + if (dp != NULL) { + break; + } - ap = ap->next; + ap = ap->next; } if (dp == NULL) { - *errp = 0; - return (0); + *errp = 0; + return (0); } /* @@ -759,40 +760,46 @@ match_fixed_name(disk_t *diskp, char *name, int *errp) slice_num = get_slice_num(dp); /* can't get slicenum, so no slice */ if (slice_num == -1) { - *errp = ENODEV; - return (1); + *errp = ENODEV; + return (1); } if ((fd = drive_open_disk(diskp, NULL, 0)) < 0) { - *errp = ENODEV; - return (1); + *errp = ENODEV; + return (1); } if ((status = read_extvtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; - } else if (status == VT_ENOTSUP && efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; + data_format = FMT_VTOC; + } else if (status == VT_ENOTSUP) { + status = efi_alloc_and_read(fd, &efip); + if (status >= 0) { + data_format = FMT_EFI; + } else if (status == VT_ERROR && errno == ENOTTY) { + *errp = 0; + return (1); + } } else { - (void) close(fd); - *errp = ENODEV; - return (1); + (void) close(fd); + *errp = ENODEV; + return (1); } (void) close(fd); if (data_format == FMT_VTOC) { - if (slice_num < vtoc.v_nparts && - vtoc.v_part[slice_num].p_size > 0) { - *errp = 0; - return (1); - } + if (slice_num < vtoc.v_nparts && + vtoc.v_part[slice_num].p_size > 0) { + *errp = 0; + return (1); + } } else { /* data_format == FMT_EFI */ - if (slice_num < efip->efi_nparts && - efip->efi_parts[slice_num].p_size > 0) { + if (slice_num < efip->efi_nparts && + efip->efi_parts[slice_num].p_size > 0) { + efi_free(efip); + *errp = 0; + return (1); + } efi_free(efip); - *errp = 0; - return (1); - } - efi_free(efip); } *errp = ENODEV; diff --git a/usr/src/lib/libefi/common/rdwr_efi.c b/usr/src/lib/libefi/common/rdwr_efi.c index e40f4f9b38..a878cb50d2 100644 --- a/usr/src/lib/libefi/common/rdwr_efi.c +++ b/usr/src/lib/libefi/common/rdwr_efi.c @@ -211,6 +211,37 @@ efi_alloc_and_read(int fd, struct dk_gpt **vtoc) int rval; uint32_t nparts; int length; + struct mboot *mbr; + struct ipart *ipart; + diskaddr_t capacity; + uint_t lbsize; + int i; + + if (read_disk_info(fd, &capacity, &lbsize) != 0) + return (VT_ERROR); + + if ((mbr = calloc(lbsize, 1)) == NULL) + return (VT_ERROR); + + if ((ioctl(fd, DKIOCGMBOOT, (caddr_t)mbr)) == -1) { + free(mbr); + return (VT_ERROR); + } + + if (mbr->signature != MBB_MAGIC) { + free(mbr); + return (VT_EINVAL); + } + ipart = (struct ipart *)(uintptr_t)mbr->parts; + + /* Check if we have partition with ID EFI_PMBR */ + for (i = 0; i < FD_NUMPART; i++) { + if (ipart[i].systid == EFI_PMBR) + break; + } + free(mbr); + if (i == FD_NUMPART) + return (VT_EINVAL); /* figure out the number of entries that would fit into 16K */ nparts = EFI_MIN_ARRAY_SIZE / sizeof (efi_gpe_t); diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c index d28e852ef6..5bd900ad00 100644 --- a/usr/src/lib/libzfs/common/libzfs_import.c +++ b/usr/src/lib/libzfs/common/libzfs_import.c @@ -33,7 +33,7 @@ * ZFS label of each device. If we successfully read the label, then we * organize the configuration information in the following hierarchy: * - * pool guid -> toplevel vdev guid -> label txg + * pool guid -> toplevel vdev guid -> label txg * * Duplicate entries matching this same tuple will be discarded. Once we have * examined every device, we pick the best label txg config for each toplevel @@ -217,7 +217,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, ne->ne_next = pl->names; pl->names = ne; - nvlist_free(config); return (0); } @@ -237,7 +236,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, &top_guid) != 0 || nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_TXG, &txg) != 0 || txg == 0) { - nvlist_free(config); return (0); } @@ -252,7 +250,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (pe == NULL) { if ((pe = zfs_alloc(hdl, sizeof (pool_entry_t))) == NULL) { - nvlist_free(config); return (-1); } pe->pe_guid = pool_guid; @@ -271,7 +268,6 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (ve == NULL) { if ((ve = zfs_alloc(hdl, sizeof (vdev_entry_t))) == NULL) { - nvlist_free(config); return (-1); } ve->ve_guid = top_guid; @@ -291,15 +287,12 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, if (ce == NULL) { if ((ce = zfs_alloc(hdl, sizeof (config_entry_t))) == NULL) { - nvlist_free(config); return (-1); } ce->ce_txg = txg; - ce->ce_config = config; + ce->ce_config = fnvlist_dup(config); ce->ce_next = ve->ve_configs; ve->ve_configs = ce; - } else { - nvlist_free(config); } /* @@ -1235,9 +1228,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) &this_guid) == 0 && iarg->guid == this_guid; } - if (!matched) { - nvlist_free(config); - } else { + if (matched) { /* * use the non-raw path for the config */ @@ -1247,6 +1238,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) config) != 0) config_failed = B_TRUE; } + nvlist_free(config); } free(slice->rn_name); free(slice); diff --git a/usr/src/lib/smhba/common/smhbaapi.h b/usr/src/lib/smhba/common/smhbaapi.h index 958b34f342..6a9310d82c 100644 --- a/usr/src/lib/smhba/common/smhbaapi.h +++ b/usr/src/lib/smhba/common/smhbaapi.h @@ -220,6 +220,7 @@ typedef HBA_UINT32 HBA_SASPHYSPEED; #define HBA_SASSPEED_1_5GBIT 0x08 /* 1.5 GBit/sec */ #define HBA_SASSPEED_3GBIT 0x09 /* 3 GBit/sec */ #define HBA_SASSPEED_6GBIT 0x0a /* 6 GBit/sec */ +#define HBA_SASSPEED_12GBIT 0x0b /* 12 GBit/sec */ /* SM-HBA 6.5.5 SAS Phy Attribute */ typedef struct SMHBA_SAS_Phy { diff --git a/usr/src/pkg/manifests/service-resource-cap.mf b/usr/src/pkg/manifests/service-resource-cap.mf index 49302f476e..24e7396a78 100644 --- a/usr/src/pkg/manifests/service-resource-cap.mf +++ b/usr/src/pkg/manifests/service-resource-cap.mf @@ -43,13 +43,11 @@ dir path=usr/share/man/man1 dir path=usr/share/man/man1m file path=lib/svc/manifest/system/rcap.xml group=sys mode=0444 file path=usr/bin/rcapstat mode=0555 -file path=usr/lib/rcap/$(ARCH32)/rcapd mode=0555 -file path=usr/lib/rcap/$(ARCH64)/rcapd mode=0555 +file path=usr/lib/rcap/rcapd mode=0555 file path=usr/sbin/rcapadm mode=0555 file path=usr/share/man/man1/rcapstat.1 file path=usr/share/man/man1m/rcapadm.1m file path=usr/share/man/man1m/rcapd.1m -hardlink path=usr/lib/rcap/rcapd target=../isaexec legacy pkg=SUNWrcapr desc="Solaris Resource Capping Daemon (Root)" \ name="Solaris Resource Capping Daemon (Root)" legacy pkg=SUNWrcapu desc="Solaris Resource Capping Daemon (Usr)" \ diff --git a/usr/src/tools/ctf/cvt/ctfmerge.c b/usr/src/tools/ctf/cvt/ctfmerge.c index b8053a7a23..d2db789e5f 100644 --- a/usr/src/tools/ctf/cvt/ctfmerge.c +++ b/usr/src/tools/ctf/cvt/ctfmerge.c @@ -504,9 +504,11 @@ worker_runphase2(workqueue_t *wq) /* * Main loop for worker threads. */ -static void -worker_thread(workqueue_t *wq) +static void * +worker_thread(void *ptr) { + workqueue_t *wq = ptr; + worker_runphase1(wq); debug(2, "%d: entering first barrier\n", pthread_self()); @@ -530,6 +532,7 @@ worker_thread(workqueue_t *wq) debug(2, "%d: phase 1 complete\n", pthread_self()); worker_runphase2(wq); + return (NULL); } /* @@ -692,7 +695,7 @@ start_threads(workqueue_t *wq) for (i = 0; i < wq->wq_nthreads; i++) { pthread_create(&wq->wq_thread[i], NULL, - (void *(*)(void *))worker_thread, wq); + worker_thread, wq); } sigset(SIGINT, handle_sig); diff --git a/usr/src/tools/ctf/cvt/ctftools.h b/usr/src/tools/ctf/cvt/ctftools.h index 755af5176d..da02df8c94 100644 --- a/usr/src/tools/ctf/cvt/ctftools.h +++ b/usr/src/tools/ctf/cvt/ctftools.h @@ -69,11 +69,11 @@ extern "C" { #endif #ifndef MAX -#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif #ifndef MIN -#define MIN(a, b) ((a) > (b) ? (b) : (a)) +#define MIN(a, b) ((a) > (b) ? (b) : (a)) #endif #define TRUE 1 @@ -282,13 +282,13 @@ typedef enum iitype { typedef struct iidesc { iitype_t ii_type; char *ii_name; - tdesc_t *ii_dtype; + tdesc_t *ii_dtype; char *ii_owner; /* File that defined this node */ int ii_flags; /* Function arguments (if any) */ int ii_nargs; - tdesc_t **ii_args; + tdesc_t **ii_args; int ii_vargs; /* Function uses varargs */ } iidesc_t; @@ -369,14 +369,15 @@ void iter_iidescs_by_name(tdata_t *, const char *, iidesc_t *iidesc_dup(iidesc_t *); iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *); void iidesc_add(hash_t *, iidesc_t *); -void iidesc_free(iidesc_t *, void *); +void iidesc_free(iidesc_t *); +void iidesc_free_cb(void *, void *); int iidesc_count_type(void *, void *); void iidesc_stats(hash_t *); int iidesc_dump(iidesc_t *); /* input.c */ typedef enum source_types { - SOURCE_NONE = 0, + SOURCE_NONE = 0, SOURCE_UNKNOWN = 1, SOURCE_C = 2, SOURCE_S = 4 diff --git a/usr/src/tools/ctf/cvt/iidesc.c b/usr/src/tools/ctf/cvt/iidesc.c index b6b9a0c7f2..0d75e3f852 100644 --- a/usr/src/tools/ctf/cvt/iidesc.c +++ b/usr/src/tools/ctf/cvt/iidesc.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines for manipulating iidesc_t structures */ @@ -99,7 +97,7 @@ iidesc_add(hash_t *hash, iidesc_t *new) bcopy(new, old, sizeof (*old)); bcopy(&tmp, new, sizeof (*new)); - iidesc_free(new, NULL); + iidesc_free(new); return; } @@ -151,17 +149,22 @@ iidesc_dup_rename(iidesc_t *src, char const *name, char const *owner) /*ARGSUSED*/ void -iidesc_free(iidesc_t *idp, void *private) +iidesc_free_cb(void *ptr, void *private) { - if (idp->ii_name) - free(idp->ii_name); - if (idp->ii_nargs) - free(idp->ii_args); - if (idp->ii_owner) - free(idp->ii_owner); + iidesc_t *idp = ptr; + + free(idp->ii_name); + free(idp->ii_args); + free(idp->ii_owner); free(idp); } +void +iidesc_free(iidesc_t *idp) +{ + iidesc_free_cb(idp, NULL); +} + int iidesc_dump(iidesc_t *ii) { diff --git a/usr/src/tools/ctf/cvt/st_parse.c b/usr/src/tools/ctf/cvt/st_parse.c index 1530734a48..03facfd5cb 100644 --- a/usr/src/tools/ctf/cvt/st_parse.c +++ b/usr/src/tools/ctf/cvt/st_parse.c @@ -448,7 +448,7 @@ parse_stab(stab_t *stab, char *cp, iidesc_t **iidescp) bzero(&resetbuf, sizeof (resetbuf)); if (rc < 0 || ii->ii_type == II_NOT) { - iidesc_free(ii, NULL); + iidesc_free(ii); return (rc); } diff --git a/usr/src/tools/ctf/cvt/stabs.c b/usr/src/tools/ctf/cvt/stabs.c index f7b3034c64..53b4565859 100644 --- a/usr/src/tools/ctf/cvt/stabs.c +++ b/usr/src/tools/ctf/cvt/stabs.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines used to read stabs data from a file, and to build a tdata structure * based on the interesting parts of that data. @@ -331,7 +329,7 @@ stabs_read(tdata_t *td, Elf *elf, const char *file) */ if (scope && stab->n_type != N_PSYM) { if (iidescp) - iidesc_free(iidescp, NULL); + iidesc_free(iidescp); goto parse_loop_end; } @@ -356,7 +354,7 @@ stabs_read(tdata_t *td, Elf *elf, const char *file) case II_PSYM: fnarg_add(curfun, iidescp); - iidesc_free(iidescp, NULL); + iidesc_free(iidescp); break; default: aborterr("invalid ii_type %d for stab type %d", diff --git a/usr/src/tools/ctf/cvt/tdata.c b/usr/src/tools/ctf/cvt/tdata.c index 295928586e..ca71168bcf 100644 --- a/usr/src/tools/ctf/cvt/tdata.c +++ b/usr/src/tools/ctf/cvt/tdata.c @@ -246,22 +246,22 @@ static void (*free_cbs[])(tdesc_t *) = { }; /*ARGSUSED1*/ -static int -tdesc_free_cb(tdesc_t *tdp, void *private) +static void +tdesc_free_cb(void *ptr, void *private) { + tdesc_t *tdp = ptr; + if (tdp->t_name) free(tdp->t_name); if (free_cbs[tdp->t_type]) free_cbs[tdp->t_type](tdp); free(tdp); - - return (1); } void tdesc_free(tdesc_t *tdp) { - (void) tdesc_free_cb(tdp, NULL); + tdesc_free_cb(tdp, NULL); } static int @@ -390,8 +390,8 @@ tdata_new(void) void tdata_free(tdata_t *td) { - hash_free(td->td_iihash, (void (*)())iidesc_free, NULL); - hash_free(td->td_layouthash, (void (*)())tdesc_free_cb, NULL); + hash_free(td->td_iihash, iidesc_free_cb, NULL); + hash_free(td->td_layouthash, tdesc_free_cb, NULL); hash_free(td->td_idhash, NULL, NULL); list_free(td->td_fwdlist, NULL, NULL); diff --git a/usr/src/uts/common/fs/zfs/dsl_scan.c b/usr/src/uts/common/fs/zfs/dsl_scan.c index cf93849a62..6fd97d9bfc 100644 --- a/usr/src/uts/common/fs/zfs/dsl_scan.c +++ b/usr/src/uts/common/fs/zfs/dsl_scan.c @@ -1951,14 +1951,14 @@ dsl_scan_scrub_cb(dsl_pool_t *dp, int zio_flags = ZIO_FLAG_SCAN_THREAD | ZIO_FLAG_RAW | ZIO_FLAG_CANFAIL; int scan_delay = 0; + count_block(dp->dp_blkstats, bp); + if (phys_birth <= scn->scn_phys.scn_min_txg || phys_birth >= scn->scn_phys.scn_max_txg) return (0); - count_block(dp->dp_blkstats, bp); - - if (BP_IS_EMBEDDED(bp)) - return (0); + /* Embedded BP's have phys_birth==0, so we reject them above. */ + ASSERT(!BP_IS_EMBEDDED(bp)); ASSERT(DSL_SCAN_IS_SCRUB_RESILVER(scn)); if (scn->scn_phys.scn_func == POOL_SCAN_SCRUB) { diff --git a/usr/src/uts/common/fs/zfs/range_tree.c b/usr/src/uts/common/fs/zfs/range_tree.c index 7c6ce90e18..a0b9e5f9a1 100644 --- a/usr/src/uts/common/fs/zfs/range_tree.c +++ b/usr/src/uts/common/fs/zfs/range_tree.c @@ -298,7 +298,6 @@ range_tree_remove(void *arg, uint64_t start, uint64_t size) static range_seg_t * range_tree_find_impl(range_tree_t *rt, uint64_t start, uint64_t size) { - avl_index_t where; range_seg_t rsearch; uint64_t end = start + size; @@ -306,7 +305,7 @@ range_tree_find_impl(range_tree_t *rt, uint64_t start, uint64_t size) rsearch.rs_start = start; rsearch.rs_end = end; - return (avl_find(&rt->rt_root, &rsearch, &where)); + return (avl_find(&rt->rt_root, &rsearch, NULL)); } static range_seg_t * @@ -407,3 +406,23 @@ range_tree_is_empty(range_tree_t *rt) ASSERT(rt != NULL); return (range_tree_space(rt) == 0); } + +uint64_t +range_tree_min(range_tree_t *rt) +{ + range_seg_t *rs = avl_first(&rt->rt_root); + return (rs != NULL ? rs->rs_start : 0); +} + +uint64_t +range_tree_max(range_tree_t *rt) +{ + range_seg_t *rs = avl_last(&rt->rt_root); + return (rs != NULL ? rs->rs_end : 0); +} + +uint64_t +range_tree_span(range_tree_t *rt) +{ + return (range_tree_max(rt) - range_tree_min(rt)); +} diff --git a/usr/src/uts/common/fs/zfs/sys/range_tree.h b/usr/src/uts/common/fs/zfs/sys/range_tree.h index 847774fb6a..9360e01509 100644 --- a/usr/src/uts/common/fs/zfs/sys/range_tree.h +++ b/usr/src/uts/common/fs/zfs/sys/range_tree.h @@ -86,6 +86,9 @@ boolean_t range_tree_is_empty(range_tree_t *rt); void range_tree_verify(range_tree_t *rt, uint64_t start, uint64_t size); void range_tree_swap(range_tree_t **rtsrc, range_tree_t **rtdst); void range_tree_stat_verify(range_tree_t *rt); +uint64_t range_tree_min(range_tree_t *rt); +uint64_t range_tree_max(range_tree_t *rt); +uint64_t range_tree_span(range_tree_t *rt); void range_tree_add(void *arg, uint64_t start, uint64_t size); void range_tree_remove(void *arg, uint64_t start, uint64_t size); diff --git a/usr/src/uts/common/fs/zfs/sys/vdev_removal.h b/usr/src/uts/common/fs/zfs/sys/vdev_removal.h index 5fcd40b6e7..3962237afd 100644 --- a/usr/src/uts/common/fs/zfs/sys/vdev_removal.h +++ b/usr/src/uts/common/fs/zfs/sys/vdev_removal.h @@ -86,6 +86,9 @@ extern void spa_vdev_remove_suspend(spa_t *); extern int spa_vdev_remove_cancel(spa_t *); extern void spa_vdev_removal_destroy(spa_vdev_removal_t *svr); +extern int vdev_removal_max_span; +extern int zfs_remove_max_segment; + #ifdef __cplusplus } #endif diff --git a/usr/src/uts/common/fs/zfs/vdev.c b/usr/src/uts/common/fs/zfs/vdev.c index db2d12db96..43c6e4c9a1 100644 --- a/usr/src/uts/common/fs/zfs/vdev.c +++ b/usr/src/uts/common/fs/zfs/vdev.c @@ -168,7 +168,7 @@ vdev_dbgmsg_print_tree(vdev_t *vd, int indent) } zfs_dbgmsg("%*svdev %u: %s%s, guid: %llu, path: %s, %s", indent, - "", vd->vdev_id, vd->vdev_ops->vdev_op_type, + "", (int)vd->vdev_id, vd->vdev_ops->vdev_op_type, vd->vdev_islog ? " (log)" : "", (u_longlong_t)vd->vdev_guid, vd->vdev_path ? vd->vdev_path : "N/A", state); diff --git a/usr/src/uts/common/fs/zfs/vdev_label.c b/usr/src/uts/common/fs/zfs/vdev_label.c index d906860346..8d5f17c15f 100644 --- a/usr/src/uts/common/fs/zfs/vdev_label.c +++ b/usr/src/uts/common/fs/zfs/vdev_label.c @@ -33,15 +33,15 @@ * 1. Uniquely identify this device as part of a ZFS pool and confirm its * identity within the pool. * - * 2. Verify that all the devices given in a configuration are present + * 2. Verify that all the devices given in a configuration are present * within the pool. * - * 3. Determine the uberblock for the pool. + * 3. Determine the uberblock for the pool. * - * 4. In case of an import operation, determine the configuration of the + * 4. In case of an import operation, determine the configuration of the * toplevel vdev of which it is a part. * - * 5. If an import operation cannot find all the devices in the pool, + * 5. If an import operation cannot find all the devices in the pool, * provide enough information to the administrator to determine which * devices are missing. * @@ -77,9 +77,9 @@ * In order to identify which labels are valid, the labels are written in the * following manner: * - * 1. For each vdev, update 'L1' to the new label - * 2. Update the uberblock - * 3. For each vdev, update 'L2' to the new label + * 1. For each vdev, update 'L1' to the new label + * 2. Update the uberblock + * 3. For each vdev, update 'L2' to the new label * * Given arbitrary failure, we can determine the correct label to use based on * the transaction group. If we fail after updating L1 but before updating the @@ -117,19 +117,19 @@ * * The nvlist describing the pool and vdev contains the following elements: * - * version ZFS on-disk version - * name Pool name - * state Pool state - * txg Transaction group in which this label was written - * pool_guid Unique identifier for this pool - * vdev_tree An nvlist describing vdev tree. + * version ZFS on-disk version + * name Pool name + * state Pool state + * txg Transaction group in which this label was written + * pool_guid Unique identifier for this pool + * vdev_tree An nvlist describing vdev tree. * features_for_read * An nvlist of the features necessary for reading the MOS. * * Each leaf device label also contains the following: * - * top_guid Unique ID for top-level vdev in which this is contained - * guid Unique ID for the leaf vdev + * top_guid Unique ID for top-level vdev in which this is contained + * guid Unique ID for the leaf vdev * * The 'vs' configuration follows the format described in 'spa_config.c'. */ @@ -390,22 +390,33 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats, * histograms. */ uint64_t seg_count = 0; + uint64_t to_alloc = vd->vdev_stat.vs_alloc; /* * There are the same number of allocated segments * as free segments, so we will have at least one - * entry per free segment. + * entry per free segment. However, small free + * segments (smaller than vdev_removal_max_span) + * will be combined with adjacent allocated segments + * as a single mapping. */ for (int i = 0; i < RANGE_TREE_HISTOGRAM_SIZE; i++) { - seg_count += vd->vdev_mg->mg_histogram[i]; + if (1ULL << (i + 1) < vdev_removal_max_span) { + to_alloc += + vd->vdev_mg->mg_histogram[i] << + i + 1; + } else { + seg_count += + vd->vdev_mg->mg_histogram[i]; + } } /* - * The maximum length of a mapping is SPA_MAXBLOCKSIZE, - * so we need at least one entry per SPA_MAXBLOCKSIZE - * of allocated data. + * The maximum length of a mapping is + * zfs_remove_max_segment, so we need at least one entry + * per zfs_remove_max_segment of allocated data. */ - seg_count += vd->vdev_stat.vs_alloc / SPA_MAXBLOCKSIZE; + seg_count += to_alloc / zfs_remove_max_segment; fnvlist_add_uint64(nv, ZPOOL_CONFIG_INDIRECT_SIZE, seg_count * diff --git a/usr/src/uts/common/fs/zfs/vdev_removal.c b/usr/src/uts/common/fs/zfs/vdev_removal.c index 06e25a59ad..c9af0e0729 100644 --- a/usr/src/uts/common/fs/zfs/vdev_removal.c +++ b/usr/src/uts/common/fs/zfs/vdev_removal.c @@ -106,6 +106,24 @@ int zfs_remove_max_copy_bytes = 64 * 1024 * 1024; int zfs_remove_max_segment = 1024 * 1024; /* + * Allow a remap segment to span free chunks of at most this size. The main + * impact of a larger span is that we will read and write larger, more + * contiguous chunks, with more "unnecessary" data -- trading off bandwidth + * for iops. The value here was chosen to align with + * zfs_vdev_read_gap_limit, which is a similar concept when doing regular + * reads (but there's no reason it has to be the same). + * + * Additionally, a higher span will have the following relatively minor + * effects: + * - the mapping will be smaller, since one entry can cover more allocated + * segments + * - more of the fragmentation in the removing device will be preserved + * - we'll do larger allocations, which may fail and fall back on smaller + * allocations + */ +int vdev_removal_max_span = 32 * 1024; + +/* * This is used by the test suite so that it can ensure that certain * actions happen while in the middle of a removal. */ @@ -726,13 +744,52 @@ vdev_mapping_sync(void *arg, dmu_tx_t *tx) spa_sync_removing_state(spa, tx); } +typedef struct vdev_copy_segment_arg { + spa_t *vcsa_spa; + dva_t *vcsa_dest_dva; + uint64_t vcsa_txg; + range_tree_t *vcsa_obsolete_segs; +} vdev_copy_segment_arg_t; + +static void +unalloc_seg(void *arg, uint64_t start, uint64_t size) +{ + vdev_copy_segment_arg_t *vcsa = arg; + spa_t *spa = vcsa->vcsa_spa; + blkptr_t bp = { 0 }; + + BP_SET_BIRTH(&bp, TXG_INITIAL, TXG_INITIAL); + BP_SET_LSIZE(&bp, size); + BP_SET_PSIZE(&bp, size); + BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF); + BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_OFF); + BP_SET_TYPE(&bp, DMU_OT_NONE); + BP_SET_LEVEL(&bp, 0); + BP_SET_DEDUP(&bp, 0); + BP_SET_BYTEORDER(&bp, ZFS_HOST_BYTEORDER); + + DVA_SET_VDEV(&bp.blk_dva[0], DVA_GET_VDEV(vcsa->vcsa_dest_dva)); + DVA_SET_OFFSET(&bp.blk_dva[0], + DVA_GET_OFFSET(vcsa->vcsa_dest_dva) + start); + DVA_SET_ASIZE(&bp.blk_dva[0], size); + + zio_free(spa, vcsa->vcsa_txg, &bp); +} + /* * All reads and writes associated with a call to spa_vdev_copy_segment() * are done. */ static void -spa_vdev_copy_nullzio_done(zio_t *zio) +spa_vdev_copy_segment_done(zio_t *zio) { + vdev_copy_segment_arg_t *vcsa = zio->io_private; + + range_tree_vacate(vcsa->vcsa_obsolete_segs, + unalloc_seg, vcsa); + range_tree_destroy(vcsa->vcsa_obsolete_segs); + kmem_free(vcsa, sizeof (*vcsa)); + spa_config_exit(zio->io_spa, SCL_STATE, zio->io_spa); } @@ -849,7 +906,8 @@ spa_vdev_copy_one_child(vdev_copy_arg_t *vca, zio_t *nzio, * read from the old location and write to the new location. */ static int -spa_vdev_copy_segment(vdev_t *vd, uint64_t start, uint64_t size, uint64_t txg, +spa_vdev_copy_segment(vdev_t *vd, range_tree_t *segs, + uint64_t maxalloc, uint64_t txg, vdev_copy_arg_t *vca, zio_alloc_list_t *zal) { metaslab_group_t *mg = vd->vdev_mg; @@ -857,8 +915,39 @@ spa_vdev_copy_segment(vdev_t *vd, uint64_t start, uint64_t size, uint64_t txg, spa_vdev_removal_t *svr = spa->spa_vdev_removal; vdev_indirect_mapping_entry_t *entry; dva_t dst = { 0 }; + uint64_t start = range_tree_min(segs); - ASSERT3U(size, <=, SPA_MAXBLOCKSIZE); + ASSERT3U(maxalloc, <=, SPA_MAXBLOCKSIZE); + + uint64_t size = range_tree_span(segs); + if (range_tree_span(segs) > maxalloc) { + /* + * We can't allocate all the segments. Prefer to end + * the allocation at the end of a segment, thus avoiding + * additional split blocks. + */ + range_seg_t search; + avl_index_t where; + search.rs_start = start + maxalloc; + search.rs_end = search.rs_start; + range_seg_t *rs = avl_find(&segs->rt_root, &search, &where); + if (rs == NULL) { + rs = avl_nearest(&segs->rt_root, where, AVL_BEFORE); + } else { + rs = AVL_PREV(&segs->rt_root, rs); + } + if (rs != NULL) { + size = rs->rs_end - start; + } else { + /* + * There are no segments that end before maxalloc. + * I.e. the first segment is larger than maxalloc, + * so we must split it. + */ + size = maxalloc; + } + } + ASSERT3U(size, <=, maxalloc); /* * We use allocator 0 for this I/O because we don't expect device remap @@ -873,6 +962,31 @@ spa_vdev_copy_segment(vdev_t *vd, uint64_t start, uint64_t size, uint64_t txg, return (error); /* + * Determine the ranges that are not actually needed. Offsets are + * relative to the start of the range to be copied (i.e. relative to the + * local variable "start"). + */ + range_tree_t *obsolete_segs = range_tree_create(NULL, NULL); + + range_seg_t *rs = avl_first(&segs->rt_root); + ASSERT3U(rs->rs_start, ==, start); + uint64_t prev_seg_end = rs->rs_end; + while ((rs = AVL_NEXT(&segs->rt_root, rs)) != NULL) { + if (rs->rs_start >= start + size) { + break; + } else { + range_tree_add(obsolete_segs, + prev_seg_end - start, + rs->rs_start - prev_seg_end); + } + prev_seg_end = rs->rs_end; + } + /* We don't end in the middle of an obsolete range */ + ASSERT3U(start + size, <=, prev_seg_end); + + range_tree_clear(segs, start, size); + + /* * We can't have any padding of the allocated size, otherwise we will * misunderstand what's allocated, and the size of the mapping. * The caller ensures this will be true by passing in a size that is @@ -883,13 +997,22 @@ spa_vdev_copy_segment(vdev_t *vd, uint64_t start, uint64_t size, uint64_t txg, entry = kmem_zalloc(sizeof (vdev_indirect_mapping_entry_t), KM_SLEEP); DVA_MAPPING_SET_SRC_OFFSET(&entry->vime_mapping, start); entry->vime_mapping.vimep_dst = dst; + if (spa_feature_is_enabled(spa, SPA_FEATURE_OBSOLETE_COUNTS)) { + entry->vime_obsolete_count = range_tree_space(obsolete_segs); + } + + vdev_copy_segment_arg_t *vcsa = kmem_zalloc(sizeof (*vcsa), KM_SLEEP); + vcsa->vcsa_dest_dva = &entry->vime_mapping.vimep_dst; + vcsa->vcsa_obsolete_segs = obsolete_segs; + vcsa->vcsa_spa = spa; + vcsa->vcsa_txg = txg; /* * See comment before spa_vdev_copy_one_child(). */ spa_config_enter(spa, SCL_STATE, spa, RW_READER); zio_t *nzio = zio_null(spa->spa_txg_zio[txg & TXG_MASK], spa, NULL, - spa_vdev_copy_nullzio_done, NULL, 0); + spa_vdev_copy_segment_done, vcsa, 0); vdev_t *dest_vd = vdev_lookup_top(spa, DVA_GET_VDEV(&dst)); if (dest_vd->vdev_ops == &vdev_mirror_ops) { for (int i = 0; i < dest_vd->vdev_children; i++) { @@ -1092,39 +1215,78 @@ spa_vdev_copy_impl(vdev_t *vd, spa_vdev_removal_t *svr, vdev_copy_arg_t *vca, mutex_enter(&svr->svr_lock); - range_seg_t *rs = avl_first(&svr->svr_allocd_segs->rt_root); - if (rs == NULL) { + /* + * Determine how big of a chunk to copy. We can allocate up + * to max_alloc bytes, and we can span up to vdev_removal_max_span + * bytes of unallocated space at a time. "segs" will track the + * allocated segments that we are copying. We may also be copying + * free segments (of up to vdev_removal_max_span bytes). + */ + range_tree_t *segs = range_tree_create(NULL, NULL); + for (;;) { + range_seg_t *rs = avl_first(&svr->svr_allocd_segs->rt_root); + if (rs == NULL) + break; + + uint64_t seg_length; + + if (range_tree_is_empty(segs)) { + /* need to truncate the first seg based on max_alloc */ + seg_length = + MIN(rs->rs_end - rs->rs_start, *max_alloc); + } else { + if (rs->rs_start - range_tree_max(segs) > + vdev_removal_max_span) { + /* + * Including this segment would cause us to + * copy a larger unneeded chunk than is allowed. + */ + break; + } else if (rs->rs_end - range_tree_min(segs) > + *max_alloc) { + /* + * This additional segment would extend past + * max_alloc. Rather than splitting this + * segment, leave it for the next mapping. + */ + break; + } else { + seg_length = rs->rs_end - rs->rs_start; + } + } + + range_tree_add(segs, rs->rs_start, seg_length); + range_tree_remove(svr->svr_allocd_segs, + rs->rs_start, seg_length); + } + + if (range_tree_is_empty(segs)) { mutex_exit(&svr->svr_lock); + range_tree_destroy(segs); return; } - uint64_t offset = rs->rs_start; - uint64_t length = MIN(rs->rs_end - rs->rs_start, *max_alloc); - - range_tree_remove(svr->svr_allocd_segs, offset, length); if (svr->svr_max_offset_to_sync[txg & TXG_MASK] == 0) { dsl_sync_task_nowait(dmu_tx_pool(tx), vdev_mapping_sync, svr, 0, ZFS_SPACE_CHECK_NONE, tx); } - svr->svr_max_offset_to_sync[txg & TXG_MASK] = offset + length; + svr->svr_max_offset_to_sync[txg & TXG_MASK] = range_tree_max(segs); /* * Note: this is the amount of *allocated* space * that we are taking care of each txg. */ - svr->svr_bytes_done[txg & TXG_MASK] += length; + svr->svr_bytes_done[txg & TXG_MASK] += range_tree_space(segs); mutex_exit(&svr->svr_lock); zio_alloc_list_t zal; metaslab_trace_init(&zal); - uint64_t thismax = *max_alloc; - while (length > 0) { - uint64_t mylen = MIN(length, thismax); - + uint64_t thismax = SPA_MAXBLOCKSIZE; + while (!range_tree_is_empty(segs)) { int error = spa_vdev_copy_segment(vd, - offset, mylen, txg, vca, &zal); + segs, thismax, txg, vca, &zal); if (error == ENOSPC) { /* @@ -1138,18 +1300,17 @@ spa_vdev_copy_impl(vdev_t *vd, spa_vdev_removal_t *svr, vdev_copy_arg_t *vca, */ ASSERT3U(spa->spa_max_ashift, >=, SPA_MINBLOCKSHIFT); ASSERT3U(spa->spa_max_ashift, ==, spa->spa_min_ashift); - thismax = P2ROUNDUP(mylen / 2, + uint64_t attempted = + MIN(range_tree_span(segs), thismax); + thismax = P2ROUNDUP(attempted / 2, 1 << spa->spa_max_ashift); - ASSERT3U(thismax, <, mylen); /* * The minimum-size allocation can not fail. */ - ASSERT3U(mylen, >, 1 << spa->spa_max_ashift); - *max_alloc = mylen - (1 << spa->spa_max_ashift); + ASSERT3U(attempted, >, 1 << spa->spa_max_ashift); + *max_alloc = attempted - (1 << spa->spa_max_ashift); } else { ASSERT0(error); - length -= mylen; - offset += mylen; /* * We've performed an allocation, so reset the @@ -1160,6 +1321,7 @@ spa_vdev_copy_impl(vdev_t *vd, spa_vdev_removal_t *svr, vdev_copy_arg_t *vca, } } metaslab_trace_fini(&zal); + range_tree_destroy(segs); } /* diff --git a/usr/src/uts/common/fs/zfs/zcp.c b/usr/src/uts/common/fs/zfs/zcp.c index 5ef77044e6..bad8a56f58 100644 --- a/usr/src/uts/common/fs/zfs/zcp.c +++ b/usr/src/uts/common/fs/zfs/zcp.c @@ -426,7 +426,7 @@ zcp_lua_to_nvlist_impl(lua_State *state, int index, nvlist_t *nvl, /* * Convert a lua value to an nvpair, adding it to an nvlist with the given key. */ -void +static void zcp_lua_to_nvlist(lua_State *state, int index, nvlist_t *nvl, const char *key) { /* @@ -438,7 +438,7 @@ zcp_lua_to_nvlist(lua_State *state, int index, nvlist_t *nvl, const char *key) (void) lua_error(state); } -int +static int zcp_lua_to_nvlist_helper(lua_State *state) { nvlist_t *nv = (nvlist_t *)lua_touserdata(state, 2); @@ -447,11 +447,12 @@ zcp_lua_to_nvlist_helper(lua_State *state) return (0); } -void +static void zcp_convert_return_values(lua_State *state, nvlist_t *nvl, const char *key, zcp_eval_arg_t *evalargs) { int err; + VERIFY3U(1, ==, lua_gettop(state)); lua_pushcfunction(state, zcp_lua_to_nvlist_helper); lua_pushlightuserdata(state, (char *)key); lua_pushlightuserdata(state, nvl); @@ -897,6 +898,7 @@ zcp_eval_impl(dmu_tx_t *tx, boolean_t sync, zcp_eval_arg_t *evalargs) ZCP_RET_RETURN, evalargs); } else if (return_count > 1) { evalargs->ea_result = SET_ERROR(ECHRNG); + lua_settop(state, 0); (void) lua_pushfstring(state, "Multiple return " "values not supported"); zcp_convert_return_values(state, evalargs->ea_outnvl, @@ -958,6 +960,7 @@ static void zcp_pool_error(zcp_eval_arg_t *evalargs, const char *poolname) { evalargs->ea_result = SET_ERROR(ECHRNG); + lua_settop(evalargs->ea_state, 0); (void) lua_pushfstring(evalargs->ea_state, "Could not open pool: %s", poolname); zcp_convert_return_values(evalargs->ea_state, evalargs->ea_outnvl, diff --git a/usr/src/uts/common/io/ldterm.c b/usr/src/uts/common/io/ldterm.c index 6c396db601..1af97c86ea 100644 --- a/usr/src/uts/common/io/ldterm.c +++ b/usr/src/uts/common/io/ldterm.c @@ -22,6 +22,7 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright (c) 2014, Joyent, Inc. All rights reserved. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -381,7 +382,7 @@ static struct streamtab ldtrinfo; static struct fmodsw fsw = { "ldterm", &ldtrinfo, - D_MTQPAIR | D_MP + D_MTQPAIR | D_MP | _D_SINGLE_INSTANCE }; static struct modlstrmod modlstrmod = { diff --git a/usr/src/uts/common/io/ptem.c b/usr/src/uts/common/io/ptem.c index 481169daf3..e4dc15a3ac 100644 --- a/usr/src/uts/common/io/ptem.c +++ b/usr/src/uts/common/io/ptem.c @@ -26,6 +26,7 @@ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -62,7 +63,7 @@ extern struct streamtab pteminfo; static struct fmodsw fsw = { "ptem", &pteminfo, - D_MTQPAIR | D_MP + D_MTQPAIR | D_MP | _D_SINGLE_INSTANCE }; static struct modlstrmod modlstrmod = { diff --git a/usr/src/uts/common/io/ttcompat.c b/usr/src/uts/common/io/ttcompat.c index ab420c82e7..22b1442e50 100644 --- a/usr/src/uts/common/io/ttcompat.c +++ b/usr/src/uts/common/io/ttcompat.c @@ -21,6 +21,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -73,7 +74,7 @@ static struct streamtab ttcoinfo; static struct fmodsw fsw = { "ttcompat", &ttcoinfo, - D_MTQPAIR | D_MP + D_MTQPAIR | D_MP | _D_SINGLE_INSTANCE }; /* diff --git a/usr/src/uts/common/io/usb/clients/hid/hid.c b/usr/src/uts/common/io/usb/clients/hid/hid.c index 2c9c88a3ec..eccd48bf08 100644 --- a/usr/src/uts/common/io/usb/clients/hid/hid.c +++ b/usr/src/uts/common/io/usb/clients/hid/hid.c @@ -441,6 +441,7 @@ hid_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) mutex_enter(&hidp->hid_mutex); if (usb_ep_xdescr_fill(USB_EP_XDESCR_CURRENT_VERSION, dip, ep_data, &hidp->hid_ep_intr_xdescr) != USB_SUCCESS) { + mutex_exit(&hidp->hid_mutex); goto fail; } @@ -1253,11 +1254,11 @@ hid_wput(queue_t *q, mblk_t *mp) { hid_state_t *hidp = (hid_state_t *)q->q_ptr; int error = USB_SUCCESS; - struct iocblk *iocbp; + struct iocblk *iocbp; mblk_t *datap; int direction; struct copyresp *crp; - queue_t *tmpq; + queue_t *tmpq; int flag; USB_DPRINTF_L4(PRINT_MASK_ALL, hidp->hid_log_handle, @@ -2772,7 +2773,7 @@ hid_send_async_ctrl_request(hid_default_pipe_arg_t *hid_default_pipe_arg, } ctrl_req->ctrl_bmRequestType = request_type; - ctrl_req->ctrl_bRequest = (uint8_t)request_request; + ctrl_req->ctrl_bRequest = (uint8_t)request_request; ctrl_req->ctrl_wValue = hid_request->hid_req_wValue; ctrl_req->ctrl_wIndex = request_index; ctrl_req->ctrl_wLength = hid_request->hid_req_wLength; diff --git a/usr/src/uts/common/os/streamio.c b/usr/src/uts/common/os/streamio.c index 21ec25b5b3..8ec67ea76a 100644 --- a/usr/src/uts/common/os/streamio.c +++ b/usr/src/uts/common/os/streamio.c @@ -25,6 +25,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2017 Joyent, Inc. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ #include <sys/types.h> @@ -3821,6 +3822,30 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, TRACE_2(TR_FAC_STREAMS_FR, TR_I_PUSH, "I_PUSH:fp %p stp %p", fp, stp); + /* + * If the module is flagged as single-instance, then check + * to see if the module is already pushed. If it is, return + * as if the push was successful. + */ + if (fp->f_qflag & _QSINGLE_INSTANCE) { + queue_t *q; + + claimstr(stp->sd_wrq); + for (q = stp->sd_wrq->q_next; q; q = q->q_next) { + if (q->q_flag & QREADR) { + q = NULL; + break; + } + if (strcmp(mname, Q2NAME(q)) == 0) + break; + } + releasestr(stp->sd_wrq); + if (q != NULL) { + fmodsw_rele(fp); + return (0); + } + } + if (error = strstartplumb(stp, flag, cmd)) { fmodsw_rele(fp); return (error); diff --git a/usr/src/uts/common/os/strsubr.c b/usr/src/uts/common/os/strsubr.c index 0d0d290fcc..959e5576f0 100644 --- a/usr/src/uts/common/os/strsubr.c +++ b/usr/src/uts/common/os/strsubr.c @@ -27,6 +27,7 @@ * Use is subject to license terms. * Copyright (c) 2016 by Delphix. All rights reserved. * Copyright 2018 Joyent, Inc. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ #include <sys/types.h> @@ -951,7 +952,7 @@ str_sendsig(vnode_t *vp, int event, uchar_t band, int error) */ static void dosendsig(proc_t *proc, int events, int sevent, k_siginfo_t *info, - uchar_t band, int error) + uchar_t band, int error) { ASSERT(MUTEX_HELD(&proc->p_lock)); @@ -2351,7 +2352,7 @@ mux_rmvedge(stdata_t *upstp, int muxid, str_stack_t *ss) */ int devflg_to_qflag(struct streamtab *stp, uint32_t devflag, uint32_t *qflagp, - uint32_t *sqtypep) + uint32_t *sqtypep) { uint32_t qflag = 0; uint32_t sqtype = 0; @@ -2465,6 +2466,17 @@ devflg_to_qflag(struct streamtab *stp, uint32_t devflag, uint32_t *qflagp, qflag |= _QDIRECT; } + /* + * Private flag used to indicate that a streams module should only + * be pushed once. The TTY streams modules have this flag since if + * libc believes itself to be an xpg4 process then it will + * automatically and unconditionally push them when a PTS device is + * opened. If an application is not aware of this then without this + * flag we would end up with duplicate modules. + */ + if (devflag & _D_SINGLE_INSTANCE) + qflag |= _QSINGLE_INSTANCE; + *qflagp = qflag; *sqtypep = sqtype; return (0); @@ -8088,7 +8100,7 @@ strflushrq(vnode_t *vp, int flag) void strsetrputhooks(vnode_t *vp, uint_t flags, - msgfunc_t protofunc, msgfunc_t miscfunc) + msgfunc_t protofunc, msgfunc_t miscfunc) { struct stdata *stp = vp->v_stream; diff --git a/usr/src/uts/common/sys/conf.h b/usr/src/uts/common/sys/conf.h index 7447db408f..4bf3d5c7e3 100644 --- a/usr/src/uts/common/sys/conf.h +++ b/usr/src/uts/common/sys/conf.h @@ -24,6 +24,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ #ifndef _SYS_CONF_H @@ -221,6 +222,8 @@ extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t, #define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */ +#define _D_SINGLE_INSTANCE 0x200000 /* Module may only be pushed once */ + #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ #ifdef __cplusplus diff --git a/usr/src/uts/common/sys/stream.h b/usr/src/uts/common/sys/stream.h index a45030ff7e..33f7f571fb 100644 --- a/usr/src/uts/common/sys/stream.h +++ b/usr/src/uts/common/sys/stream.h @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2015 Joyent, Inc. All rights reserved. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -190,6 +191,8 @@ typedef struct queue { #define _QASSOCIATED 0x10000000 /* queue is associated with a device */ #define _QDIRECT 0x20000000 /* Private; transport module uses */ /* direct interface to/from sockfs */ +#define _QSINGLE_INSTANCE 0x40000000 /* Private; module may only */ + /* be pushed once */ /* queue sqflags (protected by SQLOCK). */ #define Q_SQQUEUED 0x01 /* Queue is in the syncq list */ diff --git a/usr/src/uts/i86pc/io/apix/apix.c b/usr/src/uts/i86pc/io/apix/apix.c index 545d3a0d05..a5a4823a91 100644 --- a/usr/src/uts/i86pc/io/apix/apix.c +++ b/usr/src/uts/i86pc/io/apix/apix.c @@ -269,7 +269,7 @@ apix_probe() * * Please remove when/if the issue is resolved. */ - if (get_hwenv() == HW_XEN_HVM) + if (get_hwenv() & HW_XEN_HVM) return (PSM_FAILURE); /* check for hw features if specified */ |
