Permalink
Browse files

Merge branch 'master' of https://github.com/freebsd/freebsd

  • Loading branch information...
Ybalrid committed Feb 11, 2019
2 parents f25939d + 9e141fd commit ce57b29fe06490700fe0be8de20917e1343939f3
@@ -304,6 +304,8 @@ parent(int sock)

name = nvlist_next(nvl, &type, &cookie);
CHECK(name == NULL);

nvlist_destroy(nvl);
}

static void
@@ -18,7 +18,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 25, 2018
.Dd February 10, 2019
.Dt BECTL 8
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Ar beName@snapshot
.Nm
.Cm destroy
.Op Fl F
.Op Fl \&Fo
.Brq Ar beName | beName@snapshot
.Nm
.Cm export
@@ -124,7 +124,7 @@ If the
flag is given, a recursive boot environment will be made.
.It Xo
.Cm destroy
.Op Fl F
.Op Fl \&Fo
.Brq Ar beName | beName@snapshot
.Xc
Destroys the given
@@ -136,6 +136,14 @@ snapshot without confirmation, unlike in
Specifying
.Fl F
will automatically unmount without confirmation.
.Pp
By default,
.Nm
will warn that it is not destroying the origin of
.Ar beName .
The
.Fl o
flag may be specified to destroy the origin as well.
.It Cm export Ar sourceBe
Export
.Ar sourceBe
@@ -341,15 +341,18 @@ bectl_cmd_add(int argc, char *argv[])
static int
bectl_cmd_destroy(int argc, char *argv[])
{
char *target;
int opt, err;
bool force;
nvlist_t *props;
char *origin, *target, targetds[BE_MAXPATHLEN];
int err, flags, opt;

force = false;
while ((opt = getopt(argc, argv, "F")) != -1) {
flags = 0;
while ((opt = getopt(argc, argv, "Fo")) != -1) {
switch (opt) {
case 'F':
force = true;
flags |= BE_DESTROY_FORCE;
break;
case 'o':
flags |= BE_DESTROY_ORIGIN;
break;
default:
fprintf(stderr, "bectl destroy: unknown option '-%c'\n",
@@ -368,7 +371,24 @@ bectl_cmd_destroy(int argc, char *argv[])

target = argv[0];

err = be_destroy(be, target, force);
/* We'll emit a notice if there's an origin to be cleaned up */
if ((flags & BE_DESTROY_ORIGIN) == 0 && strchr(target, '@') == NULL) {
if (be_root_concat(be, target, targetds) != 0)
goto destroy;
if (be_prop_list_alloc(&props) != 0)
goto destroy;
if (be_get_dataset_props(be, targetds, props) != 0) {
be_prop_list_free(props);
goto destroy;
}
if (nvlist_lookup_string(props, "origin", &origin) == 0)
fprintf(stderr, "bectl destroy: leaving origin '%s' intact\n",
origin);
be_prop_list_free(props);
}

destroy:
err = be_destroy(be, target, flags);

return (err);
}
@@ -110,7 +110,7 @@ bectl_destroy_body()
bectl_create_setup ${zpool} ${disk} ${mount}
atf_check bectl -r ${zpool}/ROOT create -e default default2
atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2
atf_check bectl -r ${zpool}/ROOT destroy default2
atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2
atf_check -e not-empty -s not-exit:0 zfs get mountpoint ${zpool}/ROOT/default2
}
bectl_destroy_cleanup()
@@ -137,7 +137,7 @@ bectl_export_import_body()
atf_check -o save:exported bectl -r ${zpool}/ROOT export default
atf_check -x "bectl -r ${zpool}/ROOT import default2 < exported"
atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2
atf_check bectl -r ${zpool}/ROOT destroy default2
atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2
atf_check -e not-empty -s not-exit:0 zfs get mountpoint \
${zpool}/ROOT/default2
}
@@ -171,7 +171,7 @@ bectl_list_body()
atf_check bectl -r ${zpool}/ROOT create -e default default2
atf_check -o save:list.out bectl -r ${zpool}/ROOT list
atf_check -o not-empty grep 'default2' list.out
atf_check bectl -r ${zpool}/ROOT destroy default2
atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2
atf_check -o save:list.out bectl -r ${zpool}/ROOT list
atf_check -s not-exit:0 grep 'default2' list.out
# XXX TODO: Formatting checks
@@ -174,18 +174,7 @@ g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error)
static void
random_bits(void *p, u_int len)
{
static int fdr = -1;
int i;

if (fdr < 0) {
fdr = open("/dev/urandom", O_RDONLY);
if (fdr < 0)
err(1, "/dev/urandom");
}

i = read(fdr, p, len);
if (i != (int)len)
err(1, "read from /dev/urandom");
arc4random_buf(p, len);
}

/* XXX: not nice */
@@ -103,6 +103,7 @@ bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);

void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
void nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele);
nvpair_t *nvlist_get_array_next_nvpair(nvlist_t *nvl);

const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);

@@ -247,6 +247,15 @@ nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele)
nvl->nvl_array_next = ele;
}

nvpair_t *
nvlist_get_array_next_nvpair(nvlist_t *nvl)
{

NVLIST_ASSERT(nvl);

return (nvl->nvl_array_next);
}

bool
nvlist_in_array(const nvlist_t *nvl)
{
@@ -229,8 +229,16 @@ nvpair_remove_nvlist_array(nvpair_t *nvp)
nvlarray = __DECONST(nvlist_t **,
nvpair_get_nvlist_array(nvp, &count));
for (i = 0; i < count; i++) {
nvlist_set_array_next(nvlarray[i], NULL);
nvlist_set_parent(nvlarray[i], NULL);
nvlist_t *nvl;
nvpair_t *nnvp;

nvl = nvlarray[i];
nnvp = nvlist_get_array_next_nvpair(nvl);
if (nnvp != NULL) {
nvpair_free_structure(nnvp);
}
nvlist_set_array_next(nvl, NULL);
nvlist_set_parent(nvl, NULL);
}
}

@@ -1193,8 +1201,7 @@ nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap)
if (len < 0)
return (NULL);
nvp = nvpair_create_string(name, str);
if (nvp == NULL)
nv_free(str);
nv_free(str);
return (nvp);
}

@@ -2054,6 +2061,7 @@ nvpair_free(nvpair_t *nvp)
case NV_TYPE_DESCRIPTOR_ARRAY:
for (i = 0; i < nvp->nvp_nitems; i++)
close(((int *)(intptr_t)nvp->nvp_data)[i]);
nv_free((int *)(intptr_t)nvp->nvp_data);
break;
#endif
case NV_TYPE_NVLIST:
@@ -187,7 +187,7 @@ vtblk_proc(struct beri_vtblk_softc *sc, struct vqueue_info *vq)
break;
case VIRTIO_BLK_T_GET_ID:
/* Assume a single buffer */
strlcpy(iov[1].iov_base, sc->ident,
strncpy(iov[1].iov_base, sc->ident,
MIN(iov[1].iov_len, sizeof(sc->ident)));
err = 0;
break;
@@ -401,7 +401,7 @@ backend_info(struct beri_vtblk_softc *sc)
s+=1;
}

sprintf(sc->ident, "Virtio block backend");
strncpy(sc->ident, "Virtio block backend", sizeof(sc->ident));

return (0);
}
@@ -1051,13 +1051,9 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni,
copyhdrlen = hdrlen = ieee80211_anyhdrsize(wh);
pktlen = m0->m_pkthdr.len;
if (IEEE80211_QOS_HAS_SEQ(wh)) {
if (IEEE80211_IS_DSTODS(wh)) {
qos = *(uint16_t *)
(((struct ieee80211_qosframe_addr4 *) wh)->i_qos);
qos = *(uint16_t *)ieee80211_getqos(wh);
if (IEEE80211_IS_DSTODS(wh))
copyhdrlen -= sizeof(qos);
} else
qos = *(uint16_t *)
(((struct ieee80211_qosframe *) wh)->i_qos);
} else
qos = 0;

@@ -1952,7 +1948,6 @@ malo_rx_proc(void *arg, int npending)
struct malo_rxdesc *ds;
struct mbuf *m, *mnew;
struct ieee80211_qosframe *wh;
struct ieee80211_qosframe_addr4 *wh4;
struct ieee80211_node *ni;
int off, len, hdrlen, pktlen, rssi, ntodo;
uint8_t *data, status;
@@ -2062,15 +2057,8 @@ malo_rx_proc(void *arg, int npending)
/* NB: don't need to do this sometimes but ... */
/* XXX special case so we can memcpy after m_devget? */
ovbcopy(data + sizeof(uint16_t), wh, hdrlen);
if (IEEE80211_QOS_HAS_SEQ(wh)) {
if (IEEE80211_IS_DSTODS(wh)) {
wh4 = mtod(m,
struct ieee80211_qosframe_addr4*);
*(uint16_t *)wh4->i_qos = ds->qosctrl;
} else {
*(uint16_t *)wh->i_qos = ds->qosctrl;
}
}
if (IEEE80211_QOS_HAS_SEQ(wh))
*(uint16_t *)ieee80211_getqos(wh) = ds->qosctrl;
if (ieee80211_radiotap_active(ic)) {
sc->malo_rx_th.wr_flags = 0;
sc->malo_rx_th.wr_rate = ds->rate;
@@ -2614,7 +2614,6 @@ mwl_rx_proc(void *arg, int npending)
struct mwl_rxdesc *ds;
struct mbuf *m;
struct ieee80211_qosframe *wh;
struct ieee80211_qosframe_addr4 *wh4;
struct ieee80211_node *ni;
struct mwl_node *mn;
int off, len, hdrlen, pktlen, rssi, ntodo;
@@ -2761,15 +2760,8 @@ mwl_rx_proc(void *arg, int npending)
/* NB: don't need to do this sometimes but ... */
/* XXX special case so we can memcpy after m_devget? */
ovbcopy(data + sizeof(uint16_t), wh, hdrlen);
if (IEEE80211_QOS_HAS_SEQ(wh)) {
if (IEEE80211_IS_DSTODS(wh)) {
wh4 = mtod(m,
struct ieee80211_qosframe_addr4*);
*(uint16_t *)wh4->i_qos = ds->QosCtrl;
} else {
*(uint16_t *)wh->i_qos = ds->QosCtrl;
}
}
if (IEEE80211_QOS_HAS_SEQ(wh))
*(uint16_t *)ieee80211_getqos(wh) = ds->QosCtrl;
/*
* The f/w strips WEP header but doesn't clear
* the WEP bit; mark the packet with M_WEP so
@@ -3100,13 +3092,9 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf *
copyhdrlen = hdrlen;
pktlen = m0->m_pkthdr.len;
if (IEEE80211_QOS_HAS_SEQ(wh)) {
if (IEEE80211_IS_DSTODS(wh)) {
qos = *(uint16_t *)
(((struct ieee80211_qosframe_addr4 *) wh)->i_qos);
qos = *(uint16_t *)ieee80211_getqos(wh);
if (IEEE80211_IS_DSTODS(wh))
copyhdrlen -= sizeof(qos);
} else
qos = *(uint16_t *)
(((struct ieee80211_qosframe *) wh)->i_qos);
} else
qos = 0;

@@ -3369,11 +3369,7 @@ run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
if ((hasqos = IEEE80211_QOS_HAS_SEQ(wh))) {
uint8_t *frm;

if(IEEE80211_HAS_ADDR4(wh))
frm = ((struct ieee80211_qosframe_addr4 *)wh)->i_qos;
else
frm =((struct ieee80211_qosframe *)wh)->i_qos;

frm = ieee80211_getqos(wh);
qos = le16toh(*(const uint16_t *)frm);
tid = qos & IEEE80211_QOS_TID;
qid = TID_TO_WME_AC(tid);
@@ -863,6 +863,15 @@ rufetchtd(struct thread *td, struct rusage *ru)
calcru1(p, &td->td_rux, &ru->ru_utime, &ru->ru_stime);
}

static uint64_t
mul64_by_fraction(uint64_t a, uint64_t b, uint64_t c)
{
/*
* Compute floor(a * (b / c)) without overflowing, (b / c) <= 1.0.
*/
return ((a / c) * b + (a % c) * (b / c) + (a % c) * (b % c) / c);
}

static void
calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up,
struct timeval *sp)
@@ -892,10 +901,10 @@ calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up,
* The normal case, time increased.
* Enforce monotonicity of bucketed numbers.
*/
uu = (tu * ut) / tt;
uu = mul64_by_fraction(tu, ut, tt);
if (uu < ruxp->rux_uu)
uu = ruxp->rux_uu;
su = (tu * st) / tt;
su = mul64_by_fraction(tu, st, tt);
if (su < ruxp->rux_su)
su = ruxp->rux_su;
} else if (tu + 3 > ruxp->rux_tu || 101 * tu > 100 * ruxp->rux_tu) {
@@ -924,8 +933,8 @@ calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up,
"to %ju usec for pid %d (%s)\n",
(uintmax_t)ruxp->rux_tu, (uintmax_t)tu,
p->p_pid, p->p_comm);
uu = (tu * ut) / tt;
su = (tu * st) / tt;
uu = mul64_by_fraction(tu, ut, tt);
su = mul64_by_fraction(tu, st, tt);
}

ruxp->rux_uu = uu;
@@ -223,12 +223,11 @@ cbq_pfattach(struct pf_altq *a)
}

int
cbq_add_altq(struct pf_altq *a)
cbq_add_altq(struct ifnet *ifp, struct pf_altq *a)
{
cbq_state_t *cbqp;
struct ifnet *ifp;

if ((ifp = ifunit(a->ifname)) == NULL)
if (ifp == NULL)
return (EINVAL);
if (!ALTQ_IS_READY(&ifp->if_snd))
return (ENODEV);
@@ -89,13 +89,12 @@ codel_pfattach(struct pf_altq *a)
}

int
codel_add_altq(struct pf_altq *a)
codel_add_altq(struct ifnet *ifp, struct pf_altq *a)
{
struct codel_if *cif;
struct ifnet *ifp;
struct codel_opts *opts;

if ((ifp = ifunit(a->ifname)) == NULL)
if (ifp == NULL)
return (EINVAL);
if (!ALTQ_IS_READY(&ifp->if_snd))
return (ENODEV);
Oops, something went wrong.

0 comments on commit ce57b29

Please sign in to comment.