--- a/usr/src/lib/libgrubmgmt/common/libgrub_fs.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/lib/libgrubmgmt/common/libgrub_fs.c Sat Jul 13 21:34:47 2013 +0100
@@ -22,9 +22,12 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
/*
- * This file contains all the functions that manipualte the file
+ * This file contains all the functions that manipulate the file
* system where the GRUB menu resides.
*/
#include <stdio.h>
@@ -42,6 +45,9 @@
#include <sys/fs/ufs_mount.h>
#include <sys/dktp/fdisk.h>
#include <libfstyp.h>
+#if defined(i386) || defined(__amd64)
+#include <libfdisk.h>
+#endif
#include "libgrub_impl.h"
@@ -84,6 +90,10 @@
struct ipart *ipart;
char boot_sect[512];
char rdev[MAXNAMELEN];
+#if defined(i386) || defined(__amd64)
+ ext_part_t *epp;
+ int ext_part_found = 0;
+#endif
(void) snprintf(rdev, sizeof (rdev), "/devices%s,raw", physpath);
@@ -105,6 +115,28 @@
for (i = 0; i < FD_NUMPART; ++i) {
if (ipart[i].systid == SUNIXOS || ipart[i].systid == SUNIXOS2)
return (i);
+
+#if defined(i386) || defined(__amd64)
+ if (!fdisk_is_dos_extended(ipart[i].systid) ||
+ (ext_part_found == 1))
+ continue;
+
+ ext_part_found = 1;
+
+ if (libfdisk_init(&epp, rdev, NULL, FDISK_READ_DISK) ==
+ FDISK_SUCCESS) {
+ uint32_t begs, nums;
+ int pno;
+ int rval;
+
+ rval = fdisk_get_solaris_part(epp, &pno, &begs, &nums);
+
+ libfdisk_fini(&epp);
+
+ if (rval == FDISK_SUCCESS)
+ return (pno - 1);
+ }
+#endif
}
return (PRTNUM_INVALID);
}
@@ -146,7 +178,7 @@
/*
* On entry physpath parameter supposed to contain:
* <disk_physpath>[<space><disk_physpath>]*.
- * Retireives first <disk_physpath> that matches both partition and slice.
+ * Retrieves first <disk_physpath> that matches both partition and slice.
* If any partition and slice is acceptable, first <disk_physpath> is returned.
*/
static int
--- a/usr/src/lib/libgrubmgmt/common/libgrub_impl.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/lib/libgrubmgmt/common/libgrub_impl.h Sat Jul 13 21:34:47 2013 +0100
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
#ifndef _GRBMIMPL_H
#define _GRBMIMPL_H
@@ -34,6 +37,7 @@
#include <sys/param.h>
#include <sys/mntent.h>
#include <sys/uadmin.h>
+#include <sys/dktp/fdisk.h>
#include <libzfs.h>
#include <libdevinfo.h>
#include "libgrubmgmt.h"
@@ -55,7 +59,7 @@
#define SLCNUM_WHOLE_DISK 'q'
#define IS_SLCNUM_VALID(x) ((x) >= SLCNUM_FIRST && (x) < SLCNUM_WHOLE_DISK)
-#define IS_PRTNUM_VALID(x) ((uint_t)(x) < FD_NUMPART)
+#define IS_PRTNUM_VALID(x) ((uint_t)(x) < FD_NUMPART + MAX_EXT_PARTS)
#define GRBM_VALID_FLAG ((uint_t)1 << 31)
#define GRBM_MAXLINE 8192
--- a/usr/src/lib/libgrubmgmt/i386/Makefile Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/lib/libgrubmgmt/i386/Makefile Sat Jul 13 21:34:47 2013 +0100
@@ -22,8 +22,14 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
#
include ../Makefile.com
+#
+# Libraries added to the next line must be present in miniroot
+#
+LDLIBS += -lfdisk
+
install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- a/usr/src/uts/common/io/blkdev/blkdev.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/blkdev/blkdev.c Sat Jul 13 21:34:47 2013 +0100
@@ -20,9 +20,9 @@
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
* Copyright 2012 Garrett D'Amore <[email protected]>. All rights reserved.
* Copyright 2012 Alexey Zaytsev <[email protected]> All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/types.h>
@@ -1051,7 +1051,22 @@
minfo.dki_media_type = DK_FIXED_DISK;
minfo.dki_lbsize = (1U << bd->d_blkshift);
minfo.dki_capacity = bd->d_numblks;
- if (ddi_copyout(&minfo, ptr, sizeof (minfo), flag)) {
+ if (ddi_copyout(&minfo, ptr, sizeof (minfo), flag)) {
+ return (EFAULT);
+ }
+ return (0);
+ }
+ case DKIOCGMEDIAINFOEXT: {
+ struct dk_minfo_ext miext;
+
+ /* make sure our state information is current */
+ bd_update_state(bd);
+ bzero(&miext, sizeof (miext));
+ miext.dki_media_type = DK_FIXED_DISK;
+ miext.dki_lbsize = (1U << bd->d_blkshift);
+ miext.dki_pbsize = miext.dki_lbsize;
+ miext.dki_capacity = bd->d_numblks;
+ if (ddi_copyout(&miext, ptr, sizeof (miext), flag)) {
return (EFAULT);
}
return (0);
@@ -1074,7 +1089,7 @@
cinfo.dki_space = 0;
cinfo.dki_prio = 0;
cinfo.dki_vec = 0;
- if (ddi_copyout(&cinfo, ptr, sizeof (cinfo), flag)) {
+ if (ddi_copyout(&cinfo, ptr, sizeof (cinfo), flag)) {
return (EFAULT);
}
return (0);
--- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c Sat Jul 13 21:34:47 2013 +0100
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/conf.h>
@@ -2997,7 +2998,6 @@
{
int ret;
long resid;
- hrtime_t xfer_start, xfer_done;
if ((offset + size) > sl->sl_lu_size) {
return (SBD_IO_PAST_EOF);
@@ -3016,8 +3016,6 @@
size = store_end;
}
- xfer_start = gethrtime();
- stmf_lu_xfer_start(task);
DTRACE_PROBE5(backing__store__read__start, sbd_lu_t *, sl,
uint8_t *, buf, uint64_t, size, uint64_t, offset,
scsi_task_t *, task);
@@ -3038,8 +3036,6 @@
&resid);
rw_exit(&sl->sl_access_state_lock);
- xfer_done = gethrtime() - xfer_start;
- stmf_lu_xfer_done(task, B_TRUE /* read */, size, xfer_done);
DTRACE_PROBE6(backing__store__read__end, sbd_lu_t *, sl,
uint8_t *, buf, uint64_t, size, uint64_t, offset,
int, ret, scsi_task_t *, task);
@@ -3062,7 +3058,6 @@
long resid;
sbd_status_t sret = SBD_SUCCESS;
int ioflag;
- hrtime_t xfer_start, xfer_done;
if ((offset + size) > sl->sl_lu_size) {
return (SBD_IO_PAST_EOF);
@@ -3077,8 +3072,6 @@
ioflag = 0;
}
- xfer_start = gethrtime();
- stmf_lu_xfer_start(task);
DTRACE_PROBE5(backing__store__write__start, sbd_lu_t *, sl,
uint8_t *, buf, uint64_t, size, uint64_t, offset,
scsi_task_t *, task);
@@ -3099,8 +3092,6 @@
&resid);
rw_exit(&sl->sl_access_state_lock);
- xfer_done = gethrtime() - xfer_start;
- stmf_lu_xfer_done(task, B_FALSE /* write */, size, xfer_done);
DTRACE_PROBE6(backing__store__write__end, sbd_lu_t *, sl,
uint8_t *, buf, uint64_t, size, uint64_t, offset,
int, ret, scsi_task_t *, task);
--- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c Sat Jul 13 21:34:47 2013 +0100
@@ -20,8 +20,8 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- *
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/conf.h>
@@ -218,7 +218,6 @@
uint_t nblks;
uint64_t blksize = sl->sl_blksize;
size_t db_private_sz;
- hrtime_t xfer_start, xfer_elapsed;
uintptr_t pad;
ASSERT(rw_read_held(&sl->sl_access_state_lock));
@@ -334,18 +333,12 @@
* Accounting for start of read.
* Note there is no buffer address for the probe yet.
*/
- stmf_lu_xfer_start(task);
DTRACE_PROBE5(backing__store__read__start, sbd_lu_t *, sl,
uint8_t *, NULL, uint64_t, xfer_len,
uint64_t, offset, scsi_task_t *, task);
- xfer_start = gethrtime();
ret = sbd_zvol_alloc_read_bufs(sl, dbuf);
- xfer_elapsed = gethrtime() - xfer_start;
-
- stmf_lu_xfer_done(task, B_TRUE /* read */, (uint64_t)xfer_len,
- xfer_elapsed);
DTRACE_PROBE6(backing__store__read__end, sbd_lu_t *, sl,
uint8_t *, NULL, uint64_t, xfer_len,
uint64_t, offset, int, ret, scsi_task_t *, task);
@@ -607,7 +600,6 @@
int scmd_err, scmd_xfer_done;
stmf_status_t xfer_status = dbuf->db_xfer_status;
uint32_t data_size = dbuf->db_data_size;
- hrtime_t xfer_start;
ASSERT(zvio);
@@ -627,12 +619,9 @@
(scmd->flags & SBD_SCSI_CMD_XFER_FAIL) ||
(xfer_status != STMF_SUCCESS));
- /* start the accounting clock */
- stmf_lu_xfer_start(task);
DTRACE_PROBE5(backing__store__write__start, sbd_lu_t *, sl,
uint8_t *, NULL, uint64_t, data_size,
uint64_t, zvio->zvio_offset, scsi_task_t *, task);
- xfer_start = gethrtime();
if (scmd_err) {
/* just return the write buffers */
@@ -647,9 +636,6 @@
ret = sbd_zvol_rele_write_bufs(sl, dbuf);
}
- /* finalize accounting */
- stmf_lu_xfer_done(task, B_FALSE /* not read */, data_size,
- (gethrtime() - xfer_start));
DTRACE_PROBE6(backing__store__write__end, sbd_lu_t *, sl,
uint8_t *, NULL, uint64_t, data_size,
uint64_t, zvio->zvio_offset, int, ret, scsi_task_t *, task);
@@ -739,7 +725,6 @@
struct iovec *iov, *tiov, iov1[8];
uint32_t len, resid;
int ret, i, iovcnt, flags;
- hrtime_t xfer_start;
boolean_t is_read;
ASSERT(cmd == SBD_CMD_SCSI_READ || cmd == SBD_CMD_SCSI_WRITE);
@@ -777,9 +762,6 @@
uio.uio_resid = (uint64_t)len;
uio.uio_llimit = RLIM64_INFINITY;
- /* start the accounting clock */
- stmf_lu_xfer_start(task);
- xfer_start = gethrtime();
if (is_read == B_TRUE) {
uio.uio_fmode = FREAD;
uio.uio_extflg = UIO_COPY_CACHED;
@@ -808,9 +790,6 @@
uint8_t *, NULL, uint64_t, len, uint64_t, laddr, int, ret,
scsi_task_t *, task);
}
- /* finalize accounting */
- stmf_lu_xfer_done(task, is_read, (uint64_t)len,
- (gethrtime() - xfer_start));
if (iov != &iov1[0])
kmem_free(iov, iovcnt * sizeof (*iov));
--- a/usr/src/uts/common/io/comstar/stmf/stmf.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/comstar/stmf/stmf.c Sat Jul 13 21:34:47 2013 +0100
@@ -175,14 +175,6 @@
scsi_devid_desc_t *rport_devid);
static void stmf_irport_deregister(stmf_i_remote_port_t *irport);
-static void stmf_teardown_itl_kstats(stmf_i_itl_kstat_t *ks);
-static void stmf_delete_itl_kstat_by_lport(char *);
-static void stmf_delete_itl_kstat_by_guid(char *);
-static int stmf_itl_kstat_compare(const void*, const void*);
-static stmf_i_itl_kstat_t *stmf_itl_kstat_lookup(char *kstat_nm);
-static stmf_i_itl_kstat_t *stmf_itl_kstat_create(stmf_itl_data_t *itl,
- char *nm, scsi_devid_desc_t *lport, scsi_devid_desc_t *lun);
-
extern struct mod_ops mod_driverops;
/* =====[ Tunables ]===== */
@@ -324,9 +316,6 @@
id_space_create("lport-instances", 0, MAX_ILPORT);
stmf_state.stmf_irport_inst_space =
id_space_create("rport-instances", 0, MAX_IRPORT);
- avl_create(&stmf_state.stmf_itl_kstat_list,
- stmf_itl_kstat_compare, sizeof (stmf_i_itl_kstat_t),
- offsetof(stmf_i_itl_kstat_t, iitl_kstat_ln));
stmf_view_init();
stmf_svc_init();
stmf_dlun_init();
@@ -338,7 +327,6 @@
{
int ret;
stmf_i_remote_port_t *irport;
- stmf_i_itl_kstat_t *ks_itl;
void *avl_dest_cookie = NULL;
if (stmf_state.stmf_service_running)
@@ -379,14 +367,6 @@
id_space_destroy(stmf_state.stmf_ilport_inst_space);
id_space_destroy(stmf_state.stmf_irport_inst_space);
- avl_dest_cookie = NULL;
- while ((ks_itl = avl_destroy_nodes(&stmf_state.stmf_itl_kstat_list,
- &avl_dest_cookie)) != NULL) {
- stmf_teardown_itl_kstats(ks_itl);
- kmem_free(ks_itl, sizeof (ks_itl));
- }
- avl_destroy(&stmf_state.stmf_itl_kstat_list);
-
kmem_free(stmf_trace_buf, stmf_trace_buf_size);
mutex_destroy(&trace_buf_lock);
mutex_destroy(&stmf_state.stmf_lock);
@@ -1604,6 +1584,7 @@
return (0);
}
+
/*
* handles registration message from pppt for a logical unit
*/
@@ -3209,7 +3190,6 @@
kstat_delete(ilu->ilu_kstat_io);
mutex_destroy(&ilu->ilu_kstat_lock);
}
- stmf_delete_itl_kstat_by_guid(ilu->ilu_ascii_hex_guid);
cv_destroy(&ilu->ilu_offline_pending_cv);
mutex_exit(&stmf_state.stmf_lock);
return (STMF_SUCCESS);
@@ -3388,7 +3368,6 @@
kstat_delete(ilport->ilport_kstat_io);
mutex_destroy(&ilport->ilport_kstat_lock);
}
- stmf_delete_itl_kstat_by_lport(ilport->ilport_kstat_tgt_name);
mutex_exit(&stmf_state.stmf_lock);
return (STMF_SUCCESS);
}
@@ -3717,320 +3696,6 @@
return (NULL);
}
-#define MAX_ALIAS 128
-
-static int
-stmf_itl_kstat_compare(const void *itl_kstat_1, const void *itl_kstat_2)
-{
- const stmf_i_itl_kstat_t *kstat_nm1 = itl_kstat_1;
- const stmf_i_itl_kstat_t *kstat_nm2 = itl_kstat_2;
- int ret;
-
- ret = strcmp(kstat_nm1->iitl_kstat_nm, kstat_nm2->iitl_kstat_nm);
- if (ret < 0) {
- return (-1);
- } else if (ret > 0) {
- return (1);
- }
- return (0);
-}
-
-static stmf_i_itl_kstat_t *
-stmf_itl_kstat_lookup(char *kstat_nm)
-{
- stmf_i_itl_kstat_t tmp;
- stmf_i_itl_kstat_t *itl_kstat;
-
- ASSERT(mutex_owned(&stmf_state.stmf_lock));
- (void) strcpy(tmp.iitl_kstat_nm, kstat_nm);
- itl_kstat = avl_find(&stmf_state.stmf_itl_kstat_list, &tmp, NULL);
- return (itl_kstat);
-}
-
-static void
-stmf_delete_itl_kstat_by_lport(char *tgt)
-{
- stmf_i_itl_kstat_t *ks_itl, *next;
-
- ASSERT(mutex_owned(&stmf_state.stmf_lock));
- ks_itl = avl_first(&stmf_state.stmf_itl_kstat_list);
- for (; ks_itl != NULL; ks_itl = next) {
- next = AVL_NEXT(&stmf_state.stmf_itl_kstat_list, ks_itl);
- if (strcmp(ks_itl->iitl_kstat_lport, tgt) == 0) {
- stmf_teardown_itl_kstats(ks_itl);
- avl_remove(&stmf_state.stmf_itl_kstat_list, ks_itl);
- kmem_free(ks_itl, sizeof (stmf_i_itl_kstat_t));
- }
- }
-}
-
-static void
-stmf_delete_itl_kstat_by_guid(char *guid)
-{
- stmf_i_itl_kstat_t *ks_itl, *next;
-
- ASSERT(mutex_owned(&stmf_state.stmf_lock));
- ks_itl = avl_first(&stmf_state.stmf_itl_kstat_list);
- for (; ks_itl != NULL; ks_itl = next) {
- next = AVL_NEXT(&stmf_state.stmf_itl_kstat_list, ks_itl);
- if (strcmp(ks_itl->iitl_kstat_guid, guid) == 0) {
- stmf_teardown_itl_kstats(ks_itl);
- avl_remove(&stmf_state.stmf_itl_kstat_list, ks_itl);
- kmem_free(ks_itl, sizeof (stmf_i_itl_kstat_t));
- }
- }
-}
-
-static stmf_i_itl_kstat_t *
-stmf_itl_kstat_create(stmf_itl_data_t *itl, char *nm,
- scsi_devid_desc_t *lport, scsi_devid_desc_t *lun)
-{
- stmf_i_itl_kstat_t *ks_itl;
- int i, len;
-
- ASSERT(mutex_owned(&stmf_state.stmf_lock));
- if ((ks_itl = stmf_itl_kstat_lookup(nm)) != NULL)
- return (ks_itl);
-
- len = sizeof (stmf_i_itl_kstat_t);
- ks_itl = kmem_zalloc(len, KM_NOSLEEP);
- if (ks_itl == NULL)
- return (NULL);
-
- (void) strcpy(ks_itl->iitl_kstat_nm, nm);
- bcopy(lport->ident, ks_itl->iitl_kstat_lport, lport->ident_length);
- ks_itl->iitl_kstat_lport[lport->ident_length] = '\0';
- for (i = 0; i < STMF_GUID_INPUT / 2; i++) {
- (void) sprintf(&ks_itl->iitl_kstat_guid[i * 2], "%02x",
- lun->ident[i]);
- }
- ks_itl->iitl_kstat_strbuf = itl->itl_kstat_strbuf;
- ks_itl->iitl_kstat_strbuflen = itl->itl_kstat_strbuflen;
- ks_itl->iitl_kstat_info = itl->itl_kstat_info;
- ks_itl->iitl_kstat_taskq = itl->itl_kstat_taskq;
- ks_itl->iitl_kstat_lu_xfer = itl->itl_kstat_lu_xfer;
- ks_itl->iitl_kstat_lport_xfer = itl->itl_kstat_lport_xfer;
- avl_add(&stmf_state.stmf_itl_kstat_list, ks_itl);
-
- return (ks_itl);
-}
-
-stmf_status_t
-stmf_setup_itl_kstats(stmf_itl_data_t *itl)
-{
- char ks_itl_id[32];
- char ks_nm[KSTAT_STRLEN];
- char ks_itl_nm[KSTAT_STRLEN];
- stmf_kstat_itl_info_t *ks_itl;
- stmf_scsi_session_t *ss;
- stmf_i_scsi_session_t *iss;
- stmf_i_local_port_t *ilport;
- char *strbuf;
- int id, len, i;
- char *rport_alias;
- char *lport_alias;
- char *lu_alias;
- stmf_i_itl_kstat_t *tmp_kstat;
-
- /*
- * Allocate enough memory in the ITL to hold the relevant
- * identifiers.
- * rport and lport identifiers come from the stmf_scsi_session_t.
- * ident might not be null terminated.
- */
- ss = itl->itl_session->iss_ss;
- iss = ss->ss_stmf_private;
- ilport = ss->ss_lport->lport_stmf_private;
- (void) snprintf(ks_itl_id, 32, "%d.%d.%d",
- iss->iss_irport->irport_instance, ilport->ilport_instance,
- itl->itl_lun);
-
- (void) snprintf(ks_itl_nm, KSTAT_STRLEN, "itl_%s", ks_itl_id);
- /*
- * let's verify this itl_kstat already exist
- */
- if ((tmp_kstat = stmf_itl_kstat_lookup(ks_itl_nm)) != NULL) {
- itl->itl_kstat_strbuf = tmp_kstat->iitl_kstat_strbuf;
- itl->itl_kstat_strbuflen = tmp_kstat->iitl_kstat_strbuflen;
- itl->itl_kstat_info = tmp_kstat->iitl_kstat_info;
- itl->itl_kstat_taskq = tmp_kstat->iitl_kstat_taskq;
- itl->itl_kstat_lu_xfer = tmp_kstat->iitl_kstat_lu_xfer;
- itl->itl_kstat_lport_xfer = tmp_kstat->iitl_kstat_lport_xfer;
- return (STMF_SUCCESS);
- }
-
- /* New itl_kstat */
- rport_alias = (ss->ss_rport_alias == NULL) ?
- "" : ss->ss_rport_alias;
- lport_alias = (ss->ss_lport->lport_alias == NULL) ?
- "" : ss->ss_lport->lport_alias;
- lu_alias = (itl->itl_ilu->ilu_lu->lu_alias == NULL) ?
- "" : itl->itl_ilu->ilu_lu->lu_alias;
-
- itl->itl_kstat_strbuflen = (ss->ss_rport_id->ident_length + 1) +
- (strnlen(rport_alias, MAX_ALIAS) + 1) +
- (ss->ss_lport->lport_id->ident_length + 1) +
- (strnlen(lport_alias, MAX_ALIAS) + 1) +
- (STMF_GUID_INPUT + 1) +
- (strnlen(lu_alias, MAX_ALIAS) + 1) +
- MAX_PROTO_STR_LEN;
- itl->itl_kstat_strbuf = kmem_zalloc(itl->itl_kstat_strbuflen,
- KM_NOSLEEP);
- if (itl->itl_kstat_strbuf == NULL) {
- return (STMF_ALLOC_FAILURE);
- }
-
- ks_itl = (stmf_kstat_itl_info_t *)kmem_zalloc(sizeof (*ks_itl),
- KM_NOSLEEP);
- if (ks_itl == NULL) {
- kmem_free(itl->itl_kstat_strbuf, itl->itl_kstat_strbuflen);
- return (STMF_ALLOC_FAILURE);
- }
-
- if ((itl->itl_kstat_info = kstat_create(STMF_MODULE_NAME,
- 0, ks_itl_nm, "misc", KSTAT_TYPE_NAMED,
- sizeof (stmf_kstat_itl_info_t) / sizeof (kstat_named_t),
- KSTAT_FLAG_VIRTUAL)) == NULL) {
- goto itl_kstat_cleanup;
- }
-
- itl->itl_kstat_info->ks_data_size += itl->itl_kstat_strbuflen;
- itl->itl_kstat_info->ks_data = ks_itl;
-
- kstat_named_init(&ks_itl->i_rport_name, "rport-name",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_rport_alias, "rport-alias",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_lport_name, "lport-name",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_lport_alias, "lport-alias",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_protocol, "protocol",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_lu_guid, "lu-guid",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_lu_alias, "lu-alias",
- KSTAT_DATA_STRING);
- kstat_named_init(&ks_itl->i_lu_number, "lu-number",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_task_waitq_elapsed, "task-waitq-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_task_read_elapsed, "task-read-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_task_write_elapsed, "task-write-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_lu_read_elapsed, "lu-read-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_lu_write_elapsed, "lu-write-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_lport_read_elapsed, "lport-read-elapsed",
- KSTAT_DATA_UINT64);
- kstat_named_init(&ks_itl->i_lport_write_elapsed, "lport-write-elapsed",
- KSTAT_DATA_UINT64);
-
- strbuf = itl->itl_kstat_strbuf;
-
- /* Rport */
- len = ss->ss_rport_id->ident_length;
- bcopy(ss->ss_rport_id->ident, strbuf, len);
- strbuf += len;
- *strbuf = '\0';
- kstat_named_setstr(&ks_itl->i_rport_name, strbuf - len);
- strbuf++;
-
- len = strnlen(rport_alias, MAX_ALIAS);
- (void) strncpy(strbuf, rport_alias, len + 1);
- kstat_named_setstr(&ks_itl->i_rport_alias, strbuf);
- strbuf += len + 1;
-
- /* Lport */
- len = ss->ss_lport->lport_id->ident_length;
- bcopy(ss->ss_lport->lport_id->ident, strbuf, len);
- strbuf += len;
- *strbuf = '\0';
- kstat_named_setstr(&ks_itl->i_lport_name, strbuf - len);
- strbuf++;
-
- len = strnlen(lport_alias, MAX_ALIAS);
- (void) strncpy(strbuf, lport_alias, len + 1);
- kstat_named_setstr(&ks_itl->i_lport_alias, strbuf);
- strbuf += len + 1;
-
- id = (ss->ss_lport->lport_id->protocol_id > PROTOCOL_ANY) ?
- PROTOCOL_ANY : ss->ss_lport->lport_id->protocol_id;
- kstat_named_setstr(&ks_itl->i_protocol, protocol_ident[id]);
-
- /* LU */
- for (i = 0; i < STMF_GUID_INPUT / 2; i++) {
- (void) sprintf(&strbuf[i * 2], "%02x",
- itl->itl_ilu->ilu_lu->lu_id->ident[i]);
- }
- kstat_named_setstr(&ks_itl->i_lu_guid, strbuf);
- strbuf += STMF_GUID_INPUT + 1;
-
- len = strnlen(lu_alias, MAX_ALIAS);
- (void) strncpy(strbuf, lu_alias, len + 1);
- kstat_named_setstr(&ks_itl->i_lu_alias, strbuf);
- strbuf += len + 1;
-
- ks_itl->i_lu_number.value.ui64 = itl->itl_lun;
-
- /* Now create the I/O kstats */
- (void) snprintf(ks_nm, KSTAT_STRLEN, "itl_tasks_%s", ks_itl_id);
- if ((itl->itl_kstat_taskq = kstat_create(STMF_MODULE_NAME, 0,
- ks_nm, "io", KSTAT_TYPE_IO, 1, 0)) == NULL) {
- goto itl_kstat_cleanup;
- }
-
- (void) snprintf(ks_nm, KSTAT_STRLEN, "itl_lu_%s", ks_itl_id);
- if ((itl->itl_kstat_lu_xfer = kstat_create(STMF_MODULE_NAME, 0,
- ks_nm, "io", KSTAT_TYPE_IO, 1, 0)) == NULL) {
- goto itl_kstat_cleanup;
- }
-
- (void) snprintf(ks_nm, KSTAT_STRLEN, "itl_lport_%s", ks_itl_id);
- if ((itl->itl_kstat_lport_xfer = kstat_create(STMF_MODULE_NAME, 0,
- ks_nm, "io", KSTAT_TYPE_IO, 1, 0)) == NULL) {
- goto itl_kstat_cleanup;
- }
-
- /* Install all the kstats */
- kstat_install(itl->itl_kstat_info);
- kstat_install(itl->itl_kstat_taskq);
- kstat_install(itl->itl_kstat_lu_xfer);
- kstat_install(itl->itl_kstat_lport_xfer);
-
- /* Add new itl_kstat to stmf_itl_kstat_list */
- if (stmf_itl_kstat_create(itl, ks_itl_nm, ss->ss_lport->lport_id,
- itl->itl_ilu->ilu_lu->lu_id) != NULL)
- return (STMF_SUCCESS);
-
-itl_kstat_cleanup:
- if (itl->itl_kstat_taskq)
- kstat_delete(itl->itl_kstat_taskq);
- if (itl->itl_kstat_lu_xfer)
- kstat_delete(itl->itl_kstat_lu_xfer);
- if (itl->itl_kstat_lport_xfer)
- kstat_delete(itl->itl_kstat_lport_xfer);
- if (itl->itl_kstat_info)
- kstat_delete(itl->itl_kstat_info);
- kmem_free(ks_itl, sizeof (*ks_itl));
- kmem_free(itl->itl_kstat_strbuf, itl->itl_kstat_strbuflen);
- cmn_err(CE_WARN, "STMF: kstat_create itl failed");
- return (STMF_ALLOC_FAILURE);
-}
-
-static void
-stmf_teardown_itl_kstats(stmf_i_itl_kstat_t *ks)
-{
- kstat_delete(ks->iitl_kstat_lport_xfer);
- kstat_delete(ks->iitl_kstat_lu_xfer);
- kstat_delete(ks->iitl_kstat_taskq);
- kmem_free(ks->iitl_kstat_info->ks_data, sizeof (stmf_kstat_itl_info_t));
- kstat_delete(ks->iitl_kstat_info);
- kmem_free(ks->iitl_kstat_strbuf, ks->iitl_kstat_strbuflen);
-}
-
void
stmf_release_itl_handle(stmf_lu_t *lu, stmf_itl_data_t *itl)
{
@@ -4074,9 +3739,6 @@
iss = (stmf_i_scsi_session_t *)ss->ss_stmf_private;
}
- /*
- * Acquire stmf_lock for stmf_itl_kstat_lookup.
- */
mutex_enter(&stmf_state.stmf_lock);
rw_enter(iss->iss_lockp, RW_WRITER);
n = ((uint16_t)lun[1] | (((uint16_t)(lun[0] & 0x3F)) << 8));
@@ -4106,13 +3768,6 @@
itl->itl_lun = n;
itl->itl_handle = itl_handle;
- if (stmf_setup_itl_kstats(itl) != STMF_SUCCESS) {
- kmem_free(itl, sizeof (*itl));
- rw_exit(iss->iss_lockp);
- mutex_exit(&stmf_state.stmf_lock);
- return (STMF_ALLOC_FAILURE);
- }
-
mutex_enter(&ilu->ilu_task_lock);
itl->itl_next = ilu->ilu_itl_list;
ilu->ilu_itl_list = itl;
@@ -4142,10 +3797,6 @@
if (atomic_add_32_nv(&itl->itl_counter, -1))
return;
- drv_usecwait(10);
- if (itl->itl_counter)
- return;
-
stmf_release_itl_handle(lu, itl);
}
@@ -4216,66 +3867,6 @@
}
stmf_status_t
-stmf_deregister_itl_handle(stmf_lu_t *lu, uint8_t *lun,
- stmf_scsi_session_t *ss, uint64_t session_id, void *itl_handle)
-{
- stmf_i_scsi_session_t *iss;
- stmf_itl_data_t *itl;
- stmf_lun_map_ent_t *ent;
- stmf_lun_map_t *lm;
- int i;
- uint16_t n;
-
- if (ss == NULL) {
- if (session_id == STMF_SESSION_ID_NONE)
- return (STMF_INVALID_ARG);
- iss = stmf_session_id_to_issptr(session_id, 1);
- if (iss == NULL)
- return (STMF_NOT_FOUND);
- } else {
- iss = (stmf_i_scsi_session_t *)ss->ss_stmf_private;
- rw_enter(iss->iss_lockp, RW_WRITER);
- }
- lm = iss->iss_sm;
- if (lm == NULL) {
- rw_exit(iss->iss_lockp);
- return (STMF_NOT_FOUND);
- }
-
- if (lun) {
- n = ((uint16_t)lun[1] | (((uint16_t)(lun[0] & 0x3F)) << 8));
- ent = (stmf_lun_map_ent_t *)
- stmf_get_ent_from_map(iss->iss_sm, n);
- } else {
- if (itl_handle == NULL) {
- rw_exit(iss->iss_lockp);
- return (STMF_INVALID_ARG);
- }
- ent = NULL;
- for (i = 0; i < lm->lm_nentries; i++) {
- if (lm->lm_plus[i] == NULL)
- continue;
- ent = (stmf_lun_map_ent_t *)lm->lm_plus[i];
- if (ent->ent_itl_datap &&
- (ent->ent_itl_datap->itl_handle == itl_handle)) {
- break;
- }
- }
- }
- if ((ent == NULL) || (ent->ent_lu != lu) ||
- (ent->ent_itl_datap == NULL)) {
- rw_exit(iss->iss_lockp);
- return (STMF_NOT_FOUND);
- }
- itl = ent->ent_itl_datap;
- ent->ent_itl_datap = NULL;
- rw_exit(iss->iss_lockp);
- stmf_do_itl_dereg(lu, itl, STMF_ITL_REASON_DEREG_REQUEST);
-
- return (STMF_SUCCESS);
-}
-
-stmf_status_t
stmf_get_itl_handle(stmf_lu_t *lu, uint8_t *lun, stmf_scsi_session_t *ss,
uint64_t session_id, void **itl_handle_retp)
{
@@ -6109,6 +5700,7 @@
struct ether_addr mac;
uint8_t *e = (uint8_t *)&mac;
int hid = (int)host_id;
+ uint16_t gen_number;
if (company_id == COMPANY_ID_NONE)
company_id = COMPANY_ID_SUN;
@@ -6118,7 +5710,7 @@
p = (uint8_t *)lu_id;
- atomic_add_16(&stmf_lu_id_gen_number, 1);
+ gen_number = atomic_add_16_nv(&stmf_lu_id_gen_number, 1);
p[0] = 0xf1; p[1] = 3; p[2] = 0; p[3] = 0x10;
p[4] = ((company_id >> 20) & 0xf) | 0x60;
@@ -6139,8 +5731,8 @@
uniqtime32(×tamp32);
*t = BE_32(*t);
bcopy(t, p+14, 4);
- p[18] = (stmf_lu_id_gen_number >> 8) & 0xff;
- p[19] = stmf_lu_id_gen_number & 0xff;
+ p[18] = (gen_number >> 8) & 0xff;
+ p[19] = gen_number & 0xff;
return (STMF_SUCCESS);
}
@@ -7562,11 +7154,12 @@
if (itl == NULL || task->task_lu == dlun0)
return;
ilu = (stmf_i_lu_t *)task->task_lu->lu_stmf_private;
- mutex_enter(ilu->ilu_kstat_io->ks_lock);
itask->itask_start_timestamp = gethrtime();
- kstat_waitq_enter(KSTAT_IO_PTR(itl->itl_kstat_taskq));
- stmf_update_kstat_lu_q(itask->itask_task, kstat_waitq_enter);
- mutex_exit(ilu->ilu_kstat_io->ks_lock);
+ if (ilu->ilu_kstat_io != NULL) {
+ mutex_enter(ilu->ilu_kstat_io->ks_lock);
+ stmf_update_kstat_lu_q(itask->itask_task, kstat_waitq_enter);
+ mutex_exit(ilu->ilu_kstat_io->ks_lock);
+ }
stmf_update_kstat_lport_q(itask->itask_task, kstat_waitq_enter);
}
@@ -7581,10 +7174,11 @@
if (itl == NULL || task->task_lu == dlun0)
return;
ilu = (stmf_i_lu_t *)task->task_lu->lu_stmf_private;
- mutex_enter(ilu->ilu_kstat_io->ks_lock);
- kstat_waitq_to_runq(KSTAT_IO_PTR(itl->itl_kstat_taskq));
- stmf_update_kstat_lu_q(itask->itask_task, kstat_waitq_to_runq);
- mutex_exit(ilu->ilu_kstat_io->ks_lock);
+ if (ilu->ilu_kstat_io != NULL) {
+ mutex_enter(ilu->ilu_kstat_io->ks_lock);
+ stmf_update_kstat_lu_q(itask->itask_task, kstat_waitq_to_runq);
+ mutex_exit(ilu->ilu_kstat_io->ks_lock);
+ }
stmf_update_kstat_lport_q(itask->itask_task, kstat_waitq_to_runq);
}
@@ -7594,108 +7188,30 @@
{
stmf_itl_data_t *itl = itask->itask_itl_datap;
scsi_task_t *task = itask->itask_task;
- kstat_io_t *kip;
- hrtime_t elapsed_time;
- stmf_kstat_itl_info_t *itli;
stmf_i_lu_t *ilu;
+ itask->itask_done_timestamp = gethrtime();
+
if (itl == NULL || task->task_lu == dlun0)
return;
ilu = (stmf_i_lu_t *)task->task_lu->lu_stmf_private;
+ if (ilu->ilu_kstat_io == NULL)
+ return;
+
mutex_enter(ilu->ilu_kstat_io->ks_lock);
- itli = (stmf_kstat_itl_info_t *)KSTAT_NAMED_PTR(itl->itl_kstat_info);
- kip = KSTAT_IO_PTR(itl->itl_kstat_taskq);
-
- itli->i_task_waitq_elapsed.value.ui64 += itask->itask_waitq_time;
-
- itask->itask_done_timestamp = gethrtime();
- elapsed_time =
- itask->itask_done_timestamp - itask->itask_start_timestamp;
-
- if (task->task_flags & TF_READ_DATA) {
- kip->reads++;
- kip->nread += itask->itask_read_xfer;
- itli->i_task_read_elapsed.value.ui64 += elapsed_time;
- itli->i_lu_read_elapsed.value.ui64 +=
- itask->itask_lu_read_time;
- itli->i_lport_read_elapsed.value.ui64 +=
- itask->itask_lport_read_time;
- }
-
- if (task->task_flags & TF_WRITE_DATA) {
- kip->writes++;
- kip->nwritten += itask->itask_write_xfer;
- itli->i_task_write_elapsed.value.ui64 += elapsed_time;
- itli->i_lu_write_elapsed.value.ui64 +=
- itask->itask_lu_write_time;
- itli->i_lport_write_elapsed.value.ui64 +=
- itask->itask_lport_write_time;
- }
if (itask->itask_flags & ITASK_KSTAT_IN_RUNQ) {
- kstat_runq_exit(kip);
stmf_update_kstat_lu_q(task, kstat_runq_exit);
mutex_exit(ilu->ilu_kstat_io->ks_lock);
stmf_update_kstat_lport_q(task, kstat_runq_exit);
} else {
- kstat_waitq_exit(kip);
stmf_update_kstat_lu_q(task, kstat_waitq_exit);
mutex_exit(ilu->ilu_kstat_io->ks_lock);
stmf_update_kstat_lport_q(task, kstat_waitq_exit);
}
}
-void
-stmf_lu_xfer_start(scsi_task_t *task)
-{
- stmf_i_scsi_task_t *itask = task->task_stmf_private;
- stmf_itl_data_t *itl = itask->itask_itl_datap;
- stmf_i_lu_t *ilu = (stmf_i_lu_t *)task->task_lu->lu_stmf_private;
- kstat_io_t *kip;
-
- if (itl == NULL || task->task_lu == dlun0)
- return;
-
- kip = KSTAT_IO_PTR(itl->itl_kstat_lu_xfer);
- mutex_enter(ilu->ilu_kstat_io->ks_lock);
- kstat_runq_enter(kip);
- mutex_exit(ilu->ilu_kstat_io->ks_lock);
-}
-
-void
-stmf_lu_xfer_done(scsi_task_t *task, boolean_t read, uint64_t xfer_bytes,
- hrtime_t elapsed_time)
-{
- stmf_i_scsi_task_t *itask = task->task_stmf_private;
- stmf_itl_data_t *itl = itask->itask_itl_datap;
- stmf_i_lu_t *ilu = (stmf_i_lu_t *)task->task_lu->lu_stmf_private;
- kstat_io_t *kip;
-
- if (itl == NULL || task->task_lu == dlun0)
- return;
-
- if (read) {
- atomic_add_64((uint64_t *)&itask->itask_lu_read_time,
- elapsed_time);
- } else {
- atomic_add_64((uint64_t *)&itask->itask_lu_write_time,
- elapsed_time);
- }
-
- kip = KSTAT_IO_PTR(itl->itl_kstat_lu_xfer);
- mutex_enter(ilu->ilu_kstat_io->ks_lock);
- kstat_runq_exit(kip);
- if (read) {
- kip->reads++;
- kip->nread += xfer_bytes;
- } else {
- kip->writes++;
- kip->nwritten += xfer_bytes;
- }
- mutex_exit(ilu->ilu_kstat_io->ks_lock);
-}
-
static void
stmf_lport_xfer_start(stmf_i_scsi_task_t *itask, stmf_data_buf_t *dbuf)
{
@@ -7714,17 +7230,12 @@
stmf_lport_xfer_done(stmf_i_scsi_task_t *itask, stmf_data_buf_t *dbuf)
{
stmf_itl_data_t *itl = itask->itask_itl_datap;
- scsi_task_t *task;
- stmf_i_local_port_t *ilp;
- kstat_io_t *kip;
hrtime_t elapsed_time;
uint64_t xfer_size;
if (itl == NULL)
return;
- task = (scsi_task_t *)itask->itask_task;
- ilp = (stmf_i_local_port_t *)task->task_lport->lport_stmf_private;
xfer_size = (dbuf->db_xfer_status == STMF_SUCCESS) ?
dbuf->db_data_size : 0;
@@ -7744,17 +7255,6 @@
DTRACE_PROBE3(scsi__xfer__end, scsi_task_t *, itask->itask_task,
stmf_data_buf_t *, dbuf, hrtime_t, elapsed_time);
- kip = KSTAT_IO_PTR(itl->itl_kstat_lport_xfer);
- mutex_enter(ilp->ilport_kstat_io->ks_lock);
- if (dbuf->db_flags & DB_DIRECTION_TO_RPORT) {
- kip->reads++;
- kip->nread += xfer_size;
- } else {
- kip->writes++;
- kip->nwritten += xfer_size;
- }
- mutex_exit(ilp->ilport_kstat_io->ks_lock);
-
dbuf->db_xfer_start_timestamp = 0;
}
@@ -7864,6 +7364,7 @@
req->svc_cmd);
}
+ kmem_free(req, req->svc_req_alloc_size);
mutex_enter(&stmf_state.stmf_lock);
}
--- a/usr/src/uts/common/io/comstar/stmf/stmf_impl.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/comstar/stmf/stmf_impl.h Sat Jul 13 21:34:47 2013 +0100
@@ -166,19 +166,6 @@
avl_node_t irport_ln;
} stmf_i_remote_port_t;
-typedef struct stmf_i_itl_kstat {
- char iitl_kstat_nm[KSTAT_STRLEN];
- char iitl_kstat_lport[STMF_TGT_NAME_LEN];
- char iitl_kstat_guid[STMF_GUID_INPUT + 1];
- char *iitl_kstat_strbuf;
- int iitl_kstat_strbuflen;
- kstat_t *iitl_kstat_info;
- kstat_t *iitl_kstat_taskq;
- kstat_t *iitl_kstat_lu_xfer;
- kstat_t *iitl_kstat_lport_xfer;
- avl_node_t iitl_kstat_ln;
-} stmf_i_itl_kstat_t;
-
/*
* ilport flags
*/
@@ -327,12 +314,6 @@
uint8_t itl_flags;
uint8_t itl_hdlrm_reason;
uint16_t itl_lun;
- char *itl_kstat_strbuf;
- int itl_kstat_strbuflen;
- kstat_t *itl_kstat_info;
- kstat_t *itl_kstat_taskq;
- kstat_t *itl_kstat_lu_xfer;
- kstat_t *itl_kstat_lport_xfer;
void *itl_handle;
struct stmf_i_lu *itl_ilu;
struct stmf_i_scsi_session *itl_session;
--- a/usr/src/uts/common/io/comstar/stmf/stmf_state.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/comstar/stmf/stmf_state.h Sat Jul 13 21:34:47 2013 +0100
@@ -23,6 +23,7 @@
*/
/*
* Copyright 2011, Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#ifndef _STMF_STATE_H
#define _STMF_STATE_H
@@ -42,7 +43,6 @@
id_space_t *stmf_ilport_inst_space;
avl_tree_t stmf_irportlist;
id_space_t *stmf_irport_inst_space;
- avl_tree_t stmf_itl_kstat_list;
int stmf_nlps;
int stmf_npps;
int stmf_nlus;
--- a/usr/src/uts/common/io/idm/idm_conn_sm.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/idm/idm_conn_sm.c Sat Jul 13 21:34:47 2013 +0100
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/cpuvar.h>
@@ -609,6 +610,7 @@
* connections are shut down by a CE_LOGOUT_SESSION_SUCCESS
* event sent from the session to the IDM layer.
*/
+ (void) untimeout(ic->ic_state_timeout);
if (IDM_CONN_ISTGT(ic)) {
ic->ic_transport_ops->it_tgt_conn_disconnect(ic);
} else {
--- a/usr/src/uts/common/io/idm/idm_so.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/idm/idm_so.c Sat Jul 13 21:34:47 2013 +0100
@@ -719,9 +719,9 @@
/* Set connect options */
(void) ksocket_setsockopt(ks, SOL_SOCKET, SO_RCVBUF,
- (char *)&idm_so_rcvbuf, sizeof (int), CRED());
+ (char *)&idm_so_rcvbuf, sizeof (idm_so_rcvbuf), CRED());
(void) ksocket_setsockopt(ks, SOL_SOCKET, SO_SNDBUF,
- (char *)&idm_so_sndbuf, sizeof (int), CRED());
+ (char *)&idm_so_sndbuf, sizeof (idm_so_sndbuf), CRED());
(void) ksocket_setsockopt(ks, IPPROTO_TCP, TCP_NODELAY,
(char *)&on, sizeof (on), CRED());
}
@@ -1249,10 +1249,15 @@
(struct sockaddr *)&t_addr, &t_addrlen,
&new_so, CRED())) != 0) {
mutex_enter(&svc->is_mutex);
- if (rc == ECONNABORTED)
- continue;
- /* Connection problem */
- break;
+ if (rc != ECONNABORTED && rc != EINTR) {
+ IDM_SVC_LOG(CE_NOTE, "idm_so_svc_port_watcher:"
+ " ksocket_accept failed %d", rc);
+ }
+ /*
+ * Unclean shutdown of this thread is not handled
+ * wait for !is_thread_running.
+ */
+ continue;
}
/*
* Turn off SO_MAC_EXEMPT so future sobinds succeed
--- a/usr/src/uts/common/io/sata/adapters/ahci/ahci.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/io/sata/adapters/ahci/ahci.c Sat Jul 13 21:34:47 2013 +0100
@@ -61,7 +61,6 @@
/*
* This is the string displayed by modinfo, etc.
- * Make sure you keep the version ID up to date!
*/
static char ahci_ident[] = "ahci driver";
@@ -582,7 +581,7 @@
}
mutex_enter(&ahci_ctlp->ahcictl_mutex);
- ahci_ctlp->ahcictl_flags &= ~ AHCI_SUSPEND;
+ ahci_ctlp->ahcictl_flags &= ~AHCI_SUSPEND;
mutex_exit(&ahci_ctlp->ahcictl_mutex);
return (DDI_SUCCESS);
@@ -1464,7 +1463,7 @@
break;
case SATA_DTYPE_PMULT:
- ASSERT(AHCI_ADDR_IS_PORT(&addr)||AHCI_ADDR_IS_PMULT(&addr));
+ ASSERT(AHCI_ADDR_IS_PORT(&addr) || AHCI_ADDR_IS_PMULT(&addr));
sd->satadev_type = SATA_DTYPE_PMULT;
/* Update the number of pmports. */
@@ -1788,9 +1787,6 @@
*
* If SATA_OPMODE_POLLING flag is set, then we must poll the command
* without interrupt, otherwise we can still use the interrupt.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_do_sync_start(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -1802,6 +1798,8 @@
int instance = ddi_get_instance(ahci_ctlp->ahcictl_dip);
uint8_t port = addrp->aa_port;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp, "ahci_do_sync_start enter: "
"port %d:%d spkt 0x%p", port, addrp->aa_pmport, spkt);
@@ -1809,7 +1807,7 @@
ahci_portp->ahciport_flags |= AHCI_PORT_FLAG_POLLING;
if ((rval = ahci_deliver_satapkt(ahci_ctlp, ahci_portp,
addrp, spkt)) == AHCI_FAILURE) {
- ahci_portp->ahciport_flags &= ~ AHCI_PORT_FLAG_POLLING;
+ ahci_portp->ahciport_flags &= ~AHCI_PORT_FLAG_POLLING;
return (rval);
}
@@ -1883,9 +1881,6 @@
* algorithm.
* 1. REQUEST SENSE or READ LOG EXT command during error recovery process
* 2. READ/WRITE PORTMULT command
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_claim_free_slot(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -1895,6 +1890,8 @@
uint32_t free_slots;
int slot;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp, "ahci_claim_free_slot enter "
"ahciport_pending_tags = 0x%x "
"ahciport_pending_ncq_tags = 0x%x",
@@ -2041,8 +2038,6 @@
* Returns:
* slot number if we can obtain a slot successfully
* otherwise, return AHCI_FAILURE
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_deliver_satapkt(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -2064,6 +2059,8 @@
uint8_t *ptr2;
#endif
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
port = addrp->aa_port;
pmport = addrp->aa_pmport;
@@ -2607,7 +2604,6 @@
* during the reset operation.
*
* NOTE: ONLY called by ahci_tran_reset_dport
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_reset_device_reject_pkts(ahci_ctl_t *ahci_ctlp,
@@ -2620,6 +2616,8 @@
sata_device_t sdevice;
int ret;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_reset_device_reject_pkts on port: %d", port);
@@ -2706,7 +2704,6 @@
* during the reset operation.
*
* NOTE: ONLY called by ahci_tran_reset_dport
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_reset_pmdevice_reject_pkts(ahci_ctl_t *ahci_ctlp,
@@ -2717,6 +2714,8 @@
uint8_t pmport = addrp->aa_pmport;
sata_device_t sdevice;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY|AHCIDBG_PMULT, ahci_ctlp,
"ahci_reset_pmdevice_reject_pkts at port %d:%d", port, pmport);
@@ -2807,8 +2806,6 @@
/*
* Used to do port reset and reject all the pending packets on a port during
* the reset operation.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_reset_port_reject_pkts(ahci_ctl_t *ahci_ctlp,
@@ -2819,6 +2816,8 @@
uint32_t finished_tags = 0;
uint8_t port = addrp->aa_port;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_reset_port_reject_pkts at port: %d", port);
@@ -3262,8 +3261,6 @@
/*
* To be used to mark all the outstanding pkts with SATA_PKT_ABORTED
* when a device is unplugged or a port is deactivated.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static void
ahci_reject_all_abort_pkts(ahci_ctl_t *ahci_ctlp,
@@ -3272,6 +3269,8 @@
uint32_t slot_status = 0;
uint32_t abort_tags = 0;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY|AHCIDBG_INTR, ahci_ctlp,
"ahci_reject_all_abort_pkts at port: %d", port);
@@ -3425,7 +3424,7 @@
/* Adjust access and dma attributes for FMA */
accattr.devacc_attr_access = DDI_DEFAULT_ACC;
- buffer_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR;
+ buffer_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR;
rcvd_fis_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR;
cmd_list_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR;
cmd_table_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR;
@@ -3484,23 +3483,33 @@
}
/*
- * Check if all handles are correctly allocated. This function is only called
- * by ahci_attach(), so we do not need hold any mutex here.
+ * Check if all handles are correctly allocated.
*/
static int
ahci_check_all_handle(ahci_ctl_t *ahci_ctlp)
{
int port;
+
if (ahci_check_ctl_handle(ahci_ctlp) != DDI_SUCCESS) {
return (DDI_FAILURE);
}
+
for (port = 0; port < ahci_ctlp->ahcictl_num_ports; port++) {
+ ahci_port_t *ahci_portp;
+
if (!AHCI_PORT_IMPLEMENTED(ahci_ctlp, port))
continue;
+
+ ahci_portp = ahci_ctlp->ahcictl_ports[port];
+
+ mutex_enter(&ahci_portp->ahciport_mutex);
if (ahci_check_port_handle(ahci_ctlp, port) != DDI_SUCCESS) {
+ mutex_exit(&ahci_portp->ahciport_mutex);
return (DDI_FAILURE);
}
- }
+ mutex_exit(&ahci_portp->ahciport_mutex);
+ }
+
return (DDI_SUCCESS);
}
@@ -3522,14 +3531,15 @@
/*
* Check the DMA handles and the access handles of a controller port.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_check_port_handle(ahci_ctl_t *ahci_ctlp, int port)
{
ahci_port_t *ahci_portp = ahci_ctlp->ahcictl_ports[port];
int slot;
+
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
if ((ahci_check_dma_handle(ahci_portp->
ahciport_rcvd_fis_dma_handle) != DDI_FM_OK) ||
(ahci_check_dma_handle(ahci_portp->
@@ -3540,8 +3550,7 @@
ahciport_cmd_list_acc_handle) != DDI_FM_OK)) {
return (DDI_FAILURE);
}
- for (slot = 0; slot < ahci_ctlp->ahcictl_num_cmd_slots;
- slot ++) {
+ for (slot = 0; slot < ahci_ctlp->ahcictl_num_cmd_slots; slot++) {
if (ahci_check_slot_handle(ahci_portp, slot)
!= DDI_SUCCESS) {
return (DDI_FAILURE);
@@ -3552,12 +3561,12 @@
/*
* Check the DMA handles and the access handles of a cmd table slot.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_check_slot_handle(ahci_port_t *ahci_portp, int slot)
{
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
if ((ahci_check_acc_handle(ahci_portp->
ahciport_cmd_tables_acc_handle[slot]) != DDI_FM_OK) ||
(ahci_check_dma_handle(ahci_portp->
@@ -3658,9 +3667,6 @@
* PM_LEVEL_D0 and DDI_RESUME. The DDI_ATTACH case is different from
* other two cases; device signature probing are attempted only during
* DDI_ATTACH case.
- *
- * WARNING!!! Disable the whole controller's interrupts before calling and
- * the interrupts will be enabled upon successfully return.
*/
static int
ahci_initialize_controller(ahci_ctl_t *ahci_ctlp)
@@ -3672,6 +3678,11 @@
AHCIDBG(AHCIDBG_INIT|AHCIDBG_ENTRY, ahci_ctlp,
"ahci_initialize_controller enter", NULL);
+ /* Disable the whole controller interrupts */
+ mutex_enter(&ahci_ctlp->ahcictl_mutex);
+ ahci_disable_all_intrs(ahci_ctlp);
+ mutex_exit(&ahci_ctlp->ahcictl_mutex);
+
/* Initialize the implemented ports and structures */
for (port = 0; port < ahci_ctlp->ahcictl_num_ports; port++) {
if (!AHCI_PORT_IMPLEMENTED(ahci_ctlp, port)) {
@@ -3760,8 +3771,6 @@
* 2. Allocate ahci_pmult_info structure.
*
* NOTE: Must stop port before the function is called.
- * WARNING!!! ahciport_mutex should be acquired before the function is
- * called.
*/
static void
ahci_alloc_pmult(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -3769,6 +3778,8 @@
uint32_t port_cmd_status;
uint8_t port = ahci_portp->ahciport_port_num;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
port_cmd_status = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_PORT_PxCMD(ahci_ctlp, port));
@@ -3802,8 +3813,6 @@
* 2. Deallocate ahci_pmult_info structure.
*
* NOTE: Must stop port before the function is called.
- * WARNING!!! ahciport_mutex should be acquired before the function is
- * called.
*/
static void
ahci_dealloc_pmult(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -3811,6 +3820,8 @@
uint32_t port_cmd_status;
uint8_t port = ahci_portp->ahciport_port_num;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
port_cmd_status = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_PORT_PxCMD(ahci_ctlp, port));
@@ -3835,9 +3846,6 @@
/*
* Staggered Spin-up.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_staggered_spin_up(ahci_ctl_t *ahci_ctlp, uint8_t port)
@@ -3845,6 +3853,8 @@
uint32_t cap_status;
uint32_t port_cmd_status;
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_ports[port]->ahciport_mutex));
+
cap_status = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_GLOBAL_CAP(ahci_ctlp));
@@ -3869,15 +3879,13 @@
}
/*
- * The routine is to initialize a port. First put the port in NOTRunning
+ * The routine is to initialize a port. First put the port in NotRunning
* state, then enable port interrupt and clear Serror register. And under
* AHCI_ATTACH case, find device signature and then try to start the port.
*
* Called by
* 1. ahci_initialize_controller
* 2. ahci_intr_phyrdy_change (hotplug)
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_initialize_port(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -3888,7 +3896,7 @@
boolean_t resuming = B_TRUE; /* processing DDI_RESUME */
int ret;
- ASSERT(mutex_owned(&ahci_portp->ahciport_mutex));
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
/* AHCI_ADDR_PORT: We've no idea of the attached device here. */
ASSERT(AHCI_ADDR_IS_PORT(addrp));
@@ -4289,9 +4297,6 @@
/*
* Read/Write a register at port multiplier by SATA READ PORTMULT / SATA WRITE
* PORTMULT command. SYNC & POLLING mode is used.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_rdwr_pmult(ahci_ctl_t *ahci_ctlp, ahci_addr_t *addrp,
@@ -4314,7 +4319,7 @@
ahci_portp = ahci_ctlp->ahcictl_ports[port];
ASSERT(AHCI_ADDR_IS_PMPORT(addrp) || AHCI_ADDR_IS_PMULT(addrp));
- ASSERT(mutex_owned(&ahci_portp->ahciport_mutex));
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
/* Check the existence of the port multiplier */
if (ahci_portp->ahciport_device_type != SATA_DTYPE_PMULT)
@@ -4455,14 +4460,14 @@
* Update sata registers on port multiplier, including GSCR/PSCR registers.
* ahci_update_pmult_gscr()
* ahci_update_pmult_pscr()
- *
- * WARNING!!! ahciport_mutex should be acquired before those functions
- * get called.
*/
static int
ahci_update_pmult_gscr(ahci_ctl_t *ahci_ctlp, ahci_addr_t *addrp,
sata_pmult_gscr_t *sg)
{
+ ASSERT(MUTEX_HELD(
+ &ahci_ctlp->ahcictl_ports[addrp->aa_port]->ahciport_mutex));
+
READ_PMULT(addrp, SATA_PMULT_GSCR0, &sg->gscr0, err);
READ_PMULT(addrp, SATA_PMULT_GSCR1, &sg->gscr1, err);
READ_PMULT(addrp, SATA_PMULT_GSCR2, &sg->gscr2, err);
@@ -4479,6 +4484,8 @@
sata_device_t *sd)
{
ASSERT(AHCI_ADDR_IS_PMPORT(addrp));
+ ASSERT(MUTEX_HELD(
+ &ahci_ctlp->ahcictl_ports[addrp->aa_port]->ahciport_mutex));
READ_PMULT(addrp, SATA_PMULT_REG_SSTS, &sd->satadev_scr.sstatus, err);
READ_PMULT(addrp, SATA_PMULT_REG_SERR, &sd->satadev_scr.serror, err);
@@ -4497,9 +4504,6 @@
* Initialize a port multiplier, including
* 1. Enable FEATURES register at port multiplier. (SATA Chp.16)
* 2. Redefine MASK register. (SATA Chap 16.?)
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_initialize_pmult(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -4509,7 +4513,8 @@
uint32_t gscr64;
uint8_t port = addrp->aa_port;
- ASSERT(mutex_owned(&ahci_portp->ahciport_mutex));
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_INFO|AHCIDBG_PMULT, ahci_ctlp,
"[Initialize] Port-multiplier at port %d.", port);
@@ -4576,7 +4581,6 @@
* issue a COMRESET, then a software reset to get its signature.
*
* NOTE: This function should only be called in ahci_probe_pmport()
- * WARNING!!! ahciport_mutex should be acquired before the function.
*/
static int
ahci_initialize_pmport(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -4587,6 +4591,7 @@
uint8_t pmport = addrp->aa_pmport;
int ret = AHCI_FAILURE;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
ASSERT(AHCI_ADDR_IS_PMPORT(addrp));
AHCIDBG(AHCIDBG_INIT|AHCIDBG_ENTRY, ahci_ctlp,
@@ -4710,7 +4715,6 @@
* handle hotplug events on port multiplier ports.
*
* NOTE: Only called from ahci_tran_probe_port()
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_probe_pmult(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -4724,6 +4728,8 @@
uint8_t port = addrp->aa_port;
int npmport;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* The bits in GSCR32 refers to the pmport that has a hot-plug event. */
READ_PMULT(addrp, SATA_PMULT_GSCR32, &gscr32, err);
port_hotplug_tags = gscr32 & AHCI_PMPORT_MASK(ahci_portp);
@@ -4846,9 +4852,6 @@
/*
* Probe and initialize a port multiplier port.
* A port multiplier port could only be initilaizer here.
- *
- * WARNING!!! ahcictl_mutex should be acquired before the function
- * is called.
*/
static int
ahci_probe_pmport(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -4858,6 +4861,8 @@
uint8_t port = addrp->aa_port;
ahci_addr_t addr_pmult;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/*
* Check the parent - port multiplier first.
*/
@@ -4930,9 +4935,6 @@
* PxCMD.ST to clear PxCI. And before issuing the software reset,
* the port must be idle and PxTFD.STS.BSY and PxTFD.STS.DRQ must be
* cleared unless command list override (PxCMD.CLO) is supported.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_software_reset(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -4947,6 +4949,8 @@
uint8_t pmport = addrp->aa_pmport;
int rval = AHCI_FAILURE;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"port %d:%d device software resetting (FIS)", port, pmport);
@@ -5183,8 +5187,9 @@
* this FIS, it updates PxTFD.STS and PxTFD.ERR register fields, and updates
* the PxSIG register with the signature.
*
- * WARNING!!! ahciport_mutex should be acquired, and PxCMD.ST should be also
- * cleared before the function is called.
+ * NOTE: It is expected both PxCMD.ST and PxCMD.CR are cleared before the
+ * function is called. If not, it is assumed the interface is in hung
+ * condition.
*/
static int
ahci_port_reset(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -5200,6 +5205,8 @@
int loop_count;
int instance = ddi_get_instance(ahci_ctlp->ahcictl_dip);
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* Target is a port multiplier port? */
if (AHCI_ADDR_IS_PMPORT(addrp))
return (ahci_pmport_reset(ahci_ctlp, ahci_portp, addrp));
@@ -5684,8 +5691,7 @@
* physical communication has been established so that the signature could
* be retrieved by software reset.
*
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called. And the port interrupt is disabled.
+ * NOTE: The port interrupts should be disabled before the function is called.
*/
static void
ahci_find_dev_signature(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp,
@@ -5697,6 +5703,7 @@
uint8_t pmport = addrp->aa_pmport;
int rval;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
ASSERT(AHCI_ADDR_IS_VALID(addrp));
/*
@@ -5866,15 +5873,14 @@
* Software shall not set PxCMD.ST to '1' unless a functional device is
* present on the port(as determined by PxTFD.STS.BSY = '0',
* PxTFD.STS.DRQ = '0', and PxSSTS.DET = 3h).
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_start_port(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp, uint8_t port)
{
uint32_t port_cmd_status;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp, "ahci_start_port: %d enter", port);
if (ahci_portp->ahciport_port_state & SATA_PSTATE_FAILED) {
@@ -5922,8 +5928,6 @@
* Setup PxCLB, PxCLBU, PxFB, and PxFBU for particular port. First, we need
* to make sure PxCMD.ST, PxCMD.CR, PxCMD.FRE, and PxCMD.FR are all cleared.
* Then set PxCLB, PxCLBU, PxFB, and PxFBU.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static int
ahci_setup_port_base_addresses(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -5932,6 +5936,8 @@
uint32_t port_cmd_status = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_PORT_PxCMD(ahci_ctlp, port));
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* Step 1: Make sure both PxCMD.ST and PxCMD.CR are cleared. */
if (port_cmd_status & (AHCI_CMD_STATUS_ST | AHCI_CMD_STATUS_CR)) {
if (ahci_put_port_into_notrunning_state(ahci_ctlp, ahci_portp,
@@ -6003,9 +6009,6 @@
* Allocate the ahci_port_t including Received FIS and Command List.
* The argument - port is the physical port number, and not logical
* port number seen by the SATA framework.
- *
- * WARNING!!! ahcictl_mutex should be acquired before the function
- * is called.
*/
static int
ahci_alloc_port_state(ahci_ctl_t *ahci_ctlp, uint8_t port)
@@ -6014,6 +6017,8 @@
ahci_port_t *ahci_portp;
char taskq_name[64] = "event_handle_taskq";
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_mutex));
+
ahci_portp =
(ahci_port_t *)kmem_zalloc(sizeof (ahci_port_t), KM_SLEEP);
@@ -6099,15 +6104,13 @@
/*
* Reverse of ahci_alloc_port_state().
- *
- * WARNING!!! ahcictl_mutex should be acquired before the function
- * is called.
*/
static void
ahci_dealloc_port_state(ahci_ctl_t *ahci_ctlp, uint8_t port)
{
ahci_port_t *ahci_portp = ahci_ctlp->ahcictl_ports[port];
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_mutex));
ASSERT(ahci_portp != NULL);
mutex_enter(&ahci_portp->ahciport_mutex);
@@ -6132,9 +6135,6 @@
/*
* Allocates memory for the Received FIS Structure
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_alloc_rcvd_fis(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -6143,6 +6143,8 @@
size_t ret_len;
uint_t cookie_count;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
rcvd_fis_size = sizeof (ahci_rcvd_fis_t);
/* allocate rcvd FIS dma handle. */
@@ -6205,13 +6207,12 @@
/*
* Deallocates the Received FIS Structure
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_dealloc_rcvd_fis(ahci_port_t *ahci_portp)
{
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* Unbind the cmd list dma handle first. */
(void) ddi_dma_unbind_handle(ahci_portp->ahciport_rcvd_fis_dma_handle);
@@ -6226,9 +6227,6 @@
* Allocates memory for the Command List, which contains up to 32 entries.
* Each entry contains a command header, which is a 32-byte structure that
* includes the pointer to the command table.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_alloc_cmd_list(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -6237,6 +6235,8 @@
size_t ret_len;
uint_t cookie_count;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
cmd_list_size =
ahci_ctlp->ahcictl_num_cmd_slots * sizeof (ahci_cmd_header_t);
@@ -6316,13 +6316,12 @@
/*
* Deallocates the Command List
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_dealloc_cmd_list(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
{
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* First dealloc command table */
ahci_dealloc_cmd_tables(ahci_ctlp, ahci_portp);
@@ -6339,9 +6338,6 @@
/*
* Allocates memory for all Command Tables, which contains Command FIS,
* ATAPI Command and Physical Region Descriptor Table.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_alloc_cmd_tables(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
@@ -6351,6 +6347,8 @@
uint_t cookie_count;
int slot;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_INIT|AHCIDBG_ENTRY, ahci_ctlp,
"ahci_alloc_cmd_tables: port %d enter",
ahci_portp->ahciport_port_num);
@@ -6449,15 +6447,14 @@
/*
* Deallocates memory for all Command Tables.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_dealloc_cmd_tables(ahci_ctl_t *ahci_ctlp, ahci_port_t *ahci_portp)
{
int slot;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_dealloc_cmd_tables: %d enter",
ahci_portp->ahciport_port_num);
@@ -6479,14 +6476,13 @@
/*
* Update SATA registers at controller ports
- *
- * WARNING!!! ahciport_mutex should be acquired before those functions
- * get called.
*/
static void
ahci_update_sata_registers(ahci_ctl_t *ahci_ctlp, uint8_t port,
sata_device_t *sd)
{
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_ports[port]->ahciport_mutex));
+
sd->satadev_scr.sstatus =
ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)(AHCI_PORT_PxSSTS(ahci_ctlp, port)));
@@ -6999,9 +6995,6 @@
/*
* NCQ interrupt handler. Called upon a NCQ command is completed.
* Only be called from ahci_intr_set_device_bits().
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is
- * called.
*/
static int
ahci_intr_ncq_events(ahci_ctl_t *ahci_ctlp,
@@ -7975,13 +7968,12 @@
/*
* Enable the interrupts for a particular port.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_enable_port_intrs(ahci_ctl_t *ahci_ctlp, uint8_t port)
{
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_ports[port]->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_enable_port_intrs enter, port %d", port);
@@ -8032,15 +8024,14 @@
/*
* Enable interrupts for all the ports.
- *
- * WARNING!!! ahcictl_mutex should be acquired before the function
- * is called.
*/
static void
ahci_enable_all_intrs(ahci_ctl_t *ahci_ctlp)
{
uint32_t ghc_control;
+ ASSERT(MUTEX_HELD(&ahci_ctlp->ahcictl_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp, "ahci_enable_all_intrs enter", NULL);
ghc_control = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
@@ -8054,13 +8045,13 @@
/*
* Disable interrupts for a particular port.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_disable_port_intrs(ahci_ctl_t *ahci_ctlp, uint8_t port)
{
+ ASSERT(ahci_ctlp->ahcictl_flags & AHCI_QUIESCE ||
+ MUTEX_HELD(&ahci_ctlp->ahcictl_ports[port]->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_disable_port_intrs enter, port %d", port);
@@ -8073,22 +8064,22 @@
*
* The global bit is cleared, then all interrupt sources from all
* ports are disabled.
- *
- * WARNING!!! ahcictl_mutex should be acquired before the function
- * is called.
*/
static void
ahci_disable_all_intrs(ahci_ctl_t *ahci_ctlp)
{
uint32_t ghc_control;
+ ASSERT(ahci_ctlp->ahcictl_flags & (AHCI_ATTACH | AHCI_QUIESCE) ||
+ MUTEX_HELD(&ahci_ctlp->ahcictl_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp, "ahci_disable_all_intrs enter",
NULL);
ghc_control = ddi_get32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_GLOBAL_GHC(ahci_ctlp));
- ghc_control &= ~ AHCI_HBA_GHC_IE;
+ ghc_control &= ~AHCI_HBA_GHC_IE;
ddi_put32(ahci_ctlp->ahcictl_ahci_acc_handle,
(uint32_t *)AHCI_GLOBAL_GHC(ahci_ctlp), ghc_control);
@@ -8301,7 +8292,7 @@
* Removes the registered interrupts irrespective of whether they
* were legacy or MSI.
*
- * WARNING!!! The controller interrupts must be disabled before calling
+ * NOTE: The controller interrupts must be disabled before calling
* this routine.
*/
static void
@@ -8338,9 +8329,6 @@
* This routine tries to put port into P:NotRunning state by clearing
* PxCMD.ST. HBA will clear PxCI to 0h, PxSACT to 0h, PxCMD.CCS to 0h
* and PxCMD.CR to '0'.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static int
ahci_put_port_into_notrunning_state(ahci_ctl_t *ahci_ctlp,
@@ -8349,6 +8337,9 @@
uint32_t port_cmd_status;
int loop_count;
+ ASSERT(ahci_ctlp->ahcictl_flags & AHCI_QUIESCE ||
+ MUTEX_HELD(&ahci_ctlp->ahcictl_ports[port]->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_put_port_into_notrunning_state enter: port %d", port);
@@ -8417,11 +8408,6 @@
* + Fatal error recovery
* + To abort the timeout packet(s)
*
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called. And ahciport_mutex will be released before the reset
- * event is reported to sata module by calling sata_hba_event_notify,
- * and then be acquired again later.
- *
* NOTES!!! During this procedure, PxSERR register will be cleared, and
* according to the spec, the clearance of three bits will also clear
* three interrupt status bits.
@@ -8449,6 +8435,8 @@
int npmport = 0;
uint8_t cport = ahci_ctlp->ahcictl_port_to_cport[port];
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_restart_port_wait_till_ready: port %d enter", port);
@@ -8578,7 +8566,9 @@
* The COMRESET will make port multiplier enter legacy mode.
* Issue a software reset to make it work again.
*/
+ ahci_disable_port_intrs(ahci_ctlp, port);
ahci_find_dev_signature(ahci_ctlp, ahci_portp, &addr_port);
+ ahci_enable_port_intrs(ahci_ctlp, port);
/*
* Following codes are specific for the port multiplier
@@ -8692,8 +8682,6 @@
*
* In all these scenarios, we need to send any pending unfinished
* commands up to sata framework.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static void
ahci_mop_commands(ahci_ctl_t *ahci_ctlp,
@@ -8712,6 +8700,8 @@
int err_retri_cmd_in_progress = 0;
int rdwr_pmult_cmd_in_progress = 0;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ERRS|AHCIDBG_ENTRY, ahci_ctlp,
"ahci_mop_commands entered: port: %d slot_status: 0x%x",
ahci_portp->ahciport_port_num, slot_status);
@@ -9112,7 +9102,7 @@
ahci_portp->ahciport_err_retri_pkt = NULL;
/* Remove the flag after READ LOG EXT command is completed */
- ahci_portp->ahciport_flags &= ~ AHCI_PORT_FLAG_RDLOGEXT;
+ ahci_portp->ahciport_flags &= ~AHCI_PORT_FLAG_RDLOGEXT;
if (rdlog_spkt->satapkt_reason == SATA_PKT_COMPLETED) {
/* Update the request log data */
@@ -9234,7 +9224,7 @@
ahci_portp->ahciport_err_retri_pkt = NULL;
/* Remove the flag after REQUEST SENSE command is completed */
- ahci_portp->ahciport_flags &= ~ AHCI_PORT_FLAG_RQSENSE;
+ ahci_portp->ahciport_flags &= ~AHCI_PORT_FLAG_RQSENSE;
if (rs_spkt->satapkt_reason == SATA_PKT_COMPLETED) {
/* Update the request sense data */
@@ -9291,8 +9281,6 @@
* PxIS.HBDS - Host Bus Data Error Status
* PxIS.HBFS - Host Bus Fatal Error Status
* PxIS.TFES - Task File Error Status
- *
- * WARNING!!! ahciport_mutex should be acquired before the function is called.
*/
static void
ahci_fatal_error_recovery_handler(ahci_ctl_t *ahci_ctlp,
@@ -9313,6 +9301,8 @@
int instance = ddi_get_instance(ahci_ctlp->ahcictl_dip);
int rval;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
AHCIDBG(AHCIDBG_ENTRY, ahci_ctlp,
"ahci_fatal_error_recovery_handler enter: port %d", port);
@@ -9488,9 +9478,6 @@
* Nothing will be done when Command-based switching is employed.
*
* Currently code is neither completed nor tested.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_pmult_error_recovery_handler(ahci_ctl_t *ahci_ctlp,
@@ -9503,6 +9490,8 @@
int loop_count = 0;
ahci_addr_t addr;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
/* Nothing will be done under Command-based switching. */
if (!(ahci_ctlp->ahcictl_cap & AHCI_CAP_PMULT_FBSS))
return;
@@ -10237,6 +10226,8 @@
ahci_debug_flags = 0;
#endif
+ ahci_ctlp->ahcictl_flags |= AHCI_QUIESCE;
+
/* disable all the interrupts. */
ahci_disable_all_intrs(ahci_ctlp);
@@ -10261,19 +10252,19 @@
ahci_portp, port);
}
+ ahci_ctlp->ahcictl_flags &= ~AHCI_QUIESCE;
+
return (DDI_SUCCESS);
}
/*
* The function will add a sata packet to the done queue.
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_add_doneq(ahci_port_t *ahci_portp, sata_pkt_t *satapkt, int reason)
{
ASSERT(satapkt != NULL);
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
/* set the reason for all packets */
satapkt->satapkt_reason = reason;
@@ -10288,7 +10279,7 @@
*ahci_portp->ahciport_doneqtail = satapkt;
ahci_portp->ahciport_doneqtail =
(sata_pkt_t **)&(satapkt->satapkt_hba_driver_private);
- ahci_portp->ahciport_doneq_len ++;
+ ahci_portp->ahciport_doneq_len++;
} else if ((satapkt->satapkt_op_mode & SATA_OPMODE_SYNCH) &&
! (satapkt->satapkt_op_mode & SATA_OPMODE_POLLING))
@@ -10301,15 +10292,14 @@
/*
* The function will call completion callback of sata packet on the
* completed queue
- *
- * WARNING!!! ahciport_mutex should be acquired before the function
- * is called.
*/
static void
ahci_flush_doneq(ahci_port_t *ahci_portp)
{
sata_pkt_t *satapkt, *next;
+ ASSERT(MUTEX_HELD(&ahci_portp->ahciport_mutex));
+
if (ahci_portp->ahciport_doneq) {
satapkt = ahci_portp->ahciport_doneq;
--- a/usr/src/uts/common/os/logsubr.c Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/os/logsubr.c Sat Jul 13 21:34:47 2013 +0100
@@ -246,7 +246,7 @@
/*
* Now that logging is enabled, emit the SunOS banner.
*/
- printf("\rOpenIndiana Build %s %u-bit (illumos b49b27dcb6)\n",
+ printf("\rOpenIndiana Build %s %u-bit (illumos 01f9868a8d)\n",
utsname.version, NBBY * (uint_t)sizeof (void *));
printf("SunOS Release %s - Copyright 1983-2010 Oracle and/or its "
"affiliates.\n", utsname.release);
--- a/usr/src/uts/common/sys/lpif.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/sys/lpif.h Sat Jul 13 21:34:47 2013 +0100
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#ifndef _LPIF_H
#define _LPIF_H
@@ -131,9 +132,6 @@
stmf_status_t stmf_set_lu_access(stmf_lu_t *lup, uint8_t access_state);
stmf_status_t stmf_proxy_scsi_cmd(scsi_task_t *, stmf_data_buf_t *dbuf);
int stmf_is_standby_port(scsi_task_t *);
-void stmf_lu_xfer_start(struct scsi_task *task);
-void stmf_lu_xfer_done(struct scsi_task *task, boolean_t read,
- uint64_t xfer_bytes, hrtime_t elapsed_time);
#ifdef __cplusplus
}
--- a/usr/src/uts/common/sys/sata/adapters/ahci/ahcivar.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/sys/sata/adapters/ahci/ahcivar.h Sat Jul 13 21:34:47 2013 +0100
@@ -462,6 +462,7 @@
#define AHCI_ATTACH 0x1
#define AHCI_DETACH 0x2
#define AHCI_SUSPEND 0x4
+#define AHCI_QUIESCE 0x8
/* Values for ahcictl_cap */
/* PIO Multiple DRQ Block */
--- a/usr/src/uts/common/sys/stmf.h Fri Jul 05 20:01:41 2013 +0100
+++ b/usr/src/uts/common/sys/stmf.h Sat Jul 13 21:34:47 2013 +0100
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#ifndef _STMF_H
#define _STMF_H
@@ -384,8 +385,6 @@
stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
-stmf_status_t stmf_deregister_itl_handle(struct stmf_lu *lu, uint8_t *lun,
- struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);