summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2013-10-09 21:03:34 +0000
committermarkm <markm@FreeBSD.org>2013-10-09 21:03:34 +0000
commita9d73bef6411194603d9e7e775055b1eecf81f72 (patch)
tree3f1ae2032445c25f67a5b6645cd165067d0b8a93
parent512bff9c9fd0cf3326b33cd3e68ca57b094887b5 (diff)
parent4ab5163697ae354915222d0ef65a54ceebe7a0ee (diff)
downloadFreeBSD-src-a9d73bef6411194603d9e7e775055b1eecf81f72.zip
FreeBSD-src-a9d73bef6411194603d9e7e775055b1eecf81f72.tar.gz
MFC - tracking commit.
-rw-r--r--ObsoleteFiles.inc2
-rw-r--r--bin/Makefile1
-rw-r--r--bin/freebsd-version/Makefile (renamed from libexec/freebsd-version/Makefile)3
-rw-r--r--bin/freebsd-version/freebsd-version.1 (renamed from libexec/freebsd-version/freebsd-version.1)4
-rw-r--r--bin/freebsd-version/freebsd-version.sh.in (renamed from libexec/freebsd-version/freebsd-version.sh.in)0
-rw-r--r--lib/libprocstat/libprocstat.c24
-rw-r--r--libexec/Makefile1
-rw-r--r--sys/dev/cxgbe/t4_main.c2
-rw-r--r--sys/dev/isci/isci_io_request.c9
-rw-r--r--sys/dev/isci/isci_sysctl.c34
-rw-r--r--sys/dev/isci/isci_task_request.c13
-rw-r--r--sys/dev/iscsi/icl.c1
-rw-r--r--sys/dev/iscsi/iscsi.c79
-rw-r--r--sys/dev/ixgbe/ixgbe.c3
-rw-r--r--sys/kern/kern_descrip.c48
-rw-r--r--sys/kern/vfs_bio.c3
-rw-r--r--sys/kern/vfs_subr.c2
-rw-r--r--sys/net/if.h1
-rw-r--r--sys/net/if_ethersubr.c3
-rw-r--r--sys/net/if_lagg.c1
-rw-r--r--usr.sbin/bhyveload/bhyveload.82
21 files changed, 181 insertions, 55 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 9f3fbb9..e82f3b9 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20131009: freebsd-version moved from /libexec to /bin
+OLD_FILES+=/libexec/freebsd-version
# 20131001: ar and ranlib from binutils not used
OLD_FILES+=usr/bin/gnu-ar
OLD_FILES+=usr/bin/gnu-ranlib
diff --git a/bin/Makefile b/bin/Makefile
index e5052ca..7b6a4ab 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -15,6 +15,7 @@ SUBDIR= cat \
echo \
ed \
expr \
+ freebsd-version \
getfacl \
hostname \
kenv \
diff --git a/libexec/freebsd-version/Makefile b/bin/freebsd-version/Makefile
index 96685c4..0fe7308 100644
--- a/libexec/freebsd-version/Makefile
+++ b/bin/freebsd-version/Makefile
@@ -2,12 +2,11 @@
SCRIPTS = freebsd-version
MAN = freebsd-version.1
-BINDIR = /libexec
CLEANFILES = freebsd-version.sh
NEWVERS = ${.CURDIR}/../../sys/conf/newvers.sh
freebsd-version.sh.in: ${NEWVERS}
-freebsd-version.sh: freebsd-version.sh.in
+freebsd-version.sh: ${.CURDIR}/freebsd-version.sh.in
eval $$(egrep '^(TYPE|REVISION|BRANCH)=' ${NEWVERS}) ; \
if ! sed -e "\
s/@@TYPE@@/$${TYPE}/g; \
diff --git a/libexec/freebsd-version/freebsd-version.1 b/bin/freebsd-version/freebsd-version.1
index ee3f748..1eea5bb 100644
--- a/libexec/freebsd-version/freebsd-version.1
+++ b/bin/freebsd-version/freebsd-version.1
@@ -100,13 +100,13 @@ and the kernel.
.Sh EXAMPLES
To determine the version of the currently running userland:
.Bd -literal -offset indent
-/libexec/freebsd-version -u
+/bin/freebsd-version -u
.Ed
.Pp
To inspect a system being repaired using a live CD:
.Bd -literal -offset indent
mount -rt ufs /dev/ada0p2 /mnt
-env ROOT=/mnt /mnt/libexec/freebsd-version -ku
+env ROOT=/mnt /mnt/bin/freebsd-version -ku
.Ed
.Sh SEE ALSO
.Xr uname 1 ,
diff --git a/libexec/freebsd-version/freebsd-version.sh.in b/bin/freebsd-version/freebsd-version.sh.in
index 0f9a468..0f9a468 100644
--- a/libexec/freebsd-version/freebsd-version.sh.in
+++ b/bin/freebsd-version/freebsd-version.sh.in
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index 9056151..e1ec7af 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/ksem.h>
#include <sys/mman.h>
+#include <sys/capability.h>
#define _KERNEL
#include <sys/mount.h>
#include <sys/pipe.h>
@@ -395,7 +396,10 @@ filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
entry->fs_ref_count = refcount;
entry->fs_offset = offset;
entry->fs_path = path;
- entry->fs_cap_rights = *cap_rightsp;
+ if (cap_rightsp != NULL)
+ entry->fs_cap_rights = *cap_rightsp;
+ else
+ cap_rights_init(&entry->fs_cap_rights);
return (entry);
}
@@ -478,21 +482,21 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
/* root directory vnode, if one. */
if (filed.fd_rdir) {
entry = filestat_new_entry(filed.fd_rdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* current working directory vnode. */
if (filed.fd_cdir) {
entry = filestat_new_entry(filed.fd_cdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* jail root, if any. */
if (filed.fd_jdir) {
entry = filestat_new_entry(filed.fd_jdir, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -500,14 +504,14 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
if (kp->ki_tracep) {
entry = filestat_new_entry(kp->ki_tracep, PS_FST_TYPE_VNODE, -1,
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
- PS_FST_UFLAG_TRACE, 0, 0, NULL, 0);
+ PS_FST_UFLAG_TRACE, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
/* text vnode, if one */
if (kp->ki_textvp) {
entry = filestat_new_entry(kp->ki_textvp, PS_FST_TYPE_VNODE, -1,
- PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, 0);
+ PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -515,7 +519,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
if ((vp = getctty(kd, kp)) != NULL) {
entry = filestat_new_entry(vp, PS_FST_TYPE_VNODE, -1,
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
- PS_FST_UFLAG_CTTY, 0, 0, NULL, 0);
+ PS_FST_UFLAG_CTTY, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -578,7 +582,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
}
/* XXXRW: No capability rights support for kvm yet. */
entry = filestat_new_entry(data, type, i,
- to_filestat_flags(file.f_flag), 0, 0, 0, NULL, 0);
+ to_filestat_flags(file.f_flag), 0, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -637,7 +641,7 @@ do_mmapped:
*/
entry = filestat_new_entry(object.handle,
PS_FST_TYPE_VNODE, -1, fflags,
- PS_FST_UFLAG_MMAP, 0, 0, NULL, 0);
+ PS_FST_UFLAG_MMAP, 0, 0, NULL, NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
@@ -878,7 +882,7 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
path = NULL;
entry = filestat_new_entry(kve, PS_FST_TYPE_VNODE, -1,
fflags, PS_FST_UFLAG_MMAP, refcount, offset, path,
- 0);
+ NULL);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
diff --git a/libexec/Makefile b/libexec/Makefile
index 1039b24..0b9c961 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -8,7 +8,6 @@ SUBDIR= ${_atf} \
bootpd \
${_comsat} \
fingerd \
- freebsd-version \
ftpd \
getty \
${_mail.local} \
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index d905cd5..c46ed5a0 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -950,7 +950,7 @@ cxgbe_probe(device_t dev)
#define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \
IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \
- IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6)
+ IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS)
#define T4_CAP_ENABLE (T4_CAP)
static int
diff --git a/sys/dev/isci/isci_io_request.c b/sys/dev/isci/isci_io_request.c
index 4486f31..d1f5afe 100644
--- a/sys/dev/isci/isci_io_request.c
+++ b/sys/dev/isci/isci_io_request.c
@@ -153,11 +153,16 @@ isci_io_request_complete(SCI_CONTROLLER_HANDLE_T scif_controller,
case SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED:
isci_remote_device_reset(isci_remote_device, NULL);
+ ccb->ccb_h.status |= CAM_REQ_TERMIO;
+ isci_log_message(0, "ISCI",
+ "isci: bus=%x target=%x lun=%x cdb[0]=%x remote device reset required\n",
+ ccb->ccb_h.path_id, ccb->ccb_h.target_id,
+ ccb->ccb_h.target_lun, ccb->csio.cdb_io.cdb_bytes[0]);
+ break;
- /* drop through */
case SCI_IO_FAILURE_TERMINATED:
ccb->ccb_h.status |= CAM_REQ_TERMIO;
- isci_log_message(1, "ISCI",
+ isci_log_message(0, "ISCI",
"isci: bus=%x target=%x lun=%x cdb[0]=%x terminated\n",
ccb->ccb_h.path_id, ccb->ccb_h.target_id,
ccb->ccb_h.target_lun, ccb->csio.cdb_io.cdb_bytes[0]);
diff --git a/sys/dev/isci/isci_sysctl.c b/sys/dev/isci/isci_sysctl.c
index 6a22e38..4623a8a 100644
--- a/sys/dev/isci/isci_sysctl.c
+++ b/sys/dev/isci/isci_sysctl.c
@@ -193,6 +193,35 @@ isci_sysctl_start_phy(SYSCTL_HANDLER_ARGS)
return 0;
}
+static int
+isci_sysctl_log_frozen_lun_masks(SYSCTL_HANDLER_ARGS)
+{
+ struct isci_softc *isci = (struct isci_softc *)arg1;
+ struct ISCI_REMOTE_DEVICE *device;
+ int32_t log_frozen_devices = 0;
+ int error, i, j;
+
+ error = sysctl_handle_int(oidp, &log_frozen_devices, 0, req);
+
+ if (error || log_frozen_devices == 0)
+ return (error);
+
+ for (i = 0; i < isci->controller_count; i++) {
+ for (j = 0; j < SCI_MAX_REMOTE_DEVICES; j++) {
+ device = isci->controllers[i].remote_device[j];
+
+ if (device == NULL)
+ continue;
+
+ device_printf(isci->device,
+ "controller %d device %3d frozen_lun_mask 0x%02x\n",
+ i, j, device->frozen_lun_mask);
+ }
+ }
+
+ return (0);
+}
+
void isci_sysctl_initialize(struct isci_softc *isci)
{
struct sysctl_ctx_list *sysctl_ctx = device_get_sysctl_ctx(isci->device);
@@ -225,5 +254,10 @@ void isci_sysctl_initialize(struct isci_softc *isci)
SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO,
"start_phy", CTLTYPE_UINT| CTLFLAG_RW, isci, 0,
isci_sysctl_start_phy, "IU", "Start PHY on a controller");
+
+ SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO,
+ "log_frozen_lun_masks", CTLTYPE_UINT| CTLFLAG_RW, isci, 0,
+ isci_sysctl_log_frozen_lun_masks, "IU",
+ "Log frozen lun masks to kernel log");
}
diff --git a/sys/dev/isci/isci_task_request.c b/sys/dev/isci/isci_task_request.c
index 4ad0731..5d7f63d 100644
--- a/sys/dev/isci/isci_task_request.c
+++ b/sys/dev/isci/isci_task_request.c
@@ -194,11 +194,20 @@ isci_task_request_complete(SCI_CONTROLLER_HANDLE_T scif_controller,
break;
case SCI_TASK_FAILURE_INVALID_STATE:
+ retry_task = TRUE;
+ isci_log_message(0, "ISCI",
+ "task failure (invalid state) - retrying\n");
+ break;
+
case SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES:
- case SCI_FAILURE_TIMEOUT:
retry_task = TRUE;
isci_log_message(0, "ISCI",
- "unhandled task completion code 0x%x\n", completion_status);
+ "task failure (insufficient resources) - retrying\n");
+ break;
+
+ case SCI_FAILURE_TIMEOUT:
+ retry_task = TRUE;
+ isci_log_message(0, "ISCI", "task timeout - retrying\n");
break;
case SCI_TASK_FAILURE:
diff --git a/sys/dev/iscsi/icl.c b/sys/dev/iscsi/icl.c
index 6796878..cf58dfd 100644
--- a/sys/dev/iscsi/icl.c
+++ b/sys/dev/iscsi/icl.c
@@ -564,6 +564,7 @@ icl_conn_receive_pdu(struct icl_conn *ic, size_t *availablep)
"MaxDataSegmentLength %zd; "
"dropping connection",
len, ic->ic_max_data_segment_length);
+ error = EINVAL;
break;
}
diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c
index 2d347f3..1e65416 100644
--- a/sys/dev/iscsi/iscsi.c
+++ b/sys/dev/iscsi/iscsi.c
@@ -950,40 +950,59 @@ iscsi_pdu_handle_data_in(struct icl_pdu *response)
csio = &io->io_ccb->csio;
- if (ntohl(bhsdi->bhsdi_buffer_offset) + data_segment_len >
- csio->dxfer_len) {
+ if (io->io_received + data_segment_len > csio->dxfer_len) {
ISCSI_SESSION_WARN(is, "oversize data segment (%zd bytes "
- "at offset %d, buffer is %d)",
- data_segment_len, ntohl(bhsdi->bhsdi_buffer_offset),
- csio->dxfer_len);
+ "at offset %zd, buffer is %d)",
+ data_segment_len, io->io_received, csio->dxfer_len);
icl_pdu_free(response);
iscsi_session_reconnect(is);
return;
}
- icl_pdu_get_data(response, 0, csio->data_ptr + ntohl(bhsdi->bhsdi_buffer_offset), data_segment_len);
+ icl_pdu_get_data(response, 0, csio->data_ptr + io->io_received, data_segment_len);
io->io_received += data_segment_len;
/*
* XXX: Check DataSN.
* XXX: Check F.
*/
- if (bhsdi->bhsdi_flags & BHSDI_FLAGS_S) {
- //ISCSI_SESSION_DEBUG(is, "got S flag; status 0x%x", bhsdi->bhsdi_status);
- if (bhsdi->bhsdi_status == 0) {
- io->io_ccb->ccb_h.status = CAM_REQ_CMP;
- } else {
- if ((io->io_ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
- xpt_freeze_devq(io->io_ccb->ccb_h.path, 1);
- ISCSI_SESSION_DEBUG(is, "freezing devq");
+ if ((bhsdi->bhsdi_flags & BHSDI_FLAGS_S) == 0) {
+ /*
+ * Nothing more to do.
+ */
+ icl_pdu_free(response);
+ return;
+ }
+
+ //ISCSI_SESSION_DEBUG(is, "got S flag; status 0x%x", bhsdi->bhsdi_status);
+ if (bhsdi->bhsdi_status == 0) {
+ io->io_ccb->ccb_h.status = CAM_REQ_CMP;
+ } else {
+ if ((io->io_ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
+ xpt_freeze_devq(io->io_ccb->ccb_h.path, 1);
+ ISCSI_SESSION_DEBUG(is, "freezing devq");
+ }
+ io->io_ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_DEV_QFRZN;
+ csio->scsi_status = bhsdi->bhsdi_status;
+ }
+
+ if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
+ KASSERT(io->io_received <= csio->dxfer_len,
+ ("io->io_received > csio->dxfer_len"));
+ if (io->io_received < csio->dxfer_len) {
+ csio->resid = ntohl(bhsdi->bhsdi_residual_count);
+ if (csio->resid != csio->dxfer_len - io->io_received) {
+ ISCSI_SESSION_WARN(is, "underflow mismatch: "
+ "target indicates %d, we calculated %zd",
+ csio->resid,
+ csio->dxfer_len - io->io_received);
}
- io->io_ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_DEV_QFRZN;
- csio->scsi_status = bhsdi->bhsdi_status;
+ csio->resid = csio->dxfer_len - io->io_received;
}
- xpt_done(io->io_ccb);
- iscsi_outstanding_remove(is, io);
}
+ xpt_done(io->io_ccb);
+ iscsi_outstanding_remove(is, io);
icl_pdu_free(response);
}
@@ -1033,8 +1052,24 @@ iscsi_pdu_handle_r2t(struct icl_pdu *response)
*/
io->io_datasn = 0;
+
off = ntohl(bhsr2t->bhsr2t_buffer_offset);
+ if (off > csio->dxfer_len) {
+ ISCSI_SESSION_WARN(is, "target requested invalid offset "
+ "%zd, buffer is is %d; reconnecting", off, csio->dxfer_len);
+ icl_pdu_free(response);
+ iscsi_session_reconnect(is);
+ return;
+ }
+
total_len = ntohl(bhsr2t->bhsr2t_desired_data_transfer_length);
+ if (total_len == 0 || total_len > csio->dxfer_len) {
+ ISCSI_SESSION_WARN(is, "target requested invalid length "
+ "%zd, buffer is %d; reconnecting", total_len, csio->dxfer_len);
+ icl_pdu_free(response);
+ iscsi_session_reconnect(is);
+ return;
+ }
//ISCSI_SESSION_DEBUG(is, "r2t; off %zd, len %zd", off, total_len);
@@ -1045,7 +1080,8 @@ iscsi_pdu_handle_r2t(struct icl_pdu *response)
len = is->is_max_data_segment_length;
if (off + len > csio->dxfer_len) {
- ISCSI_SESSION_WARN(is, "bad off %zd, len %d",
+ ISCSI_SESSION_WARN(is, "target requested invalid "
+ "length/offset %zd, buffer is %d; reconnecting",
off + len, csio->dxfer_len);
icl_pdu_free(response);
iscsi_session_reconnect(is);
@@ -1068,8 +1104,11 @@ iscsi_pdu_handle_r2t(struct icl_pdu *response)
bhsr2t->bhsr2t_target_transfer_tag;
bhsdo->bhsdo_datasn = htonl(io->io_datasn++);
bhsdo->bhsdo_buffer_offset = htonl(off);
- error = icl_pdu_append_data(request, csio->data_ptr + off, len, M_NOWAIT);
+ error = icl_pdu_append_data(request, csio->data_ptr + off, len,
+ M_NOWAIT);
if (error != 0) {
+ ISCSI_SESSION_WARN(is, "failed to allocate memory; "
+ "reconnecting");
icl_pdu_free(request);
icl_pdu_free(response);
iscsi_session_reconnect(is);
diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c
index 3434125..e913bd5 100644
--- a/sys/dev/ixgbe/ixgbe.c
+++ b/sys/dev/ixgbe/ixgbe.c
@@ -2662,7 +2662,8 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
ifp->if_capabilities |= IFCAP_LRO;
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING
| IFCAP_VLAN_HWTSO
- | IFCAP_VLAN_MTU;
+ | IFCAP_VLAN_MTU
+ | IFCAP_HWSTATS;
ifp->if_capenable = ifp->if_capabilities;
/*
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index a1021e1..c1f0d38 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -119,6 +119,7 @@ static int closefp(struct filedesc *fdp, int fd, struct file *fp,
static int fd_first_free(struct filedesc *fdp, int low, int size);
static int fd_last_used(struct filedesc *fdp, int size);
static void fdgrowtable(struct filedesc *fdp, int nfd);
+static void fdgrowtable_exp(struct filedesc *fdp, int nfd);
static void fdunused(struct filedesc *fdp, int fd);
static void fdused(struct filedesc *fdp, int fd);
static int fill_pipe_info(struct pipe *pi, struct kinfo_file *kif);
@@ -129,6 +130,7 @@ static int fill_sem_info(struct file *fp, struct kinfo_file *kif);
static int fill_shm_info(struct file *fp, struct kinfo_file *kif);
static int fill_socket_info(struct socket *so, struct kinfo_file *kif);
static int fill_vnode_info(struct vnode *vp, struct kinfo_file *kif);
+static int getmaxfd(struct proc *p);
/*
* Each process has:
@@ -771,6 +773,18 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
return (error);
}
+static int
+getmaxfd(struct proc *p)
+{
+ int maxfd;
+
+ PROC_LOCK(p);
+ maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
+ PROC_UNLOCK(p);
+
+ return (maxfd);
+}
+
/*
* Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
*/
@@ -797,9 +811,7 @@ do_dup(struct thread *td, int flags, int old, int new,
return (EBADF);
if (new < 0)
return (flags & DUP_FCNTL ? EINVAL : EBADF);
- PROC_LOCK(p);
- maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
- PROC_UNLOCK(p);
+ maxfd = getmaxfd(p);
if (new >= maxfd)
return (flags & DUP_FCNTL ? EINVAL : EBADF);
@@ -844,7 +856,7 @@ do_dup(struct thread *td, int flags, int old, int new,
return (EMFILE);
}
#endif
- fdgrowtable(fdp, new + 1);
+ fdgrowtable_exp(fdp, new + 1);
oldfde = &fdp->fd_ofiles[old];
}
newfde = &fdp->fd_ofiles[new];
@@ -1467,6 +1479,24 @@ filecaps_validate(const struct filecaps *fcaps, const char *func)
("%s: ioctls without CAP_IOCTL", func));
}
+static void
+fdgrowtable_exp(struct filedesc *fdp, int nfd)
+{
+ int nfd1, maxfd;
+
+ FILEDESC_XLOCK_ASSERT(fdp);
+
+ nfd1 = fdp->fd_nfiles * 2;
+ if (nfd1 < nfd)
+ nfd1 = nfd;
+ maxfd = getmaxfd(curproc);
+ if (maxfd < nfd1)
+ nfd1 = maxfd;
+ KASSERT(nfd <= nfd1,
+ ("too low nfd1 %d %d %d %d", nfd, fdp->fd_nfiles, maxfd, nfd1));
+ fdgrowtable(fdp, nfd1);
+}
+
/*
* Grow the file table to accomodate (at least) nfd descriptors.
*/
@@ -1563,9 +1593,7 @@ fdalloc(struct thread *td, int minfd, int *result)
if (fdp->fd_freefile > minfd)
minfd = fdp->fd_freefile;
- PROC_LOCK(p);
- maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
- PROC_UNLOCK(p);
+ maxfd = getmaxfd(p);
/*
* Search the bitmap for a free descriptor starting at minfd.
@@ -1587,7 +1615,7 @@ fdalloc(struct thread *td, int minfd, int *result)
* fd is already equal to first free descriptor >= minfd, so
* we only need to grow the table and we are done.
*/
- fdgrowtable(fdp, allocfd);
+ fdgrowtable_exp(fdp, allocfd);
}
/*
@@ -1652,9 +1680,7 @@ fdavail(struct thread *td, int n)
* call racct_add() from there instead of dealing with containers
* here.
*/
- PROC_LOCK(p);
- lim = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
- PROC_UNLOCK(p);
+ lim = getmaxfd(p);
if ((i = lim - fdp->fd_nfiles) > 0 && (n -= i) <= 0)
return (1);
last = min(fdp->fd_nfiles, lim);
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 1690ee5..362de37 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -2076,7 +2076,8 @@ getnewbuf_bufd_help(struct vnode *vp, int gbflags, int slpflag, int slptimeo,
wait = MNT_NOWAIT;
mtx_lock(&nblock);
while (needsbuffer & flags) {
- if (vp != NULL && (td->td_pflags & TDP_BUFNEED) == 0) {
+ if (vp != NULL && vp->v_type != VCHR &&
+ (td->td_pflags & TDP_BUFNEED) == 0) {
mtx_unlock(&nblock);
/*
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 930a3c8..91c64a3 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1315,6 +1315,8 @@ vinvalbuf(struct vnode *vp, int flags, int slpflag, int slptimeo)
CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags);
ASSERT_VOP_LOCKED(vp, "vinvalbuf");
+ if (vp->v_object != NULL && vp->v_object->handle != vp)
+ return (0);
return (bufobj_invalbuf(&vp->v_bufobj, flags, slpflag, slptimeo));
}
diff --git a/sys/net/if.h b/sys/net/if.h
index ab98ec0..80a7112 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -231,6 +231,7 @@ struct if_data {
#define IFCAP_NETMAP 0x100000 /* netmap mode supported/enabled */
#define IFCAP_RXCSUM_IPV6 0x200000 /* can offload checksum on IPv6 RX */
#define IFCAP_TXCSUM_IPV6 0x400000 /* can offload checksum on IPv6 TX */
+#define IFCAP_HWSTATS 0x800000 /* manages counters internally */
#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index f1a1666..26e6edb 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -528,7 +528,8 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
m->m_flags &= ~M_HASFCS;
}
- ifp->if_ibytes += m->m_pkthdr.len;
+ if (!(ifp->if_capenable & IFCAP_HWSTATS))
+ ifp->if_ibytes += m->m_pkthdr.len;
/* Allow monitor mode to claim this frame, after stats are updated. */
if (ifp->if_flags & IFF_MONITOR) {
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index 27bab87..258c2f9 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -347,6 +347,7 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params)
ifp->if_init = lagg_init;
ifp->if_ioctl = lagg_ioctl;
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
+ ifp->if_capenable = ifp->if_capabilities = IFCAP_HWSTATS;
/*
* Attach as an ordinary ethernet device, children will be attached
diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8
index 2c0edac..2efcad0 100644
--- a/usr.sbin/bhyveload/bhyveload.8
+++ b/usr.sbin/bhyveload/bhyveload.8
@@ -1,4 +1,4 @@
-\"
+.\"
.\" Copyright (c) 2012 NetApp Inc
.\" All rights reserved.
.\"
OpenPOWER on IntegriCloud