svn commit: r322214 - in head/tests: etc/rc.d sys/acl sys/file sys/geom/class/eli sys/geom/class/gate sys/geom/class/mirror sys/geom/class/nop sys/geom/class/uzip sys/kern sys/kqueue/libkqueue sys/...

2017-08-07 Thread Ngie Cooper
Author: ngie
Date: Tue Aug  8 04:59:16 2017
New Revision: 322214
URL: https://svnweb.freebsd.org/changeset/base/322214

Log:
  Make test scripts under tests/... non-executable
  
  Executable bits should be set at install time instead of in the repo.
  Setting executable bits on files triggers false positives with Phabricator.
  
  MFC after:2 months

Modified:
Directory Properties:
  head/tests/etc/rc.d/routing_test.sh   (props changed)
  head/tests/sys/acl/aclfuzzer.sh   (props changed)
  head/tests/sys/acl/mktrivial.sh   (props changed)
  head/tests/sys/file/flock_test.sh   (props changed)
  head/tests/sys/geom/class/eli/conf.sh   (props changed)
  head/tests/sys/geom/class/eli/init_alias_test.sh   (props changed)
  head/tests/sys/geom/class/gate/ggate_test.sh   (props changed)
  head/tests/sys/geom/class/mirror/8_test.sh   (props changed)
  head/tests/sys/geom/class/mirror/9_test.sh   (props changed)
  head/tests/sys/geom/class/nop/nop_test.sh   (props changed)
  head/tests/sys/geom/class/uzip/conf.sh   (props changed)
  head/tests/sys/kern/coredump_phnum_test.sh   (props changed)
  head/tests/sys/kqueue/libkqueue/kqueue_test.sh   (props changed)
  head/tests/sys/mac/portacl/misc.sh   (props changed)
  head/tests/sys/mac/portacl/nobody_test.sh   (props changed)
  head/tests/sys/mac/portacl/root_test.sh   (props changed)
  head/tests/sys/mqueue/mqueue_test.sh   (props changed)
  head/tests/sys/netinet/fibs_test.sh   (props changed)
  head/tests/sys/opencrypto/runtests.sh   (props changed)
  head/tests/sys/vfs/trailing_slash.sh   (props changed)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322213 - head/sys/compat/linuxkpi/common/include/linux

2017-08-07 Thread Mark Johnston
Author: markj
Date: Tue Aug  8 04:34:02 2017
New Revision: 322213
URL: https://svnweb.freebsd.org/changeset/base/322213

Log:
  Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI.
  
  Reviewed by:  hselasky
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D11871

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/include/linux/timer.h

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Tue Aug  8 
04:30:22 2017(r322212)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Tue Aug  8 
04:34:02 2017(r322213)
@@ -36,14 +36,16 @@
 #include 
 #include 
 #include 
+#include 
 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -149,5 +151,14 @@ int linux_schedule_timeout(int timeout);
 
 #defineio_schedule()   schedule()
 #defineio_schedule_timeout(timeout)schedule_timeout(timeout)
+
+static inline uint64_t
+local_clock(void)
+{
+   struct timespec ts;
+
+   nanotime();
+   return ((uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec);
+}
 
 #endif /* _LINUX_SCHED_H_ */

Modified: head/sys/compat/linuxkpi/common/include/linux/timer.h
==
--- head/sys/compat/linuxkpi/common/include/linux/timer.h   Tue Aug  8 
04:30:22 2017(r322212)
+++ head/sys/compat/linuxkpi/common/include/linux/timer.h   Tue Aug  8 
04:34:02 2017(r322213)
@@ -46,15 +46,20 @@ struct timer_list {
 
 extern unsigned long linux_timer_hz_mask;
 
-#definesetup_timer(timer, func, dat)   
\
-do {   \
+#defineTIMER_IRQSAFE   0x0001
+
+#definesetup_timer(timer, func, dat) do {  
\
(timer)->function = (func); \
(timer)->data = (dat);  \
callout_init(&(timer)->timer_callout, 1);   \
 } while (0)
 
-#defineinit_timer(timer)   
\
-do {   \
+#define__setup_timer(timer, func, dat, flags) do { 
\
+   CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0);  \
+   setup_timer(timer, func, dat);  \
+} while (0)
+
+#defineinit_timer(timer) do {  
\
(timer)->function = NULL;   \
(timer)->data = 0;  \
callout_init(&(timer)->timer_callout, 1);   \
@@ -67,9 +72,10 @@ extern void add_timer_on(struct timer_list *, int cpu)
 #definedel_timer(timer)callout_stop(&(timer)->timer_callout)
 #definedel_timer_sync(timer)   callout_drain(&(timer)->timer_callout)
 #definetimer_pending(timer)callout_pending(&(timer)->timer_callout)
-#defineround_jiffies(j) \
+#defineround_jiffies(j)\
((unsigned long)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask))
-#defineround_jiffies_relative(j) \
-   round_jiffies(j)
+#defineround_jiffies_relative(j) round_jiffies(j)
+#defineround_jiffies_up(j) round_jiffies(j)
+#defineround_jiffies_up_relative(j) round_jiffies_up(j)
 
 #endif /* _LINUX_TIMER_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322212 - head/sys/compat/linuxkpi/common/include/linux

2017-08-07 Thread Mark Johnston
Author: markj
Date: Tue Aug  8 04:30:22 2017
New Revision: 322212
URL: https://svnweb.freebsd.org/changeset/base/322212

Log:
  Add macros for defining attribute groups and for WO and RW attributes.
  
  Reviewed by:  hselasky
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D11872

Modified:
  head/sys/compat/linuxkpi/common/include/linux/device.h
  head/sys/compat/linuxkpi/common/include/linux/sysfs.h

Modified: head/sys/compat/linuxkpi/common/include/linux/device.h
==
--- head/sys/compat/linuxkpi/common/include/linux/device.h  Tue Aug  8 
04:10:46 2017(r322211)
+++ head/sys/compat/linuxkpi/common/include/linux/device.h  Tue Aug  8 
04:30:22 2017(r322212)
@@ -142,7 +142,13 @@ struct device_attribute {
 
 #defineDEVICE_ATTR(_name, _mode, _show, _store)
\
struct device_attribute dev_attr_##_name =  \
-   { { #_name, NULL, _mode }, _show, _store }
+   __ATTR(_name, _mode, _show, _store)
+#defineDEVICE_ATTR_RO(_name)   
\
+   struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
+#defineDEVICE_ATTR_WO(_name)   
\
+   struct device_attribute dev_attr_##_name = __ATTR_WO(_name)
+#defineDEVICE_ATTR_RW(_name)   
\
+   struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
 
 /* Simple class attribute that is just a static string */
 struct class_attribute_string {

Modified: head/sys/compat/linuxkpi/common/include/linux/sysfs.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sysfs.h   Tue Aug  8 
04:10:46 2017(r322211)
+++ head/sys/compat/linuxkpi/common/include/linux/sysfs.h   Tue Aug  8 
04:30:22 2017(r322212)
@@ -54,13 +54,20 @@ struct attribute_group {
.attr = { .name = __stringify(_name), .mode = _mode },  \
 .show = _show, .store  = _store,   \
 }
+#define__ATTR_RO(_name)__ATTR(_name, 0444, _name##_show, NULL)
+#define__ATTR_WO(_name)__ATTR(_name, 0200, NULL, _name##_store)
+#define__ATTR_RW(_name)__ATTR(_name, 0644, _name##_show, 
_name##_store)
 
-#define__ATTR_RO(_name) {  
\
-   .attr = { .name = __stringify(_name), .mode = 0444 },   \
-   .show   = _name##_show, \
-}
-
 #define__ATTR_NULL { .attr = { .name = NULL } }
+
+#defineATTRIBUTE_GROUPS(_name) 
\
+   static struct attribute_group _name##_group = { \
+   .attrs = _name##_attrs, \
+   };  \
+   static struct attribute_group *_name##_groups[] = { \
+   &_name##_group, \
+   NULL,   \
+   };
 
 /*
  * Handle our generic '\0' terminated 'C' string.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322211 - in head: contrib/netbsd-tests/lib/libc/regex/data lib/libc/regex

2017-08-07 Thread Kyle Evans
Author: kevans
Date: Tue Aug  8 04:10:46 2017
New Revision: 322211
URL: https://svnweb.freebsd.org/changeset/base/322211

Log:
  regex(3): Handle invalid {} constructs consistently and adjust tests
  
  Currently, regex(3) exhibits the following wrong behavior as demonstrated
  with sed:
  
   - echo "a{1,2,3}b" | sed -r "s/{/_/" (1)
   - echo "a{1,2,3}b" | sed "s/\}/_/"   (2)
   - echo "a{1,2,3}b" | sed -r "s/{}/_/"(3)
  
  Cases (1) and (3) should throw errors but they actually succeed, and (2)
  throws an error when it should match the literal '}'. The correct behavior
  was decided by comparing to the behavior with the equivalent BRE (1)(3) or
  ERE (2) and consulting POSIX, along with some reasonable evaluation.
  
  Tests were also adjusted/added accordingly.
  
  PR:   166861
  Reviewed by:  emaste, ngie, pfg
  Approved by:  emaste (mentor)
  MFC after:never
  Differential Revision:https://reviews.freebsd.org/D10315

Modified:
  head/contrib/netbsd-tests/lib/libc/regex/data/repet_bounded.in
  head/contrib/netbsd-tests/lib/libc/regex/data/repet_multi.in
  head/lib/libc/regex/regcomp.c

Modified: head/contrib/netbsd-tests/lib/libc/regex/data/repet_bounded.in
==
--- head/contrib/netbsd-tests/lib/libc/regex/data/repet_bounded.in  Tue Aug 
 8 00:31:10 2017(r322210)
+++ head/contrib/netbsd-tests/lib/libc/regex/data/repet_bounded.in  Tue Aug 
 8 04:10:46 2017(r322211)
@@ -1,9 +1,24 @@
 # the dreaded bounded repetitions
-{  &   {   {
-{abc   &   {abc{abc
+# Begin FreeBSD
+{  C   BADRPT
+{  b   {   {
+\{ -   {   {
+\{ bC  BADRPT
+{} C   BADRPT
+{} b   {}  {}
+\{\}   -   {}  {}
+\{\}   bC  BADRPT
+}  &   }   }
+\} &   }   }
+{abc   b   {abc{abc
+{abc   C   BADRPT
+# End FreeBSD
 {1 C   BADRPT
 {1}C   BADRPT
-a{b&   a{b a{b
+# Begin FreeBSD
+a{bb   a{b a{b
+a{bC   BADRPT
+# End FreeBSD
 a{1}b  -   ab  ab
 a\{1\}bb   ab  ab
 a{1,}b -   ab  ab
@@ -16,9 +31,15 @@ a{1a C   EBRACE
 a\{1a  bC  EBRACE
 a{1a}  C   BADBR
 a\{1a\}bC  BADBR
-a{,2}  -   a{,2}   a{,2}
+# Begin FreeBSD
+a{,2}  b   a{,2}   a{,2}
+a{,2}  C   BADBR
+# End FreeBSD
 a\{,2\}bC  BADBR
-a{,}   -   a{,}a{,}
+# Begin FreeBSD
+a{,}   b   a{,}a{,}
+a{,}   C   BADBR
+# End FreeBSD
 a\{,\} bC  BADBR
 a{1,x} C   BADBR
 a\{1,x\}   bC  BADBR

Modified: head/contrib/netbsd-tests/lib/libc/regex/data/repet_multi.in
==
--- head/contrib/netbsd-tests/lib/libc/regex/data/repet_multi.inTue Aug 
 8 00:31:10 2017(r322210)
+++ head/contrib/netbsd-tests/lib/libc/regex/data/repet_multi.inTue Aug 
 8 04:10:46 2017(r322211)
@@ -15,7 +15,10 @@ a?{1}C   BADRPT
 a{1}*  C   BADRPT
 a{1}+  C   BADRPT
 a{1}?  C   BADRPT
-a*{b}  -   a{b}a{b}
+# Begin FreeBSD
+a*{b}  b   a{b}a{b}
+a*{b}  C   BADRPT
+# End FreeBSD
 a\{1\}\{1\}bC  BADRPT
 a*\{1\}bC  BADRPT
 a\{1\}*bC  BADRPT

Modified: head/lib/libc/regex/regcomp.c
==
--- head/lib/libc/regex/regcomp.c   Tue Aug  8 00:31:10 2017
(r322210)
+++ head/lib/libc/regex/regcomp.c   Tue Aug  8 04:10:46 2017
(r322211)
@@ -412,6 +412,7 @@ p_ere_exp(struct parse *p, struct branchc *bc)
case '*':
case '+':
case '?':
+   case '{':
SETERROR(REG_BADRPT);
break;
case '.':
@@ -438,9 +439,6 @@ p_ere_exp(struct parse *p, struct branchc *bc)
break;
}
break;
-   case '{':   /* okay as ordinary except if digit follows */
-   (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
-   /* FALLTHROUGH */
default:
if (p->error != 0)
return (false);
@@ -454,9 +452,11 @@ p_ere_exp(struct parse *p, struct branchc *bc)
return (false);
c = PEEK();
/* we call { a repetition if followed by a digit */
-   if (!( c == '*' || c == '+' || c == '?' ||
-   (c == '{' && MORE2() && isdigit((uch)PEEK2())) 
))
+   if (!( c == '*' || c == '+' || c == '?' || 

svn commit: r322210 - head/bin/pkill

2017-08-07 Thread Lawrence Stewart
Author: lstewart
Date: Tue Aug  8 00:31:10 2017
New Revision: 322210
URL: https://svnweb.freebsd.org/changeset/base/322210

Log:
  pgrep naively appends the delimiter to all PIDs including the last
  e.g. "pgrep -d, getty" outputs "1399,1386,1309,1308,1307,1306,1305,1302,"
  Ensure the list is correctly delimited by suppressing the emission of the
  delimiter after the final PID.
  
  Reviewed by:  imp, kib
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D8537

Modified:
  head/bin/pkill/pkill.c

Modified: head/bin/pkill/pkill.c
==
--- head/bin/pkill/pkill.c  Mon Aug  7 23:33:05 2017(r322209)
+++ head/bin/pkill/pkill.c  Tue Aug  8 00:31:10 2017(r322210)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -656,10 +657,12 @@ killact(const struct kinfo_proc *kp)
 static int
 grepact(const struct kinfo_proc *kp)
 {
+   static bool first = true;
 
-   show_process(kp);
-   if (!quiet)
+   if (!quiet && !first)
printf("%s", delim);
+   show_process(kp);
+   first = false;
return (1);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322209 - head/sys/dev/mmc

2017-08-07 Thread Marius Strobl
Author: marius
Date: Mon Aug  7 23:33:05 2017
New Revision: 322209
URL: https://svnweb.freebsd.org/changeset/base/322209

Log:
  - If available, use TRIM instead of ERASE for implementing BIO_DELETE.
This also involves adding a quirk table as TRIM is broken for some
Kingston eMMC devices, though. Compared to ERASE (declared "legacy"
in the eMMC specification v5.1), TRIM has the advantage of operating
on write sectors rather than on erase sectors, which typically are
of a much larger size. Thus, employing TRIM, we don't need to fiddle
with coalescing BIO_DELETE requests that are also of (write) sector
units into erase sectors, which might not even add up in all cases.
  - For some SanDisk iNAND devices, the CMD38 argument, e. g. ERASE,
TRIM etc., has to be specified via EXT_CSD[113], which now is also
handled via a quirk.
  - My initial understanding was that for eMMC partitions, the granularity
should be used as erase sector size, e. g. 128 KB for boot partitions.
However, rereading the relevant parts of the eMMC specification v5.1,
this isn't actually correct. So drop the code which used partition
granularities for delmaxsize and stripesize. For the most part, this
change is a NOP, though, because a) for ERASE, mmcsd_delete() used
the erase sector size unconditionally for all partitions anyway and
b) g_disk_limit() doesn't actually take the stripesize into account.
  - Take some more advantage of mmcsd_errmsg() in mmcsd(4) for making
error codes human readable.

Modified:
  head/sys/dev/mmc/bridge.h
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcreg.h
  head/sys/dev/mmc/mmcsd.c
  head/sys/dev/mmc/mmcvar.h

Modified: head/sys/dev/mmc/bridge.h
==
--- head/sys/dev/mmc/bridge.h   Mon Aug  7 23:32:00 2017(r322208)
+++ head/sys/dev/mmc/bridge.h   Mon Aug  7 23:33:05 2017(r322209)
@@ -180,7 +180,7 @@ struct mmc_host {
 extern driver_t   mmc_driver;
 extern devclass_t mmc_devclass;
 
-#defineMMC_VERSION 4
+#defineMMC_VERSION 5
 
 #defineMMC_DECLARE_BRIDGE(name)
\
 DRIVER_MODULE(mmc, name, mmc_driver, mmc_devclass, NULL, NULL);\

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Mon Aug  7 23:32:00 2017(r322208)
+++ head/sys/dev/mmc/mmc.c  Mon Aug  7 23:33:05 2017(r322209)
@@ -104,12 +104,34 @@ struct mmc_ivars {
uint32_t hs_tran_speed; /* Max speed in high speed mode */
uint32_t erase_sector;  /* Card native erase sector size */
uint32_t cmd6_time; /* Generic switch timeout [us] */
+   uint32_t quirks;/* Quirks as per mmc_quirk->quirks */
char card_id_string[64];/* Formatted CID info (serial, MFG, etc) */
char card_sn_string[16];/* Formatted serial # for disk->d_ident */
 };
 
 #defineCMD_RETRIES 3
 
+static const struct mmc_quirk mmc_quirks[] = {
+   /*
+* For some SanDisk iNAND devices, the CMD38 argument needs to be
+* provided in EXT_CSD[113].
+*/
+   { 0x2, 0x100,   "SEM02G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM04G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM08G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM16G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM32G", MMC_QUIRK_INAND_CMD38 },
+
+   /*
+* Disable TRIM for Kingston eMMCs where a firmware bug can lead to
+* unrecoverable data corruption.
+*/
+   { 0x70, MMC_QUIRK_OID_ANY,  "V10008", MMC_QUIRK_BROKEN_TRIM },
+   { 0x70, MMC_QUIRK_OID_ANY,  "V10016", MMC_QUIRK_BROKEN_TRIM },
+
+   { 0x0, 0x0, NULL, 0x0 }
+};
+
 static SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, NULL, "mmc driver");
 
 static int mmc_debug;
@@ -1109,7 +1131,7 @@ mmc_format_card_id_string(struct mmc_ivars *ivar)
/*
 * Format a card ID string for use by the mmcsd driver, it's what
 * appears between the <> in the following:
-* mmcsd0: 968MB  at mmc0
+* mmcsd0: 968MB  at mmc0
 * 22.5MHz/4bit/128-block
 *
 * Also format just the card serial number, which the mmcsd driver will
@@ -1547,6 +1569,7 @@ mmc_log_card(device_t dev, struct mmc_ivars *ivar, int
break;
}
}
+   device_printf(dev, " quirks: %b\n", ivar->quirks, MMC_QUIRKS_FMT);
device_printf(dev, " bus: %ubit, %uMHz (%s timing)\n",
(ivar->bus_width == bus_width_1 ? 1 :
(ivar->bus_width == bus_width_4 ? 4 : 8)),
@@ -1563,6 +1586,7 @@ mmc_discover_cards(struct mmc_softc *sc)
u_char switch_res[64];
uint32_t raw_cid[4];
struct mmc_ivars *ivar = NULL;
+

svn commit: r322206 - head/sys/geom

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 22:42:46 2017
New Revision: 322206
URL: https://svnweb.freebsd.org/changeset/base/322206

Log:
  Eliminate useless adjustments of aliased device.
  
  No need to set any fields in the cloned device. devfs uses symlinks,
  so the adev entries returned won't be presented to the drivers. Since
  we don't save copies, nothing else will see them. This code came from
  the old compat code, and it appears to be obsolete or never needed.
  
  Submitted by: kib@
  Differential Review: https://reviews.freebsd.org/D11919

Modified:
  head/sys/geom/geom_dev.c

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cMon Aug  7 22:30:18 2017(r322205)
+++ head/sys/geom/geom_dev.cMon Aug  7 22:42:46 2017(r322206)
@@ -369,9 +369,6 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp,
__func__, gap->ga_alias, error);
continue;
}
-   adev->si_flags |= SI_UNMAPPED;
-   adev->si_iosize_max = dev->si_iosize_max;
-   adev->si_drv2 = dev->si_drv2;
snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias);
devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322198 - in head: share/man/man9 sys/geom

2017-08-07 Thread Warner Losh
On Mon, Aug 7, 2017 at 4:20 PM, Nathan Whitehorn 
wrote:

>
>
> On 08/07/17 14:32, Warner Losh wrote:
>
>
>
> On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn 
> wrote:
>
>> It would be really nice to let gpart provide aliases correct to partition
>> labels, which would fix the existing racy and unreliable glabel code. Do
>> you see any obstacles to using this code for that?
>
>
> I'm not sure I understand well enough the issue here to have an opinion.
>
>
> We get /dev/gpt/foo (etc.) right now by parsing the GPT labels with a
> completely parallel piece of code to gpart and then create an extra geom
> provider based on the label. This falls down in four ways:
> 1. The code is racy. It is perfectly possible to get a GPT label set by
> gpart but not have it picked up by glabel for some period of time that may
> be infinite (until a retaste), since the events don't propagate.
> 2. The resulting /dev entry is unpredictable from the label, since glabel
> internally does some fixups related to spaces, etc. You need to copy and
> paste glabel's munging code.
> 3. It isn't implemented for all of the schemes gpart supports since it has
> a reimplementation of the partition table parser.
> 4. Because it uses an extra provider, mounting, say, /dev/adaXpY causes
> /dev/gpt/Z to vanish.
>
> This combination of things is why we don't currently use labels in the
> installer and never have. Having gpart internally create symlinks would fix
> all of this at a stroke. I will take a look at this some more and see how
> hard it would be to implement; at the very least, I think you would also
> need a disk_remove_alias() or the like.
>

I've experienced all but #1 and #2. I've run systems for about a decade
with root mounted on /dev/gpt/HOST-root, usr on /dev/gpt/HOST-usr, etc.
Must have gotten lucky, or not hit the use case that you've seen.

Not sure what's up with #3, but it sounds orthogonal and an incomplete
gpart/glabel integration.

#4 has always bothered me. While device aliases like I've done here would
solve that problem, I'm not sure what other issues there'd be demoting
glabel devices to mere /dev/ nodes from first class geom objects.

The main issue I see is needing to have the aliases in place when tasting
time comes for the geom being tasted. I haven't thought through geom's
sequence enough to know if that would be more robust or not.

Warner


-Nathan
>
>
> Warner
>
> On 08/07/17 14:12, Warner Losh wrote:
>>
>>> Author: imp
>>> Date: Mon Aug  7 21:12:38 2017
>>> New Revision: 322198
>>> URL: https://svnweb.freebsd.org/changeset/base/322198
>>>
>>> Log:
>>>Expose API to allow disks to ask for alias names in devfs.
>>>   Implement disk_add_alias to allow aliases to be added to disks. All
>>>disk have a primary name (say "foo") can also have secondary names
>>>(say "bar") such that all instances of "foo" also have a "bar"
>>>alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes
>>>created by the foo driver and gpart, device nodes bar0, bar0p1, bar1,
>>>bar1s1 and bar1s1a will appear as symlinks back to the original nodes.
>>>This generalizes to multiple aliases. However, since the unit number
>>>follows the primary name, multiple device drivers can't create the
>>>same aliases unless those drives coorinate the unit number space (eg
>>>you couldn't add an alias 'disk' to both 'da' and 'ada' because it's
>>>possible to have da0 and ada0, because 'disk0' is ambiguous).
>>>   Differential Revision: https://reviews.freebsd.org/D11873
>>>
>>> Modified:
>>>head/share/man/man9/disk.9
>>>head/sys/geom/geom_disk.c
>>>head/sys/geom/geom_disk.h
>>>
>>> Modified: head/share/man/man9/disk.9
>>> 
>>> ==
>>> --- head/share/man/man9/disk.9  Mon Aug  7 21:12:33 2017(r322197)
>>> +++ head/share/man/man9/disk.9  Mon Aug  7 21:12:38 2017(r322198)
>>> @@ -27,7 +27,7 @@
>>>   .\"
>>>   .\" $FreeBSD$
>>>   .\"
>>> -.Dd October 30, 2012
>>> +.Dd August 3, 2017
>>>   .Dt DISK 9
>>>   .Os
>>>   .Sh NAME
>>> @@ -45,6 +45,8 @@
>>>   .Fn disk_destroy "struct disk *disk"
>>>   .Ft int
>>>   .Fn disk_resize "struct disk *disk" "int flags"
>>> +.Ft void
>>> +.Fn disk_add_alias "struct disk *disk" "const char *alias"
>>>   .Sh DESCRIPTION
>>>   The disk storage API permits kernel device drivers providing access to
>>>   disk-like storage devices to advertise the device to other kernel
>>> @@ -69,6 +71,20 @@ function,
>>>   fill in the fields and call
>>>   .Fn disk_create
>>>   when the device is ready to service requests.
>>> +.Fn disk_add_alias
>>> +adds an alias for the disk and must be called before
>>> +.Fn disk_create ,
>>> +but may be called multiple times.
>>> +For each alias added, a device node will be created with
>>> +.Xr make_dev_alias 9
>>> +in the same way primary device nodes are created with
>>> +.Xr make_dev 9
>>> 

Re: svn commit: r322198 - in head: share/man/man9 sys/geom

2017-08-07 Thread Nathan Whitehorn



On 08/07/17 14:32, Warner Losh wrote:



On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn 
> wrote:


It would be really nice to let gpart provide aliases correct to
partition labels, which would fix the existing racy and unreliable
glabel code. Do you see any obstacles to using this code for that?


I'm not sure I understand well enough the issue here to have an opinion.


We get /dev/gpt/foo (etc.) right now by parsing the GPT labels with a 
completely parallel piece of code to gpart and then create an extra geom 
provider based on the label. This falls down in four ways:
1. The code is racy. It is perfectly possible to get a GPT label set by 
gpart but not have it picked up by glabel for some period of time that 
may be infinite (until a retaste), since the events don't propagate.
2. The resulting /dev entry is unpredictable from the label, since 
glabel internally does some fixups related to spaces, etc. You need to 
copy and paste glabel's munging code.
3. It isn't implemented for all of the schemes gpart supports since it 
has a reimplementation of the partition table parser.
4. Because it uses an extra provider, mounting, say, /dev/adaXpY causes 
/dev/gpt/Z to vanish.


This combination of things is why we don't currently use labels in the 
installer and never have. Having gpart internally create symlinks would 
fix all of this at a stroke. I will take a look at this some more and 
see how hard it would be to implement; at the very least, I think you 
would also need a disk_remove_alias() or the like.

-Nathan


Warner

On 08/07/17 14:12, Warner Losh wrote:

Author: imp
Date: Mon Aug  7 21:12:38 2017
New Revision: 322198
URL: https://svnweb.freebsd.org/changeset/base/322198


Log:
   Expose API to allow disks to ask for alias names in devfs.
  Implement disk_add_alias to allow aliases to be added to
disks. All
   disk have a primary name (say "foo") can also have
secondary names
   (say "bar") such that all instances of "foo" also have a "bar"
   alias. So if you have foo0, foo0p1, foo1, foo1s1 and
foo1s1a nodes
   created by the foo driver and gpart, device nodes bar0,
bar0p1, bar1,
   bar1s1 and bar1s1a will appear as symlinks back to the
original nodes.
   This generalizes to multiple aliases. However, since the
unit number
   follows the primary name, multiple device drivers can't
create the
   same aliases unless those drives coorinate the unit number
space (eg
   you couldn't add an alias 'disk' to both 'da' and 'ada'
because it's
   possible to have da0 and ada0, because 'disk0' is ambiguous).
  Differential Revision:
https://reviews.freebsd.org/D11873


Modified:
   head/share/man/man9/disk.9
   head/sys/geom/geom_disk.c
   head/sys/geom/geom_disk.h

Modified: head/share/man/man9/disk.9

==
--- head/share/man/man9/disk.9  Mon Aug  7 21:12:33 2017 
  (r322197)
+++ head/share/man/man9/disk.9  Mon Aug  7 21:12:38 2017 
  (r322198)

@@ -27,7 +27,7 @@
  .\"
  .\" $FreeBSD$
  .\"
-.Dd October 30, 2012
+.Dd August 3, 2017
  .Dt DISK 9
  .Os
  .Sh NAME
@@ -45,6 +45,8 @@
  .Fn disk_destroy "struct disk *disk"
  .Ft int
  .Fn disk_resize "struct disk *disk" "int flags"
+.Ft void
+.Fn disk_add_alias "struct disk *disk" "const char *alias"
  .Sh DESCRIPTION
  The disk storage API permits kernel device drivers providing
access to
  disk-like storage devices to advertise the device to other
kernel
@@ -69,6 +71,20 @@ function,
  fill in the fields and call
  .Fn disk_create
  when the device is ready to service requests.
+.Fn disk_add_alias
+adds an alias for the disk and must be called before
+.Fn disk_create ,
+but may be called multiple times.
+For each alias added, a device node will be created with
+.Xr make_dev_alias 9
+in the same way primary device nodes are created with
+.Xr make_dev 9
+for
+.Va d_name
+and
+.Va d_unit .
+Care should be taken to ensure that only one driver creates
aliases
+for any given name.
  .Fn disk_resize
  can be called by the driver after modifying
  .Va d_mediasize
@@ -227,7 +243,13 @@ structure for this disk device.
  .El
  .Sh SEE ALSO
  .Xr GEOM 4 

Re: svn commit: r322196 - head/sys/geom

2017-08-07 Thread Warner Losh
On Mon, Aug 7, 2017 at 3:51 PM, Konstantin Belousov 
wrote:

> On Mon, Aug 07, 2017 at 03:37:57PM -0600, Warner Losh wrote:
> > On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov  >
> > wrote:
> >
> > > On Mon, Aug 07, 2017 at 09:12:28PM +, Warner Losh wrote:
> > > > + LIST_FOREACH(gap, >geom->aliases, ga_next) {
> > > > + error = make_dev_alias_p(MAKEDEV_CHECKNAME |
> > > MAKEDEV_WAITOK, , dev,
> > > > + "%s", gap->ga_alias);
> > > > + if (error) {
> > > > + printf("%s: make_dev_alias_p() failed (name=%s,
> > > error=%d)\n",
> > > > + __func__, gap->ga_alias, error);
> > > > + continue;
> > > > + }
> > > > + adev->si_flags |= SI_UNMAPPED;
> > > Why do you set the flag unconditionally ?
> >
> >
> > Because it's set for "dev" unconditionally and the old compat code did it
> > too...
> >
> > > + adev->si_iosize_max = dev->si_iosize_max;
> > > > + adev->si_drv2 = dev->si_drv2;
> > > And what are you trying to do by these initializations, including the
> > > si_flags adjustment ?
> > >
> >
> > The old (ad->ada) compat code set them. Though to be honest, I didn't
> drill
> > down into the devfs code to see if that as still relevant. It sounds like
> > maybe not relevant...
> >
> >
> > > Aliases cause creation of symlinks in the devfs populate loop, which
> > > makes it impossible to access the alias cdevs.
> > >
> >
> > True enough. If so, do you think these adjustments to adev can just be
> > removed entirely? A quick look in devfs code suggests that it doesn't
> > matter since, as you point out, it's a symlink not a new, different node.
> Yes, I think that the adev tweaks are not needed.  I will be surprised
> if it appears to be used, but then there might be some hole in the
> devfs symlinks handling.
>

Maybe I'm just setting 'dead variables' here that don't matter. I don't
know that this is required, just kept the same code that used to 'work'.


> That said, since you mentioned ada/ad aliases, are they still in the tree ?
> If yes, do you plan to convert them as well ?
>

That code was removed in 11. I thought about bringing the code that ada
used to implement them back verbatim for nda (and soon mda), but thought
this approach was better and more general (and less error prone). I have no
plans to re-add them.

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322196 - head/sys/geom

2017-08-07 Thread Konstantin Belousov
On Mon, Aug 07, 2017 at 03:37:57PM -0600, Warner Losh wrote:
> On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov 
> wrote:
> 
> > On Mon, Aug 07, 2017 at 09:12:28PM +, Warner Losh wrote:
> > > + LIST_FOREACH(gap, >geom->aliases, ga_next) {
> > > + error = make_dev_alias_p(MAKEDEV_CHECKNAME |
> > MAKEDEV_WAITOK, , dev,
> > > + "%s", gap->ga_alias);
> > > + if (error) {
> > > + printf("%s: make_dev_alias_p() failed (name=%s,
> > error=%d)\n",
> > > + __func__, gap->ga_alias, error);
> > > + continue;
> > > + }
> > > + adev->si_flags |= SI_UNMAPPED;
> > Why do you set the flag unconditionally ?
> 
> 
> Because it's set for "dev" unconditionally and the old compat code did it
> too...
> 
> > + adev->si_iosize_max = dev->si_iosize_max;
> > > + adev->si_drv2 = dev->si_drv2;
> > And what are you trying to do by these initializations, including the
> > si_flags adjustment ?
> >
> 
> The old (ad->ada) compat code set them. Though to be honest, I didn't drill
> down into the devfs code to see if that as still relevant. It sounds like
> maybe not relevant...
> 
> 
> > Aliases cause creation of symlinks in the devfs populate loop, which
> > makes it impossible to access the alias cdevs.
> >
> 
> True enough. If so, do you think these adjustments to adev can just be
> removed entirely? A quick look in devfs code suggests that it doesn't
> matter since, as you point out, it's a symlink not a new, different node.
Yes, I think that the adev tweaks are not needed.  I will be surprised
if it appears to be used, but then there might be some hole in the
devfs symlinks handling.

That said, since you mentioned ada/ad aliases, are they still in the tree ?
If yes, do you plan to convert them as well ?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322203 - head/usr.sbin/tzsetup

2017-08-07 Thread Marius Strobl
Author: marius
Date: Mon Aug  7 21:38:10 2017
New Revision: 322203
URL: https://svnweb.freebsd.org/changeset/base/322203

Log:
  Revert the parts of r322097 related to /etc/wall_cmos_clock handling as
  the previous behavior actually is required for setting up configurations
  in which the RTC is using UTC but the timezone is not. Still, besides
  uniform error handling, that file should get the same treatment in the
  non-interactive variants supported by tzsetup(8).

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Mon Aug  7 21:29:55 2017
(r322202)
+++ head/usr.sbin/tzsetup/tzsetup.c Mon Aug  7 21:38:10 2017
(r322203)
@@ -866,48 +866,10 @@ install_zoneinfo_file(const char *zoneinfo_file)
 static int
 install_zoneinfo(const char *zoneinfo)
 {
-   int fd, rv;
+   int rv;
FILE*f;
charpath_zoneinfo_file[MAXPATHLEN];
-   charprompt[SILLY_BUFFER_SIZE], title[64];
 
-   if (reallydoit) {
-   if (strcmp(zoneinfo, "UTC") == 0) {
-   if (unlink(path_wall_cmos_clock) < 0 &&
-   errno != ENOENT) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-   "Could not delete %s: %s",
-   path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-#endif
-   fprintf(stderr, "%s\n", prompt);
-
-   return (DITEM_FAILURE | DITEM_RECREATE);
-   }
-   } else {
-   fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT |
-   O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
-   if (fd < 0) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-   "Could not create %s: %s",
-   path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-#endif
-   fprintf(stderr, "%s\n", prompt);
-   return (DITEM_FAILURE | DITEM_RECREATE);
-   }
-   close(fd);
-   }
-   }
-
if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
"%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo);
@@ -938,6 +900,7 @@ main(int argc, char **argv)
 {
 #ifdef HAVE_DIALOG
chartitle[64], prompt[128];
+   int fd;
 #endif
int c, rv, skiputc;
charvm_guest[16] = "";
@@ -992,7 +955,6 @@ main(int argc, char **argv)
_PATH_WALL_CMOS_CLOCK);
}
 
-
/* Override the user-supplied umask. */
(void)umask(S_IWGRP | S_IWOTH);
 
@@ -1059,11 +1021,19 @@ main(int argc, char **argv)
yesno = dialog_yesno(title, prompt, 7, 73);
dlg_restore_vars(_vars);
if (!yesno) {
+   if (reallydoit)
+   unlink(path_wall_cmos_clock);
+   } else {
if (reallydoit) {
-   rv = install_zoneinfo("UTC");
-   dlg_clear();
-   end_dialog();
-   exit(rv & ~DITEM_LEAVE_MENU);
+   fd = open(path_wall_cmos_clock,
+   O_WRONLY | O_CREAT | O_TRUNC,
+   S_IRUSR | S_IRGRP | S_IROTH);
+   if (fd < 0) {
+   end_dialog();
+   err(1, "create %s",
+   path_wall_cmos_clock);
+   }
+   close(fd);
}
}
dlg_clear();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322196 - head/sys/geom

2017-08-07 Thread Warner Losh
On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov 
wrote:

> On Mon, Aug 07, 2017 at 09:12:28PM +, Warner Losh wrote:
> > + LIST_FOREACH(gap, >geom->aliases, ga_next) {
> > + error = make_dev_alias_p(MAKEDEV_CHECKNAME |
> MAKEDEV_WAITOK, , dev,
> > + "%s", gap->ga_alias);
> > + if (error) {
> > + printf("%s: make_dev_alias_p() failed (name=%s,
> error=%d)\n",
> > + __func__, gap->ga_alias, error);
> > + continue;
> > + }
> > + adev->si_flags |= SI_UNMAPPED;
> Why do you set the flag unconditionally ?


Because it's set for "dev" unconditionally and the old compat code did it
too...

> + adev->si_iosize_max = dev->si_iosize_max;
> > + adev->si_drv2 = dev->si_drv2;
> And what are you trying to do by these initializations, including the
> si_flags adjustment ?
>

The old (ad->ada) compat code set them. Though to be honest, I didn't drill
down into the devfs code to see if that as still relevant. It sounds like
maybe not relevant...


> Aliases cause creation of symlinks in the devfs populate loop, which
> makes it impossible to access the alias cdevs.
>

True enough. If so, do you think these adjustments to adev can just be
removed entirely? A quick look in devfs code suggests that it doesn't
matter since, as you point out, it's a symlink not a new, different node.

Thanks for the feedback.

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322198 - in head: share/man/man9 sys/geom

2017-08-07 Thread Warner Losh
On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn 
wrote:

> It would be really nice to let gpart provide aliases correct to partition
> labels, which would fix the existing racy and unreliable glabel code. Do
> you see any obstacles to using this code for that?


I'm not sure I understand well enough the issue here to have an opinion.

Warner

On 08/07/17 14:12, Warner Losh wrote:
>
>> Author: imp
>> Date: Mon Aug  7 21:12:38 2017
>> New Revision: 322198
>> URL: https://svnweb.freebsd.org/changeset/base/322198
>>
>> Log:
>>Expose API to allow disks to ask for alias names in devfs.
>>   Implement disk_add_alias to allow aliases to be added to disks. All
>>disk have a primary name (say "foo") can also have secondary names
>>(say "bar") such that all instances of "foo" also have a "bar"
>>alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes
>>created by the foo driver and gpart, device nodes bar0, bar0p1, bar1,
>>bar1s1 and bar1s1a will appear as symlinks back to the original nodes.
>>This generalizes to multiple aliases. However, since the unit number
>>follows the primary name, multiple device drivers can't create the
>>same aliases unless those drives coorinate the unit number space (eg
>>you couldn't add an alias 'disk' to both 'da' and 'ada' because it's
>>possible to have da0 and ada0, because 'disk0' is ambiguous).
>>   Differential Revision: https://reviews.freebsd.org/D11873
>>
>> Modified:
>>head/share/man/man9/disk.9
>>head/sys/geom/geom_disk.c
>>head/sys/geom/geom_disk.h
>>
>> Modified: head/share/man/man9/disk.9
>> 
>> ==
>> --- head/share/man/man9/disk.9  Mon Aug  7 21:12:33 2017(r322197)
>> +++ head/share/man/man9/disk.9  Mon Aug  7 21:12:38 2017(r322198)
>> @@ -27,7 +27,7 @@
>>   .\"
>>   .\" $FreeBSD$
>>   .\"
>> -.Dd October 30, 2012
>> +.Dd August 3, 2017
>>   .Dt DISK 9
>>   .Os
>>   .Sh NAME
>> @@ -45,6 +45,8 @@
>>   .Fn disk_destroy "struct disk *disk"
>>   .Ft int
>>   .Fn disk_resize "struct disk *disk" "int flags"
>> +.Ft void
>> +.Fn disk_add_alias "struct disk *disk" "const char *alias"
>>   .Sh DESCRIPTION
>>   The disk storage API permits kernel device drivers providing access to
>>   disk-like storage devices to advertise the device to other kernel
>> @@ -69,6 +71,20 @@ function,
>>   fill in the fields and call
>>   .Fn disk_create
>>   when the device is ready to service requests.
>> +.Fn disk_add_alias
>> +adds an alias for the disk and must be called before
>> +.Fn disk_create ,
>> +but may be called multiple times.
>> +For each alias added, a device node will be created with
>> +.Xr make_dev_alias 9
>> +in the same way primary device nodes are created with
>> +.Xr make_dev 9
>> +for
>> +.Va d_name
>> +and
>> +.Va d_unit .
>> +Care should be taken to ensure that only one driver creates aliases
>> +for any given name.
>>   .Fn disk_resize
>>   can be called by the driver after modifying
>>   .Va d_mediasize
>> @@ -227,7 +243,13 @@ structure for this disk device.
>>   .El
>>   .Sh SEE ALSO
>>   .Xr GEOM 4 ,
>> -.Xr devfs 5
>> +.Xr devfs 5 ,
>> +.Xr MAKE_DEV 9
>>   .Sh AUTHORS
>>   This manual page was written by
>>   .An Robert Watson .
>> +.Sh BUGS
>> +Disk aliases are not a general purpose aliasing mechanism, but are
>> +intended only to ease the transition from one name to another.
>> +They can be used to ensure that nvd0 and nda0 are the same thing.
>> +They cannot be used to implement the diskX concept from macOS.
>>
>> Modified: head/sys/geom/geom_disk.c
>> 
>> ==
>> --- head/sys/geom/geom_disk.c   Mon Aug  7 21:12:33 2017(r322197)
>> +++ head/sys/geom/geom_disk.c   Mon Aug  7 21:12:38 2017(r322198)
>> @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag)
>> struct g_provider *pp;
>> struct disk *dp;
>> struct g_disk_softc *sc;
>> +   struct disk_alias *dap;
>> char tmpstr[80];
>> if (flag == EV_CANCEL)
>> @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag)
>> sc->dp = dp;
>> gp = g_new_geomf(_disk_class, "%s%d", dp->d_name, dp->d_unit);
>> gp->softc = sc;
>> +   LIST_FOREACH(dap, >d_aliases, da_next) {
>> +   snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias,
>> dp->d_unit);
>> +   g_geom_add_alias(gp, tmpstr);
>> +   }
>> pp = g_new_providerf(gp, "%s", gp->name);
>> devstat_remove_entry(pp->stat);
>> pp->stat = NULL;
>> @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag)
>> struct disk *dp;
>> struct g_geom *gp;
>> struct g_disk_softc *sc;
>> +   struct disk_alias *dap, *daptmp;
>> g_topology_assert();
>> dp = ptr;
>> @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag)
>> dp->d_geom = NULL;

svn commit: r322202 - head

2017-08-07 Thread Ed Maste
Author: emaste
Date: Mon Aug  7 21:29:55 2017
New Revision: 322202
URL: https://svnweb.freebsd.org/changeset/base/322202

Log:
  UPDATING: clarify what the RCMDS knob controls

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Mon Aug  7 21:23:59 2017(r322201)
+++ head/UPDATING   Mon Aug  7 21:29:55 2017(r322202)
@@ -64,8 +64,8 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
and upgrading, if you are not already using clang 3.5.0 or higher.
 
 20170701:
-   WITHOUT_RCMDS is now the default. Set WITH_RCMDS if you need them to be
-   built with the base system.
+   WITHOUT_RCMDS is now the default. Set WITH_RCMDS if you need the
+   r-commands (rlogin, rsh, etc.) to be built with the base system.
 
 20170625:
The FreeBSD/powerpc platform now uses a 64-bit type for time_t.  This is
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322196 - head/sys/geom

2017-08-07 Thread Konstantin Belousov
On Mon, Aug 07, 2017 at 09:12:28PM +, Warner Losh wrote:
> + LIST_FOREACH(gap, >geom->aliases, ga_next) {
> + error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, 
> , dev,
> + "%s", gap->ga_alias);
> + if (error) {
> + printf("%s: make_dev_alias_p() failed (name=%s, 
> error=%d)\n",
> + __func__, gap->ga_alias, error);
> + continue;
> + }
> + adev->si_flags |= SI_UNMAPPED;
Why do you set the flag unconditionally ?

> + adev->si_iosize_max = dev->si_iosize_max;
> + adev->si_drv2 = dev->si_drv2;
And what are you trying to do by these initializations, including the
si_flags adjustment ?

Aliases cause creation of symlinks in the devfs populate loop, which
makes it impossible to access the alias cdevs.

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r322198 - in head: share/man/man9 sys/geom

2017-08-07 Thread Nathan Whitehorn
It would be really nice to let gpart provide aliases correct to 
partition labels, which would fix the existing racy and unreliable 
glabel code. Do you see any obstacles to using this code for that?

-Nathan

On 08/07/17 14:12, Warner Losh wrote:

Author: imp
Date: Mon Aug  7 21:12:38 2017
New Revision: 322198
URL: https://svnweb.freebsd.org/changeset/base/322198

Log:
   Expose API to allow disks to ask for alias names in devfs.
   
   Implement disk_add_alias to allow aliases to be added to disks. All

   disk have a primary name (say "foo") can also have secondary names
   (say "bar") such that all instances of "foo" also have a "bar"
   alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes
   created by the foo driver and gpart, device nodes bar0, bar0p1, bar1,
   bar1s1 and bar1s1a will appear as symlinks back to the original nodes.
   This generalizes to multiple aliases. However, since the unit number
   follows the primary name, multiple device drivers can't create the
   same aliases unless those drives coorinate the unit number space (eg
   you couldn't add an alias 'disk' to both 'da' and 'ada' because it's
   possible to have da0 and ada0, because 'disk0' is ambiguous).
   
   Differential Revision: https://reviews.freebsd.org/D11873


Modified:
   head/share/man/man9/disk.9
   head/sys/geom/geom_disk.c
   head/sys/geom/geom_disk.h

Modified: head/share/man/man9/disk.9
==
--- head/share/man/man9/disk.9  Mon Aug  7 21:12:33 2017(r322197)
+++ head/share/man/man9/disk.9  Mon Aug  7 21:12:38 2017(r322198)
@@ -27,7 +27,7 @@
  .\"
  .\" $FreeBSD$
  .\"
-.Dd October 30, 2012
+.Dd August 3, 2017
  .Dt DISK 9
  .Os
  .Sh NAME
@@ -45,6 +45,8 @@
  .Fn disk_destroy "struct disk *disk"
  .Ft int
  .Fn disk_resize "struct disk *disk" "int flags"
+.Ft void
+.Fn disk_add_alias "struct disk *disk" "const char *alias"
  .Sh DESCRIPTION
  The disk storage API permits kernel device drivers providing access to
  disk-like storage devices to advertise the device to other kernel
@@ -69,6 +71,20 @@ function,
  fill in the fields and call
  .Fn disk_create
  when the device is ready to service requests.
+.Fn disk_add_alias
+adds an alias for the disk and must be called before
+.Fn disk_create ,
+but may be called multiple times.
+For each alias added, a device node will be created with
+.Xr make_dev_alias 9
+in the same way primary device nodes are created with
+.Xr make_dev 9
+for
+.Va d_name
+and
+.Va d_unit .
+Care should be taken to ensure that only one driver creates aliases
+for any given name.
  .Fn disk_resize
  can be called by the driver after modifying
  .Va d_mediasize
@@ -227,7 +243,13 @@ structure for this disk device.
  .El
  .Sh SEE ALSO
  .Xr GEOM 4 ,
-.Xr devfs 5
+.Xr devfs 5 ,
+.Xr MAKE_DEV 9
  .Sh AUTHORS
  This manual page was written by
  .An Robert Watson .
+.Sh BUGS
+Disk aliases are not a general purpose aliasing mechanism, but are
+intended only to ease the transition from one name to another.
+They can be used to ensure that nvd0 and nda0 are the same thing.
+They cannot be used to implement the diskX concept from macOS.

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Mon Aug  7 21:12:33 2017(r322197)
+++ head/sys/geom/geom_disk.c   Mon Aug  7 21:12:38 2017(r322198)
@@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag)
struct g_provider *pp;
struct disk *dp;
struct g_disk_softc *sc;
+   struct disk_alias *dap;
char tmpstr[80];
  
  	if (flag == EV_CANCEL)

@@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag)
sc->dp = dp;
gp = g_new_geomf(_disk_class, "%s%d", dp->d_name, dp->d_unit);
gp->softc = sc;
+   LIST_FOREACH(dap, >d_aliases, da_next) {
+   snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, 
dp->d_unit);
+   g_geom_add_alias(gp, tmpstr);
+   }
pp = g_new_providerf(gp, "%s", gp->name);
devstat_remove_entry(pp->stat);
pp->stat = NULL;
@@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag)
struct disk *dp;
struct g_geom *gp;
struct g_disk_softc *sc;
+   struct disk_alias *dap, *daptmp;
  
  	g_topology_assert();

dp = ptr;
@@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag)
dp->d_geom = NULL;
g_wither_geom(gp, ENXIO);
}
+   LIST_FOREACH_SAFE(dap, >d_aliases, da_next, daptmp)
+   g_free(dap);
  
  	g_free(dp);

  }
@@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size)
  struct disk *
  disk_alloc(void)
  {
+   struct disk *dp;
  
-	return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO));

+   dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO);
+   LIST_INIT(>d_aliases);
+   return (dp);
  }
  
  void

@@ -882,6 +893,18 

svn commit: r322201 - head/sbin/fsck_ffs

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:23:59 2017
New Revision: 322201
URL: https://svnweb.freebsd.org/changeset/base/322201

Log:
  In debug mode, print the differences between the superblock and
  alternate superblock when the values disagree and we're going to
  reject it.
  
  Differential Revision: https://reviews.freebsd.org/D11589

Modified:
  head/sbin/fsck_ffs/setup.c

Modified: head/sbin/fsck_ffs/setup.c
==
--- head/sbin/fsck_ffs/setup.c  Mon Aug  7 21:23:54 2017(r322200)
+++ head/sbin/fsck_ffs/setup.c  Mon Aug  7 21:23:59 2017(r322201)
@@ -294,7 +294,7 @@ int
 readsb(int listerr)
 {
ufs2_daddr_t super;
-   int i;
+   int i, bad;
 
if (bflag) {
super = bflag;
@@ -344,43 +344,53 @@ readsb(int listerr)
dev_bsize = sblock.fs_fsize / fsbtodb(, 1);
sblk.b_bno = super / dev_bsize;
sblk.b_size = SBLOCKSIZE;
-   if (bflag)
-   goto out;
/*
 * Compare all fields that should not differ in alternate super block.
 * When an alternate super-block is specified this check is skipped.
 */
+   if (bflag)
+   goto out;
getblk(, cgsblock(, sblock.fs_ncg - 1), sblock.fs_sbsize);
if (asblk.b_errs)
return (0);
-   if (altsblock.fs_sblkno != sblock.fs_sblkno ||
-   altsblock.fs_cblkno != sblock.fs_cblkno ||
-   altsblock.fs_iblkno != sblock.fs_iblkno ||
-   altsblock.fs_dblkno != sblock.fs_dblkno ||
-   altsblock.fs_ncg != sblock.fs_ncg ||
-   altsblock.fs_bsize != sblock.fs_bsize ||
-   altsblock.fs_fsize != sblock.fs_fsize ||
-   altsblock.fs_frag != sblock.fs_frag ||
-   altsblock.fs_bmask != sblock.fs_bmask ||
-   altsblock.fs_fmask != sblock.fs_fmask ||
-   altsblock.fs_bshift != sblock.fs_bshift ||
-   altsblock.fs_fshift != sblock.fs_fshift ||
-   altsblock.fs_fragshift != sblock.fs_fragshift ||
-   altsblock.fs_fsbtodb != sblock.fs_fsbtodb ||
-   altsblock.fs_sbsize != sblock.fs_sbsize ||
-   altsblock.fs_nindir != sblock.fs_nindir ||
-   altsblock.fs_inopb != sblock.fs_inopb ||
-   altsblock.fs_cssize != sblock.fs_cssize ||
-   altsblock.fs_ipg != sblock.fs_ipg ||
-   altsblock.fs_fpg != sblock.fs_fpg ||
-   altsblock.fs_magic != sblock.fs_magic) {
+   bad = 0;
+#define CHK(x, y)  \
+   if (altsblock.x != sblock.x) {  \
+   bad++;  \
+   if (listerr && debug)   \
+   printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs 
" y "\n", \
+   #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \
+   }
+   CHK(fs_sblkno, "%jd");
+   CHK(fs_cblkno, "%jd");
+   CHK(fs_iblkno, "%jd");
+   CHK(fs_dblkno, "%jd");
+   CHK(fs_ncg, "%jd");
+   CHK(fs_bsize, "%jd");
+   CHK(fs_fsize, "%jd");
+   CHK(fs_frag, "%jd");
+   CHK(fs_bmask, "%#jx");
+   CHK(fs_fmask, "%#jx");
+   CHK(fs_bshift, "%jd");
+   CHK(fs_fshift, "%jd");
+   CHK(fs_fragshift, "%jd");
+   CHK(fs_fsbtodb, "%jd");
+   CHK(fs_sbsize, "%jd");
+   CHK(fs_nindir, "%jd");
+   CHK(fs_inopb, "%jd");
+   CHK(fs_cssize, "%jd");
+   CHK(fs_ipg, "%jd");
+   CHK(fs_fpg, "%jd");
+   CHK(fs_magic, "%#jx");
+#undef CHK
+   if (bad) {
if (listerr == 0)
return (0);
if (preen)
printf("%s: ", cdevname);
printf(
"VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n"
-   "FIRST ALTERNATE LSB=%jd\n",
+   "LAST ALTERNATE LSB=%jd\n",
sblk.b_bno, asblk.b_bno);
if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0)
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322200 - head/sbin/fsck_ffs

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:23:54 2017
New Revision: 322200
URL: https://svnweb.freebsd.org/changeset/base/322200

Log:
  Make it possible to ignore superblock mismatch. This will not fix such
  a mismatch, but will allow fsck to continue when the last alternate
  superblock gets corrupted somehow.
  
  Also, remove searching for alternate super blocks. It should have been
  removed two years ago with r276737 by imp@. Leave minor vestiges in
  place in case someone wants to solve the hard problem of knowing where
  altnernate superblocks live without access to data formerly stored in
  disklabels.
  
  Differential Revision: https://reviews.freebsd.org/D11589

Modified:
  head/sbin/fsck_ffs/setup.c

Modified: head/sbin/fsck_ffs/setup.c
==
--- head/sbin/fsck_ffs/setup.c  Mon Aug  7 21:12:43 2017(r322199)
+++ head/sbin/fsck_ffs/setup.c  Mon Aug  7 21:23:54 2017(r322200)
@@ -68,10 +68,9 @@ static void badsb(int listerr, const char *s);
 int
 setup(char *dev)
 {
-   long cg, asked, i, j;
+   long asked, i, j;
long bmapsize;
struct stat statb;
-   struct fs proto;
size_t size;
 
havesb = 0;
@@ -178,26 +177,8 @@ setup(char *dev)
skipclean = 0;
if (bflag || preen)
return(0);
-   if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
-   return (0);
-   for (cg = 0; cg < proto.fs_ncg; cg++) {
-   bflag = fsbtodb(, cgsblock(, cg));
-   if (readsb(0) != 0)
-   break;
-   }
-   if (cg >= proto.fs_ncg) {
-   printf("%s %s\n%s %s\n%s %s\n",
-   "SEARCH FOR ALTERNATE SUPER-BLOCK",
-   "FAILED. YOU MUST USE THE",
-   "-b OPTION TO FSCK TO SPECIFY THE",
-   "LOCATION OF AN ALTERNATE",
-   "SUPER-BLOCK TO SUPPLY NEEDED",
-   "INFORMATION; SEE fsck_ffs(8).");
-   bflag = 0;
-   return(0);
-   }
-   pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag);
-   bflag = 0;
+   /* Looking for alternates is hard punt for now but retain 
structure */
+   return (0);
}
if (skipclean && ckclean && sblock.fs_clean) {
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
@@ -393,9 +374,16 @@ readsb(int listerr)
altsblock.fs_ipg != sblock.fs_ipg ||
altsblock.fs_fpg != sblock.fs_fpg ||
altsblock.fs_magic != sblock.fs_magic) {
-   badsb(listerr,
-   "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE");
-   return (0);
+   if (listerr == 0)
+   return (0);
+   if (preen)
+   printf("%s: ", cdevname);
+   printf(
+   "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n"
+   "FIRST ALTERNATE LSB=%jd\n",
+   sblk.b_bno, asblk.b_bno);
+   if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0)
+   return (0);
}
 out:
/*
@@ -415,17 +403,6 @@ out:
}
havesb = 1;
return (1);
-}
-
-static void
-badsb(int listerr, const char *s)
-{
-
-   if (!listerr)
-   return;
-   if (preen)
-   printf("%s: ", cdevname);
-   pfatal("BAD SUPER BLOCK: %s\n", s);
 }
 
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322199 - head/sys/cam/nvme

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:12:43 2017
New Revision: 322199
URL: https://svnweb.freebsd.org/changeset/base/322199

Log:
  Add nvd alias to nda ndoes.
  
  All ndaX and ndaXpY nodes will appear as nvdX and nvdXpY as well
  (through symlinks in devfs via the normal disk aliasing mechanism in
  GEOM).
  
  Differential Revision: https://reviews.freebsd.org/D11873

Modified:
  head/sys/cam/nvme/nvme_da.c

Modified: head/sys/cam/nvme/nvme_da.c
==
--- head/sys/cam/nvme/nvme_da.c Mon Aug  7 21:12:38 2017(r322198)
+++ head/sys/cam/nvme/nvme_da.c Mon Aug  7 21:12:43 2017(r322199)
@@ -808,6 +808,10 @@ ndaregister(struct cam_periph *periph, void *arg)
DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT | XPORT_DEVSTAT_TYPE(cpi.transport),
DEVSTAT_PRIORITY_DISK);
+   /*
+* Add alias for older nvd drives to ease transition.
+*/
+   disk_add_alias(disk, "nvd");
 
/*
 * Acquire a reference to the periph before we register with GEOM.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322198 - in head: share/man/man9 sys/geom

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:12:38 2017
New Revision: 322198
URL: https://svnweb.freebsd.org/changeset/base/322198

Log:
  Expose API to allow disks to ask for alias names in devfs.
  
  Implement disk_add_alias to allow aliases to be added to disks. All
  disk have a primary name (say "foo") can also have secondary names
  (say "bar") such that all instances of "foo" also have a "bar"
  alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes
  created by the foo driver and gpart, device nodes bar0, bar0p1, bar1,
  bar1s1 and bar1s1a will appear as symlinks back to the original nodes.
  This generalizes to multiple aliases. However, since the unit number
  follows the primary name, multiple device drivers can't create the
  same aliases unless those drives coorinate the unit number space (eg
  you couldn't add an alias 'disk' to both 'da' and 'ada' because it's
  possible to have da0 and ada0, because 'disk0' is ambiguous).
  
  Differential Revision: https://reviews.freebsd.org/D11873

Modified:
  head/share/man/man9/disk.9
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_disk.h

Modified: head/share/man/man9/disk.9
==
--- head/share/man/man9/disk.9  Mon Aug  7 21:12:33 2017(r322197)
+++ head/share/man/man9/disk.9  Mon Aug  7 21:12:38 2017(r322198)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 30, 2012
+.Dd August 3, 2017
 .Dt DISK 9
 .Os
 .Sh NAME
@@ -45,6 +45,8 @@
 .Fn disk_destroy "struct disk *disk"
 .Ft int
 .Fn disk_resize "struct disk *disk" "int flags"
+.Ft void
+.Fn disk_add_alias "struct disk *disk" "const char *alias"
 .Sh DESCRIPTION
 The disk storage API permits kernel device drivers providing access to
 disk-like storage devices to advertise the device to other kernel
@@ -69,6 +71,20 @@ function,
 fill in the fields and call
 .Fn disk_create
 when the device is ready to service requests.
+.Fn disk_add_alias
+adds an alias for the disk and must be called before
+.Fn disk_create ,
+but may be called multiple times.
+For each alias added, a device node will be created with
+.Xr make_dev_alias 9
+in the same way primary device nodes are created with
+.Xr make_dev 9
+for
+.Va d_name
+and
+.Va d_unit .
+Care should be taken to ensure that only one driver creates aliases
+for any given name.
 .Fn disk_resize
 can be called by the driver after modifying
 .Va d_mediasize
@@ -227,7 +243,13 @@ structure for this disk device.
 .El
 .Sh SEE ALSO
 .Xr GEOM 4 ,
-.Xr devfs 5
+.Xr devfs 5 ,
+.Xr MAKE_DEV 9
 .Sh AUTHORS
 This manual page was written by
 .An Robert Watson .
+.Sh BUGS
+Disk aliases are not a general purpose aliasing mechanism, but are
+intended only to ease the transition from one name to another.
+They can be used to ensure that nvd0 and nda0 are the same thing.
+They cannot be used to implement the diskX concept from macOS.

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Mon Aug  7 21:12:33 2017(r322197)
+++ head/sys/geom/geom_disk.c   Mon Aug  7 21:12:38 2017(r322198)
@@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag)
struct g_provider *pp;
struct disk *dp;
struct g_disk_softc *sc;
+   struct disk_alias *dap;
char tmpstr[80];
 
if (flag == EV_CANCEL)
@@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag)
sc->dp = dp;
gp = g_new_geomf(_disk_class, "%s%d", dp->d_name, dp->d_unit);
gp->softc = sc;
+   LIST_FOREACH(dap, >d_aliases, da_next) {
+   snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, 
dp->d_unit);
+   g_geom_add_alias(gp, tmpstr);
+   }
pp = g_new_providerf(gp, "%s", gp->name);
devstat_remove_entry(pp->stat);
pp->stat = NULL;
@@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag)
struct disk *dp;
struct g_geom *gp;
struct g_disk_softc *sc;
+   struct disk_alias *dap, *daptmp;
 
g_topology_assert();
dp = ptr;
@@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag)
dp->d_geom = NULL;
g_wither_geom(gp, ENXIO);
}
+   LIST_FOREACH_SAFE(dap, >d_aliases, da_next, daptmp)
+   g_free(dap);
 
g_free(dp);
 }
@@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size)
 struct disk *
 disk_alloc(void)
 {
+   struct disk *dp;
 
-   return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO));
+   dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO);
+   LIST_INIT(>d_aliases);
+   return (dp);
 }
 
 void
@@ -882,6 +893,18 @@ disk_destroy(struct disk *dp)
if (dp->d_devstat != NULL)
devstat_remove_entry(dp->d_devstat);
g_post_event(g_disk_destroy, dp, M_WAITOK, NULL);
+}
+
+void
+disk_add_alias(struct disk *dp, const char *name)
+{
+   struct disk_alias *dap;
+
+   dap 

svn commit: r322196 - head/sys/geom

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:12:28 2017
New Revision: 322196
URL: https://svnweb.freebsd.org/changeset/base/322196

Log:
  Add aliasing concept to geom.
  
  Add an alias name list to geoms. Use them in geom_dev to create
  aliases. Previously, geom_dev would create an device node for the name
  of the geom. Now, additional nodes are created pointing back to the
  primary node with make_dev_alias_p. Aliases must be in place on the
  geom before any tasting occurs.
  
  Differential Revision: https://reviews.freebsd.org/D11873

Modified:
  head/sys/geom/geom.h
  head/sys/geom/geom_dev.c
  head/sys/geom/geom_dump.c
  head/sys/geom/geom_subr.c

Modified: head/sys/geom/geom.h
==
--- head/sys/geom/geom.hMon Aug  7 19:56:09 2017(r322195)
+++ head/sys/geom/geom.hMon Aug  7 21:12:28 2017(r322196)
@@ -120,6 +120,15 @@ struct g_class {
LIST_HEAD(,g_geom)  geom;
 };
 
+/*
+ * The g_geom_alias is a list node for aliases for the geom name
+ * for device node creation.
+ */
+struct g_geom_alias {
+   LIST_ENTRY(g_geom_alias) ga_next;
+   const char  *ga_alias;
+};
+
 #define G_VERSION_00   0x19950323
 #define G_VERSION_01   0x20041207  /* add fflag to g_ioctl_t */
 #define G_VERSION  G_VERSION_01
@@ -150,6 +159,7 @@ struct g_geom {
unsignedflags;
 #defineG_GEOM_WITHER   1
 #defineG_GEOM_VOLATILE_BIO 2
+   LIST_HEAD(,g_geom_alias) aliases;
 };
 
 /*
@@ -269,6 +279,7 @@ void g_destroy_provider(struct g_provider *pp);
 void g_detach(struct g_consumer *cp);
 void g_error_provider(struct g_provider *pp, int error);
 struct g_provider *g_provider_by_name(char const *arg);
+void g_geom_add_alias(struct g_geom *gp, const char *alias);
 int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
 #define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
 int g_handleattr(struct bio *bp, const char *attribute, const void *val,

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cMon Aug  7 19:56:09 2017(r322195)
+++ head/sys/geom/geom_dev.cMon Aug  7 21:12:28 2017(r322196)
@@ -315,10 +315,11 @@ static struct g_geom *
 g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
 {
struct g_geom *gp;
+   struct g_geom_alias *gap;
struct g_consumer *cp;
struct g_dev_softc *sc;
int error;
-   struct cdev *dev;
+   struct cdev *dev, *adev;
char buf[SPECNAMELEN + 6];
 
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
@@ -357,6 +358,23 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp,
g_dev_attrchanged(cp, "GEOM::physpath");
snprintf(buf, sizeof(buf), "cdev=%s", gp->name);
devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
+   /*
+* Now add all the aliases for this drive
+*/
+   LIST_FOREACH(gap, >geom->aliases, ga_next) {
+   error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, 
, dev,
+   "%s", gap->ga_alias);
+   if (error) {
+   printf("%s: make_dev_alias_p() failed (name=%s, 
error=%d)\n",
+   __func__, gap->ga_alias, error);
+   continue;
+   }
+   adev->si_flags |= SI_UNMAPPED;
+   adev->si_iosize_max = dev->si_iosize_max;
+   adev->si_drv2 = dev->si_drv2;
+   snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias);
+   devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
+   }
 
return (gp);
 }

Modified: head/sys/geom/geom_dump.c
==
--- head/sys/geom/geom_dump.c   Mon Aug  7 19:56:09 2017(r322195)
+++ head/sys/geom/geom_dump.c   Mon Aug  7 21:12:28 2017(r322196)
@@ -234,6 +234,7 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct
 {
struct g_consumer *cp2;
struct g_provider *pp2;
+   struct g_geom_alias *gap;
 
sbuf_printf(sb, "\n", gp);
sbuf_printf(sb, "  \n", gp->class);
@@ -258,6 +259,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct
if (pp != NULL && pp != pp2)
continue;
g_conf_provider(sb, pp2);
+   }
+   LIST_FOREACH(gap, >aliases, ga_next) {
+   sbuf_printf(sb, "  \n");
+   g_conf_printf_escaped(sb, "%s", gap->ga_alias);
+   sbuf_printf(sb, "  \n");
}
sbuf_printf(sb, "\n");
 }

Modified: head/sys/geom/geom_subr.c
==
--- head/sys/geom/geom_subr.c   Mon Aug  7 19:56:09 2017

svn commit: r322197 - head/sys/geom/part

2017-08-07 Thread Warner Losh
Author: imp
Date: Mon Aug  7 21:12:33 2017
New Revision: 322197
URL: https://svnweb.freebsd.org/changeset/base/322197

Log:
  Add alias support to gpart.
  
  When we're creating new providers for each of the partitions, add
  aliases to the geom before we create the provider so when geom_dev
  tastes the provider, the aliases are in place so the proper /dev
  entries are created. So foo5p6 gets created as an alias for bar5p6
  when foo is an alias for bar in the geom we're partitioning with
  g_part. This also copies aliases from the container geom (eg disk) to
  the label geom (the disk with GPT partitioning) so that aliases nest
  properly.
  
  Differential Revision: https://reviews.freebsd.org/D11873

Modified:
  head/sys/geom/part/g_part.c

Modified: head/sys/geom/part/g_part.c
==
--- head/sys/geom/part/g_part.c Mon Aug  7 21:12:28 2017(r322196)
+++ head/sys/geom/part/g_part.c Mon Aug  7 21:12:33 2017(r322197)
@@ -429,6 +429,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t
struct g_consumer *cp;
struct g_provider *pp;
struct sbuf *sb;
+   struct g_geom_alias *gap;
off_t offset;
 
cp = LIST_FIRST(>consumer);
@@ -439,6 +440,19 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t
entry->gpe_offset = offset;
 
if (entry->gpe_pp == NULL) {
+   /*
+* Add aliases to the geom before we create the provider so that
+* geom_dev can taste it with all the aliases in place so all
+* the aliased dev_t instances get created for each partition
+* (eg foo5p7 gets created for bar5p7 when foo is an alias of 
bar).
+*/
+   LIST_FOREACH(gap, >gpt_gp->aliases, ga_next) {
+   sb = sbuf_new_auto();
+   G_PART_FULLNAME(table, entry, sb, gap->ga_alias);
+   sbuf_finish(sb);
+   g_geom_add_alias(gp, sbuf_data(sb));
+   sbuf_delete(sb);
+   }
sb = sbuf_new_auto();
G_PART_FULLNAME(table, entry, sb, gp->name);
sbuf_finish(sb);
@@ -1901,6 +1915,7 @@ g_part_taste(struct g_class *mp, struct g_provider *pp
struct g_part_entry *entry;
struct g_part_table *table;
struct root_hold_token *rht;
+   struct g_geom_alias *gap;
int attr, depth;
int error;
 
@@ -1913,10 +1928,12 @@ g_part_taste(struct g_class *mp, struct g_provider *pp
 
/*
 * Create a GEOM with consumer and hook it up to the provider.
-* With that we become part of the topology. Optain read access
+* With that we become part of the topology. Obtain read access
 * to the provider.
 */
gp = g_new_geomf(mp, "%s", pp->name);
+   LIST_FOREACH(gap, >geom->aliases, ga_next)
+   g_geom_add_alias(gp, gap->ga_alias);
cp = g_new_consumer(gp);
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322179 - head/sys/geom/journal

2017-08-07 Thread Kirk McKusick
Author: mckusick
Date: Mon Aug  7 19:40:03 2017
New Revision: 322179
URL: https://svnweb.freebsd.org/changeset/base/322179

Log:
  gjournal is broken in handling its flush_queue. If we have 10 bio's
  in the flush_queue:
   1 2 3 4 5 6 7 8 9 10
  and another 10 bio's go into the flush queue after only the first five
  bio's are removed from the flush queue, the queue should look like:
   6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,
  but because of the bug we end up with
   6 11 12 13 14  15 16 17 18 19 20 7 8 9 10.
  So the sequence of the bio's is damaged in the flush queue (and
  therefore in the journal on disk !). This error can be triggered by
  ffs_snapshot() when a block is read with readblock() and gjournal finds
  this block in the broken flush queue before it goes to the correct
  active queue.
  
  The fix is to place all new blocks at the end of the queue.
  
  Submitted by: Dr. Andreas Longwitz 
  Discussed with: kib
  MFC after: 1 week

Modified:
  head/sys/geom/journal/g_journal.c
  head/sys/geom/journal/g_journal.h

Modified: head/sys/geom/journal/g_journal.c
==
--- head/sys/geom/journal/g_journal.c   Mon Aug  7 19:18:27 2017
(r322178)
+++ head/sys/geom/journal/g_journal.c   Mon Aug  7 19:40:03 2017
(r322179)
@@ -1261,7 +1261,7 @@ g_journal_flush(struct g_journal_softc *sc)
strlcpy(hdr.jrh_magic, GJ_RECORD_HEADER_MAGIC, sizeof(hdr.jrh_magic));
 
bioq = >sc_active.jj_queue;
-   pbp = sc->sc_flush_queue;
+   GJQ_LAST(sc->sc_flush_queue, pbp);
 
fbp = g_alloc_bio();
fbp->bio_parent = NULL;

Modified: head/sys/geom/journal/g_journal.h
==
--- head/sys/geom/journal/g_journal.h   Mon Aug  7 19:18:27 2017
(r322178)
+++ head/sys/geom/journal/g_journal.h   Mon Aug  7 19:40:03 2017
(r322179)
@@ -182,6 +182,17 @@ struct g_journal_softc {
(pbp)->bio_next = (bp); \
}   \
 } while (0)
+#define GJQ_LAST(head, bp) do {
\
+   struct bio *_bp;\
+   \
+   if ((head) == NULL) {   \
+   (bp) = (head);  \
+   break;  \
+   }   \
+   for (_bp = (head); _bp->bio_next != NULL; _bp = _bp->bio_next)  \
+   continue;   \
+   (bp) = (_bp);   \
+} while (0)
 #defineGJQ_FIRST(head) (head)
 #defineGJQ_REMOVE(head, bp)do {
\
struct bio *_bp;\
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322178 - head/sys/geom/journal

2017-08-07 Thread Kirk McKusick
Author: mckusick
Date: Mon Aug  7 19:18:27 2017
New Revision: 322178
URL: https://svnweb.freebsd.org/changeset/base/322178

Log:
  sysctl kern.geom.journal.cache.limit shows negative value for FreeBSD/amd64
  system having over 4GB RAM. That's due to:
  
  1) the limit being u_int instead of u_long like vm.kmem_size (the limit is
 half of vm.kmem_size by default for amd64);
  2) sysctl handler g_journal_cache_limit_sysctl() using u_int instead of 
u_long.
  
  The fix is to replace u_int with u_long for the kern.geom.journal.cache.limit
  sysctl variable.
  
  PR: 198500
  Submitted by: Dr. Andreas Longwitz 
  Reported by: Eugene Grosbein
  Discussed with: kib
  MFC after: 1 week

Modified:
  head/sys/geom/journal/g_journal.c

Modified: head/sys/geom/journal/g_journal.c
==
--- head/sys/geom/journal/g_journal.c   Mon Aug  7 18:01:27 2017
(r322177)
+++ head/sys/geom/journal/g_journal.c   Mon Aug  7 19:18:27 2017
(r322178)
@@ -130,26 +130,26 @@ SYSCTL_PROC(_kern_geom_journal, OID_AUTO, record_entri
 SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW,
 _journal_do_optimize, 0, "Try to combine bios on flush and copy");
 
-static u_int g_journal_cache_used = 0;
-static u_int g_journal_cache_limit = 64 * 1024 * 1024;
+static u_long g_journal_cache_used = 0;
+static u_long g_journal_cache_limit = 64 * 1024 * 1024;
 static u_int g_journal_cache_divisor = 2;
 static u_int g_journal_cache_switch = 90;
 static u_int g_journal_cache_misses = 0;
 static u_int g_journal_cache_alloc_failures = 0;
-static u_int g_journal_cache_low = 0;
+static u_long g_journal_cache_low = 0;
 
 static SYSCTL_NODE(_kern_geom_journal, OID_AUTO, cache, CTLFLAG_RW, 0,
 "GEOM_JOURNAL cache");
-SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD,
+SYSCTL_ULONG(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD,
 _journal_cache_used, 0, "Number of allocated bytes");
 static int
 g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS)
 {
-   u_int limit;
+   u_long limit;
int error;
 
limit = g_journal_cache_limit;
-   error = sysctl_handle_int(oidp, , 0, req);
+   error = sysctl_handle_long(oidp, , 0, req);
if (error != 0 || req->newptr == NULL)
return (error);
g_journal_cache_limit = limit;
@@ -157,7 +157,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS)
return (0);
 }
 SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit,
-CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I",
+CTLTYPE_ULONG | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I",
 "Maximum number of allocated bytes");
 SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN,
 _journal_cache_divisor, 0,
@@ -3046,9 +3046,9 @@ g_journal_switcher(void *arg)
kproc_exit(0);
}
if (error == 0 && g_journal_sync_requested == 0) {
-   GJ_DEBUG(1, "Out of cache, force switch (used=%u "
-   "limit=%u).", g_journal_cache_used,
-   g_journal_cache_limit);
+   GJ_DEBUG(1, "Out of cache, force switch (used=%jd "
+   "limit=%jd).", (intmax_t)g_journal_cache_used,
+   (intmax_t)g_journal_cache_limit);
}
GJ_TIMER_START(1, );
g_journal_do_switch(mp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322177 - head/usr.bin/indent

2017-08-07 Thread Kyle Evans
Author: kevans
Date: Mon Aug  7 18:01:27 2017
New Revision: 322177
URL: https://svnweb.freebsd.org/changeset/base/322177

Log:
  Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
  
  Instead of using a non-configurable ".BAK" suffix, respect the
  SIMPLE_BACKUP_SUFFIX environment variable also used by patch(1). This
  simplifies cleanup operations in some patch/indent workflows.
  
  Reviewed by:  cem (earlier version), emaste, pstef
  Approved by:  emaste (mentor)
  Differential Revision:https://reviews.freebsd.org/D10921

Modified:
  head/usr.bin/indent/indent.1
  head/usr.bin/indent/indent.c

Modified: head/usr.bin/indent/indent.1
==
--- head/usr.bin/indent/indent.1Mon Aug  7 17:30:22 2017
(r322176)
+++ head/usr.bin/indent/indent.1Mon Aug  7 18:01:27 2017
(r322177)
@@ -30,7 +30,7 @@
 .\"@(#)indent.18.1 (Berkeley) 7/1/93
 .\" $FreeBSD$
 .\"
-.Dd July 25, 2017
+.Dd August 7, 2017
 .Dt INDENT 1
 .Os
 .Sh NAME
@@ -119,7 +119,10 @@ If
 is named
 .Sq Pa /blah/blah/file ,
 the backup file is named
-.Sq Pa file.BAK .
+.Sq Pa file.BAK
+by default. The extension used for the backup file may be overridden using the
+.Ev SIMPLE_BACKUP_SUFFIX
+environment variable.
 .Pp
 If
 .Ar output-file

Modified: head/usr.bin/indent/indent.c
==
--- head/usr.bin/indent/indent.cMon Aug  7 17:30:22 2017
(r322176)
+++ head/usr.bin/indent/indent.cMon Aug  7 18:01:27 2017
(r322177)
@@ -71,6 +71,8 @@ const char *in_name = "Standard Input";   /* will always
 * file */
 const char *out_name = "Standard Output";  /* will always point to name
 * of output file */
+const char *simple_backup_suffix = ".BAK"; /* Suffix to use for backup
+* files */
 charbakfile[MAXPATHLEN] = "";
 
 int
@@ -99,8 +101,8 @@ main(int argc, char **argv)
 
 int last_else = 0; /* true iff last keyword was an else */
 const char *profile_name = NULL;
+const char *envval = NULL;
 
-
 /*---*\
 |INITIALIZATION  |
 \*---*/
@@ -160,6 +162,10 @@ main(int argc, char **argv)
 output = NULL;
 tabs_to_var = 0;
 
+envval = getenv("SIMPLE_BACKUP_SUFFIX");
+if (envval)
+simple_backup_suffix = envval;
+
 /*--*\
 |  COMMAND LINE SCAN|
 \*--*/
@@ -1234,7 +1240,7 @@ bakcopy(void)
p--;
 if (*p == '/')
p++;
-sprintf(bakfile, "%s.BAK", p);
+sprintf(bakfile, "%s%s", p, simple_backup_suffix);
 
 /* copy in_name to backup file */
 bakchn = creat(bakfile, 0600);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322175 - head/sys/amd64/amd64

2017-08-07 Thread Konstantin Belousov
Author: kib
Date: Mon Aug  7 17:29:54 2017
New Revision: 322175
URL: https://svnweb.freebsd.org/changeset/base/322175

Log:
  Avoid DI recursion when reclaim_pv_chunk() is called from
  pmap_advise() or pmap_remove().
  
  Reported and tested by:   pho (previous version)
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Mon Aug  7 17:29:48 2017(r322174)
+++ head/sys/amd64/amd64/pmap.c Mon Aug  7 17:29:54 2017(r322175)
@@ -428,8 +428,15 @@ static struct lock_object invl_gen_ts = {
.lo_name = "invlts",
 };
 
+static bool
+pmap_not_in_di(void)
+{
+
+   return (curthread->td_md.md_invl_gen.gen == 0);
+}
+
 #definePMAP_ASSERT_NOT_IN_DI() \
-KASSERT(curthread->td_md.md_invl_gen.gen == 0, ("DI already started"))
+KASSERT(pmap_not_in_di(), ("DI already started"))
 
 /*
  * Start a new Delayed Invalidation (DI) block of code, executed by
@@ -2856,6 +2863,19 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG
"Current number of spare pv entries");
 #endif
 
+static void
+reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked_pmap, bool start_di)
+{
+
+   if (pmap == NULL)
+   return;
+   pmap_invalidate_all(pmap);
+   if (pmap != locked_pmap)
+   PMAP_UNLOCK(pmap);
+   if (start_di)
+   pmap_delayed_invl_finished();
+}
+
 /*
  * We are in a serious low memory condition.  Resort to
  * drastic measures to free some pages so we can allocate
@@ -2883,6 +2903,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
struct spglist free;
uint64_t inuse;
int bit, field, freed;
+   bool start_di;
 
PMAP_LOCK_ASSERT(locked_pmap, MA_OWNED);
KASSERT(lockp != NULL, ("reclaim_pv_chunk: lockp is NULL"));
@@ -2891,19 +2912,21 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
PG_G = PG_A = PG_M = PG_RW = 0;
SLIST_INIT();
TAILQ_INIT(_tail);
-   pmap_delayed_invl_started();
+
+   /*
+* A delayed invalidation block should already be active if
+* pmap_advise() or pmap_remove() called this function by way
+* of pmap_demote_pde_locked().
+*/
+   start_di = pmap_not_in_di();
+
mtx_lock(_chunks_mutex);
while ((pc = TAILQ_FIRST(_chunks)) != NULL && SLIST_EMPTY()) {
TAILQ_REMOVE(_chunks, pc, pc_lru);
mtx_unlock(_chunks_mutex);
if (pmap != pc->pc_pmap) {
-   if (pmap != NULL) {
-   pmap_invalidate_all(pmap);
-   if (pmap != locked_pmap)
-   PMAP_UNLOCK(pmap);
-   }
-   pmap_delayed_invl_finished();
-   pmap_delayed_invl_started();
+   reclaim_pv_chunk_leave_pmap(pmap, locked_pmap,
+   start_di);
pmap = pc->pc_pmap;
/* Avoid deadlock and lock recursion. */
if (pmap > locked_pmap) {
@@ -2920,6 +2943,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
PG_A = pmap_accessed_bit(pmap);
PG_M = pmap_modified_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
+   if (start_di)
+   pmap_delayed_invl_started();
}
 
/*
@@ -2994,12 +3019,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
}
TAILQ_CONCAT(_chunks, _tail, pc_lru);
mtx_unlock(_chunks_mutex);
-   if (pmap != NULL) {
-   pmap_invalidate_all(pmap);
-   if (pmap != locked_pmap)
-   PMAP_UNLOCK(pmap);
-   }
-   pmap_delayed_invl_finished();
+   reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di);
if (m_pc == NULL && !SLIST_EMPTY()) {
m_pc = SLIST_FIRST();
SLIST_REMOVE_HEAD(, plinks.s.ss);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322171 - head/sys/amd64/amd64

2017-08-07 Thread Konstantin Belousov
Author: kib
Date: Mon Aug  7 17:23:10 2017
New Revision: 322171
URL: https://svnweb.freebsd.org/changeset/base/322171

Log:
  Explain why delayed invalidation is not required in pmap_protect() and
  pmap_remove_pages().
  
  Submitted by: alc
  MFC after:1 week

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Mon Aug  7 16:23:53 2017(r322170)
+++ head/sys/amd64/amd64/pmap.c Mon Aug  7 17:23:10 2017(r322171)
@@ -4085,6 +4085,26 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t
PG_RW = pmap_rw_bit(pmap);
anychanged = FALSE;
 
+   /*
+* Although this function delays and batches the invalidation
+* of stale TLB entries, it does not need to call
+* pmap_delayed_invl_started() and
+* pmap_delayed_invl_finished(), because it does not
+* ordinarily destroy mappings.  Stale TLB entries from
+* protection-only changes need only be invalidated before the
+* pmap lock is released, because protection-only changes do
+* not destroy PV entries.  Even operations that iterate over
+* a physical page's PV list of mappings, like
+* pmap_remove_write(), acquire the pmap lock for each
+* mapping.  Consequently, for protection-only changes, the
+* pmap lock suffices to synchronize both page table and TLB
+* updates.
+*
+* This function only destroys a mapping if pmap_demote_pde()
+* fails.  In that case, stale TLB entries are immediately
+* invalidated.
+*/
+   
PMAP_LOCK(pmap);
for (; sva < eva; sva = va_next) {
 
@@ -5469,6 +5489,15 @@ pmap_page_is_mapped(vm_page_t m)
  * no processor is currently accessing the user address space.  In
  * particular, a page table entry's dirty bit won't change state once
  * this function starts.
+ *
+ * Although this function destroys all of the pmap's managed,
+ * non-wired mappings, it can delay and batch the invalidation of TLB
+ * entries without calling pmap_delayed_invl_started() and
+ * pmap_delayed_invl_finished().  Because the pmap is not active on
+ * any other processor, none of these TLB entries will ever be used
+ * before their eventual invalidation.  Consequently, there is no need
+ * for either pmap_remove_all() or pmap_remove_write() to wait for
+ * that eventual TLB invalidation.
  */
 void
 pmap_remove_pages(pmap_t pmap)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322170 - head

2017-08-07 Thread Dimitry Andric
Author: dim
Date: Mon Aug  7 16:23:53 2017
New Revision: 322170
URL: https://svnweb.freebsd.org/changeset/base/322170

Log:
  Follow-up to r321684 (Don't use libc++ when cross-building for gcc
  arches), and handle two more cases where libc++ includes could be
  incorrectly enabled, in case the host compiler is clang 5.0.0, and the
  target (cross) compiler is gcc 4.2.1.
  
  Noted by: bdrewery
  MFC after:3 days
  X-MFC-With:   321684

Modified:
  head/Makefile.inc1
  head/Makefile.libcompat

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Mon Aug  7 14:34:05 2017(r322169)
+++ head/Makefile.inc1  Mon Aug  7 16:23:53 2017(r322170)
@@ -2742,8 +2742,7 @@ CD2CFLAGS+=   -isystem ${XDDESTDIR}/usr/include 
-L${XDDE
 # combined with --sysroot.
 CD2CFLAGS+=-B${XDDESTDIR}/usr/lib
 # Force using libc++ for external GCC.
-# XXX: This should be checking MK_GNUCXX == no
-.if ${X_COMPILER_VERSION} >= 40800
+.if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
 CD2CXXFLAGS+=  -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
-nostdinc++
 .endif

Modified: head/Makefile.libcompat
==
--- head/Makefile.libcompat Mon Aug  7 14:34:05 2017(r322169)
+++ head/Makefile.libcompat Mon Aug  7 16:23:53 2017(r322170)
@@ -99,8 +99,7 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat
 # sysroot path which --sysroot does not actually do for headers.
 LIBCOMPATCFLAGS+=  -isystem ${LIBCOMPATTMP}/usr/include
 # Force using libc++ for external GCC.
-# XXX: This should be checking MK_GNUCXX == no
-.if ${X_COMPILER_VERSION} >= 40800 && \
+.if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 && \
 (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
 LIBCOMPATCXXFLAGS+=-isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \
-nostdinc++
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322169 - in head/sys/compat/linuxkpi/common: include/linux src

2017-08-07 Thread Alexander Motin
Author: mav
Date: Mon Aug  7 14:34:05 2017
New Revision: 322169
URL: https://svnweb.freebsd.org/changeset/base/322169

Log:
  Fix hrtimer_active() in case of cancellation.
  
  While there, switch to FreeBSD internal callout active status.
  
  Reviewed by:  markj, hselasky
  Sponsored by: iXsystems, Inc.
  Differential Revision:https://reviews.freebsd.org/D11900

Modified:
  head/sys/compat/linuxkpi/common/include/linux/hrtimer.h
  head/sys/compat/linuxkpi/common/src/linux_hrtimer.c

Modified: head/sys/compat/linuxkpi/common/include/linux/hrtimer.h
==
--- head/sys/compat/linuxkpi/common/include/linux/hrtimer.h Mon Aug  7 
14:09:57 2017(r322168)
+++ head/sys/compat/linuxkpi/common/include/linux/hrtimer.h Mon Aug  7 
14:34:05 2017(r322169)
@@ -48,7 +48,6 @@ struct hrtimer {
enum hrtimer_restart (*function)(struct hrtimer *);
struct mtx mtx;
struct callout callout;
-   uint32_t flags;
 };
 
 #definehrtimer_active(hrtimer) linux_hrtimer_active(hrtimer)

Modified: head/sys/compat/linuxkpi/common/src/linux_hrtimer.c
==
--- head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Mon Aug  7 14:09:57 
2017(r322168)
+++ head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Mon Aug  7 14:34:05 
2017(r322169)
@@ -37,9 +37,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-/* hrtimer flags */
-#defineHRTIMER_ACTIVE  0x01
-
 static void
 hrtimer_call_handler(void *arg)
 {
@@ -49,7 +46,7 @@ hrtimer_call_handler(void *arg)
hrtimer = arg;
ret = hrtimer->function(hrtimer);
MPASS(ret == HRTIMER_NORESTART);
-   hrtimer->flags &= ~HRTIMER_ACTIVE;
+   callout_deactivate(>callout);
 }
 
 bool
@@ -58,19 +55,20 @@ linux_hrtimer_active(struct hrtimer *hrtimer)
bool ret;
 
mtx_lock(>mtx);
-   ret = (hrtimer->flags & HRTIMER_ACTIVE) != 0;
+   ret = callout_active(>callout);
mtx_unlock(>mtx);
return (ret);
 }
 
+/*
+ * Cancel active hrtimer.
+ * Return 1 if timer was active and cancellation succeeded, or 0 otherwise.
+ */
 int
 linux_hrtimer_cancel(struct hrtimer *hrtimer)
 {
 
-   if (!hrtimer_active(hrtimer))
-   return (0);
-   (void)callout_drain(>callout);
-   return (1);
+   return (callout_drain(>callout) > 0);
 }
 
 void
@@ -78,7 +76,6 @@ linux_hrtimer_init(struct hrtimer *hrtimer)
 {
 
hrtimer->function = NULL;
-   hrtimer->flags = 0;
mtx_init(>mtx, "hrtimer", NULL, MTX_DEF | MTX_RECURSE);
callout_init_mtx(>callout, >mtx, 0);
 }
@@ -103,6 +100,5 @@ linux_hrtimer_start_range_ns(struct hrtimer *hrtimer, 
mtx_lock(>mtx);
callout_reset_sbt(>callout, nstosbt(time.tv64), nstosbt(nsec),
hrtimer_call_handler, hrtimer, 0);
-   hrtimer->flags |= HRTIMER_ACTIVE;
mtx_unlock(>mtx);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322168 - in head: cddl/contrib/opensolaris/lib/libdtrace/common contrib/compiler-rt/lib/builtins contrib/compiler-rt/lib/sanitizer_common contrib/elftoolchain/libelf contrib/jemalloc/i...

2017-08-07 Thread Ruslan Bukin
Author: br
Date: Mon Aug  7 14:09:57 2017
New Revision: 322168
URL: https://svnweb.freebsd.org/changeset/base/322168

Log:
  o Replace __riscv__ with __riscv
  o Replace __riscv64 with (__riscv && __riscv_xlen == 64)
  
  This is required to support new GCC 7.1 compiler.
  This is compatible with current GCC 6.1 compiler.
  
  RISC-V is extensible ISA and the idea here is to have built-in define
  per each extension, so together with __riscv we will have some subset
  of these as well (depending on -march string passed to compiler):
  
  __riscv_compressed
  __riscv_atomic
  __riscv_mul
  __riscv_div
  __riscv_muldiv
  __riscv_fdiv
  __riscv_fsqrt
  __riscv_float_abi_soft
  __riscv_float_abi_single
  __riscv_float_abi_double
  __riscv_cmodel_medlow
  __riscv_cmodel_medany
  __riscv_cmodel_pic
  __riscv_xlen
  
  Reviewed by:  ngie
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D11901

Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
  head/contrib/compiler-rt/lib/builtins/int_lib.h
  
head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
  head/contrib/elftoolchain/libelf/_libelf_config.h
  head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_types.h
  head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
  head/contrib/llvm/projects/libunwind/include/__libunwind_config.h
  head/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S
  head/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S
  head/contrib/llvm/projects/libunwind/src/config.h
  head/contrib/llvm/projects/libunwind/src/libunwind.cpp
  head/contrib/netbsd-tests/lib/libc/gen/t_dir.c
  head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
  head/contrib/zstd/lib/common/xxhash.c
  head/lib/libc/gen/tls.c
  head/lib/libproc/proc_bkpt.c
  head/lib/libproc/proc_regs.c
  head/libexec/rtld-elf/rtld.c
  head/share/man/man7/arch.7
  head/sys/cddl/compat/opensolaris/sys/atomic.h
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
  head/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h
  head/sys/cddl/dev/profile/profile.c
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/dev/sym/sym_hipd.c
  head/sys/kern/subr_devmap.c
  head/sys/modules/dtrace/dtraceall/dtraceall.c
  head/sys/sys/cdefs.h
  head/usr.bin/ldd/ldd.c
  head/usr.bin/xlint/lint1/param.h

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
==
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.cMon Aug 
 7 14:04:19 2017(r322167)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.cMon Aug 
 7 14:09:57 2017(r322168)
@@ -250,7 +250,7 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__L
dofr[j].dofr_offset + 4;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
R_PPC_REL32);
-#elif defined(__riscv__)
+#elif defined(__riscv)
 /* XXX */
 printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
 #else
@@ -430,7 +430,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof,
dofr[j].dofr_offset;
rel->r_info = ELF64_R_INFO(count + dep->de_global,
R_PPC64_REL64);
-#elif defined(__riscv__)
+#elif defined(__riscv)
 /* XXX */
 #elif defined(__i386) || defined(__amd64)
rel->r_offset = s->dofs_offset +
@@ -904,7 +904,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, 
 
return (0);
 }
-#elif defined(__riscv__)
+#elif defined(__riscv)
 /* XXX */
 static int
 dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
==
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c  Mon Aug 
 7 14:04:19 2017(r322167)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c  Mon Aug 
 7 14:09:57 2017(r322168)
@@ -311,7 +311,7 @@ pfprint_fp(dtrace_hdl_t *dtp, FILE *fp, const char *fo
return (dt_printf(dtp, fp, format,
*((double *)addr) / n));
 #if !defined(__arm__) && !defined(__powerpc__) && \
-!defined(__mips__) && !defined(__riscv__)
+!defined(__mips__) && !defined(__riscv)
case sizeof (long double):
return (dt_printf(dtp, fp, format,
*((long double *)addr) / ldn));

Modified: head/contrib/compiler-rt/lib/builtins/int_lib.h
==
--- head/contrib/compiler-rt/lib/builtins/int_lib.h Mon Aug  7 14:04:19 
2017(r322167)
+++ 

svn commit: r322167 - head/sys/conf

2017-08-07 Thread Navdeep Parhar
Author: np
Date: Mon Aug  7 14:04:19 2017
New Revision: 322167
URL: https://svnweb.freebsd.org/changeset/base/322167

Log:
  cxgbe(4): Add the T6 and T5 Unified Wire configuration files to the
  kernel, just like for T4, when the driver is compiled into the kernel.
  
  Reported by:  mav@
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Mon Aug  7 13:27:35 2017(r322166)
+++ head/sys/conf/files Mon Aug  7 14:04:19 2017(r322167)
@@ -1399,7 +1399,7 @@ t4fw.fw   optional cxgbe  
\
no-obj no-implicit-rule \
clean   "t4fw.fw"
 t5fw_cfg.c optional cxgbe  \
-   compile-with"${AWK} -f $S/tools/fw_stub.awk t5fw_cfg.fw:t5fw_cfg 
t5fw.fw:t5fw -mt5fw_cfg -c${.TARGET}" \
+   compile-with"${AWK} -f $S/tools/fw_stub.awk t5fw_cfg.fw:t5fw_cfg 
t5fw_cfg_uwire.fw:t5fw_cfg_uwire t4fw.fw:t4fw -mt5fw_cfg -c${.TARGET}" \
no-implicit-rule before-depend local\
clean   "t5fw_cfg.c"
 t5fw_cfg.fwo   optional cxgbe  \
@@ -1412,6 +1412,16 @@ t5fw_cfg.fw  optional cxgbe  
\
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t5fw_cfg.fw"
+t5fw_cfg_uwire.fwo optional cxgbe  \
+   dependency  "t5fw_cfg_uwire.fw" \
+   compile-with"${NORMAL_FWO}" \
+   no-implicit-rule\
+   clean   "t5fw_cfg_uwire.fwo"
+t5fw_cfg_uwire.fw  optional cxgbe  \
+   dependency  "$S/dev/cxgbe/firmware/t5fw_cfg_uwire.txt"  \
+   compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
+   no-obj no-implicit-rule \
+   clean   "t5fw_cfg_uwire.fw"
 t5fw.fwo   optional cxgbe  \
dependency  "t5fw.fw"   \
compile-with"${NORMAL_FWO}" \
@@ -1423,7 +1433,7 @@ t5fw.fw   optional cxgbe  
\
no-obj no-implicit-rule \
clean   "t5fw.fw"
 t6fw_cfg.c optional cxgbe  \
-   compile-with"${AWK} -f $S/tools/fw_stub.awk t6fw_cfg.fw:t6fw_cfg 
t6fw.fw:t6fw -mt6fw_cfg -c${.TARGET}" \
+   compile-with"${AWK} -f $S/tools/fw_stub.awk t6fw_cfg.fw:t6fw_cfg 
t6fw_cfg_uwire.fw:t6fw_cfg_uwire t6fw.fw:t6fw -mt6fw_cfg -c${.TARGET}" \
no-implicit-rule before-depend local\
clean   "t6fw_cfg.c"
 t6fw_cfg.fwo   optional cxgbe  \
@@ -1436,6 +1446,16 @@ t6fw_cfg.fw  optional cxgbe  
\
compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
no-obj no-implicit-rule \
clean   "t6fw_cfg.fw"
+t6fw_cfg_uwire.fwo optional cxgbe  \
+   dependency  "t6fw_cfg_uwire.fw" \
+   compile-with"${NORMAL_FWO}" \
+   no-implicit-rule\
+   clean   "t6fw_cfg_uwire.fwo"
+t6fw_cfg_uwire.fw  optional cxgbe  \
+   dependency  "$S/dev/cxgbe/firmware/t6fw_cfg_uwire.txt"  \
+   compile-with"${CP} ${.ALLSRC} ${.TARGET}"   \
+   no-obj no-implicit-rule \
+   clean   "t6fw_cfg_uwire.fw"
 t6fw.fwo   optional cxgbe  \
dependency  "t6fw.fw"   \
compile-with"${NORMAL_FWO}" \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322139 - in head: contrib/top usr.bin/top

2017-08-07 Thread Pietro Cerutti
Author: gahr (ports committer)
Date: Mon Aug  7 08:45:08 2017
New Revision: 322139
URL: https://svnweb.freebsd.org/changeset/base/322139

Log:
  Enhance top(1) to filter on multiple usernames
  
  Reviewed by:  cognet, bapt
  Approved by:  cognet
  MFC after:1 week
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D11840

Modified:
  head/contrib/top/machine.h
  head/contrib/top/top.c
  head/contrib/top/top.xs
  head/usr.bin/top/machine.c

Modified: head/contrib/top/machine.h
==
--- head/contrib/top/machine.h  Mon Aug  7 07:40:00 2017(r322138)
+++ head/contrib/top/machine.h  Mon Aug  7 08:45:08 2017(r322139)
@@ -70,7 +70,8 @@ struct process_select
 int self;  /* show self */
 int system;/* show system processes */
 int thread;/* show threads */
-int uid;   /* only this uid (unless uid == -1) */
+#define TOP_MAX_UIDS 8
+int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */
 int wcpu;  /* show weighted cpu */
 int jid;   /* only this jid (unless jid == -1) */
 int jail;  /* show jail ID */

Modified: head/contrib/top/top.c
==
--- head/contrib/top/top.c  Mon Aug  7 07:40:00 2017(r322138)
+++ head/contrib/top/top.c  Mon Aug  7 08:45:08 2017(r322139)
@@ -134,7 +134,110 @@ void (*d_process)(int line, char *thisline) = i_proces
 
 void reset_display(void);
 
+static void
+reset_uids()
+{
+for (size_t i = 0; i < TOP_MAX_UIDS; ++i)
+   ps.uid[i] = -1;
+}
 
+static int
+add_uid(int uid)
+{
+size_t i = 0;
+
+/* Add the uid if there's room */
+for (; i < TOP_MAX_UIDS; ++i)
+{
+   if (ps.uid[i] == -1 || ps.uid[i] == uid)
+   {
+   ps.uid[i] = uid;
+   break;
+   }
+}
+
+return (i == TOP_MAX_UIDS);
+}
+
+static void
+rem_uid(int uid)
+{
+size_t i = 0;
+size_t where = TOP_MAX_UIDS;
+
+/* Look for the user to remove - no problem if it's not there */
+for (; i < TOP_MAX_UIDS; ++i)
+{
+   if (ps.uid[i] == -1)
+   break;
+   if (ps.uid[i] == uid)
+   where = i;
+}
+
+/* Make sure we don't leave a hole in the middle */
+if (where != TOP_MAX_UIDS)
+{
+   ps.uid[where] = ps.uid[i-1];
+   ps.uid[i-1] = -1;
+}
+}
+
+static int
+handle_user(char *buf, size_t buflen)
+{
+int rc = 0;
+int uid = -1;
+char *buf2 = buf;
+
+new_message(MT_standout, "Username to show (+ for all): ");
+if (readline(buf, buflen, No) <= 0)
+{
+   clear_message();
+   return rc;
+}
+
+if (buf[0] == '+' || buf[0] == '-')
+{
+   if (buf[1] == '\0')
+   {
+   reset_uids();
+   goto end;
+   }
+   else
+   ++buf2;
+}
+
+if ((uid = userid(buf2)) == -1)
+{
+   new_message(MT_standout, " %s: unknown user", buf2);
+   rc = 1;
+   goto end;
+}
+
+if (buf2 == buf)
+{
+   reset_uids();
+   ps.uid[0] = uid;
+   goto end;
+}
+
+if (buf[0] == '+')
+{
+   if (add_uid(uid))
+   {
+   new_message(MT_standout, " too many users, reset with '+'");
+   rc = 1;
+   goto end;
+   }
+}
+else
+   rem_uid(uid);
+
+end:
+putchar('\r');
+return rc;
+}
+
 int
 main(argc, argv)
 
@@ -252,7 +355,7 @@ char *argv[];
 ps.idle= Yes;
 ps.self= -1;
 ps.system  = No;
-ps.uid = -1;
+reset_uids();
 ps.thread  = No;
 ps.wcpu= 1;
 ps.jid = -1;
@@ -299,7 +402,7 @@ char *argv[];
break;
 
  case 'U': /* display only username's processes */
-   if ((ps.uid = userid(optarg)) == -1)
+   if ((ps.uid[0] = userid(optarg)) == -1)
{
fprintf(stderr, "%s: unknown user\n", optarg);
exit(1);
@@ -1004,31 +1107,8 @@ restart:
break;
 
case CMD_user:
-   new_message(MT_standout,
-   "Username to show (+ for all): ");
-   if (readline(tempbuf2, sizeof(tempbuf2), No) > 
0)
-   {
-   if (tempbuf2[0] == '+' &&
-   tempbuf2[1] == '\0')
-   {
-   ps.uid = -1;
-   }
-   else if ((i = userid(tempbuf2)) == -1)
-   {
-   new_message(MT_standout,
-   " %s: unknown user", tempbuf2);
-