Showing with 50 additions and 65 deletions.
  1. +1 −1 sbin/dump/dump.h
  2. +2 −2 sbin/dump/main.c
  3. +4 −4 sbin/dump/traverse.c
  4. +0 −2 sys/dev/tws/tws.c
  5. +0 −11 sys/dev/tws/tws_cam.c
  6. +0 −7 sys/dev/tws/tws_services.h
  7. +0 −1 sys/kern/genoffset.c
  8. +43 −37 sys/kern/subr_epoch.c
@@ -126,7 +126,7 @@ void dumpabort(int signo) __dead2;
void dump_getfstab(void);

char *rawname(char *cp);
union dinode *getinode(ino_t inum, int *mode);
union dinode *getinode0(ino_t inum, int *mode);

/* rdump routines */
#ifdef RDUMP
@@ -549,7 +549,7 @@ main(int argc, char *argv[])
/*
* Skip directory inodes deleted and maybe reallocated
*/
dp = getinode(ino, &mode);
dp = getinode0(ino, &mode);
if (mode != IFDIR)
continue;
(void)dumpino(dp, ino);
@@ -568,7 +568,7 @@ main(int argc, char *argv[])
/*
* Skip inodes deleted and reallocated as directories.
*/
dp = getinode(ino, &mode);
dp = getinode0(ino, &mode);
if (mode == IFDIR)
continue;
(void)dumpino(dp, ino);
@@ -195,7 +195,7 @@ mapfiles(ino_t maxino, long *tapesize)
}
for (i = 0; i < inosused; i++, ino++) {
if (ino < UFS_ROOTINO ||
(dp = getinode(ino, &mode)) == NULL ||
(dp = getinode0(ino, &mode)) == NULL ||
(mode & IFMT) == 0)
continue;
if (ino >= maxino) {
@@ -277,7 +277,7 @@ mapdirs(ino_t maxino, long *tapesize)
nodump = !nonodump && (TSTINO(ino, usedinomap) == 0);
if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
continue;
dp = getinode(ino, &i);
dp = getinode0(ino, &i);
/*
* inode buf may change in searchdir().
*/
@@ -421,7 +421,7 @@ searchdir(
continue;
}
if (nodump) {
ip = getinode(dp->d_ino, &mode);
ip = getinode0(dp->d_ino, &mode);
if (TSTINO(dp->d_ino, dumpinomap)) {
CLRINO(dp->d_ino, dumpinomap);
*tapesize -= blockest(ip);
@@ -875,7 +875,7 @@ writeheader(ino_t ino)
}

union dinode *
getinode(ino_t inum, int *modep)
getinode0(ino_t inum, int *modep)
{
static ino_t minino, maxino;
static caddr_t inoblock;
@@ -445,9 +445,7 @@ tws_setup_intr(struct tws_softc *sc, int irqs)
if (!(sc->intr_handle[i])) {
if ((error = bus_setup_intr(sc->tws_dev, sc->irq_res[i],
INTR_TYPE_CAM | INTR_MPSAFE,
#if (__FreeBSD_version >= 700000)
NULL,
#endif
tws_intr, sc, &sc->intr_handle[i]))) {
tws_log(sc, SETUP_INTR_RES);
return(FAILURE);
@@ -160,9 +160,7 @@ tws_cam_attach(struct tws_softc *sc)
*/
sc->sim = cam_sim_alloc(tws_action, tws_poll, "tws", sc,
device_get_unit(sc->tws_dev),
#if (__FreeBSD_version >= 700000)
&sc->sim_lock,
#endif
tws_cam_depth, 1, devq);
/* 1, 1, devq); */
if (sc->sim == NULL) {
@@ -172,9 +170,7 @@ tws_cam_attach(struct tws_softc *sc)
/* Register the bus. */
mtx_lock(&sc->sim_lock);
if (xpt_bus_register(sc->sim,
#if (__FreeBSD_version >= 700000)
sc->tws_dev,
#endif
0) != CAM_SUCCESS) {
cam_sim_free(sc->sim, TRUE); /* passing true will free the devq */
sc->sim = NULL; /* so cam_detach will not try to free it */
@@ -269,7 +265,6 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
{
TWS_TRACE_DEBUG(sc, "get tran settings", sim, ccb);

#if (__FreeBSD_version >= 700000 )
ccb->cts.protocol = PROTO_SCSI;
ccb->cts.protocol_version = SCSI_REV_2;
ccb->cts.transport = XPORT_SPI;
@@ -279,10 +274,6 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
ccb->cts.xport_specific.spi.flags = CTS_SPI_FLAGS_DISC_ENB;
ccb->cts.proto_specific.scsi.valid = CTS_SCSI_VALID_TQ;
ccb->cts.proto_specific.scsi.flags = CTS_SCSI_FLAGS_TAG_ENB;
#else
ccb->cts.valid = (CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID);
ccb->cts.flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
#endif
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);

@@ -314,13 +305,11 @@ tws_action(struct cam_sim *sim, union ccb *ccb)
strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN);
strlcpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN);
strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN);
#if (__FreeBSD_version >= 700000 )
ccb->cpi.transport = XPORT_SPI;
ccb->cpi.transport_version = 2;
ccb->cpi.protocol = PROTO_SCSI;
ccb->cpi.protocol_version = SCSI_REV_2;
ccb->cpi.maxio = TWS_MAX_IO_SIZE;
#endif
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);

@@ -131,12 +131,5 @@ struct error_desc {


/* ------------------------ */
#if (__FreeBSD_version >= 700000)
#include <sys/clock.h>
#define TWS_LOCAL_TIME (time_second - utc_offset())
#else
#include <machine/clock.h>
#define TWS_LOCAL_TIME (time_second - (tz_minuteswest * 60) - \
(wall_cmos_clock ? adjkerntz : 0))
#endif

@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/assym.h>
#include <sys/proc.h>

OFFSYM(td_pre_epoch_prio, thread, u_char);
OFFSYM(td_priority, thread, u_char);
OFFSYM(td_epochnest, thread, u_char);
OFFSYM(td_critnest, thread, u_int);
@@ -141,11 +141,15 @@ epoch_init(void *arg __unused)
epoch_call_count = counter_u64_alloc(M_WAITOK);
epoch_call_task_count = counter_u64_alloc(M_WAITOK);

pcpu_zone_record = uma_zcreate("epoch_record pcpu", sizeof(struct epoch_record),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
pcpu_zone_record = uma_zcreate("epoch_record pcpu",
sizeof(struct epoch_record), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, UMA_ZONE_PCPU);
CPU_FOREACH(cpu) {
GROUPTASK_INIT(DPCPU_ID_PTR(cpu, epoch_cb_task), 0, epoch_call_task, NULL);
taskqgroup_attach_cpu(qgroup_softirq, DPCPU_ID_PTR(cpu, epoch_cb_task), NULL, cpu, -1, "epoch call task");
GROUPTASK_INIT(DPCPU_ID_PTR(cpu, epoch_cb_task), 0,
epoch_call_task, NULL);
taskqgroup_attach_cpu(qgroup_softirq,
DPCPU_ID_PTR(cpu, epoch_cb_task), NULL, cpu, -1,
"epoch call task");
}
inited = 1;
global_epoch = epoch_alloc(0);
@@ -240,7 +244,7 @@ void
epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
{
struct epoch_record *er;
struct thread_lite *td;
struct thread *td;

MPASS(cold || epoch != NULL);
INIT_CHECK(epoch);
@@ -249,11 +253,11 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
et->et_magic_pre = EPOCH_MAGIC0;
et->et_magic_post = EPOCH_MAGIC1;
#endif
td = (struct thread_lite *)curthread;
et->et_td = (void*)td;
td = curthread;
et->et_td = td;
td->td_epochnest++;
critical_enter();
sched_pin_lite(td);
sched_pin();

td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
@@ -265,12 +269,12 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
void
epoch_enter(epoch_t epoch)
{
struct thread_lite *td;
struct thread *td;
epoch_record_t er;

MPASS(cold || epoch != NULL);
INIT_CHECK(epoch);
td = (struct thread_lite *)curthread;
td = curthread;

td->td_epochnest++;
critical_enter();
@@ -282,18 +286,18 @@ void
epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
{
struct epoch_record *er;
struct thread_lite *td;
struct thread *td;

INIT_CHECK(epoch);
td = (struct thread_lite *)curthread;
td = curthread;
critical_enter();
sched_unpin_lite(td);
sched_unpin();
MPASS(td->td_epochnest);
td->td_epochnest--;
er = epoch_currecord(epoch);
MPASS(epoch->e_flags & EPOCH_PREEMPT);
MPASS(et != NULL);
MPASS(et->et_td == (struct thread *)td);
MPASS(et->et_td == td);
#ifdef EPOCH_TRACKER_DEBUG
MPASS(et->et_magic_pre == EPOCH_MAGIC0);
MPASS(et->et_magic_post == EPOCH_MAGIC1);
@@ -307,18 +311,18 @@ epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
TAILQ_REMOVE(&er->er_tdlist, et, et_link);
er->er_gen++;
if (__predict_false(td->td_pre_epoch_prio != td->td_priority))
epoch_adjust_prio((struct thread *)td, td->td_pre_epoch_prio);
epoch_adjust_prio(td, td->td_pre_epoch_prio);
critical_exit();
}

void
epoch_exit(epoch_t epoch)
{
struct thread_lite *td;
struct thread *td;
epoch_record_t er;

INIT_CHECK(epoch);
td = (struct thread_lite *)curthread;
td = curthread;
MPASS(td->td_epochnest);
td->td_epochnest--;
er = epoch_currecord(epoch);
@@ -327,12 +331,12 @@ epoch_exit(epoch_t epoch)
}

/*
* epoch_block_handler_preempt is a callback from the ck code when another thread is
* currently in an epoch section.
* epoch_block_handler_preempt() is a callback from the CK code when another
* thread is currently in an epoch section.
*/
static void
epoch_block_handler_preempt(struct ck_epoch *global __unused, ck_epoch_record_t *cr,
void *arg __unused)
epoch_block_handler_preempt(struct ck_epoch *global __unused,
ck_epoch_record_t *cr, void *arg __unused)
{
epoch_record_t record;
struct thread *td, *owner, *curwaittd;
@@ -424,25 +428,27 @@ epoch_block_handler_preempt(struct ck_epoch *global __unused, ck_epoch_record_t
if (TD_IS_INHIBITED(curwaittd) && TD_ON_LOCK(curwaittd) &&
((ts = curwaittd->td_blocked) != NULL)) {
/*
* We unlock td to allow turnstile_wait to reacquire the
* the thread lock. Before unlocking it we enter a critical
* section to prevent preemption after we reenable interrupts
* by dropping the thread lock in order to prevent curwaittd
* from getting to run.
* We unlock td to allow turnstile_wait to reacquire
* the thread lock. Before unlocking it we enter a
* critical section to prevent preemption after we
* reenable interrupts by dropping the thread lock in
* order to prevent curwaittd from getting to run.
*/
critical_enter();
thread_unlock(td);
owner = turnstile_lock(ts, &lock);
/*
* The owner pointer indicates that the lock succeeded. Only
* in case we hold the lock and the turnstile we locked is still
* the one that curwaittd is blocked on can we continue. Otherwise
* The turnstile pointer has been changed out from underneath
* us, as in the case where the lock holder has signalled curwaittd,
* The owner pointer indicates that the lock succeeded.
* Only in case we hold the lock and the turnstile we
* locked is still the one that curwaittd is blocked on
* can we continue. Otherwise the turnstile pointer has
* been changed out from underneath us, as in the case
* where the lock holder has signalled curwaittd,
* and we need to continue.
*/
if (owner != NULL && ts == curwaittd->td_blocked) {
MPASS(TD_IS_INHIBITED(curwaittd) && TD_ON_LOCK(curwaittd));
MPASS(TD_IS_INHIBITED(curwaittd) &&
TD_ON_LOCK(curwaittd));
critical_exit();
turnstile_wait(ts, owner, curwaittd->td_tsqueue);
counter_u64_add(turnstile_count, 1);
@@ -492,9 +498,8 @@ epoch_wait_preempt(epoch_t epoch)
if ((epoch->e_flags & EPOCH_LOCKED) == 0)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"epoch_wait() can be long running");
KASSERT(!in_epoch(epoch),
("epoch_wait_preempt() called in the middle "
"of an epoch section of the same epoch"));
KASSERT(!in_epoch(epoch), ("epoch_wait_preempt() called in the middle "
"of an epoch section of the same epoch"));
#endif
thread_lock(td);
DROP_GIANT();
@@ -507,7 +512,8 @@ epoch_wait_preempt(epoch_t epoch)
td->td_pinned = 0;
sched_bind(td, old_cpu);

ck_epoch_synchronize_wait(&epoch->e_epoch, epoch_block_handler_preempt, NULL);
ck_epoch_synchronize_wait(&epoch->e_epoch, epoch_block_handler_preempt,
NULL);

/* restore CPU binding, if any */
if (was_bound != 0) {
@@ -608,7 +614,7 @@ epoch_call_task(void *arg __unused)
head = ck_stack_batch_pop_npsc(&cb_stack);
for (cursor = head; cursor != NULL; cursor = next) {
struct ck_epoch_entry *entry =
ck_epoch_entry_container(cursor);
ck_epoch_entry_container(cursor);

next = CK_STACK_NEXT(cursor);
entry->function(entry);