Re: svn commit: r368736 - head/tools/tools/git/hooks

2020-12-28 Thread Alan Somers
On Mon, Dec 28, 2020 at 3:29 PM Ed Maste  wrote:

> On Mon, 28 Dec 2020 at 14:34, Alan Somers  wrote:
> >
> > On Thu, Dec 17, 2020 at 12:58 PM Ed Maste  wrote:
> >>
> >> Author: emaste
> >> Date: Thu Dec 17 19:58:29 2020
> >> New Revision: 368736
> >> URL: https://svnweb.freebsd.org/changeset/base/368736
> >>
> >> Log:
> >>   Add initial version of git commit message preparation hook
> >>
> > Thanks!  But how can we use it?  Is there a "git config" incantation
> that will use this file?
>
> Just copy it into .git/hooks/. Can also fetch the latest version
> directly from cgit; lwhsu added this to
> https://github.com/bsdimp/freebsd-git-docs/blob/main/URLs.md:
>
> fetch
> https://cgit.freebsd.org/src/plain/tools/tools/git/hooks/prepare-commit-msg
> -o
> <https://cgit.freebsd.org/src/plain/tools/tools/git/hooks/prepare-commit-msg-o>
> .git/hooks
> chmod 755 .git/hooks/prepare-commit-msg
>
> I'd like us to end up with a setup-repo.sh or such that will offer to
> take care of all of these things.
>
> >Also, this seems too complicated.  Git already has a "config.template"
> configuration variable.   Could we just use that instead, or does it not
> work for some reason?
>
> It does work, although it's a bit awkward. For one thing, the provided
> template is placed at the top of the message, followed by the default
> message, but our addition is really commented-out information and fits
> best in the middle of the existing text - after the "Please enter
> the..." and before the list of changes and such. With config.template
> we'd end up with something like:
>
> 
>
> # PR:   
> # ...
> # Differential Revision:<https://reviews.freebsd.org/D###>
> #
> # Please enter the commit message for your changes. Lines starting
> # with '#' will be ignored, and an empty message aborts the commit.
> #
> # ...
> 
>
> Additionally we might want to make some more programmatic changes in
> the default message (depending on the resolution of some open
> questions). For example we could strip the "MFC after" line that's
> copied from the original commit, when preparing the commit message for
> a MFC/cherry-pick.
>

Thanks for the explanation.  It all makes sense, and the commit template
works.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r366697 - head/usr.bin/xinstall

2020-12-28 Thread Alan Somers
BTW, I have a WIP patch to xinstall to make it use copy_file_range.  The
patch works, but I never wrote a fallback path in case copy_file_range
fails for some reason.  Alex, would you be interested to finish the patch?
-Alan

On Wed, Oct 14, 2020 at 7:35 AM Alexander Richardson <
arichard...@freebsd.org> wrote:

> On Wed, 14 Oct 2020 at 14:29, Mateusz Guzik  wrote:
> >
> > This should use copy_file_range (also available on Linux).
> >
>
> I agree. I even mentioned this in
> https://reviews.freebsd.org/D26041#589287.
> This change avoids the two unnecessary syscalls, but I agree that
> longer-term install should share the copy_file_range code with cp.
> The only thing that copy_file_range won't speed up is the check
> whether source and target are already identical.
>
> Alex
>
> > On 10/14/20, Alex Richardson  wrote:
> > > Author: arichardson
> > > Date: Wed Oct 14 12:28:41 2020
> > > New Revision: 366697
> > > URL: https://svnweb.freebsd.org/changeset/base/366697
> > >
> > > Log:
> > >   install(1): Avoid unncessary fstatfs() calls and use mmap() based on
> size
> > >
> > >   According to git blame the trymmap() function was added in 1996 to
> skip
> > >   mmap() calls for NFS file systems. However, nowadays mmap() should be
> > >   perfectly safe even on NFS. Importantly, onl ufs and cd9660 file
> systems
> > >   were whitelisted so we don't use mmap() on ZFS. It also prevents the
> use
> > >   of mmap() when bootstrapping from macOS/Linux since on those systems
> the
> > >   trymmap() function was always returning zero due to the missing
> > > MFSNAMELEN
> > >   define.
> > >
> > >   This change keeps the trymmap() function but changes it to check
> whether
> > >   using mmap() can reduce the number of system calls that are required.
> > >   Using mmap() only reduces the number of system calls if we need
> multiple
> > > read()
> > >   syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is
> more
> > > expensive
> > >   than read() so this sets the threshold at 4 fewer syscalls.
> Additionally,
> > > for
> > >   larger file size mmap() can significantly increase the number of page
> > > faults,
> > >   so avoid it in that case.
> > >
> > >   It's unclear whether using mmap() is ever faster than a read with an
> > > appropriate
> > >   buffer size, but this change at least removes two unnecessary system
> > > calls
> > >   for every file that is installed.
> > >
> > >   Reviewed By:markj
> > >   Differential Revision: https://reviews.freebsd.org/D26041
> > >
> > > Modified:
> > >   head/usr.bin/xinstall/xinstall.c
> > >
> > > Modified: head/usr.bin/xinstall/xinstall.c
> > >
> ==
> > > --- head/usr.bin/xinstall/xinstall.c  Wed Oct 14 10:12:39 2020
> (r366696)
> > > +++ head/usr.bin/xinstall/xinstall.c  Wed Oct 14 12:28:41 2020
> (r366697)
> > > @@ -148,7 +148,7 @@ static void   metadata_log(const char *, const
> char *, s
> > >   const char *, const char *, off_t);
> > >  static int   parseid(const char *, id_t *);
> > >  static int   strip(const char *, int, const char *, char **);
> > > -static int   trymmap(int);
> > > +static int   trymmap(size_t);
> > >  static void  usage(void);
> > >
> > >  int
> > > @@ -1087,7 +1087,7 @@ compare(int from_fd, const char *from_name
> __unused,
> > > s
> > >   if (do_digest)
> > >   digest_init();
> > >   done_compare = 0;
> > > - if (trymmap(from_fd) && trymmap(to_fd)) {
> > > + if (trymmap(from_len) && trymmap(to_len)) {
> > >   p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
> > >   from_fd, (off_t)0);
> > >   if (p == MAP_FAILED)
> > > @@ -1248,13 +1248,8 @@ copy(int from_fd, const char *from_name, int
> to_fd,
> > > co
> > >
> > >   digest_init();
> > >
> > > - /*
> > > -  * Mmap and write if less than 8M (the limit is so we don't
> totally
> > > -  * trash memory on big files.  This is really a minor hack, but
> it
> > > -  * wins some CPU back.
> > > -  */
> > >   done_copy = 0;
> > > - if (size <= 8 * 1048576 && trymmap(from_fd) &&
> > > + if (trymmap((size_t)size) &&
> > >   (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
> > >   from_fd, (off_t)0)) != MAP_FAILED) {
> > >   nw = write(to_fd, p, size);
> > > @@ -1523,20 +1518,23 @@ usage(void)
> > >   *   return true (1) if mmap should be tried, false (0) if not.
> > >   */
> > >  static int
> > > -trymmap(int fd)
> > > +trymmap(size_t filesize)
> > >  {
> > > -/*
> > > - * The ifdef is for bootstrapping - f_fstypename doesn't exist in
> > > - * pre-Lite2-merge systems.
> > > - */
> > > -#ifdef MFSNAMELEN
> > > - struct statfs stfs;
> > > -
> > > - if (fstatfs(fd, ) != 0)
> > > - return (0);
> > > - if (strcmp(stfs.f_fstypename, "ufs") == 0 ||
> > > - 

Re: svn commit: r368736 - head/tools/tools/git/hooks

2020-12-28 Thread Alan Somers
On Thu, Dec 17, 2020 at 12:58 PM Ed Maste  wrote:

> Author: emaste
> Date: Thu Dec 17 19:58:29 2020
> New Revision: 368736
> URL: https://svnweb.freebsd.org/changeset/base/368736
>
> Log:
>   Add initial version of git commit message preparation hook
>
>   Start with a slightly modified version of the SVN commit template, to
>   allow developers to experiment.  This will be updated in the future as
>   our process and techniques evolve.
>
>   This can be installed by copying or symlinking into the .git/hooks/
>   directory.
>
>   Feedback from:cem, jhb
>   Reviewed by:  imp
>   Sponsored by: The FreeBSD Foundation
>   Differential Revision:https://reviews.freebsd.org/D27633
>
> Added:
>   head/tools/tools/git/hooks/
>   head/tools/tools/git/hooks/prepare-commit-msg   (contents, props changed)
>

Thanks!  But how can we use it?  Is there a "git config" incantation that
will use this file?  Also, this seems too complicated.  Git already has a
"config.template" configuration variable.   Could we just use that instead,
or does it not work for some reason?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365917 - in releng/12.2: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zpool sys/cddl/compat/opensolaris/kern sys/cddl/compat/opensolaris/sys sys/cddl/contrib/opensola

2020-12-16 Thread Alan Somers
On Sat, Sep 19, 2020 at 2:47 PM Allan Jude  wrote:

> Author: allanjude
> Date: Sat Sep 19 20:46:56 2020
> New Revision: 365917
> URL: https://svnweb.freebsd.org/changeset/base/365917
>
> Log:
>   MFS r365689,r365808,r365860
>
>   MFOpenZFS: Introduce read/write kstats per dataset
>
>   The following patch introduces a few statistics on reads and writes
>   grouped by dataset. These statistics are implemented as kstats
>   (backed by aggregate sums for performance) and can be retrieved by
>   using the dataset objset ID number. The motivation for this change is
>   to provide some preliminary analytics on dataset usage/performance.
>
>   Reviewed-by: Richard Elling 
>   Reviewed-by: Brian Behlendorf 
>   Reviewed by: Matthew Ahrens 
>   Signed-off-by: Serapheim Dimitropoulos 
>
>   openzfs/zfs@a448a2557ec4938ed6944c7766fe0b8e6e5f6456
>
>   Also contains parts of:
>   MFOpenZFS: Connect dataset_kstats for FreeBSD
>
>   Example output:
>   kstat.zfs.mypool.dataset.objset-0x10b.nread: 150528
>   kstat.zfs.mypool.dataset.objset-0x10b.reads: 48
>   kstat.zfs.mypool.dataset.objset-0x10b.nwritten: 134217728
>   kstat.zfs.mypool.dataset.objset-0x10b.writes: 1024
>   kstat.zfs.mypool.dataset.objset-0x10b.dataset_name: mypool/datasetname
>
>   Reviewed-by: Ryan Moeller 
>   Reviewed by: Sean Eric Fagan 
>   Reviewed-by: Serapheim Dimitropoulos 
>   Reviewed-by: Brian Behlendorf 
>   Signed-off-by: Allan Jude 
>
>   openzfs/zfs@4547fc4e071ceb1818b3a46c3035b923e06e5390
>
>   Approved by:  re (gjb)
>   Relnotes: yes
>   Sponsored by: Klara Inc.
>

This sounds quite useful!  I've often wished that I could see per-dataset
traffic statistics.  Are there any user-friendly frontends to this?  Like
zfs-stats, or an updated zpool iostat?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368597 - stable/12/sbin/ping6

2020-12-12 Thread Alan Somers
Author: asomers
Date: Sat Dec 12 23:01:11 2020
New Revision: 368597
URL: https://svnweb.freebsd.org/changeset/base/368597

Log:
  MFC r367976:
  
  ping6: update usage text after r365547

Modified:
  stable/12/sbin/ping6/ping6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/ping6/ping6.c
==
--- stable/12/sbin/ping6/ping6.cSat Dec 12 22:57:28 2020
(r368596)
+++ stable/12/sbin/ping6/ping6.cSat Dec 12 23:01:11 2020
(r368597)
@@ -2838,7 +2838,7 @@ usage(void)
"\n"
" [-p pattern] [-S sourceaddr] [-s packetsize] "
"[-x waittime]\n"
-   " [-X timeout] [hops ...] host\n");
+   " [-X timeout] [-z tclass] [hops ...] host\n");
exit(1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368596 - stable/12/tests/sys/fs/fusefs

2020-12-12 Thread Alan Somers
Author: asomers
Date: Sat Dec 12 22:57:28 2020
New Revision: 368596
URL: https://svnweb.freebsd.org/changeset/base/368596

Log:
  MFC r366365:
  
  fusefs tests: quell Coverity "Argument cannot be negative" warnings
  
  Must abort tests early if open(2) fails.
  
  Reported by:  Coverity
  Coverity CID: 1432810 and many others
  Reviewed by:  kevans
  Differential Revision:https://reviews.freebsd.org/D26635

Modified:
  stable/12/tests/sys/fs/fusefs/allow_other.cc
  stable/12/tests/sys/fs/fusefs/create.cc
  stable/12/tests/sys/fs/fusefs/default_permissions.cc
  stable/12/tests/sys/fs/fusefs/flush.cc
  stable/12/tests/sys/fs/fusefs/open.cc
  stable/12/tests/sys/fs/fusefs/opendir.cc
  stable/12/tests/sys/fs/fusefs/release.cc
  stable/12/tests/sys/fs/fusefs/releasedir.cc
  stable/12/tests/sys/fs/fusefs/write.cc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/fs/fusefs/allow_other.cc
==
--- stable/12/tests/sys/fs/fusefs/allow_other.ccSat Dec 12 22:51:30 
2020(r368595)
+++ stable/12/tests/sys/fs/fusefs/allow_other.ccSat Dec 12 22:57:28 
2020(r368596)
@@ -168,7 +168,7 @@ TEST_F(AllowOther, privilege_escalation)
.WillRepeatedly(Invoke(ReturnErrno(EPERM)));
 
fd1 = open(FULLPATH, O_RDONLY);
-   EXPECT_LE(0, fd1) << strerror(errno);
+   ASSERT_LE(0, fd1) << strerror(errno);
}, [] {
int fd0;
 

Modified: stable/12/tests/sys/fs/fusefs/create.cc
==
--- stable/12/tests/sys/fs/fusefs/create.cc Sat Dec 12 22:51:30 2020
(r368595)
+++ stable/12/tests/sys/fs/fusefs/create.cc Sat Dec 12 22:57:28 2020
(r368596)
@@ -143,7 +143,7 @@ TEST_F(Create, attr_cache)
).Times(0);
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -184,7 +184,7 @@ TEST_F(Create, clear_attr_cache)
 
EXPECT_EQ(0, stat("mountpoint", )) << strerror(errno);
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
EXPECT_EQ(0, stat("mountpoint", )) << strerror(errno);
 
leak(fd);
@@ -254,7 +254,7 @@ TEST_F(Create, Enosys)
})));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -366,7 +366,7 @@ TEST_F(Create, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -398,7 +398,7 @@ TEST_F(Create, wronly_0444)
}));
 
fd = open(FULLPATH, O_CREAT | O_WRONLY, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -422,7 +422,7 @@ TEST_F(Create_7_8, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -446,6 +446,6 @@ TEST_F(Create_7_11, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }

Modified: stable/12/tests/sys/fs/fusefs/default_permissions.cc
==
--- stable/12/tests/sys/fs/fusefs/default_permissions.ccSat Dec 12 
22:51:30 2020(r368595)
+++ stable/12/tests/sys/fs/fusefs/default_permissions.ccSat Dec 12 
22:57:28 2020(r368596)
@@ -490,7 +490,7 @@ TEST_F(Create, ok)
expect_create(RELPATH, ino);
 
fd = open(FULLPATH, O_CREAT | O_EXCL, 0644);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -765,7 +765,7 @@ TEST_F(Open, ok)
expect_open(ino, 0, 1);
 
fd = open(FULLPATH, O_RDONLY);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 

Modified: stable/12/tests/sys/fs/fusefs/flush.cc
==
--- stable/12/tests/sys/fs/fusefs/flush.cc  Sat Dec 12 22:51:30 2020
(r368595)
+++ stable/12/tests/sys/fs/fusefs/flush.cc  Sat Dec 12 22:57:28 2020
(r368596)
@@ -102,10 +102,10 @@ TEST_F(Flush, open_twice)
expect_release();
 
fd = open(FULLPATH, O_WRONLY);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
 
fd2 = open(FULLPATH, O_WRONLY);
-   EXPECT_LE(0, fd2) << strerror(errno);
+   

svn commit: r368491 - stable/12/cddl/contrib/opensolaris/lib/libzfs/common

2020-12-09 Thread Alan Somers
Author: asomers
Date: Wed Dec  9 20:06:37 2020
New Revision: 368491
URL: https://svnweb.freebsd.org/changeset/base/368491

Log:
  ZFS: fix spurious EBUSY after zfs receive to an existing dataset
  
  If you do a "zfs send -p  | zfs receive -F " to an existing but
  empty dataset, the receive will complete successfully but spuriously fail
  with exit status 1 and the message "cannot mount 'pool/dataset': mountpoint
  or dataset is busy".
  
  The root cause is a merge error made in r344569 and MFCed in r345578, which
  merged changes a10d50f999 and e63ac16d25 from ZoL.  The merge:
  * failed to flip a == to an != like the upstream change did, and
  * Left out one chunk
  
  Direct commit to stable/12 because head has moved on to OpenZFS.
  
  PR:   251694
  Reviewed by:  bapt
  Sponsored by: Axcient

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Dec  9 18:43:58 2020(r368490)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Dec  9 20:06:37 2020(r368491)
@@ -895,13 +895,25 @@ libzfs_mnttab_add(libzfs_handle_t *hdl, const char *sp
mnttab_node_t *mtn;
 
pthread_mutex_lock(>libzfs_mnttab_cache_lock);
-   if (avl_numnodes(>libzfs_mnttab_cache) == 0) {
+   if (avl_numnodes(>libzfs_mnttab_cache) != 0) {
mtn = zfs_alloc(hdl, sizeof (mnttab_node_t));
mtn->mtn_mt.mnt_special = zfs_strdup(hdl, special);
mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, mountp);
mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, MNTTYPE_ZFS);
mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, mntopts);
-   avl_add(>libzfs_mnttab_cache, mtn);
+   /*
+* Another thread may have already added this entry
+* via libzfs_mnttab_update. If so we should skip it.
+*/
+   if (avl_find(>libzfs_mnttab_cache, mtn, NULL) != NULL) {
+   free(mtn->mtn_mt.mnt_special);
+   free(mtn->mtn_mt.mnt_mountp);
+   free(mtn->mtn_mt.mnt_fstype);
+   free(mtn->mtn_mt.mnt_mntopts);
+   free(mtn);
+   } else {
+   avl_add(>libzfs_mnttab_cache, mtn);
+   }
}
pthread_mutex_unlock(>libzfs_mnttab_cache_lock);
 }  
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368272 - head/tests/sys/aio

2020-12-01 Thread Alan Somers
Author: asomers
Date: Wed Dec  2 00:53:03 2020
New Revision: 368272
URL: https://svnweb.freebsd.org/changeset/base/368272

Log:
  AIO tests: update expected failure messages after r368265
  
  PR:   220398, 251515
  MFC after:1 week
  MFC-With: r368265

Modified:
  head/tests/sys/aio/lio_test.c

Modified: head/tests/sys/aio/lio_test.c
==
--- head/tests/sys/aio/lio_test.c   Wed Dec  2 00:48:15 2020
(r368271)
+++ head/tests/sys/aio/lio_test.c   Wed Dec  2 00:53:03 2020
(r368272)
@@ -143,8 +143,8 @@ ATF_TC_BODY(lio_listio_empty_nowait_kevent, tc)
int kq, result;
void *udata = (void*)0xdeadbeefdeadbeef;
 
-   atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends"
-   " asynchronous notification if nent==0");
+   atf_tc_expect_timeout("Bug 251515 - lio_listio(2) never sends"
+   " kevent if nent==0");
kq = kqueue();
ATF_REQUIRE(kq > 0);
sev.sigev_notify = SIGEV_KEVENT;
@@ -168,8 +168,6 @@ ATF_TC_BODY(lio_listio_empty_nowait_signal, tc)
struct aiocb *list = NULL;
struct sigevent sev;
 
-   atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends"
-   " asynchronous notification if nent==0");
ATF_REQUIRE_EQ(0, sem_init(, false, 0));
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = SIGUSR1;
@@ -189,9 +187,6 @@ ATF_TC_BODY(lio_listio_empty_nowait_thread, tc)
struct aiocb *list = NULL;
struct sigevent sev;
 
-   atf_tc_skip("Sometimes hangs and sometimes passes");
-   atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends"
-   " asynchronous notification if nent==0");
ATF_REQUIRE_EQ(0, sem_init(, false, 0));
bzero(, sizeof(sev));
sev.sigev_notify = SIGEV_THREAD;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368233 - in stable/12: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/sys/fs

2020-12-01 Thread Alan Somers
Author: asomers
Date: Tue Dec  1 15:15:18 2020
New Revision: 368233
URL: https://svnweb.freebsd.org/changeset/base/368233

Log:
  Fix error merging r354116 from OpenZFS
  
  When we merged 4c0883fb4af0d5565459099b98fcf90ecbfa1ca1 from OpenZFS (svn
  r354116), there were some merge conflicts.  One of those was resolved
  incorrectly, causing "zfs receive" to fail to delete snapshots that a "zfs
  send -R" stream has deleted.
  
  This change corrects that merge conflict, and also reduces some harmless
  diffs vis-a-vis OpenZFS that were also introduced by the same revision.
  Direct commit to stable/12 because head has moved on to OpenZFS.
  
  PR:   249438
  Reported by:  Dmitry Wagin 
  Reviewed by:  mmacy
  Sponsored by: Axcient

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Tue Dec  1 15:11:16 2020(r368232)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Tue Dec  1 15:15:18 2020(r368233)
@@ -613,8 +613,8 @@ typedef struct send_data {
const char *fromsnap;
const char *tosnap;
boolean_t recursive;
-   boolean_t verbose;
boolean_t replicate;
+   boolean_t verbose;
 
/*
 * The header nvlist is of the following format:
@@ -848,36 +848,36 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
rv = -1;
goto out;
}
-   VERIFY(0 == nvlist_add_uint64(nvfs, "origin",
-   origin->zfs_dmustats.dds_guid));
+   fnvlist_add_uint64(nvfs, "origin",
+   origin->zfs_dmustats.dds_guid);
}
 
/* iterate over props */
-   VERIFY(0 == nvlist_alloc(, NV_UNIQUE_NAME, 0));
+   nv = fnvlist_alloc();
send_iterate_prop(zhp, nv);
-   VERIFY(0 == nvlist_add_nvlist(nvfs, "props", nv));
-   nvlist_free(nv);
+   fnvlist_add_nvlist(nvfs, "props", nv);
+   fnvlist_free(nv);
 
/* iterate over snaps, and set sd->parent_fromsnap_guid */
+   sd->parent_fromsnap_guid = 0;
+   sd->parent_snaps = fnvlist_alloc();
+   sd->snapprops = fnvlist_alloc();
if (!sd->replicate && fromsnap_txg != 0)
min_txg = fromsnap_txg;
if (!sd->replicate && tosnap_txg != 0)
max_txg = tosnap_txg;
-   sd->parent_fromsnap_guid = 0;
-   VERIFY(0 == nvlist_alloc(>parent_snaps, NV_UNIQUE_NAME, 0));
-   VERIFY(0 == nvlist_alloc(>snapprops, NV_UNIQUE_NAME, 0));
(void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd,
min_txg, max_txg);
-   VERIFY(0 == nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps));
-   VERIFY(0 == nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops));
+   fnvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps);
+   fnvlist_add_nvlist(nvfs, "snapprops", sd->snapprops);
fnvlist_free(sd->parent_snaps);
fnvlist_free(sd->snapprops);
 
/* add this fs to nvlist */
(void) snprintf(guidstring, sizeof (guidstring),
"0x%llx", (longlong_t)guid);
-   VERIFY(0 == nvlist_add_nvlist(sd->fss, guidstring, nvfs));
-   nvlist_free(nvfs);
+   fnvlist_add_nvlist(sd->fss, guidstring, nvfs);
+   fnvlist_free(nvfs);
 
/* iterate over children */
if (sd->recursive)
@@ -894,13 +894,12 @@ out:
 
 static int
 gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap,
-const char *tosnap, boolean_t recursive, boolean_t verbose,
-boolean_t replicate, nvlist_t **nvlp, avl_tree_t **avlp)
+const char *tosnap, boolean_t recursive, boolean_t replicate,
+boolean_t verbose, nvlist_t **nvlp, avl_tree_t **avlp)
 {
zfs_handle_t *zhp;
-   int error;
-   uint64_t min_txg = 0, max_txg = 0;
send_data_t sd = { 0 };
+   int error;
 
zhp = zfs_open(hdl, fsname, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
if (zhp == NULL)
@@ -911,8 +910,8 @@ gather_nvlist(libzfs_handle_t *hdl, const char *fsname
sd.fromsnap = fromsnap;
sd.tosnap = tosnap;
sd.recursive = recursive;
-   sd.verbose = verbose;
sd.replicate = replicate;
+   sd.verbose = verbose;
 
if ((error = send_iterate_fs(zhp, )) != 0) {
nvlist_free(sd.fss);
@@ -1349,10 +1348,10 @@ static int
 dump_filesystem(zfs_handle_t *zhp, void *arg)
 {
int rv = 0;
-   uint64_t min_txg = 0, max_txg = 0;
send_dump_data_t *sdd = arg;
boolean_t missingfrom = B_FALSE;
zfs_cmd_t zc = { 0 };
+   uint64_t min_txg = 0, max_txg = 0;
 
(void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s",
  

svn commit: r368131 - head/sbin/ping

2020-11-28 Thread Alan Somers
Author: asomers
Date: Sat Nov 28 23:24:19 2020
New Revision: 368131
URL: https://svnweb.freebsd.org/changeset/base/368131

Log:
  ping: allow building without INET support
  
  Building without INET6 support was already possible. Now it's possible to
  build ping with only INET6, or even with neither INET nor INET6.
  
  Reported by:  bz
  Reviewed by:  bz
  MFC-With: 368045
  Differential Revision:https://reviews.freebsd.org/D27394

Modified:
  head/sbin/ping/Makefile
  head/sbin/ping/main.c

Modified: head/sbin/ping/Makefile
==
--- head/sbin/ping/Makefile Sat Nov 28 22:34:33 2020(r368130)
+++ head/sbin/ping/Makefile Sat Nov 28 23:24:19 2020(r368131)
@@ -5,11 +5,16 @@
 
 PACKAGE=runtime
 PROG=  ping
-SRCS=  main.c ping.c utils.c
+SRCS=  main.c
 MAN=   ping.8
 BINOWN=root
 BINMODE=4555
 LIBADD=m
+
+.if ${MK_INET_SUPPORT}!= "no"
+CFLAGS+= -DINET
+SRCS+= ping.c utils.c
+.endif
 
 .if ${MK_INET6_SUPPORT} != "no"
 CFLAGS+= -DINET6 -DKAME_SCOPEID

Modified: head/sbin/ping/main.c
==
--- head/sbin/ping/main.c   Sat Nov 28 22:34:33 2020(r368130)
+++ head/sbin/ping/main.c   Sat Nov 28 23:24:19 2020(r368131)
@@ -44,40 +44,51 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "main.h"
+#ifdef INET
 #include "ping.h"
+#endif
 #ifdef INET6
 #include "ping6.h"
 #endif
 
-#ifdef INET6
+#if defined(INET) && defined(INET6)
 #defineOPTSTR ":46"
-#else
+#elif defined(INET)
 #define OPTSTR ":4"
+#elif defined(INET6)
+#defineOPTSTR ":6"
+#else
+#define OPTSTR ""
 #endif
 
 int
 main(int argc, char *argv[])
 {
+#if defined(INET) && defined(INET6)
struct in_addr a;
+   struct in6_addr a6;
+#endif
+#if defined(INET) || defined(INET6)
struct addrinfo hints;
+#endif
int ch;
-   bool ipv4;
+#ifdef INET
+   bool ipv4 = false;
+#endif
 #ifdef INET6
-   struct in6_addr a6;
-   bool ipv6;
+   bool ipv6 = false;
 
if (strcmp(getprogname(), "ping6") == 0)
ipv6 = true;
-   else
-   ipv6 = false;
 #endif
-   ipv4 = false;
 
while ((ch = getopt(argc, argv, OPTSTR)) != -1) {
switch(ch) {
+#ifdef INET
case '4':
ipv4 = true;
break;
+#endif
 #ifdef INET6
case '6':
ipv6 = true;
@@ -93,20 +104,18 @@ main(int argc, char *argv[])
 
optreset = 1;
optind = 1;
-#ifdef INET6
+#if defined(INET) && defined(INET6)
if (ipv4 && ipv6)
errx(1, "-4 and -6 cannot be used simultaneously");
 #endif
 
+#if defined(INET) && defined(INET6)
if (inet_pton(AF_INET, argv[argc - 1], ) == 1) {
-#ifdef INET6
if (ipv6)
errx(1, "IPv6 requested but IPv4 target address "
"provided");
-#endif
hints.ai_family = AF_INET;
}
-#ifdef INET6
else if (inet_pton(AF_INET6, argv[argc - 1], ) == 1) {
if (ipv4)
errx(1, "IPv4 requested but IPv6 target address "
@@ -114,7 +123,6 @@ main(int argc, char *argv[])
hints.ai_family = AF_INET6;
} else if (ipv6)
hints.ai_family = AF_INET6;
-#endif
else if (ipv4)
hints.ai_family = AF_INET;
else {
@@ -129,22 +137,30 @@ main(int argc, char *argv[])
freeaddrinfo(res);
}
}
+#elif defined(INET)
+   hints.ai_family = AF_INET;
+#elif defined(INET6)
+   hints.ai_family = AF_INET6;
+#endif
 
+#ifdef INET
if (hints.ai_family == AF_INET)
return ping(argc, argv);
+#endif /* INET */
 #ifdef INET6
-   else if (hints.ai_family == AF_INET6)
+   if (hints.ai_family == AF_INET6)
return ping6(argc, argv);
-#endif
-   else
-   errx(1, "Unknown host");
+#endif /* INET6 */
+   errx(1, "Unknown host");
 }
 
 void
 usage(void)
 {
(void)fprintf(stderr,
-   "usage: ping [-4AaDdfHnoQqRrv] [-C pcp] [-c count] "
+   "usage:\n"
+#ifdef INET
+   "\tping [-4AaDdfHnoQqRrv] [-C pcp] [-c count] "
"[-G sweepmaxsize]\n"
"   [-g sweepminsize] [-h sweepincrsize] [-i wait] "
"[-l preload]\n"
@@ -155,7 +171,7 @@ usage(void)
"[-p pattern] [-S src_addr] \n"
"   [-s packetsize] [-t timeout] [-W waittime] [-z tos] "
"IPv4-host\n"
-   "   ping [-4AaDdfHLnoQqRrv] [-C pcp] [-c count] [-I iface] "
+   "\tping [-4AaDdfHLnoQqRrv] [-C pcp] [-c count] [-I iface] "
"[-i wait]\n"
"   [-l preload] [-M mask | time] [-m ttl] "
 #ifdef IPSEC
@@ -164,8 +180,9 @@ usage(void)
"[-p pattern]\n"
"   

Re: svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-27 Thread Alan Somers
On Fri, Nov 27, 2020 at 5:08 AM Bjoern A. Zeeb <
bzeeb-li...@lists.zabbadoz.net> wrote:

> On 26 Nov 2020, at 18:51, Alan Somers wrote:
>
> > On Thu, Nov 26, 2020 at 2:16 AM Bjoern A. Zeeb <
> > bzeeb-li...@lists.zabbadoz.net> wrote:
> >
> >> On 26 Nov 2020, at 4:29, Alan Somers wrote:
> >>
> >>> Author: asomers
> >>> Date: Thu Nov 26 04:29:30 2020
> >>> New Revision: 368045
> >>> URL: https://svnweb.freebsd.org/changeset/base/368045
> >>>
> >>> Log:
> >>>   Merge ping6 to ping
> >>>
> >>>   There is now a single ping binary, which chooses to use ICMP or
> >>> ICMPv4
> >>>   based on the -4 and -6 options, and the format of the address.
> >>>
> >>>   Submitted by:   Ján Sučan 
> >>>   Sponsored by:   Google LLC (Google Summer of Code 2019)
> >>>   MFC after:  Never
> >>>   Differential Revision:  https://reviews.freebsd.org/D21377
> >>
> >> I don’t have IPv4 anymore.
> >> I don’t see any WITHOUT_INET or -DINET checks.
> >> How can I compile INET out now?
> >>
> >
> > I don't see any such checks before, either.  Was it ever possible to
> > exclude ping by building WITHOUT_INET?
>
> No, for various reasons including startup scripts relying on it etc.
> I think no one ever bothered to fully find it all.
>
> But it was possible to just ditch the binary (not installing it into
> custom images, or rm -f it post-install along with other things).
>
>
> Now it’s a “dual-stack handling” binary and those we’ve tried
> with a lot of care to make sure they grow compiling out both ways as you
> cannot throw away the binary anymore.
>
> I don’t know how hard it is to do this now.  I’ll be happy to have a
> look and help if it’s not a 5 minute job for you knowing the code and
> split up.   Would we just have to handle main.c with #ifdefs and the old
> ping[4] files from the Makefile or is ping6 also using shared code from
> the former ping[4]?
>
>
> /bz
>

Yes, that's about right.  ping.c is the old ping.c, and ping6.c is the old
ping6.c, with main() removed from both.  So it should be pretty easy to
compile out INET.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368090 - stable/12/lib/libc/tests/iconv

2020-11-26 Thread Alan Somers
Author: asomers
Date: Fri Nov 27 04:45:10 2020
New Revision: 368090
URL: https://svnweb.freebsd.org/changeset/base/368090

Log:
  MFC r366132:
  
  lib/libc/tests/iconv: raise WARNS to 6

Modified:
  stable/12/lib/libc/tests/iconv/Makefile
  stable/12/lib/libc/tests/iconv/iconvctl_test.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/tests/iconv/Makefile
==
--- stable/12/lib/libc/tests/iconv/Makefile Fri Nov 27 03:17:21 2020
(r368089)
+++ stable/12/lib/libc/tests/iconv/Makefile Fri Nov 27 04:45:10 2020
(r368090)
@@ -3,6 +3,5 @@
 TESTSDIR=  ${TESTSBASE}/lib/libc/iconv
 
 ATF_TESTS_C+=  iconvctl_test
-WARNS?=2
 
 .include 

Modified: stable/12/lib/libc/tests/iconv/iconvctl_test.c
==
--- stable/12/lib/libc/tests/iconv/iconvctl_test.c  Fri Nov 27 03:17:21 
2020(r368089)
+++ stable/12/lib/libc/tests/iconv/iconvctl_test.c  Fri Nov 27 04:45:10 
2020(r368090)
@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-void
+static void
 test_trivialp(const char *src, const char *dst, int expected)
 {
iconv_t ic;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368088 - stable/12/lib/libc/tests/sys

2020-11-26 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 23:54:13 2020
New Revision: 368088
URL: https://svnweb.freebsd.org/changeset/base/368088

Log:
  MFC r366131:
  
  lib/libc/tests/sys: raise WARNS to 6

Modified:
  stable/12/lib/libc/tests/sys/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/tests/sys/Makefile
==
--- stable/12/lib/libc/tests/sys/Makefile   Thu Nov 26 23:44:57 2020
(r368087)
+++ stable/12/lib/libc/tests/sys/Makefile   Thu Nov 26 23:54:13 2020
(r368088)
@@ -80,12 +80,6 @@ LIBADD.timer_create_test+=   rt
 SRCS.mlock_test+=  mlock_helper.c
 SRCS.setrlimit_test+=  mlock_helper.c
 
-.if ${COMPILER_TYPE} == "gcc"
-WARNS?=3
-.else
-WARNS?=4
-.endif
-
 FILESGROUPS+=  truncate_test_FILES
 
 truncate_test_FILES=   truncate_test.root_owned
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368087 - stable/12/sys/kern

2020-11-26 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 23:44:57 2020
New Revision: 368087
URL: https://svnweb.freebsd.org/changeset/base/368087

Log:
  MFC r366118:
  
  Fix some signed/unsigned comparison warnings in NFS
  
  Reviewed by:  rmacklem
  Differential Revision:https://reviews.freebsd.org/D26533

Modified:
  stable/12/sys/kern/subr_acl_nfs4.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_acl_nfs4.c
==
--- stable/12/sys/kern/subr_acl_nfs4.c  Thu Nov 26 23:35:13 2020
(r368086)
+++ stable/12/sys/kern/subr_acl_nfs4.c  Thu Nov 26 23:44:57 2020
(r368087)
@@ -349,9 +349,9 @@ _acl_append(struct acl *aclp, acl_tag_t tag, acl_perm_
 }
 
 static struct acl_entry *
-_acl_duplicate_entry(struct acl *aclp, int entry_index)
+_acl_duplicate_entry(struct acl *aclp, unsigned entry_index)
 {
-   int i;
+   unsigned i;
 
KASSERT(aclp->acl_cnt + 1 <= ACL_MAX_ENTRIES,
("aclp->acl_cnt + 1 <= ACL_MAX_ENTRIES"));
@@ -368,7 +368,8 @@ static void
 acl_nfs4_sync_acl_from_mode_draft(struct acl *aclp, mode_t mode,
 int file_owner_id)
 {
-   int i, meets, must_append;
+   int meets, must_append;
+   unsigned i;
struct acl_entry *entry, *copy, *previous,
*a1, *a2, *a3, *a4, *a5, *a6;
mode_t amode;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368086 - stable/12/tools/regression/fsx

2020-11-26 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 23:35:13 2020
New Revision: 368086
URL: https://svnweb.freebsd.org/changeset/base/368086

Log:
  MFC r365956:
  
  fsx: fix build with WARNS=6
  
  * signed/unsigned comparisons
  * use standard warn(3)
  * Suppress warnings about local vars and funcs not declared static
  * const-correctness
  * declaration shadows a variable in the global scope
  
  Reviewed by:  kevans
  Differential Revision:https://reviews.freebsd.org/D26516

Modified:
  stable/12/tools/regression/fsx/Makefile
  stable/12/tools/regression/fsx/fsx.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/regression/fsx/Makefile
==
--- stable/12/tools/regression/fsx/Makefile Thu Nov 26 23:34:02 2020
(r368085)
+++ stable/12/tools/regression/fsx/Makefile Thu Nov 26 23:35:13 2020
(r368086)
@@ -4,4 +4,9 @@ PROG=   fsx
 
 MAN=
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
+
+# Don't require static declarations.  It's line noise in a single-file program.
+CWARNFLAGS+= -Wno-strict-prototypes -Wno-missing-prototypes

Modified: stable/12/tools/regression/fsx/fsx.c
==
--- stable/12/tools/regression/fsx/fsx.cThu Nov 26 23:34:02 2020
(r368085)
+++ stable/12/tools/regression/fsx/fsx.cThu Nov 26 23:35:13 2020
(r368086)
@@ -112,7 +112,7 @@ int closeprob = 0;  /* -c flag */
 intinvlprob = 0;   /* -i flag */
 intdebug = 0;  /* -d flag */
 unsigned long  debugstart = 0; /* -D flag */
-unsigned long  maxfilelen = 256 * 1024;/* -l flag */
+off_t  maxfilelen = 256 * 1024;/* -l flag */
 intsizechecks = 1; /* -n flag disables them */
 intmaxoplen = 64 * 1024;   /* -o flag */
 intquiet = 0;  /* -q flag */
@@ -138,33 +138,8 @@ int invl = 0;
 
 
 void
-vwarnc(code, fmt, ap)
-   int code;
-   const char *fmt;
-   va_list ap;
+prt(const char *fmt, ...)
 {
-   fprintf(stderr, "fsx: ");
-   if (fmt != NULL) {
-   vfprintf(stderr, fmt, ap);
-   fprintf(stderr, ": ");
-   }
-   fprintf(stderr, "%s\n", strerror(code));
-}
-
-
-void
-warn(const char * fmt, ...)
-{
-   va_list ap;
-   va_start(ap, fmt);
-   vwarnc(errno, fmt, ap);
-   va_end(ap);
-}
-
-
-void
-prt(char *fmt, ...)
-{
va_list args;
 
va_start(args, fmt);
@@ -179,7 +154,7 @@ prt(char *fmt, ...)
 }
 
 void
-prterr(char *prefix)
+prterr(const char *prefix)
 {
prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
 }
@@ -317,12 +292,12 @@ logdump(void)
 
 
 void
-save_buffer(char *buffer, off_t bufferlength, int fd)
+save_buffer(char *buffer, off_t bufferlength, int savefd)
 {
off_t ret;
ssize_t byteswritten;
 
-   if (fd <= 0 || bufferlength == 0)
+   if (savefd <= 0 || bufferlength == 0)
return;
 
if (bufferlength > SSIZE_MAX) {
@@ -330,7 +305,7 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
exit(67);
}
if (lite) {
-   off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END);
+   off_t size_by_seek = lseek(savefd, (off_t)0, SEEK_END);
if (size_by_seek == (off_t)-1)
prterr("save_buffer: lseek eof");
else if (bufferlength > size_by_seek) {
@@ -340,11 +315,11 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
}
}
 
-   ret = lseek(fd, (off_t)0, SEEK_SET);
+   ret = lseek(savefd, (off_t)0, SEEK_SET);
if (ret == (off_t)-1)
prterr("save_buffer: lseek 0");

-   byteswritten = write(fd, buffer, (size_t)bufferlength);
+   byteswritten = write(savefd, buffer, (size_t)bufferlength);
if (byteswritten != bufferlength) {
if (byteswritten == -1)
prterr("save_buffer write");
@@ -458,10 +433,10 @@ check_trunc_hack(void)
 
 
 void
-doread(unsigned offset, unsigned size)
+doread(off_t offset, off_t size)
 {
off_t ret;
-   unsigned iret;
+   ssize_t iret;
 
offset -= offset % readbdy;
if (size == 0) {
@@ -509,7 +484,7 @@ doread(unsigned offset, unsigned size)
 
 
 void
-check_eofpage(char *s, unsigned offset, char *p, int size)
+check_eofpage(const char *s, unsigned offset, char *p, int size)
 {
uintptr_t last_page, should_be_zero;
 
@@ -592,7 +567,7 @@ domapread(unsigned offset, unsigned size)
 
 
 void
-gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
+gendata(unsigned offset, unsigned size)
 {
while (size--) {
good_buf[offset] = testcalls % 256; 
@@ -607,7 +582,7 @@ void
 dowrite(unsigned offset, unsigned size)
 {
off_t ret;
-   

svn commit: r368085 - stable/12/lib/libc/gen

2020-11-26 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 23:34:02 2020
New Revision: 368085
URL: https://svnweb.freebsd.org/changeset/base/368085

Log:
  MFC r365910:
  
  fix integer underflow in getgrnam_r and getpwnam_r
  
  Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
  triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
  return ERANGE instead of 0.
  
  Fix the user's buffer size check, and add a correct check for a too-small
  nscd buffer.
  
  PR:   248932
  Event:September 2020 Bugathon
  Reviewed by:  markj
  Sponsored by: Axcient
  Differential Revision: https://reviews.freebsd.org/D26204

Modified:
  stable/12/lib/libc/gen/getgrent.c
  stable/12/lib/libc/gen/getpwent.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/gen/getgrent.c
==
--- stable/12/lib/libc/gen/getgrent.c   Thu Nov 26 22:49:05 2020
(r368084)
+++ stable/12/lib/libc/gen/getgrent.c   Thu Nov 26 23:34:02 2020
(r368085)
@@ -334,14 +334,27 @@ grp_unmarshal_func(char *buffer, size_t buffer_size, v
orig_buf_size = va_arg(ap, size_t);
ret_errno = va_arg(ap, int *);
 
-   if (orig_buf_size <
-   buffer_size - sizeof(struct group) - sizeof(char *)) {
+   if (orig_buf_size + sizeof(struct group) + sizeof(char *) < buffer_size)
+   {
*ret_errno = ERANGE;
return (NS_RETURN);
+   } else if (buffer_size < sizeof(struct group) + sizeof(char *)) {
+   /*
+* nscd(8) sometimes returns buffer_size=1 for nonexistent
+* entries.
+*/
+   *ret_errno = 0;
+   return (NS_NOTFOUND);
}
 
memcpy(grp, buffer, sizeof(struct group));
memcpy(, buffer + sizeof(struct group), sizeof(char *));
+
+   if (orig_buf_size + sizeof(struct group) + sizeof(char *) +
+   _ALIGN(p) - (size_t)p < buffer_size) {
+   *ret_errno = ERANGE;
+   return (NS_RETURN);
+   }
 
orig_buf = (char *)_ALIGN(orig_buf);
memcpy(orig_buf, buffer + sizeof(struct group) + sizeof(char *) +

Modified: stable/12/lib/libc/gen/getpwent.c
==
--- stable/12/lib/libc/gen/getpwent.c   Thu Nov 26 22:49:05 2020
(r368084)
+++ stable/12/lib/libc/gen/getpwent.c   Thu Nov 26 23:34:02 2020
(r368085)
@@ -389,10 +389,17 @@ pwd_unmarshal_func(char *buffer, size_t buffer_size, v
orig_buf_size = va_arg(ap, size_t);
ret_errno = va_arg(ap, int *);
 
-   if (orig_buf_size <
-   buffer_size - sizeof(struct passwd) - sizeof(char *)) {
+   if (orig_buf_size + sizeof(struct passwd) + sizeof(char *) <
+   buffer_size) {
*ret_errno = ERANGE;
return (NS_RETURN);
+   } else if (buffer_size < sizeof(struct passwd) + sizeof(char *)) {
+   /*
+* nscd(8) sometimes returns buffer_size=1 for nonexistent
+* entries.
+*/
+   *ret_errno = 0;
+   return (NS_NOTFOUND);
}
 
memcpy(pwd, buffer, sizeof(struct passwd));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-26 Thread Alan Somers
On Thu, Nov 26, 2020 at 2:16 AM Bjoern A. Zeeb <
bzeeb-li...@lists.zabbadoz.net> wrote:

> On 26 Nov 2020, at 4:29, Alan Somers wrote:
>
> > Author: asomers
> > Date: Thu Nov 26 04:29:30 2020
> > New Revision: 368045
> > URL: https://svnweb.freebsd.org/changeset/base/368045
> >
> > Log:
> >   Merge ping6 to ping
> >
> >   There is now a single ping binary, which chooses to use ICMP or
> > ICMPv4
> >   based on the -4 and -6 options, and the format of the address.
> >
> >   Submitted by:   Ján Sučan 
> >   Sponsored by:   Google LLC (Google Summer of Code 2019)
> >   MFC after:  Never
> >   Differential Revision:  https://reviews.freebsd.org/D21377
>
> I don’t have IPv4 anymore.
> I don’t see any WITHOUT_INET or -DINET checks.
> How can I compile INET out now?
>

I don't see any such checks before, either.  Was it ever possible to
exclude ping by building WITHOUT_INET?


>
>
> Also can we please have a ping6 [binary, compat shell script, or
> hardlink] back which defaults to -6 with appropriate option parsing by
> default?
> People used that in scripts and whatnot for about 20 years (and
> there’s even still stuff in tools in our own tree referencing it).
>

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


svn commit: r368078 - in head: . rescue/rescue sbin/ping sbin/ping/tests tools/build/mk

2020-11-26 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 18:33:04 2020
New Revision: 368078
URL: https://svnweb.freebsd.org/changeset/base/368078

Log:
  ping: add a ping6 hard link for backwards compatibility
  
  When invoked as "ping6", ping will now attempt to use ICMPv6 for hostnames
  that resolve both IPv4 and IPv6 addresses.
  
  Reviewed by:  bz, manu
  MFC-With: r368045
  Differential Revision:https://reviews.freebsd.org/D27384

Modified:
  head/ObsoleteFiles.inc
  head/rescue/rescue/Makefile
  head/sbin/ping/Makefile
  head/sbin/ping/main.c
  head/sbin/ping/ping.8
  head/sbin/ping/tests/ping_test.sh
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Nov 26 18:16:32 2020(r368077)
+++ head/ObsoleteFiles.inc  Thu Nov 26 18:33:04 2020(r368078)
@@ -37,8 +37,6 @@
 # done
 
 # 20201124: ping6(8) was merged into ping(8)
-OLD_FILES+=sbin/ping6
-OLD_FILES+=rescue/ping6
 OLD_FILES+=usr/lib/debug/sbin/ping6.debug
 OLD_FILES+=usr/share/man/man8/ping6.8.gz
 OLD_FILES+=usr/tests/sbin/ping6/Kyuafile

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Thu Nov 26 18:16:32 2020(r368077)
+++ head/rescue/rescue/Makefile Thu Nov 26 18:33:04 2020(r368078)
@@ -103,6 +103,7 @@ CRUNCH_PROGS_sbin+= ccdconfig
 .endif
 
 .if ${MK_INET6_SUPPORT} != "no"
+CRUNCH_ALIAS_ping= ping6
 CRUNCH_PROGS_sbin+= rtsol
 .endif
 

Modified: head/sbin/ping/Makefile
==
--- head/sbin/ping/Makefile Thu Nov 26 18:16:32 2020(r368077)
+++ head/sbin/ping/Makefile Thu Nov 26 18:33:04 2020(r368078)
@@ -15,6 +15,7 @@ LIBADD=   m
 CFLAGS+= -DINET6 -DKAME_SCOPEID
 SRCS+= ping6.c
 LIBADD+= md
+LINKS= ${BINDIR}/ping ${BINDIR}/ping6
 .endif
 
 .if ${MK_DYNAMICROOT} == "no"

Modified: head/sbin/ping/main.c
==
--- head/sbin/ping/main.c   Thu Nov 26 18:16:32 2020(r368077)
+++ head/sbin/ping/main.c   Thu Nov 26 18:33:04 2020(r368078)
@@ -66,7 +66,10 @@ main(int argc, char *argv[])
struct in6_addr a6;
bool ipv6;
 
-   ipv6 = false;
+   if (strcmp(getprogname(), "ping6") == 0)
+   ipv6 = true;
+   else
+   ipv6 = false;
 #endif
ipv4 = false;
 

Modified: head/sbin/ping/ping.8
==
--- head/sbin/ping/ping.8   Thu Nov 26 18:16:32 2020(r368077)
+++ head/sbin/ping/ping.8   Thu Nov 26 18:33:04 2020(r368078)
@@ -28,7 +28,7 @@
 .\" @(#)ping.8 8.2 (Berkeley) 12/11/93
 .\" $FreeBSD$
 .\"
-.Dd November 24, 2020
+.Dd November 26, 2020
 .Dt PING 8
 .Os
 .Sh NAME
@@ -141,6 +141,9 @@ the specific IP version can be requested by
 or
 .Fl 6
 options, respectively.
+For backwards-compatibility, ICMPv6 can also be selected by invoking the binary
+as
+.Nm ping6 .
 .Ss Options common to both IPv4 and IPv6 targets
 .Bl -tag -width indent
 .It Fl A

Modified: head/sbin/ping/tests/ping_test.sh
==
--- head/sbin/ping/tests/ping_test.sh   Thu Nov 26 18:16:32 2020
(r368077)
+++ head/sbin/ping/tests/ping_test.sh   Thu Nov 26 18:33:04 2020
(r368078)
@@ -53,9 +53,23 @@ ping_6_c1_s8_t1_body() {
 check_ping_statistics std.out $(atf_get_srcdir)/ping_6_c1_s8_t1.out
 }
 
+atf_test_case ping6_c1_s8_t1
+ping6_c1_s8_t1_head() {
+atf_set "descr" "Use IPv6 when invoked as ping6"
+}
+ping6_c1_s8_t1_body() {
+if ! getaddrinfo -f inet6 localhost 1>/dev/null 2>&1; then
+   atf_skip "IPv6 is not configured"
+fi
+atf_check -s exit:0 -o save:std.out -e empty \
+ ping6 -c 1 -s 8 -t 1 localhost
+check_ping_statistics std.out $(atf_get_srcdir)/ping_6_c1_s8_t1.out
+}
+
 atf_init_test_cases() {
 atf_add_test_case ping_c1_s56_t1
 atf_add_test_case ping_6_c1_s8_t1
+atf_add_test_case ping6_c1_s8_t1
 }
 
 check_ping_statistics() {

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Thu Nov 26 18:16:32 
2020(r368077)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Thu Nov 26 18:33:04 
2020(r368078)
@@ -2583,6 +2583,7 @@ OLD_DIRS+=usr/share/i18n/csmapper/GB
 .endif
 
 .if ${MK_INET6} == no
+OLD_FILES+=sbin/ping6
 OLD_FILES+=sbin/rtsol
 OLD_FILES+=usr/sbin/ip6addrctl
 OLD_FILES+=usr/sbin/mld6query
@@ -2611,6 +2612,7 @@ OLD_FILES+=usr/share/man/man8/traceroute6.8.gz
 .endif
 
 .if ${MK_INET6_SUPPORT} == no
+OLD_FILES+=rescue/ping6
 OLD_FILES+=rescue/rtsol
 .endif
 

Re: svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-26 Thread Alan Somers
> >
> > >  I think you should add a LINKS=... here so people script which uses
> > > ping6 won't break (and of course adding support in the code to do ipv6
> > > ping if progname is ping6 if this isn't the case).
> > >
> > >  Cheers,
> > >
> > > --
> > > Emmanuel Vadot 
> > >
> >
> > Yes, that would make sense.  But for how long?  Would the ping6 hard link
> > stick around forever, or eventually be removed in some future version of
> > FreeBSD?
>
>  I have no opinion on this matter.
>  But since ping6 was present for a very long time I guess we're stuck
> with it for a long time too.
>

Do you have an opinion on whether there should be a /rescue/ping6 link too?
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-26 Thread Alan Somers
On Thu, Nov 26, 2020 at 1:27 AM Emmanuel Vadot 
wrote:

>
>  Hi Alan,
>
> On Thu, 26 Nov 2020 04:29:31 +0000 (UTC)
> Alan Somers  wrote:
>
> > Author: asomers
> > Date: Thu Nov 26 04:29:30 2020
> > New Revision: 368045
> > URL: https://svnweb.freebsd.org/changeset/base/368045
> >
> > Log:
> >   Merge ping6 to ping
> >
> >   There is now a single ping binary, which chooses to use ICMP or ICMPv4
> >   based on the -4 and -6 options, and the format of the address.
> >
> >   Submitted by:   Ján Su?an 
> >   Sponsored by:   Google LLC (Google Summer of Code 2019)
> >   MFC after:  Never
> >   Differential Revision:  https://reviews.freebsd.org/D21377
> >
> > Added:
> >   head/sbin/ping/main.c   (contents, props changed)
> >   head/sbin/ping/main.h   (contents, props changed)
> >   head/sbin/ping/ping.h   (contents, props changed)
> >   head/sbin/ping/ping6.c
> >  - copied, changed from r368010, head/sbin/ping6/ping6.c
> >   head/sbin/ping/ping6.h   (contents, props changed)
> >   head/sbin/ping/tests/ping_6_c1_s8_t1.out
> >  - copied unchanged from r368010,
> head/sbin/ping6/tests/ping6_c1_s8_t1.out
> > Deleted:
> >   head/sbin/ping6/Makefile
> >   head/sbin/ping6/Makefile.depend
> >   head/sbin/ping6/ping6.8
> >   head/sbin/ping6/ping6.c
> >   head/sbin/ping6/tests/Makefile
> >   head/sbin/ping6/tests/ping6_c1_s8_t1.out
> >   head/sbin/ping6/tests/ping6_test.sh
> > Modified:
> >   head/ObsoleteFiles.inc
> >   head/UPDATING
> >   head/etc/mtree/BSD.tests.dist
> >   head/rescue/rescue/Makefile
> >   head/sbin/Makefile
> >   head/sbin/ping/Makefile
> >   head/sbin/ping/ping.8
> >   head/sbin/ping/ping.c
> >   head/sbin/ping/tests/Makefile
> >   head/sbin/ping/tests/ping_test.sh
> >   head/tools/build/mk/OptionalObsoleteFiles.inc
> >
> > Modified: head/ObsoleteFiles.inc
> >
> ==
> > --- head/ObsoleteFiles.incThu Nov 26 02:14:52 2020(r368044)
> > +++ head/ObsoleteFiles.incThu Nov 26 04:29:30 2020(r368045)
> > @@ -36,6 +36,16 @@
> >  #   xargs -n1 | sort | uniq -d;
> >  # done
> >
> > +# 20201124: ping6(8) was merged into ping(8)
> > +OLD_FILES+=sbin/ping6
> > +OLD_FILES+=rescue/ping6
> > +OLD_FILES+=usr/lib/debug/sbin/ping6.debug
> > +OLD_FILES+=usr/share/man/man8/ping6.8.gz
> > +OLD_FILES+=usr/tests/sbin/ping6/Kyuafile
> > +OLD_FILES+=usr/tests/sbin/ping6/ping6_c1_s8_t1.out
> > +OLD_FILES+=usr/tests/sbin/ping6/ping6_test
> > +OLD_DIRS+=usr/tests/sbin/ping6
> > +
> >  # 20201025: Remove cal data files
> >  OLD_FILES+=usr/share/calendar/calendar.all
> >  OLD_FILES+=usr/share/calendar/calendar.australia
> >
> > Modified: head/UPDATING
> >
> ==
> > --- head/UPDATING Thu Nov 26 02:14:52 2020(r368044)
> > +++ head/UPDATING Thu Nov 26 04:29:30 2020(r368045)
> > @@ -26,6 +26,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
> >   world, or to merely disable the most expensive debugging
> functionality
> >   at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
> >
> > +20201124:
> > + ping6 has been merged into ping.  It can now be called as "ping
> -6".
> > + See ping(8) for details.
> > +
> >  20201108:
> >   Default value of net.add_addr_allfibs has been changed to 0.
> >   If you have multi-fib configuration and rely on existence of all
> >
> > Modified: head/etc/mtree/BSD.tests.dist
> >
> ==
> > --- head/etc/mtree/BSD.tests.dist Thu Nov 26 02:14:52 2020
> (r368044)
> > +++ head/etc/mtree/BSD.tests.dist Thu Nov 26 04:29:30 2020
> (r368045)
> > @@ -448,8 +448,6 @@
> >  ..
> >  ping
> >  ..
> > -ping6
> > -..
> >  route
> >  ..
> >  ..
> >
> > Modified: head/rescue/rescue/Makefile
> >
> ==
> > --- head/rescue/rescue/Makefile   Thu Nov 26 02:14:52 2020
> (r368044)
> > +++ head/rescue/rescue/Makefile   Thu Nov 26 04:29:30 2020
> (r368045)
> > @@ -103,7 +103,6 @@ CRUNCH_PROGS_sbin+= ccdconfig
> >  .endif
> >
> >  

svn commit: r368046 - in head: contrib/traceroute share/man/man4 tests/sys/netinet tests/sys/netinet6 tests/sys/netipsec/tunnel tests/sys/netpfil/common tests/sys/netpfil/pf usr.sbin/traceroute6

2020-11-25 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 04:55:02 2020
New Revision: 368046
URL: https://svnweb.freebsd.org/changeset/base/368046

Log:
  ping: fix some man pages and tests after r368045
  
  MFC-with: r368045

Modified:
  head/contrib/traceroute/traceroute.8
  head/share/man/man4/inet6.4
  head/tests/sys/netinet/carp.sh
  head/tests/sys/netinet6/exthdr.sh
  head/tests/sys/netinet6/lpm6.sh
  head/tests/sys/netinet6/output6.sh
  head/tests/sys/netipsec/tunnel/utils.subr
  head/tests/sys/netpfil/common/pass_block.sh
  head/tests/sys/netpfil/pf/fragmentation.sh
  head/tests/sys/netpfil/pf/pass_block.sh
  head/tests/sys/netpfil/pf/table.sh
  head/usr.sbin/traceroute6/traceroute6.8

Modified: head/contrib/traceroute/traceroute.8
==
--- head/contrib/traceroute/traceroute.8Thu Nov 26 04:29:30 2020
(r368045)
+++ head/contrib/traceroute/traceroute.8Thu Nov 26 04:55:02 2020
(r368046)
@@ -16,7 +16,7 @@
 .\"$Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $
 .\"$FreeBSD$
 .\"
-.Dd June 20, 2019
+.Dd November 25, 2020
 .Dt TRACEROUTE 8
 .Os
 .Sh NAME
@@ -377,7 +377,6 @@ during normal operations or from automated scripts.
 .Sh SEE ALSO
 .Xr netstat 1 ,
 .Xr ping 8 ,
-.Xr ping6 8 ,
 .Xr traceroute6 8 .
 .Sh AUTHORS
 Implemented by Van Jacobson from a suggestion by Steve Deering.  Debugged

Modified: head/share/man/man4/inet6.4
==
--- head/share/man/man4/inet6.4 Thu Nov 26 04:29:30 2020(r368045)
+++ head/share/man/man4/inet6.4 Thu Nov 26 04:55:02 2020(r368046)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 14, 2018
+.Dd November 25, 2020
 .Dt INET6 4
 .Os
 .Sh NAME
@@ -130,7 +130,7 @@ or
 are able to use this notation.
 With special programs
 like
-.Xr ping6 8 ,
+.Xr ping 8 ,
 you can specify the outgoing interface by an extra command line option
 to disambiguate scoped addresses.
 .Pp

Modified: head/tests/sys/netinet/carp.sh
==
--- head/tests/sys/netinet/carp.sh  Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet/carp.sh  Thu Nov 26 04:55:02 2020
(r368046)
@@ -137,7 +137,7 @@ basic_v6_body()
carp_basic_v6_three ${epair_two}b
 
atf_check -s exit:0 -o ignore jexec carp_basic_v6_one \
-   ping6 -c 3 2001:db8::0:1
+   ping -6 -c 3 2001:db8::0:1
 }
 
 basic_v6_cleanup()

Modified: head/tests/sys/netinet6/exthdr.sh
==
--- head/tests/sys/netinet6/exthdr.sh   Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet6/exthdr.sh   Thu Nov 26 04:55:02 2020
(r368046)
@@ -74,7 +74,7 @@ exthdr_body() {
pyname=$(atf_get ident)
pyname=${pyname%*_[0-9]}
 
-   atf_check -o ignore -s exit:0 ping6 -c 3 -q -o ${ip6b}
+   atf_check -o ignore -s exit:0 ping -6 -c 3 -q -o ${ip6b}
 
atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \
--sendif ${epair}a --recvif ${epair}a \

Modified: head/tests/sys/netinet6/lpm6.sh
==
--- head/tests/sys/netinet6/lpm6.sh Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet6/lpm6.sh Thu Nov 26 04:55:02 2020
(r368046)
@@ -100,7 +100,7 @@ lpm6_test1_success_body()
valid_message="${count} packets transmitted, ${count} packets received"

# Check that ${net_dst}:2:0 goes via epair0
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:0
+   atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f 
-nc${count} ${net_dst}:2:0
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk 
'$1!~/^Name/{print$8}'`
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk 
'$1!~/^Name/{print$8}'`
if [ ${pkt_0} -le ${count} ]; then
@@ -109,7 +109,7 @@ lpm6_test1_success_body()
fi
 
# Check that ${net_dst}:2:1 goes via epair1
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:1
+   atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f 
-nc${count} ${net_dst}:2:1
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk 
'$1!~/^Name/{print$8}'`
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk 
'$1!~/^Name/{print$8}'`
if [ ${pkt_1} -le ${count} ]; then
@@ -163,7 +163,7 @@ lpm6_test2_success_body()
valid_message="${count} packets transmitted, ${count} packets received"

# Check that ${net_dst}:2:0 goes via epair1
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:0
+   atf_check -o match:"${valid_message}" 

svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-25 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 04:29:30 2020
New Revision: 368045
URL: https://svnweb.freebsd.org/changeset/base/368045

Log:
  Merge ping6 to ping
  
  There is now a single ping binary, which chooses to use ICMP or ICMPv4
  based on the -4 and -6 options, and the format of the address.
  
  Submitted by: Ján Sučan 
  Sponsored by: Google LLC (Google Summer of Code 2019)
  MFC after:Never
  Differential Revision:https://reviews.freebsd.org/D21377

Added:
  head/sbin/ping/main.c   (contents, props changed)
  head/sbin/ping/main.h   (contents, props changed)
  head/sbin/ping/ping.h   (contents, props changed)
  head/sbin/ping/ping6.c
 - copied, changed from r368010, head/sbin/ping6/ping6.c
  head/sbin/ping/ping6.h   (contents, props changed)
  head/sbin/ping/tests/ping_6_c1_s8_t1.out
 - copied unchanged from r368010, head/sbin/ping6/tests/ping6_c1_s8_t1.out
Deleted:
  head/sbin/ping6/Makefile
  head/sbin/ping6/Makefile.depend
  head/sbin/ping6/ping6.8
  head/sbin/ping6/ping6.c
  head/sbin/ping6/tests/Makefile
  head/sbin/ping6/tests/ping6_c1_s8_t1.out
  head/sbin/ping6/tests/ping6_test.sh
Modified:
  head/ObsoleteFiles.inc
  head/UPDATING
  head/etc/mtree/BSD.tests.dist
  head/rescue/rescue/Makefile
  head/sbin/Makefile
  head/sbin/ping/Makefile
  head/sbin/ping/ping.8
  head/sbin/ping/ping.c
  head/sbin/ping/tests/Makefile
  head/sbin/ping/tests/ping_test.sh
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Nov 26 02:14:52 2020(r368044)
+++ head/ObsoleteFiles.inc  Thu Nov 26 04:29:30 2020(r368045)
@@ -36,6 +36,16 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20201124: ping6(8) was merged into ping(8)
+OLD_FILES+=sbin/ping6
+OLD_FILES+=rescue/ping6
+OLD_FILES+=usr/lib/debug/sbin/ping6.debug
+OLD_FILES+=usr/share/man/man8/ping6.8.gz
+OLD_FILES+=usr/tests/sbin/ping6/Kyuafile
+OLD_FILES+=usr/tests/sbin/ping6/ping6_c1_s8_t1.out
+OLD_FILES+=usr/tests/sbin/ping6/ping6_test
+OLD_DIRS+=usr/tests/sbin/ping6
+
 # 20201025: Remove cal data files
 OLD_FILES+=usr/share/calendar/calendar.all
 OLD_FILES+=usr/share/calendar/calendar.australia

Modified: head/UPDATING
==
--- head/UPDATING   Thu Nov 26 02:14:52 2020(r368044)
+++ head/UPDATING   Thu Nov 26 04:29:30 2020(r368045)
@@ -26,6 +26,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
world, or to merely disable the most expensive debugging functionality
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20201124:
+   ping6 has been merged into ping.  It can now be called as "ping -6".
+   See ping(8) for details.
+
 20201108:
Default value of net.add_addr_allfibs has been changed to 0.
If you have multi-fib configuration and rely on existence of all

Modified: head/etc/mtree/BSD.tests.dist
==
--- head/etc/mtree/BSD.tests.dist   Thu Nov 26 02:14:52 2020
(r368044)
+++ head/etc/mtree/BSD.tests.dist   Thu Nov 26 04:29:30 2020
(r368045)
@@ -448,8 +448,6 @@
 ..
 ping
 ..
-ping6
-..
 route
 ..
 ..

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Thu Nov 26 02:14:52 2020(r368044)
+++ head/rescue/rescue/Makefile Thu Nov 26 04:29:30 2020(r368045)
@@ -103,7 +103,6 @@ CRUNCH_PROGS_sbin+= ccdconfig
 .endif
 
 .if ${MK_INET6_SUPPORT} != "no"
-CRUNCH_PROGS_sbin+= ping6
 CRUNCH_PROGS_sbin+= rtsol
 .endif
 

Modified: head/sbin/Makefile
==
--- head/sbin/Makefile  Thu Nov 26 02:14:52 2020(r368044)
+++ head/sbin/Makefile  Thu Nov 26 04:29:30 2020(r368045)
@@ -73,7 +73,6 @@ SUBDIR.${MK_CCD}+=ccdconfig
 SUBDIR.${MK_CXX}+= devd
 SUBDIR.${MK_HAST}+=hastctl
 SUBDIR.${MK_HAST}+=hastd
-SUBDIR.${MK_INET6}+=   ping6
 SUBDIR.${MK_INET6}+=   rtsol
 SUBDIR.${MK_IPFILTER}+=ipf
 SUBDIR.${MK_IPFW}+=ipfw

Modified: head/sbin/ping/Makefile
==
--- head/sbin/ping/Makefile Thu Nov 26 02:14:52 2020(r368044)
+++ head/sbin/ping/Makefile Thu Nov 26 04:29:30 2020(r368045)
@@ -5,11 +5,17 @@
 
 PACKAGE=runtime
 PROG=  ping
-SRCS=  ping.c utils.c
+SRCS=  main.c ping.c utils.c
 MAN=   ping.8
 BINOWN=root
 BINMODE=4555
 LIBADD=m
+
+.if ${MK_INET6_SUPPORT} != "no"
+CFLAGS+= -DINET6 -DKAME_SCOPEID
+SRCS+= ping6.c
+LIBADD+= md
+.endif
 
 .if ${MK_DYNAMICROOT} == "no"
 .warning ${PROG} built without libcasper support

Added: head/sbin/ping/main.c

svn commit: r367976 - head/sbin/ping6

2020-11-23 Thread Alan Somers
Author: asomers
Date: Tue Nov 24 02:51:45 2020
New Revision: 367976
URL: https://svnweb.freebsd.org/changeset/base/367976

Log:
  ping6: update usage text after r365547
  
  MFC after:2 weeks

Modified:
  head/sbin/ping6/ping6.c

Modified: head/sbin/ping6/ping6.c
==
--- head/sbin/ping6/ping6.c Tue Nov 24 02:05:43 2020(r367975)
+++ head/sbin/ping6/ping6.c Tue Nov 24 02:51:45 2020(r367976)
@@ -2868,7 +2868,8 @@ usage(void)
" [-P policy]"
 #endif
" [-S sourceaddr] [-s packetsize]\n"
-   " [-t timeout] [-W waittime] [hops ...] host\n");
+   " [-t timeout] [-W waittime] [-z tclass] [hops ...] "
+   "host\n");
exit(1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367785 - in head/sys: fs/nfs nfsserver

2020-11-17 Thread Alan Somers
Author: asomers
Date: Wed Nov 18 04:35:49 2020
New Revision: 367785
URL: https://svnweb.freebsd.org/changeset/base/367785

Log:
  nfs: Mark unused statistics variable as reserved
  
  FreeBSD's NFS exporter has long exported some unused statistics fields.
  Revision r366992 removed them from nfsstat. This revision renames those
  fields in the kernel's exported structures to make it clear to other
  consumers that they are unused.
  
  Reported by:  emaste
  Reviewed by:  emaste
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D27258

Modified:
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfsport.h
  head/sys/nfsserver/nfsrvstats.h

Modified: head/sys/fs/nfs/nfs_commonport.c
==
--- head/sys/fs/nfs/nfs_commonport.cWed Nov 18 03:43:03 2020
(r367784)
+++ head/sys/fs/nfs/nfs_commonport.cWed Nov 18 04:35:49 2020
(r367785)
@@ -541,16 +541,15 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
i < NFSV42_NOPS + NFSV4OP_FAKENOPS; i++, j++)
oldnfsstats.srvrpccnt[j] =
nfsstatsv1.srvrpccnt[i];
-   oldnfsstats.srvrpc_errs = nfsstatsv1.srvrpc_errs;
-   oldnfsstats.srv_errs = nfsstatsv1.srv_errs;
+   oldnfsstats.reserved_0 = 0;
+   oldnfsstats.reserved_1 = 0;
oldnfsstats.rpcrequests = nfsstatsv1.rpcrequests;
oldnfsstats.rpctimeouts = nfsstatsv1.rpctimeouts;
oldnfsstats.rpcunexpected = nfsstatsv1.rpcunexpected;
oldnfsstats.rpcinvalid = nfsstatsv1.rpcinvalid;
oldnfsstats.srvcache_inproghits =
nfsstatsv1.srvcache_inproghits;
-   oldnfsstats.srvcache_idemdonehits =
-   nfsstatsv1.srvcache_idemdonehits;
+   oldnfsstats.reserved_2 = 0;
oldnfsstats.srvcache_nonidemdonehits =
nfsstatsv1.srvcache_nonidemdonehits;
oldnfsstats.srvcache_misses =
@@ -636,10 +635,8 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
 i++, j++)
nfsstatsov1.srvrpccnt[j] =
nfsstatsv1.srvrpccnt[i];
-   nfsstatsov1.srvrpc_errs =
-   nfsstatsv1.srvrpc_errs;
-   nfsstatsov1.srv_errs =
-   nfsstatsv1.srv_errs;
+   nfsstatsov1.reserved_0 = 0;
+   nfsstatsov1.reserved_1 = 0;
nfsstatsov1.rpcrequests =
nfsstatsv1.rpcrequests;
nfsstatsov1.rpctimeouts =
@@ -650,8 +647,7 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
nfsstatsv1.rpcinvalid;
nfsstatsov1.srvcache_inproghits =
nfsstatsv1.srvcache_inproghits;
-   nfsstatsov1.srvcache_idemdonehits =
-   nfsstatsv1.srvcache_idemdonehits;
+   nfsstatsov1.reserved_2 = 0;
nfsstatsov1.srvcache_nonidemdonehits =
nfsstatsv1.srvcache_nonidemdonehits;
nfsstatsov1.srvcache_misses =
@@ -750,10 +746,7 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
sizeof(nfsstatsv1.rpccnt));
}
if ((uap->flag & NFSSVC_ZEROSRVSTATS) != 0) {
-   nfsstatsv1.srvrpc_errs = 0;
-   nfsstatsv1.srv_errs = 0;
nfsstatsv1.srvcache_inproghits = 0;
-   nfsstatsv1.srvcache_idemdonehits = 0;
nfsstatsv1.srvcache_nonidemdonehits = 0;
nfsstatsv1.srvcache_misses = 0;
nfsstatsv1.srvcache_tcppeak = 0;

Modified: head/sys/fs/nfs/nfsport.h
==
--- head/sys/fs/nfs/nfsport.h   Wed Nov 18 03:43:03 2020(r367784)
+++ head/sys/fs/nfs/nfsport.h   Wed Nov 18 04:35:49 2020(r367785)
@@ -447,14 +447,14 @@ struct nfsstatsv1 {
uint64_trpccnt[NFSV42_NPROCS + 15];
uint64_trpcretries;
uint64_t

svn commit: r366992 - head/usr.bin/nfsstat

2020-10-23 Thread Alan Somers
Author: asomers
Date: Sat Oct 24 05:52:29 2020
New Revision: 366992
URL: https://svnweb.freebsd.org/changeset/base/366992

Log:
  nfsstat: delete unused fields
  
  Ever since r192762 nfsstat has included a few fields whose values were
  always 0. They were copied from OpenBSD, but have never been used on
  FreeBSD. Don't display them.
  
  Reviewed by:  rmacklem
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26920

Modified:
  head/usr.bin/nfsstat/nfsstat.c

Modified: head/usr.bin/nfsstat/nfsstat.c
==
--- head/usr.bin/nfsstat/nfsstat.c  Sat Oct 24 05:26:58 2020
(r366991)
+++ head/usr.bin/nfsstat/nfsstat.c  Sat Oct 24 05:52:29 2020
(r366992)
@@ -450,12 +450,7 @@ intpr(int clientOnly, int serverOnly)
xo_close_container("operations");
 
xo_open_container("server");
-   xo_emit("{T:Server Re-Failed}\n");
-   xo_emit("{:retfailed/%16ju}\n", 
(uintmax_t)ext_nfsstats.srvrpc_errs);
 
-   xo_emit("{T:Server Faults}\n");
-   xo_emit("{:faults/%13ju}\n", (uintmax_t)ext_nfsstats.srv_errs);
-
xo_emit("{T:Server Write Gathering:/%13.13s}\n");
 
xo_emit("{T:WriteOps/%13.13s}{T:WriteRPC/%13.13s}"
@@ -473,12 +468,10 @@ intpr(int clientOnly, int serverOnly)
 
xo_open_container("cache");
xo_emit("{T:Server Cache Stats:/%13.13s}\n");
-   xo_emit("{T:Inprog/%13.13s}{T:Idem/%13.13s}"
+   xo_emit("{T:Inprog/%13.13s}"
"{T:Non-Idem/%13.13s}{T:Misses/%13.13s}\n");
-   xo_emit("{:inprog/%13ju}{:idem/%13ju}"
-   "{:nonidem/%13ju}{:misses/%13ju}\n",
+   xo_emit("{:inprog/%13ju}{:nonidem/%13ju}{:misses/%13ju}\n",
(uintmax_t)ext_nfsstats.srvcache_inproghits,
-   (uintmax_t)ext_nfsstats.srvcache_idemdonehits,
(uintmax_t)ext_nfsstats.srvcache_nonidemdonehits,
(uintmax_t)ext_nfsstats.srvcache_misses);
xo_close_container("cache");
@@ -1057,17 +1050,12 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41)
if (printtitle)
xo_emit("{T:Server:}\n");
xo_open_container("server");
-   xo_emit("{T:Retfailed/%13.13s}{T:Faults/%13.13s}"
-   "{T:Clients/%13.13s}\n");
-   xo_emit("{:retfailed/%13ju}{:faults/%13ju}{:clients/%13ju}\n",
-   (uintmax_t)ext_nfsstats.srv_errs,
-   (uintmax_t)ext_nfsstats.srvrpc_errs,
-   (uintmax_t)ext_nfsstats.srvclients);
-   xo_emit("{T:OpenOwner/%13.13s}{T:Opens/%13.13s}"
-   "{T:LockOwner/%13.13s}{T:Locks/%13.13s}"
+   xo_emit("{T:Clients/%13.13s}{T:OpenOwner/%13.13s}"
+   "{T:Opens/%13.13s}{T:LockOwner/%13.13s}{T:Locks/%13.13s}"
"{T:Delegs/%13.13s}\n");
-   xo_emit("{:openowner/%13ju}{:opens/%13ju}{:lockowner/%13ju}"
- "{:locks/%13ju}{:delegs/%13ju}\n",
+   xo_emit("{:clients/%13ju}{:openowner/%13ju}{:opens/%13ju}"
+   "{:lockowner/%13ju}{:locks/%13ju}{:delegs/%13ju}\n",
+   (uintmax_t)ext_nfsstats.srvclients,
(uintmax_t)ext_nfsstats.srvopenowners,
(uintmax_t)ext_nfsstats.srvopens,
(uintmax_t)ext_nfsstats.srvlockowners,
@@ -1078,13 +1066,12 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41)
if (printtitle)
xo_emit("{T:Server Cache Stats:}\n");
xo_open_container("cache");
-   xo_emit("{T:Inprog/%13.13s}{T:Idem/%13.13s}"
+   xo_emit("{T:Inprog/%13.13s}"
"{T:Non-idem/%13.13s}{T:Misses/%13.13s}"
"{T:CacheSize/%13.13s}{T:TCPPeak/%13.13s}\n");
-   xo_emit("{:inprog/%13ju}{:idem/%13ju}{:nonidem/%13ju}"
+   xo_emit("{:inprog/%13ju}{:nonidem/%13ju}"
"{:misses/%13ju}{:cachesize/%13ju}{:tcppeak/%13ju}\n",
(uintmax_t)ext_nfsstats.srvcache_inproghits,
-   (uintmax_t)ext_nfsstats.srvcache_idemdonehits,
(uintmax_t)ext_nfsstats.srvcache_nonidemdonehits,
(uintmax_t)ext_nfsstats.srvcache_misses,
(uintmax_t)ext_nfsstats.srvcache_size,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366365 - head/tests/sys/fs/fusefs

2020-10-02 Thread Alan Somers
Author: asomers
Date: Fri Oct  2 17:06:05 2020
New Revision: 366365
URL: https://svnweb.freebsd.org/changeset/base/366365

Log:
  fusefs tests: quell Coverity "Argument cannot be negative" warnings
  
  Must abort tests early if open(2) fails.
  
  Reported by:  Coverity
  Coverity CID: 1432810 and many others
  Reviewed by:  kevans
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26635

Modified:
  head/tests/sys/fs/fusefs/allow_other.cc
  head/tests/sys/fs/fusefs/create.cc
  head/tests/sys/fs/fusefs/default_permissions.cc
  head/tests/sys/fs/fusefs/flush.cc
  head/tests/sys/fs/fusefs/open.cc
  head/tests/sys/fs/fusefs/opendir.cc
  head/tests/sys/fs/fusefs/release.cc
  head/tests/sys/fs/fusefs/releasedir.cc
  head/tests/sys/fs/fusefs/write.cc

Modified: head/tests/sys/fs/fusefs/allow_other.cc
==
--- head/tests/sys/fs/fusefs/allow_other.cc Fri Oct  2 15:37:51 2020
(r366364)
+++ head/tests/sys/fs/fusefs/allow_other.cc Fri Oct  2 17:06:05 2020
(r366365)
@@ -168,7 +168,7 @@ TEST_F(AllowOther, privilege_escalation)
.WillRepeatedly(Invoke(ReturnErrno(EPERM)));
 
fd1 = open(FULLPATH, O_RDONLY);
-   EXPECT_LE(0, fd1) << strerror(errno);
+   ASSERT_LE(0, fd1) << strerror(errno);
}, [] {
int fd0;
 

Modified: head/tests/sys/fs/fusefs/create.cc
==
--- head/tests/sys/fs/fusefs/create.cc  Fri Oct  2 15:37:51 2020
(r366364)
+++ head/tests/sys/fs/fusefs/create.cc  Fri Oct  2 17:06:05 2020
(r366365)
@@ -143,7 +143,7 @@ TEST_F(Create, attr_cache)
).Times(0);
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -184,7 +184,7 @@ TEST_F(Create, clear_attr_cache)
 
EXPECT_EQ(0, stat("mountpoint", )) << strerror(errno);
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
EXPECT_EQ(0, stat("mountpoint", )) << strerror(errno);
 
leak(fd);
@@ -254,7 +254,7 @@ TEST_F(Create, Enosys)
})));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -366,7 +366,7 @@ TEST_F(Create, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -398,7 +398,7 @@ TEST_F(Create, wronly_0444)
}));
 
fd = open(FULLPATH, O_CREAT | O_WRONLY, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -422,7 +422,7 @@ TEST_F(Create_7_8, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -446,6 +446,6 @@ TEST_F(Create_7_11, ok)
}));
 
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }

Modified: head/tests/sys/fs/fusefs/default_permissions.cc
==
--- head/tests/sys/fs/fusefs/default_permissions.cc Fri Oct  2 15:37:51 
2020(r366364)
+++ head/tests/sys/fs/fusefs/default_permissions.cc Fri Oct  2 17:06:05 
2020(r366365)
@@ -490,7 +490,7 @@ TEST_F(Create, ok)
expect_create(RELPATH, ino);
 
fd = open(FULLPATH, O_CREAT | O_EXCL, 0644);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 
@@ -765,7 +765,7 @@ TEST_F(Open, ok)
expect_open(ino, 0, 1);
 
fd = open(FULLPATH, O_RDONLY);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
leak(fd);
 }
 

Modified: head/tests/sys/fs/fusefs/flush.cc
==
--- head/tests/sys/fs/fusefs/flush.cc   Fri Oct  2 15:37:51 2020
(r366364)
+++ head/tests/sys/fs/fusefs/flush.cc   Fri Oct  2 17:06:05 2020
(r366365)
@@ -102,10 +102,10 @@ TEST_F(Flush, open_twice)
expect_release();
 
fd = open(FULLPATH, O_WRONLY);
-   EXPECT_LE(0, fd) << strerror(errno);
+   ASSERT_LE(0, fd) << strerror(errno);
 
fd2 = open(FULLPATH, O_WRONLY);
-   EXPECT_LE(0, fd2) << strerror(errno);
+   ASSERT_LE(0, fd2) << strerror(errno);
 
EXPECT_EQ(0, close(fd2)) << strerror(errno);
EXPECT_EQ(0, close(fd)) << strerror(errno);
@@ -132,7 +132,7 @@ TEST_F(Flush, eio)
   

svn commit: r366341 - stable/12/cddl/contrib/opensolaris/lib/libzfs/common

2020-10-01 Thread Alan Somers
Author: asomers
Date: Thu Oct  1 19:55:52 2020
New Revision: 366341
URL: https://svnweb.freebsd.org/changeset/base/366341

Log:
  zfs: fix "zfs receive" of interrupted stream without "-F" after r366180
  
  The OpenZFS test suite revealed a regression with the changes made by
  r366180 and r364974: "zfs recv" resuming and interrupted stream without -F
  would refuse to run, complaining that "dataset exists".
  
  Direct commit to stable/12 because head has moved to the OpenZFS code base.
  
  Upstream issue: https://github.com/openzfs/zfs/issues/10995
  
  Reviewed by:  mmacy
  MFC after:3 days
  MFC-with: 366180
  Sponsored by: Axcient

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Thu Oct  1 19:17:03 2020(r366340)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Thu Oct  1 19:55:52 2020(r366341)
@@ -3138,7 +3138,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
char prop_errbuf[1024];
const char *chopprefix;
boolean_t newfs = B_FALSE;
-   boolean_t stream_wantsnewfs;
+   boolean_t stream_wantsnewfs, stream_resumingnewfs;
uint64_t parent_snapguid = 0;
prop_changelist_t *clp = NULL;
nvlist_t *snapprops_nvlist = NULL;
@@ -3301,7 +3301,9 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) &
DMU_BACKUP_FEATURE_RESUMING;
stream_wantsnewfs = (drrb->drr_fromguid == 0 ||
-   (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap);
+   (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap) && !resuming;
+   stream_resumingnewfs = (drrb->drr_fromguid == 0 ||
+   (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap) && resuming;
 
if (stream_wantsnewfs) {
/*
@@ -3433,7 +3435,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
}
 
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
-   stream_wantsnewfs) {
+   (stream_wantsnewfs || stream_resumingnewfs)) {
/* We can't do online recv in this case */
clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0);
if (clp == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r366207 - head/lib/libc/gen

2020-09-27 Thread Alan Somers
On Sun, Sep 27, 2020 at 5:15 PM Konstantin Belousov 
wrote:

> On Sun, Sep 27, 2020 at 10:26:41PM +0000, Alan Somers wrote:
> > Author: asomers
> > Date: Sun Sep 27 22:26:41 2020
> > New Revision: 366207
> > URL: https://svnweb.freebsd.org/changeset/base/366207
> >
> > Log:
> >   Misc compiler warning fixes in lib/libc
> >
> >   Reviewed by:kevans, imp
> >   MFC after:  2 weeks
> >   Differential Revision:  https://reviews.freebsd.org/D26534
> >
> > Modified:
> >   head/lib/libc/gen/auxv.c
> >   head/lib/libc/gen/basename_compat.c
> >   head/lib/libc/gen/crypt.c
> >   head/lib/libc/gen/dirname_compat.c
> >   head/lib/libc/gen/fts-compat.c
> >   head/lib/libc/gen/ftw-compat11.c
> >   head/lib/libc/gen/getentropy.c
> >
> > Modified: head/lib/libc/gen/auxv.c
> >
> ==
> > --- head/lib/libc/gen/auxv.c  Sun Sep 27 21:43:19 2020(r366206)
> > +++ head/lib/libc/gen/auxv.c  Sun Sep 27 22:26:41 2020(r366207)
> > @@ -67,7 +67,8 @@ __init_elf_aux_vector(void)
> >  }
> >
> >  static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
> > -static int pagesize, osreldate, canary_len, ncpus, pagesizes_len,
> bsdflags;
> > +static int pagesize, osreldate, ncpus, bsdflags;
> > +static size_t canary_len, pagesizes_len;
> >  static int hwcap_present, hwcap2_present;
> >  static char *canary, *pagesizes, *execpath;
> >  static void *ps_strings, *timekeep;
> > @@ -245,16 +246,21 @@ int
> >  _elf_aux_info(int aux, void *buf, int buflen)
> >  {
> >   int res;
> > + size_t buflen_;
> >
> >   __init_elf_aux_vector();
> >   if (__elf_aux_vector == NULL)
> >   return (ENOSYS);
> >   _once(_once, init_aux);
> >
> > + if (buflen < 0)
> > + return (EINVAL);
> > + buflen_ = (size_t)buflen;
> > +
> >   switch (aux) {
> >   case AT_CANARY:
> > - if (canary != NULL && canary_len >= buflen) {
> > - memcpy(buf, canary, buflen);
> > + if (canary != NULL && canary_len >= buflen_) {
> > + memcpy(buf, canary, buflen_);
> >   memset(canary, 0, canary_len);
> >   canary = NULL;
> >   res = 0;
> > @@ -267,35 +273,35 @@ _elf_aux_info(int aux, void *buf, int buflen)
> >   else if (buf == NULL)
> >   res = EINVAL;
> >   else {
> > - if (strlcpy(buf, execpath, buflen) >= buflen)
> > + if (strlcpy(buf, execpath, buflen_) >= buflen_)
> >   res = EINVAL;
> >   else
> >   res = 0;
> >   }
> >   break;
> >   case AT_HWCAP:
> > - if (hwcap_present && buflen == sizeof(u_long)) {
> > + if (hwcap_present && buflen_ == sizeof(u_long)) {
> >   *(u_long *)buf = hwcap;
> >   res = 0;
> >   } else
> >   res = ENOENT;
> >   break;
> >   case AT_HWCAP2:
> > - if (hwcap2_present && buflen == sizeof(u_long)) {
> > + if (hwcap2_present && buflen_ == sizeof(u_long)) {
> >   *(u_long *)buf = hwcap2;
> >   res = 0;
> >   } else
> >   res = ENOENT;
> >   break;
> >   case AT_PAGESIZES:
> > - if (pagesizes != NULL && pagesizes_len >= buflen) {
> > - memcpy(buf, pagesizes, buflen);
> > + if (pagesizes != NULL && pagesizes_len >= buflen_) {
> > + memcpy(buf, pagesizes, buflen_);
> >   res = 0;
> >   } else
> >   res = ENOENT;
> >   break;
> >   case AT_PAGESZ:
> > - if (buflen == sizeof(int)) {
> > + if (buflen_ == sizeof(int)) {
> >   if (pagesize != 0) {
> >   *(int *)buf = pagesize;
> >   res = 0;
> > @@ -305,7 +311,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
> >   res = EINVAL;
> >   break;
> >   case 

svn commit: r366211 - in releng/12.2: sys/fs/fuse tests/sys/fs/fusefs

2020-09-27 Thread Alan Somers
Author: asomers
Date: Mon Sep 28 00:23:59 2020
New Revision: 366211
URL: https://svnweb.freebsd.org/changeset/base/366211

Log:
  MF stable/12 r366190:
  
  fusefs: fix mmap'd writes in direct_io mode
  
  If a FUSE server returns FOPEN_DIRECT_IO in response to FUSE_OPEN, that
  instructs the kernel to bypass the page cache for that file. This feature
  is also known by libfuse's name: "direct_io".
  
  However, when accessing a file via mmap, there is no possible way to bypass
  the cache completely. This change fixes a deadlock that would happen when
  an mmap'd write tried to invalidate a portion of the cache, wrongly assuming
  that a write couldn't possibly come from cache if direct_io were set.
  
  Arguably, we could instead disable mmap for files with FOPEN_DIRECT_IO set.
  But allowing it is less likely to cause user complaints, and is more in
  keeping with the spirit of open(2), where O_DIRECT instructs the kernel to
  "reduce", not "eliminate" cache effects.
  
  PR:   247276
  Approved by:  re (gjb)
  Reported by:  trape...@spawn.link
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D26485

Modified:
  releng/12.2/sys/fs/fuse/fuse_io.c
  releng/12.2/tests/sys/fs/fusefs/write.cc
Directory Properties:
  releng/12.2/   (props changed)

Modified: releng/12.2/sys/fs/fuse/fuse_io.c
==
--- releng/12.2/sys/fs/fuse/fuse_io.c   Sun Sep 27 23:01:54 2020
(r366210)
+++ releng/12.2/sys/fs/fuse/fuse_io.c   Mon Sep 28 00:23:59 2020
(r366211)
@@ -291,6 +291,7 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
fuse_vnode_update(vp, FN_MTIMECHANGE | FN_CTIMECHANGE);
if (directio) {
off_t start, end, filesize;
+   bool pages = (ioflag & IO_VMIO) != 0;
 
SDT_PROBE2(fusefs, , io, trace, 1,
"direct write of vnode");
@@ -301,15 +302,14 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
 
start = uio->uio_offset;
end = start + uio->uio_resid;
-   KASSERT((ioflag & (IO_VMIO | IO_DIRECT)) !=
-   (IO_VMIO | IO_DIRECT),
-   ("IO_DIRECT used for a cache flush?"));
-   /* Invalidate the write cache when writing directly */
-   err = fuse_inval_buf_range(vp, filesize, start, end);
-   if (err)
-   return (err);
+   if (!pages) {
+   err = fuse_inval_buf_range(vp, filesize, start,
+   end);
+   if (err)
+   return (err);
+   }
err = fuse_write_directbackend(vp, uio, cred, fufh,
-   filesize, ioflag, false);
+   filesize, ioflag, pages);
} else {
SDT_PROBE2(fusefs, , io, trace, 1,
"buffered write of vnode");

Modified: releng/12.2/tests/sys/fs/fusefs/write.cc
==
--- releng/12.2/tests/sys/fs/fusefs/write.ccSun Sep 27 23:01:54 2020
(r366210)
+++ releng/12.2/tests/sys/fs/fusefs/write.ccMon Sep 28 00:23:59 2020
(r366211)
@@ -923,6 +923,76 @@ TEST_F(WriteBack, o_direct)
leak(fd);
 }
 
+TEST_F(WriteBack, direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = "some_file.txt";
+   const char *CONTENTS = "abcdefgh";
+   uint64_t ino = 42;
+   int fd;
+   ssize_t bufsize = strlen(CONTENTS);
+   uint8_t readbuf[bufsize];
+
+   expect_lookup(RELPATH, ino, 0);
+   expect_open(ino, FOPEN_DIRECT_IO, 1);
+   FuseTest::expect_write(ino, 0, bufsize, bufsize, 0, FUSE_WRITE_CACHE,
+   CONTENTS);
+   expect_read(ino, 0, bufsize, bufsize, CONTENTS);
+
+   fd = open(FULLPATH, O_RDWR);
+   EXPECT_LE(0, fd) << strerror(errno);
+
+   ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
+   /* A subsequent read must query the daemon because cache is empty */
+   ASSERT_EQ(0, lseek(fd, 0, SEEK_SET)) << strerror(errno);
+   ASSERT_EQ(0, fcntl(fd, F_SETFL, 0)) << strerror(errno);
+   ASSERT_EQ(bufsize, read(fd, readbuf, bufsize)) << strerror(errno);
+   leak(fd);
+}
+
+/*
+ * mmap should still be possible even if the server used direct_io.  Mmap will
+ * still use the cache, though.
+ *
+ * Regression test for bug 247276
+ * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247276
+ */
+TEST_F(WriteBack, mmap_direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = 

svn commit: r366207 - head/lib/libc/gen

2020-09-27 Thread Alan Somers
Author: asomers
Date: Sun Sep 27 22:26:41 2020
New Revision: 366207
URL: https://svnweb.freebsd.org/changeset/base/366207

Log:
  Misc compiler warning fixes in lib/libc
  
  Reviewed by:  kevans, imp
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26534

Modified:
  head/lib/libc/gen/auxv.c
  head/lib/libc/gen/basename_compat.c
  head/lib/libc/gen/crypt.c
  head/lib/libc/gen/dirname_compat.c
  head/lib/libc/gen/fts-compat.c
  head/lib/libc/gen/ftw-compat11.c
  head/lib/libc/gen/getentropy.c

Modified: head/lib/libc/gen/auxv.c
==
--- head/lib/libc/gen/auxv.cSun Sep 27 21:43:19 2020(r366206)
+++ head/lib/libc/gen/auxv.cSun Sep 27 22:26:41 2020(r366207)
@@ -67,7 +67,8 @@ __init_elf_aux_vector(void)
 }
 
 static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
-static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
+static int pagesize, osreldate, ncpus, bsdflags;
+static size_t canary_len, pagesizes_len;
 static int hwcap_present, hwcap2_present;
 static char *canary, *pagesizes, *execpath;
 static void *ps_strings, *timekeep;
@@ -245,16 +246,21 @@ int
 _elf_aux_info(int aux, void *buf, int buflen)
 {
int res;
+   size_t buflen_;
 
__init_elf_aux_vector();
if (__elf_aux_vector == NULL)
return (ENOSYS);
_once(_once, init_aux);
 
+   if (buflen < 0)
+   return (EINVAL);
+   buflen_ = (size_t)buflen;
+
switch (aux) {
case AT_CANARY:
-   if (canary != NULL && canary_len >= buflen) {
-   memcpy(buf, canary, buflen);
+   if (canary != NULL && canary_len >= buflen_) {
+   memcpy(buf, canary, buflen_);
memset(canary, 0, canary_len);
canary = NULL;
res = 0;
@@ -267,35 +273,35 @@ _elf_aux_info(int aux, void *buf, int buflen)
else if (buf == NULL)
res = EINVAL;
else {
-   if (strlcpy(buf, execpath, buflen) >= buflen)
+   if (strlcpy(buf, execpath, buflen_) >= buflen_)
res = EINVAL;
else
res = 0;
}
break;
case AT_HWCAP:
-   if (hwcap_present && buflen == sizeof(u_long)) {
+   if (hwcap_present && buflen_ == sizeof(u_long)) {
*(u_long *)buf = hwcap;
res = 0;
} else
res = ENOENT;
break;
case AT_HWCAP2:
-   if (hwcap2_present && buflen == sizeof(u_long)) {
+   if (hwcap2_present && buflen_ == sizeof(u_long)) {
*(u_long *)buf = hwcap2;
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESIZES:
-   if (pagesizes != NULL && pagesizes_len >= buflen) {
-   memcpy(buf, pagesizes, buflen);
+   if (pagesizes != NULL && pagesizes_len >= buflen_) {
+   memcpy(buf, pagesizes, buflen_);
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESZ:
-   if (buflen == sizeof(int)) {
+   if (buflen_ == sizeof(int)) {
if (pagesize != 0) {
*(int *)buf = pagesize;
res = 0;
@@ -305,7 +311,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_OSRELDATE:
-   if (buflen == sizeof(int)) {
+   if (buflen_ == sizeof(int)) {
if (osreldate != 0) {
*(int *)buf = osreldate;
res = 0;
@@ -315,7 +321,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_NCPUS:
-   if (buflen == sizeof(int)) {
+   if (buflen_ == sizeof(int)) {
if (ncpus != 0) {
*(int *)buf = ncpus;
res = 0;
@@ -325,7 +331,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_TIMEKEEP:
-   if (buflen == sizeof(void *)) {
+   if (buflen_ == sizeof(void *)) {
if (timekeep != NULL) {
*(void **)buf = timekeep;
res = 0;
@@ -335,14 +341,14 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;

svn commit: r366190 - in stable/12: sys/fs/fuse tests/sys/fs/fusefs

2020-09-26 Thread Alan Somers
Author: asomers
Date: Sun Sep 27 02:59:28 2020
New Revision: 366190
URL: https://svnweb.freebsd.org/changeset/base/366190

Log:
  MFC r366121:
  
  fusefs: fix mmap'd writes in direct_io mode
  
  If a FUSE server returns FOPEN_DIRECT_IO in response to FUSE_OPEN, that
  instructs the kernel to bypass the page cache for that file. This feature
  is also known by libfuse's name: "direct_io".
  
  However, when accessing a file via mmap, there is no possible way to bypass
  the cache completely. This change fixes a deadlock that would happen when
  an mmap'd write tried to invalidate a portion of the cache, wrongly assuming
  that a write couldn't possibly come from cache if direct_io were set.
  
  Arguably, we could instead disable mmap for files with FOPEN_DIRECT_IO set.
  But allowing it is less likely to cause user complaints, and is more in
  keeping with the spirit of open(2), where O_DIRECT instructs the kernel to
  "reduce", not "eliminate" cache effects.
  
  PR:   247276
  Reported by:  trape...@spawn.link
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D26485

Modified:
  stable/12/sys/fs/fuse/fuse_io.c
  stable/12/tests/sys/fs/fusefs/write.cc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/fuse/fuse_io.c
==
--- stable/12/sys/fs/fuse/fuse_io.c Sat Sep 26 23:05:38 2020
(r366189)
+++ stable/12/sys/fs/fuse/fuse_io.c Sun Sep 27 02:59:28 2020
(r366190)
@@ -291,6 +291,7 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
fuse_vnode_update(vp, FN_MTIMECHANGE | FN_CTIMECHANGE);
if (directio) {
off_t start, end, filesize;
+   bool pages = (ioflag & IO_VMIO) != 0;
 
SDT_PROBE2(fusefs, , io, trace, 1,
"direct write of vnode");
@@ -301,15 +302,14 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
 
start = uio->uio_offset;
end = start + uio->uio_resid;
-   KASSERT((ioflag & (IO_VMIO | IO_DIRECT)) !=
-   (IO_VMIO | IO_DIRECT),
-   ("IO_DIRECT used for a cache flush?"));
-   /* Invalidate the write cache when writing directly */
-   err = fuse_inval_buf_range(vp, filesize, start, end);
-   if (err)
-   return (err);
+   if (!pages) {
+   err = fuse_inval_buf_range(vp, filesize, start,
+   end);
+   if (err)
+   return (err);
+   }
err = fuse_write_directbackend(vp, uio, cred, fufh,
-   filesize, ioflag, false);
+   filesize, ioflag, pages);
} else {
SDT_PROBE2(fusefs, , io, trace, 1,
"buffered write of vnode");

Modified: stable/12/tests/sys/fs/fusefs/write.cc
==
--- stable/12/tests/sys/fs/fusefs/write.cc  Sat Sep 26 23:05:38 2020
(r366189)
+++ stable/12/tests/sys/fs/fusefs/write.cc  Sun Sep 27 02:59:28 2020
(r366190)
@@ -923,6 +923,76 @@ TEST_F(WriteBack, o_direct)
leak(fd);
 }
 
+TEST_F(WriteBack, direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = "some_file.txt";
+   const char *CONTENTS = "abcdefgh";
+   uint64_t ino = 42;
+   int fd;
+   ssize_t bufsize = strlen(CONTENTS);
+   uint8_t readbuf[bufsize];
+
+   expect_lookup(RELPATH, ino, 0);
+   expect_open(ino, FOPEN_DIRECT_IO, 1);
+   FuseTest::expect_write(ino, 0, bufsize, bufsize, 0, FUSE_WRITE_CACHE,
+   CONTENTS);
+   expect_read(ino, 0, bufsize, bufsize, CONTENTS);
+
+   fd = open(FULLPATH, O_RDWR);
+   EXPECT_LE(0, fd) << strerror(errno);
+
+   ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
+   /* A subsequent read must query the daemon because cache is empty */
+   ASSERT_EQ(0, lseek(fd, 0, SEEK_SET)) << strerror(errno);
+   ASSERT_EQ(0, fcntl(fd, F_SETFL, 0)) << strerror(errno);
+   ASSERT_EQ(bufsize, read(fd, readbuf, bufsize)) << strerror(errno);
+   leak(fd);
+}
+
+/*
+ * mmap should still be possible even if the server used direct_io.  Mmap will
+ * still use the cache, though.
+ *
+ * Regression test for bug 247276
+ * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247276
+ */
+TEST_F(WriteBack, mmap_direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = "some_file.txt";
+   const char *CONTENTS = 

svn commit: r366180 - stable/12/cddl/contrib/opensolaris/lib/libzfs/common

2020-09-25 Thread Alan Somers
Author: asomers
Date: Sat Sep 26 02:50:28 2020
New Revision: 366180
URL: https://svnweb.freebsd.org/changeset/base/366180

Log:
  zfs: Fix resuming receive stream to dataset with mounted clone
  
  My fix for bug 248606 (zfs receive: Input/output error accessing dataset
  after resuming interrupted receive), r364412, introduced a regression:
  attempting to resume a receive into a dataset with a mounted clone would
  fail if that clone were in-use.  This change reverts r364412 and fixes it in
  a better way.
  
  Background:
  When ZFS receives a stream, it may decide to unmount and remount the
  destination and all of its children.  However, ever since resumable
  send/receive was implemented, ZFS has skipped the unmount/remount step when
  resuming a stream.  I don't know why.
  
  That let to bug 248606.  When resuming the stream, ZFS didn't unmount and
  remount the destination, leaving a destroyed dataset mounted.
  
  My original fix was to always unmount and remount when resuming a receive,
  but that caused other problems, like bug 249579.  A better solution is to
  unmount and remount when resuming a receive of a stream that would've
  unmounted and remounted when it was new.
  
  Direct commit to stable/12 because head has moved to OpenZFS.  The bug
  exists there, too, but a change to the OpenZFS code can't be merged to the
  old ZFS code.
  
  PR:   249579
  Reviewed by:  mmacy
  MFC after:1 week
  Sponsored by: Axcient

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sat Sep 26 00:58:27 2020(r366179)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sat Sep 26 02:50:28 2020(r366180)
@@ -3301,7 +3301,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) &
DMU_BACKUP_FEATURE_RESUMING;
stream_wantsnewfs = (drrb->drr_fromguid == 0 ||
-   (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap) && !resuming;
+   (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap);
 
if (stream_wantsnewfs) {
/*
@@ -3433,7 +3433,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
}
 
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
-   (stream_wantsnewfs || resuming)) {
+   stream_wantsnewfs) {
/* We can't do online recv in this case */
clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0);
if (clp == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366132 - head/lib/libc/tests/iconv

2020-09-24 Thread Alan Somers
Author: asomers
Date: Thu Sep 24 21:42:44 2020
New Revision: 366132
URL: https://svnweb.freebsd.org/changeset/base/366132

Log:
  lib/libc/tests/iconv: raise WARNS to 6
  
  MFC after:2 weeks

Modified:
  head/lib/libc/tests/iconv/Makefile
  head/lib/libc/tests/iconv/iconvctl_test.c

Modified: head/lib/libc/tests/iconv/Makefile
==
--- head/lib/libc/tests/iconv/Makefile  Thu Sep 24 21:39:09 2020
(r366131)
+++ head/lib/libc/tests/iconv/Makefile  Thu Sep 24 21:42:44 2020
(r366132)
@@ -3,6 +3,5 @@
 TESTSDIR=  ${TESTSBASE}/lib/libc/iconv
 
 ATF_TESTS_C+=  iconvctl_test
-WARNS?=2
 
 .include 

Modified: head/lib/libc/tests/iconv/iconvctl_test.c
==
--- head/lib/libc/tests/iconv/iconvctl_test.c   Thu Sep 24 21:39:09 2020
(r366131)
+++ head/lib/libc/tests/iconv/iconvctl_test.c   Thu Sep 24 21:42:44 2020
(r366132)
@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-void
+static void
 test_trivialp(const char *src, const char *dst, int expected)
 {
iconv_t ic;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366131 - head/lib/libc/tests/sys

2020-09-24 Thread Alan Somers
Author: asomers
Date: Thu Sep 24 21:39:09 2020
New Revision: 366131
URL: https://svnweb.freebsd.org/changeset/base/366131

Log:
  lib/libc/tests/sys: raise WARNS to 6
  
  MFC after:2 weeks

Modified:
  head/lib/libc/tests/sys/Makefile

Modified: head/lib/libc/tests/sys/Makefile
==
--- head/lib/libc/tests/sys/MakefileThu Sep 24 20:01:31 2020
(r366130)
+++ head/lib/libc/tests/sys/MakefileThu Sep 24 21:39:09 2020
(r366131)
@@ -78,12 +78,6 @@ LIBADD.timer_create_test+=   rt
 SRCS.mlock_test+=  mlock_helper.c
 SRCS.setrlimit_test+=  mlock_helper.c
 
-.if ${COMPILER_TYPE} == "gcc"
-WARNS?=3
-.else
-WARNS?=4
-.endif
-
 FILESGROUPS+=  truncate_test_FILES
 
 truncate_test_FILES=   truncate_test.root_owned
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366121 - in head: sys/fs/fuse tests/sys/fs/fusefs

2020-09-24 Thread Alan Somers
Author: asomers
Date: Thu Sep 24 16:27:53 2020
New Revision: 366121
URL: https://svnweb.freebsd.org/changeset/base/366121

Log:
  fusefs: fix mmap'd writes in direct_io mode
  
  If a FUSE server returns FOPEN_DIRECT_IO in response to FUSE_OPEN, that
  instructs the kernel to bypass the page cache for that file. This feature
  is also known by libfuse's name: "direct_io".
  
  However, when accessing a file via mmap, there is no possible way to bypass
  the cache completely. This change fixes a deadlock that would happen when
  an mmap'd write tried to invalidate a portion of the cache, wrongly assuming
  that a write couldn't possibly come from cache if direct_io were set.
  
  Arguably, we could instead disable mmap for files with FOPEN_DIRECT_IO set.
  But allowing it is less likely to cause user complaints, and is more in
  keeping with the spirit of open(2), where O_DIRECT instructs the kernel to
  "reduce", not "eliminate" cache effects.
  
  PR:   247276
  Reported by:  trape...@spawn.link
  Reviewed by:  cem
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D26485

Modified:
  head/sys/fs/fuse/fuse_io.c
  head/tests/sys/fs/fusefs/write.cc

Modified: head/sys/fs/fuse/fuse_io.c
==
--- head/sys/fs/fuse/fuse_io.c  Thu Sep 24 16:21:30 2020(r366120)
+++ head/sys/fs/fuse/fuse_io.c  Thu Sep 24 16:27:53 2020(r366121)
@@ -291,6 +291,7 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
fuse_vnode_update(vp, FN_MTIMECHANGE | FN_CTIMECHANGE);
if (directio) {
off_t start, end, filesize;
+   bool pages = (ioflag & IO_VMIO) != 0;
 
SDT_PROBE2(fusefs, , io, trace, 1,
"direct write of vnode");
@@ -301,15 +302,14 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in
 
start = uio->uio_offset;
end = start + uio->uio_resid;
-   KASSERT((ioflag & (IO_VMIO | IO_DIRECT)) !=
-   (IO_VMIO | IO_DIRECT),
-   ("IO_DIRECT used for a cache flush?"));
-   /* Invalidate the write cache when writing directly */
-   err = fuse_inval_buf_range(vp, filesize, start, end);
-   if (err)
-   return (err);
+   if (!pages) {
+   err = fuse_inval_buf_range(vp, filesize, start,
+   end);
+   if (err)
+   return (err);
+   }
err = fuse_write_directbackend(vp, uio, cred, fufh,
-   filesize, ioflag, false);
+   filesize, ioflag, pages);
} else {
SDT_PROBE2(fusefs, , io, trace, 1,
"buffered write of vnode");

Modified: head/tests/sys/fs/fusefs/write.cc
==
--- head/tests/sys/fs/fusefs/write.cc   Thu Sep 24 16:21:30 2020
(r366120)
+++ head/tests/sys/fs/fusefs/write.cc   Thu Sep 24 16:27:53 2020
(r366121)
@@ -923,6 +923,76 @@ TEST_F(WriteBack, o_direct)
leak(fd);
 }
 
+TEST_F(WriteBack, direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = "some_file.txt";
+   const char *CONTENTS = "abcdefgh";
+   uint64_t ino = 42;
+   int fd;
+   ssize_t bufsize = strlen(CONTENTS);
+   uint8_t readbuf[bufsize];
+
+   expect_lookup(RELPATH, ino, 0);
+   expect_open(ino, FOPEN_DIRECT_IO, 1);
+   FuseTest::expect_write(ino, 0, bufsize, bufsize, 0, FUSE_WRITE_CACHE,
+   CONTENTS);
+   expect_read(ino, 0, bufsize, bufsize, CONTENTS);
+
+   fd = open(FULLPATH, O_RDWR);
+   EXPECT_LE(0, fd) << strerror(errno);
+
+   ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno);
+   /* A subsequent read must query the daemon because cache is empty */
+   ASSERT_EQ(0, lseek(fd, 0, SEEK_SET)) << strerror(errno);
+   ASSERT_EQ(0, fcntl(fd, F_SETFL, 0)) << strerror(errno);
+   ASSERT_EQ(bufsize, read(fd, readbuf, bufsize)) << strerror(errno);
+   leak(fd);
+}
+
+/*
+ * mmap should still be possible even if the server used direct_io.  Mmap will
+ * still use the cache, though.
+ *
+ * Regression test for bug 247276
+ * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247276
+ */
+TEST_F(WriteBack, mmap_direct_io)
+{
+   const char FULLPATH[] = "mountpoint/some_file.txt";
+   const char RELPATH[] = "some_file.txt";
+   const char *CONTENTS = "abcdefgh";
+   uint64_t ino = 42;
+   int fd;
+   size_t len;
+   ssize_t bufsize = 

svn commit: r366118 - head/sys/kern

2020-09-24 Thread Alan Somers
Author: asomers
Date: Thu Sep 24 15:38:01 2020
New Revision: 366118
URL: https://svnweb.freebsd.org/changeset/base/366118

Log:
  Fix some signed/unsigned comparison warnings in NFS
  
  Reviewed by:  rmacklem
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26533

Modified:
  head/sys/kern/subr_acl_nfs4.c

Modified: head/sys/kern/subr_acl_nfs4.c
==
--- head/sys/kern/subr_acl_nfs4.c   Thu Sep 24 15:34:47 2020
(r366117)
+++ head/sys/kern/subr_acl_nfs4.c   Thu Sep 24 15:38:01 2020
(r366118)
@@ -342,9 +342,9 @@ _acl_append(struct acl *aclp, acl_tag_t tag, acl_perm_
 }
 
 static struct acl_entry *
-_acl_duplicate_entry(struct acl *aclp, int entry_index)
+_acl_duplicate_entry(struct acl *aclp, unsigned entry_index)
 {
-   int i;
+   unsigned i;
 
KASSERT(aclp->acl_cnt + 1 <= ACL_MAX_ENTRIES,
("aclp->acl_cnt + 1 <= ACL_MAX_ENTRIES"));
@@ -361,7 +361,8 @@ static void
 acl_nfs4_sync_acl_from_mode_draft(struct acl *aclp, mode_t mode,
 int file_owner_id)
 {
-   int i, meets, must_append;
+   int meets, must_append;
+   unsigned i;
struct acl_entry *entry, *copy, *previous,
*a1, *a2, *a3, *a4, *a5, *a6;
mode_t amode;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
Go ahead and commit.  Consider it reviewed by me.  And if I understand
correctly, this commit means there's no need for a special updating
procedure, right?

On Tue, Sep 22, 2020 at 6:55 PM Warner Losh  wrote:

>
>
> On Tue, Sep 22, 2020 at 5:17 PM Kyle Evans  wrote:
>
>> On Tue, Sep 22, 2020, 17:02 Warner Losh  wrote:
>>
>>>
>>>
>>> On Tue, Sep 22, 2020 at 3:55 PM Kyle Evans  wrote:
>>>
 On Tue, Sep 22, 2020 at 4:53 PM Ian Lepore  wrote:
 >
 > On Tue, 2020-09-22 at 15:50 -0600, Warner Losh wrote:
 > > I think it's a great leap sideways, but I've done cp /dev/null foo
 to
 > > clear
 > > it out for 35 years now... It's why it feels like a workaround.
 > >
 > > Though it is a legit optimization, no matter the feelings. As for
 > > clearer,
 > > I'm less sure since then I have to remember what the : operator
 does.
 > >
 > > Warner
 > >
 >
 > For me, :> is idiomatic (but ugly).
 >
 > On the other hand, the cp /dev/null had a nice dogfooding aspect to
 > it... when we broke cp by accident, its use in the build system was
 the
 > first alarm to go off.
 >
 > --Ian
 >

 To be honest, this is a case that really should be covered by
 regression tests somewhere.

>>>
>>> It should (but isn't yet).
>>>
>>> Ian is right for old-school FreeBSD thinking. In that thinking the build
>>> system should use an eclectic mix of tools to act as a fire-wall against
>>> accidental breakage.
>>>
>>> Complete, effective, test suites give much better coverage... if they
>>> are run...
>>>
>>> So until we run tests frequently, with loud regression squawking that's
>>> as effective as build breakage, I tend to fall in the 'all of the above'
>>> camp until that's in place... :)
>>>
>>> Warner
>>>
>>> P.S. though not, if I suppose, if it means that we're slowing down the
>>> regression coverage uptake...
>>>
>>
>> --
>>
>> The test build was fine, please confirm if I can commit it or if someone
>> else would like to write the UPDATING notice or start bootstrapping cp on
>> systems that were affected. I'm not comfortable with not taking any path at
>> all here, but this is a lot of friction for a small mechanical change to
>> ease the pain.
>>
>
> Sorry if I wasn't clear: I'm not objecting to the quick mechanical change
> so much as complaining that I wish we had better test coverage. Don't let
> that stop you from doing what's right (or I can if you'd like).
>
> Warner
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
It doesn't feel like a workaround to me.  I think Kyle's version is clearer
than the original.

On Tue, Sep 22, 2020 at 3:45 PM Warner Losh  wrote:

>
>
> On Tue, Sep 22, 2020 at 3:42 PM Kyle Evans  wrote:
>
>> cp is already fixed, people are still feeling the fallout of being
>> within those revisions and needing to bootstrap their own cp. We can
>> reduce the number of components these invocations rely on trivially to
>> shell built-in mechanics, why not do so?
>>
>
> Fair point. I just bristle at putting workarounds in for valid /bin/sh
> syntax because we opposed for a few days. so long as it's an unconditional
> clearing of the file to be zero length, I'm OK with that.
>
> Warner
>
>
>> On Tue, Sep 22, 2020 at 4:40 PM Warner Losh  wrote:
>> >
>> > So why do we need a workaround at all? cp /dev/null has been fixed, and
>> that's way more important to get right.
>> >
>> > I don't want to paper-over issues with this at all, though if we use
>> the host's (now broken) cp, I suppose that might be OK in the short term.
>> If that's the case, then maybe this is OK.
>> >
>> > Otherwise, I'd strongly prefer we fix cp.
>> >
>> > Warner
>> >
>> > On Tue, Sep 22, 2020 at 3:31 PM Alan Somers 
>> wrote:
>> >>
>> >> +1.
>> >>
>> >> On Tue, Sep 22, 2020 at 3:27 PM Kyle Evans  wrote:
>> >>>
>> >>> I'm running a build at the suggestion of mjg to confirm there aren't
>> >>> any others hiding that can be converted, and I will commit after I've
>> >>> verified that this is it.
>> >>>
>> >>> On Tue, Sep 22, 2020 at 4:02 PM Alan Somers 
>> wrote:
>> >>> >
>> >>> > LGTM.
>> >>> >
>> >>> > On Tue, Sep 22, 2020 at 2:59 PM Kyle Evans 
>> wrote:
>> >>> >>
>> >>> >> Perhaps:
>> >>> >>
>> >>> >> diff --git a/stand/i386/zfsboot/Makefile
>> b/stand/i386/zfsboot/Makefile
>> >>> >> index ff315abc0ef..7e362b43a39 100644
>> >>> >> --- a/stand/i386/zfsboot/Makefile
>> >>> >> +++ b/stand/i386/zfsboot/Makefile
>> >>> >> @@ -81,7 +81,7 @@ zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
>> >>> >> -o ${.TARGET} -P 1 zfsboot.bin
>> >>> >>
>> >>> >>  zfsboot.ldr:
>> >>> >> -   cp /dev/null ${.TARGET}
>> >>> >> +   :> ${.TARGET}
>> >>> >>
>> >>> >>  zfsboot.bin: zfsboot.out
>> >>> >> ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
>> >>> >> diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile
>> >>> >> index effece9e01b..63cd46a9c54 100644
>> >>> >> --- a/stand/libsa/Makefile
>> >>> >> +++ b/stand/libsa/Makefile
>> >>> >> @@ -122,7 +122,7 @@ beforedepend:
>> >>> >> ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
>> >>> >> ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
>> >>> >> for i in _time.h _strings.h _string.h; do \
>> >>> >> -   [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
>> >>> >> +   [ -f xlocale/$$i ] || :> xlocale/$$i; \
>> >>> >> done; \
>> >>> >> for i in ${STAND_H_INC}; do \
>> >>> >> ln -sf ${SASRC}/stand.h $$i; \
>> >>> >>
>> >>> >>
>> >>> >> On Tue, Sep 22, 2020 at 3:58 PM Alan Somers 
>> wrote:
>> >>> >> >
>> >>> >> > Looks like two places in stand.  Is there any reason why
>> Mateusz's suggestion wouldn't work?
>> >>> >> >
>> >>> >> > > rg -g Makefile 'cp.*/dev/null'
>> >>> >> > stand/libsa/Makefile
>> >>> >> > 125: [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
>> >>> >> >
>> >>> >> > stand/i386/zfsboot/Makefile
>> >>> >> > 82: cp /dev/null ${.TARGET}
>> >>> >> >
>> >>> >> > On Tue, Sep 22, 2020 at 2:54 PM Mateusz Guzik 
>> wrote:
>> >>> >> >>
>> >>> >> >> Can we instead add a workaround 

Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
+1.

On Tue, Sep 22, 2020 at 3:27 PM Kyle Evans  wrote:

> I'm running a build at the suggestion of mjg to confirm there aren't
> any others hiding that can be converted, and I will commit after I've
> verified that this is it.
>
> On Tue, Sep 22, 2020 at 4:02 PM Alan Somers  wrote:
> >
> > LGTM.
> >
> > On Tue, Sep 22, 2020 at 2:59 PM Kyle Evans  wrote:
> >>
> >> Perhaps:
> >>
> >> diff --git a/stand/i386/zfsboot/Makefile b/stand/i386/zfsboot/Makefile
> >> index ff315abc0ef..7e362b43a39 100644
> >> --- a/stand/i386/zfsboot/Makefile
> >> +++ b/stand/i386/zfsboot/Makefile
> >> @@ -81,7 +81,7 @@ zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
> >> -o ${.TARGET} -P 1 zfsboot.bin
> >>
> >>  zfsboot.ldr:
> >> -   cp /dev/null ${.TARGET}
> >> +   :> ${.TARGET}
> >>
> >>  zfsboot.bin: zfsboot.out
> >> ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
> >> diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile
> >> index effece9e01b..63cd46a9c54 100644
> >> --- a/stand/libsa/Makefile
> >> +++ b/stand/libsa/Makefile
> >> @@ -122,7 +122,7 @@ beforedepend:
> >> ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
> >> ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
> >> for i in _time.h _strings.h _string.h; do \
> >> -   [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
> >> +   [ -f xlocale/$$i ] || :> xlocale/$$i; \
> >> done; \
> >> for i in ${STAND_H_INC}; do \
> >> ln -sf ${SASRC}/stand.h $$i; \
> >>
> >>
> >> On Tue, Sep 22, 2020 at 3:58 PM Alan Somers 
> wrote:
> >> >
> >> > Looks like two places in stand.  Is there any reason why Mateusz's
> suggestion wouldn't work?
> >> >
> >> > > rg -g Makefile 'cp.*/dev/null'
> >> > stand/libsa/Makefile
> >> > 125: [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
> >> >
> >> > stand/i386/zfsboot/Makefile
> >> > 82: cp /dev/null ${.TARGET}
> >> >
> >> > On Tue, Sep 22, 2020 at 2:54 PM Mateusz Guzik 
> wrote:
> >> >>
> >> >> Can we instead add a workaround to the build tree?
> >> >>
> >> >> Where is cp /dev/null coming from anyway? Perhaps this can be patched
> >> >> to touch the target file.
> >> >>
> >> >> On 9/22/20, Alan Somers  wrote:
> >> >> > On Tue, Sep 22, 2020 at 2:48 PM Kyle Evans 
> wrote:
> >> >> >
> >> >> >> On Fri, Sep 11, 2020 at 3:49 PM Alan Somers 
> wrote:
> >> >> >> >
> >> >> >> > Author: asomers
> >> >> >> > Date: Fri Sep 11 20:49:36 2020
> >> >> >> > New Revision: 365643
> >> >> >> > URL: https://svnweb.freebsd.org/changeset/base/365643
> >> >> >> >
> >> >> >> > Log:
> >> >> >> >   cp: fall back to read/write if copy_file_range fails
> >> >> >> >
> >> >> >> >   Even though copy_file_range has a file-system agnostic
> version, it
> >> >> >> still
> >> >> >> >   fails on devfs (perhaps because the file descriptor is
> non-seekable?)
> >> >> >> In
> >> >> >> >   that case, fallback to old-fashioned read/write. Fixes
> >> >> >> >   "cp /dev/null /tmp/null"
> >> >> >> >
> >> >> >>
> >> >> >> Hi,
> >> >> >>
> >> >> >> Any objection to adding a quick UPDATING entry for this? I'm
> seeing
> >> >> >> occasional reports of this breakage as recent as today on IRC from
> >> >> >> folks that were a little bit thrown off by this because it throws
> up
> >> >> >> fairly far into the build and looks like a stand build regression
> >> >> >> instead of a cp regression.
> >> >> >>
> >> >> >> Thanks,
> >> >> >>
> >> >> >> Kyle Evans
> >> >> >>
> >> >> >
> >> >> > No objection.  Can you suggest the proper wording?
> >> >> > ___
> >> >> > svn-src-all@freebsd.org mailing list
> >> >> > https://lists.freebsd.org/mailman/listinfo/svn-src-all
> >> >> > To unsubscribe, send any mail to "
> svn-src-all-unsubscr...@freebsd.org"
> >> >> >
> >> >>
> >> >>
> >> >> --
> >> >> Mateusz Guzik 
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
LGTM.

On Tue, Sep 22, 2020 at 2:59 PM Kyle Evans  wrote:

> Perhaps:
>
> diff --git a/stand/i386/zfsboot/Makefile b/stand/i386/zfsboot/Makefile
> index ff315abc0ef..7e362b43a39 100644
> --- a/stand/i386/zfsboot/Makefile
> +++ b/stand/i386/zfsboot/Makefile
> @@ -81,7 +81,7 @@ zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
> -o ${.TARGET} -P 1 zfsboot.bin
>
>  zfsboot.ldr:
> -   cp /dev/null ${.TARGET}
> +   :> ${.TARGET}
>
>  zfsboot.bin: zfsboot.out
> ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
> diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile
> index effece9e01b..63cd46a9c54 100644
> --- a/stand/libsa/Makefile
> +++ b/stand/libsa/Makefile
> @@ -122,7 +122,7 @@ beforedepend:
> ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
> ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
> for i in _time.h _strings.h _string.h; do \
> -   [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
> +   [ -f xlocale/$$i ] || :> xlocale/$$i; \
> done; \
> for i in ${STAND_H_INC}; do \
>     ln -sf ${SASRC}/stand.h $$i; \
>
>
> On Tue, Sep 22, 2020 at 3:58 PM Alan Somers  wrote:
> >
> > Looks like two places in stand.  Is there any reason why Mateusz's
> suggestion wouldn't work?
> >
> > > rg -g Makefile 'cp.*/dev/null'
> > stand/libsa/Makefile
> > 125: [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
> >
> > stand/i386/zfsboot/Makefile
> > 82: cp /dev/null ${.TARGET}
> >
> > On Tue, Sep 22, 2020 at 2:54 PM Mateusz Guzik  wrote:
> >>
> >> Can we instead add a workaround to the build tree?
> >>
> >> Where is cp /dev/null coming from anyway? Perhaps this can be patched
> >> to touch the target file.
> >>
> >> On 9/22/20, Alan Somers  wrote:
> >> > On Tue, Sep 22, 2020 at 2:48 PM Kyle Evans 
> wrote:
> >> >
> >> >> On Fri, Sep 11, 2020 at 3:49 PM Alan Somers 
> wrote:
> >> >> >
> >> >> > Author: asomers
> >> >> > Date: Fri Sep 11 20:49:36 2020
> >> >> > New Revision: 365643
> >> >> > URL: https://svnweb.freebsd.org/changeset/base/365643
> >> >> >
> >> >> > Log:
> >> >> >   cp: fall back to read/write if copy_file_range fails
> >> >> >
> >> >> >   Even though copy_file_range has a file-system agnostic version,
> it
> >> >> still
> >> >> >   fails on devfs (perhaps because the file descriptor is
> non-seekable?)
> >> >> In
> >> >> >   that case, fallback to old-fashioned read/write. Fixes
> >> >> >   "cp /dev/null /tmp/null"
> >> >> >
> >> >>
> >> >> Hi,
> >> >>
> >> >> Any objection to adding a quick UPDATING entry for this? I'm seeing
> >> >> occasional reports of this breakage as recent as today on IRC from
> >> >> folks that were a little bit thrown off by this because it throws up
> >> >> fairly far into the build and looks like a stand build regression
> >> >> instead of a cp regression.
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Kyle Evans
> >> >>
> >> >
> >> > No objection.  Can you suggest the proper wording?
> >> > ___
> >> > svn-src-all@freebsd.org mailing list
> >> > https://lists.freebsd.org/mailman/listinfo/svn-src-all
> >> > To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org
> "
> >> >
> >>
> >>
> >> --
> >> Mateusz Guzik 
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
Looks like two places in stand.  Is there any reason why Mateusz's
suggestion wouldn't work?

> rg -g Makefile 'cp.*/dev/null'
stand/libsa/Makefile
125: [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \

stand/i386/zfsboot/Makefile
82: cp /dev/null ${.TARGET}

On Tue, Sep 22, 2020 at 2:54 PM Mateusz Guzik  wrote:

> Can we instead add a workaround to the build tree?
>
> Where is cp /dev/null coming from anyway? Perhaps this can be patched
> to touch the target file.
>
> On 9/22/20, Alan Somers  wrote:
> > On Tue, Sep 22, 2020 at 2:48 PM Kyle Evans  wrote:
> >
> >> On Fri, Sep 11, 2020 at 3:49 PM Alan Somers 
> wrote:
> >> >
> >> > Author: asomers
> >> > Date: Fri Sep 11 20:49:36 2020
> >> > New Revision: 365643
> >> > URL: https://svnweb.freebsd.org/changeset/base/365643
> >> >
> >> > Log:
> >> >   cp: fall back to read/write if copy_file_range fails
> >> >
> >> >   Even though copy_file_range has a file-system agnostic version, it
> >> still
> >> >   fails on devfs (perhaps because the file descriptor is
> non-seekable?)
> >> In
> >> >   that case, fallback to old-fashioned read/write. Fixes
> >> >   "cp /dev/null /tmp/null"
> >> >
> >>
> >> Hi,
> >>
> >> Any objection to adding a quick UPDATING entry for this? I'm seeing
> >> occasional reports of this breakage as recent as today on IRC from
> >> folks that were a little bit thrown off by this because it throws up
> >> fairly far into the build and looks like a stand build regression
> >> instead of a cp regression.
> >>
> >> Thanks,
> >>
> >> Kyle Evans
> >>
> >
> > No objection.  Can you suggest the proper wording?
> > ___
> > svn-src-all@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/svn-src-all
> > To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
> >
>
>
> --
> Mateusz Guzik 
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-22 Thread Alan Somers
On Tue, Sep 22, 2020 at 2:48 PM Kyle Evans  wrote:

> On Fri, Sep 11, 2020 at 3:49 PM Alan Somers  wrote:
> >
> > Author: asomers
> > Date: Fri Sep 11 20:49:36 2020
> > New Revision: 365643
> > URL: https://svnweb.freebsd.org/changeset/base/365643
> >
> > Log:
> >   cp: fall back to read/write if copy_file_range fails
> >
> >   Even though copy_file_range has a file-system agnostic version, it
> still
> >   fails on devfs (perhaps because the file descriptor is non-seekable?)
> In
> >   that case, fallback to old-fashioned read/write. Fixes
> >   "cp /dev/null /tmp/null"
> >
>
> Hi,
>
> Any objection to adding a quick UPDATING entry for this? I'm seeing
> occasional reports of this breakage as recent as today on IRC from
> folks that were a little bit thrown off by this because it throws up
> fairly far into the build and looks like a stand build regression
> instead of a cp regression.
>
> Thanks,
>
> Kyle Evans
>

No objection.  Can you suggest the proper wording?
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365956 - head/tools/regression/fsx

2020-09-21 Thread Alan Somers
Author: asomers
Date: Mon Sep 21 17:48:28 2020
New Revision: 365956
URL: https://svnweb.freebsd.org/changeset/base/365956

Log:
  fsx: fix build with WARNS=6
  
  * signed/unsigned comparisons
  * use standard warn(3)
  * Suppress warnings about local vars and funcs not declared static
  * const-correctness
  * declaration shadows a variable in the global scope
  
  Reviewed by:  kevans
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26516

Modified:
  head/tools/regression/fsx/Makefile
  head/tools/regression/fsx/fsx.c

Modified: head/tools/regression/fsx/Makefile
==
--- head/tools/regression/fsx/Makefile  Mon Sep 21 17:28:41 2020
(r365955)
+++ head/tools/regression/fsx/Makefile  Mon Sep 21 17:48:28 2020
(r365956)
@@ -4,4 +4,9 @@ PROG=   fsx
 
 MAN=
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
+
+# Don't require static declarations.  It's line noise in a single-file program.
+CWARNFLAGS+= -Wno-strict-prototypes -Wno-missing-prototypes

Modified: head/tools/regression/fsx/fsx.c
==
--- head/tools/regression/fsx/fsx.c Mon Sep 21 17:28:41 2020
(r365955)
+++ head/tools/regression/fsx/fsx.c Mon Sep 21 17:48:28 2020
(r365956)
@@ -112,7 +112,7 @@ int closeprob = 0;  /* -c flag */
 intinvlprob = 0;   /* -i flag */
 intdebug = 0;  /* -d flag */
 unsigned long  debugstart = 0; /* -D flag */
-unsigned long  maxfilelen = 256 * 1024;/* -l flag */
+off_t  maxfilelen = 256 * 1024;/* -l flag */
 intsizechecks = 1; /* -n flag disables them */
 intmaxoplen = 64 * 1024;   /* -o flag */
 intquiet = 0;  /* -q flag */
@@ -138,33 +138,8 @@ int invl = 0;
 
 
 void
-vwarnc(code, fmt, ap)
-   int code;
-   const char *fmt;
-   va_list ap;
+prt(const char *fmt, ...)
 {
-   fprintf(stderr, "fsx: ");
-   if (fmt != NULL) {
-   vfprintf(stderr, fmt, ap);
-   fprintf(stderr, ": ");
-   }
-   fprintf(stderr, "%s\n", strerror(code));
-}
-
-
-void
-warn(const char * fmt, ...)
-{
-   va_list ap;
-   va_start(ap, fmt);
-   vwarnc(errno, fmt, ap);
-   va_end(ap);
-}
-
-
-void
-prt(char *fmt, ...)
-{
va_list args;
 
va_start(args, fmt);
@@ -179,7 +154,7 @@ prt(char *fmt, ...)
 }
 
 void
-prterr(char *prefix)
+prterr(const char *prefix)
 {
prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
 }
@@ -317,12 +292,12 @@ logdump(void)
 
 
 void
-save_buffer(char *buffer, off_t bufferlength, int fd)
+save_buffer(char *buffer, off_t bufferlength, int savefd)
 {
off_t ret;
ssize_t byteswritten;
 
-   if (fd <= 0 || bufferlength == 0)
+   if (savefd <= 0 || bufferlength == 0)
return;
 
if (bufferlength > SSIZE_MAX) {
@@ -330,7 +305,7 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
exit(67);
}
if (lite) {
-   off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END);
+   off_t size_by_seek = lseek(savefd, (off_t)0, SEEK_END);
if (size_by_seek == (off_t)-1)
prterr("save_buffer: lseek eof");
else if (bufferlength > size_by_seek) {
@@ -340,11 +315,11 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
}
}
 
-   ret = lseek(fd, (off_t)0, SEEK_SET);
+   ret = lseek(savefd, (off_t)0, SEEK_SET);
if (ret == (off_t)-1)
prterr("save_buffer: lseek 0");

-   byteswritten = write(fd, buffer, (size_t)bufferlength);
+   byteswritten = write(savefd, buffer, (size_t)bufferlength);
if (byteswritten != bufferlength) {
if (byteswritten == -1)
prterr("save_buffer write");
@@ -458,10 +433,10 @@ check_trunc_hack(void)
 
 
 void
-doread(unsigned offset, unsigned size)
+doread(off_t offset, off_t size)
 {
off_t ret;
-   unsigned iret;
+   ssize_t iret;
 
offset -= offset % readbdy;
if (size == 0) {
@@ -509,7 +484,7 @@ doread(unsigned offset, unsigned size)
 
 
 void
-check_eofpage(char *s, unsigned offset, char *p, int size)
+check_eofpage(const char *s, unsigned offset, char *p, int size)
 {
uintptr_t last_page, should_be_zero;
 
@@ -592,7 +567,7 @@ domapread(unsigned offset, unsigned size)
 
 
 void
-gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
+gendata(unsigned offset, unsigned size)
 {
while (size--) {
good_buf[offset] = testcalls % 256; 
@@ -607,7 +582,7 @@ void
 dowrite(unsigned offset, unsigned size)
 {
off_t ret;
-   unsigned iret;
+   ssize_t iret;
 
offset -= offset % writebdy;
if (size == 0) {

Re: svn commit: r365643 - head/bin/cp

2020-09-19 Thread Alan Somers
On Sat, Sep 19, 2020 at 5:32 PM Konstantin Belousov 
wrote:

> On Sat, Sep 19, 2020 at 11:18:56PM +, Rick Macklem wrote:
> > Alan Somers wrote:
> > >On Fri, Sep 11, 2020 at 3:52 PM Rick Macklem  <mailto:rmack...@uoguelph.ca>> wrote:
> > >Konstantin Belousov wrote:
> > >>On Fri, Sep 11, 2020 at 08:49:36PM +, Alan Somers wrote:
> > >>> Author: asomers
> > >>> Date: Fri Sep 11 20:49:36 2020
> > >>> New Revision: 365643
> > >>> URL: https://svnweb.freebsd.org/changeset/base/365643
> > >>>
> > >>> Log:
> > >>>   cp: fall back to read/write if copy_file_range fails
> > >>>
> > >>>   Even though copy_file_range has a file-system agnostic version, it
> still
> > >>>   fails on devfs (perhaps because the file descriptor is
> non-seekable?) In
> > >>>   that case, fallback to old-fashioned read/write. Fixes
> > >>>   "cp /dev/null /tmp/null"
> > >>
> > >>Devices are seekable.
> > >>
> > >>The reason for EINVAL is that vn_copy_file_range() checks that both in
> and out
> > >>vnodes are VREG.  For devfs, they are VCHR.
> > >
> > >I coded the syscall to the Linux man page, which states that EINVAL is
> returned
> > >if either fd does not refer to a regular file.
> > >Having said that, I do not recall testing the VCHR case under Linux.
> (ie. It might
> > >actually work and the man page turns out to be incorrect?)
> > >
> > >I will test this case under Linux when I get home next week, rick
> > I'll admit I haven't tested this in Linux to see if they do return
> EINVAL.
> >
> > >Since there's no standard, I think it's fine for us to support devfs if
> possible.
> > 1 - I think this is a good question for a mailing list like
> freebsd-current@.
> > 2 - I see Linux as the de-facto standard these days and consider POSIX no
> >   longer relevant, but that's just mho.
> > 3 - For NFSv4.2, the Copy operation will fail for non-regular files, so
> if you
> >   do this, you will need to handle the fall-back to using the
> generic code.
> >   (Should be doable, but you need to be aware of this case.)
> >
> > Having said the above, it is up to the "collective" and not me and, as
> such,
> > I suggest #1, to see whether others think doing a non-Linux compatible
> > version makes sense for FreeBSD?
>
> I believe that allowing devfs nodes for vn_copy_file() is not very good
> idea.  For /dev/null driver returns EOF, but think about real devices or
> even better, /dev/zero that never EOF its output.
>
> Is vn_copy_file() interruptible ?  I think not.  So if insane range is
> specified, we have unstoppable copier that fills the disk (at best).
>

I can think of good use cases for copy_file_range on a device:

1) Network block devices.  I don't know if the iSCSI, NBD, or Ceph RBD
protocols currently support server-side copies, but it's reasonable that
they might.  If they ever do, FreeBSD would need copy_file_range to take
advantage.
2) CUSE.  I think Linux's CUSE already supports copy_file_range, since a
CUSE device on Linux is basically just a single-file FUSE file system.  We
might add support to our CUSE driver someday.
3) zvols.  This is the use case that matters the most to me.  I have a
large amount of data stored in plain files that I would like to convert to
zvols.  dd should be able to do that using copy_file_range.

In my opinion, the utility of those cases outweighs the risk of a
long-running interruptible syscall.  And in any case, it is documented that
copy_file_range may return EINTR.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365911 - stable/12/share/man/man5

2020-09-19 Thread Alan Somers
Author: asomers
Date: Sat Sep 19 19:48:15 2020
New Revision: 365911
URL: https://svnweb.freebsd.org/changeset/base/365911

Log:
  MFC r365391, r365415
  
  r365391:
  nsswitch.conf(5): recommend placing cache after files
  
  When cache precedes files, and nscd is configured to allow negative caching,
  commands like "pw groupadd" can fail. The sequence of events looks like:
  
  1. A command like pkg(8) looks up the group, and finds it absent.
  2. pkg invokes pw(8) to add the group
  3. pkg queries the group, but nscd says it doesn't exist, since it has a
 negative cache entry for that group.
  
  See also: 
https://lists.freebsd.org/pipermail/freebsd-current/2012-January/031595.html
  
  Reviewed by:  bcr (manpages)
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26184
  
  r365415:
  nsswitch.conf.5: style fixes
  
  Fix some whitespace, and remove the .Tn macro
  
  Reported by:  mandoc, igor
  Reviewed by:  bcr (manpages)
  Differential Revision:https://reviews.freebsd.org/D26345

Modified:
  stable/12/share/man/man5/nsswitch.conf.5
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man5/nsswitch.conf.5
==
--- stable/12/share/man/man5/nsswitch.conf.5Sat Sep 19 19:08:27 2020
(r365910)
+++ stable/12/share/man/man5/nsswitch.conf.5Sat Sep 19 19:48:15 2020
(r365911)
@@ -1,4 +1,4 @@
-.\"$NetBSD: nsswitch.conf.5,v 1.14 1999/03/17 20:19:47 garbled Exp $
+.\" $NetBSD: nsswitch.conf.5,v 1.14 1999/03/17 20:19:47 garbled Exp $
 .\"
 .\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -16,7 +16,7 @@
 .\"documentation and/or other materials provided with the distribution.
 .\" 3. All advertising materials mentioning features or use of this software
 .\"must display the following acknowledgement:
-.\"This product includes software developed by Luke Mewburn.
+.\"This product includes software developed by Luke Mewburn.
 .\" 4. The name of the author may not be used to endorse or promote products
 .\"derived from this software without specific prior written permission.
 .\"
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 6, 2016
+.Dd September 6, 2020
 .Dt NSSWITCH.CONF 5
 .Os
 .Sh NAME
@@ -48,8 +48,7 @@ file specifies how the
 .Pp
 The configuration file controls how a process looks up various databases
 containing information regarding hosts, users (passwords), groups, etc.
-Each database comes from a source (such as local files, DNS,
-.Tn NIS ,
+Each database comes from a source (such as local files, DNS, NIS ,
 and cache), and the order to look up the sources is specified in
 .Nm .
 .Pp
@@ -180,9 +179,7 @@ Try the next source
 Return with the current result
 .El
 .Ss Format of file
-A
-.Tn BNF
-description of the syntax of
+A BNF description of the syntax of
 .Nm
 is:
 .Pp
@@ -222,20 +219,24 @@ and continue on anything else (i.e,
 .Ss Cache
 You can enable caching for the particular database by specifying
 .Dq cache
-as the first source in the
+in the
 .Nm
 file.
+It should come after
+.Dq files ,
+but before remote sources like
+.Dq nis .
 You should also enable caching for this database in
 .Xr nscd.conf 5 .
-If for the particular query
+If for a particular query
 .Dq cache
-source returns success, no further sources are queried.
+source returns success, then no further sources are queried.
 On the other hand, if there are no previously cached data, the
 query result will be placed into the cache right after
 all other sources are processed.
-Note, that
+Note that
 .Dq cache
-requires
+requires the
 .Xr nscd 8
 daemon to be running.
 .Ss Compat mode: +/- syntax
@@ -244,12 +245,10 @@ In historical multi-source implementations, the
 and
 .Sq -
 characters are used to specify the importing of user password and
-group information from
-.Tn NIS .
+group information from NIS .
 Although
 .Nm
-provides alternative methods of accessing distributed sources such as
-.Tn NIS ,
+provides alternative methods of accessing distributed sources such as NIS ,
 specifying a sole source of
 .Dq compat
 will provide the historical behaviour.
@@ -319,15 +318,14 @@ resides in
 .Pa /etc .
 .El
 .Sh EXAMPLES
-To lookup hosts in cache, then in
+To lookup hosts in
 .Pa /etc/hosts
-and then from the DNS, and lookup user information from
-.Tn NIS
-then files, use:
+, then in cache,
+and then from the DNS, and lookup user information from NIS then files, use:
 .Pp
 .Bl -tag -width passwd: -compact
 .It hosts:
-cache files dns
+files cache dns
 .It passwd:
 nis [notfound=return] files
 .It group:
@@ -349,9 +347,7 @@ entries.
 .Fx Ns 's
 .Lb libc
 provides stubs for compatibility with NSS modules
-written for the
-.Tn GNU
-C Library
+written for the GNU C Library
 .Nm nsswitch
 interface.
 However, these stubs only support the use of the
@@ -377,10 +373,8 @@ Project, where it appeared first in
 

svn commit: r365910 - head/lib/libc/gen

2020-09-19 Thread Alan Somers
Author: asomers
Date: Sat Sep 19 19:08:27 2020
New Revision: 365910
URL: https://svnweb.freebsd.org/changeset/base/365910

Log:
  fix integer underflow in getgrnam_r and getpwnam_r
  
  Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
  triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
  return ERANGE instead of 0.
  
  Fix the user's buffer size check, and add a correct check for a too-small
  nscd buffer.
  
  PR:   248932
  Event:September 2020 Bugathon
  Reviewed by:  markj
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision: https://reviews.freebsd.org/D26204

Modified:
  head/lib/libc/gen/getgrent.c
  head/lib/libc/gen/getpwent.c

Modified: head/lib/libc/gen/getgrent.c
==
--- head/lib/libc/gen/getgrent.cSat Sep 19 18:25:52 2020
(r365909)
+++ head/lib/libc/gen/getgrent.cSat Sep 19 19:08:27 2020
(r365910)
@@ -334,14 +334,27 @@ grp_unmarshal_func(char *buffer, size_t buffer_size, v
orig_buf_size = va_arg(ap, size_t);
ret_errno = va_arg(ap, int *);
 
-   if (orig_buf_size <
-   buffer_size - sizeof(struct group) - sizeof(char *)) {
+   if (orig_buf_size + sizeof(struct group) + sizeof(char *) < buffer_size)
+   {
*ret_errno = ERANGE;
return (NS_RETURN);
+   } else if (buffer_size < sizeof(struct group) + sizeof(char *)) {
+   /*
+* nscd(8) sometimes returns buffer_size=1 for nonexistent
+* entries.
+*/
+   *ret_errno = 0;
+   return (NS_NOTFOUND);
}
 
memcpy(grp, buffer, sizeof(struct group));
memcpy(, buffer + sizeof(struct group), sizeof(char *));
+
+   if (orig_buf_size + sizeof(struct group) + sizeof(char *) +
+   _ALIGN(p) - (size_t)p < buffer_size) {
+   *ret_errno = ERANGE;
+   return (NS_RETURN);
+   }
 
orig_buf = (char *)_ALIGN(orig_buf);
memcpy(orig_buf, buffer + sizeof(struct group) + sizeof(char *) +

Modified: head/lib/libc/gen/getpwent.c
==
--- head/lib/libc/gen/getpwent.cSat Sep 19 18:25:52 2020
(r365909)
+++ head/lib/libc/gen/getpwent.cSat Sep 19 19:08:27 2020
(r365910)
@@ -389,10 +389,17 @@ pwd_unmarshal_func(char *buffer, size_t buffer_size, v
orig_buf_size = va_arg(ap, size_t);
ret_errno = va_arg(ap, int *);
 
-   if (orig_buf_size <
-   buffer_size - sizeof(struct passwd) - sizeof(char *)) {
+   if (orig_buf_size + sizeof(struct passwd) + sizeof(char *) <
+   buffer_size) {
*ret_errno = ERANGE;
return (NS_RETURN);
+   } else if (buffer_size < sizeof(struct passwd) + sizeof(char *)) {
+   /*
+* nscd(8) sometimes returns buffer_size=1 for nonexistent
+* entries.
+*/
+   *ret_errno = 0;
+   return (NS_NOTFOUND);
}
 
memcpy(pwd, buffer, sizeof(struct passwd));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365909 - stable/12/tests/sys/opencrypto

2020-09-19 Thread Alan Somers
Author: asomers
Date: Sat Sep 19 18:25:52 2020
New Revision: 365909
URL: https://svnweb.freebsd.org/changeset/base/365909

Log:
  MFC r363361:
  
  tests/sys/opencrypto: use python3
  
  python2 will be EOL soon
  
  Reviewed by:  lwhsu, jmg
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25682

Modified:
  stable/12/tests/sys/opencrypto/Makefile
  stable/12/tests/sys/opencrypto/cryptodev.py
  stable/12/tests/sys/opencrypto/cryptotest.py
  stable/12/tests/sys/opencrypto/runtests.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/opencrypto/Makefile
==
--- stable/12/tests/sys/opencrypto/Makefile Sat Sep 19 18:02:55 2020
(r365908)
+++ stable/12/tests/sys/opencrypto/Makefile Sat Sep 19 18:25:52 2020
(r365909)
@@ -14,7 +14,7 @@ ATF_TESTS_C+= blake2_test poly1305_test
 
 TAP_TESTS_SH+= runtests
 
-TEST_METADATA.runtests+= required_programs="python2"
+TEST_METADATA.runtests+= required_programs="python3"
 TEST_METADATA.runtests+= required_user="root"
 
 PYMODULES= cryptodev.py cryptodevh.py cryptotest.py

Modified: stable/12/tests/sys/opencrypto/cryptodev.py
==
--- stable/12/tests/sys/opencrypto/cryptodev.py Sat Sep 19 18:02:55 2020
(r365908)
+++ stable/12/tests/sys/opencrypto/cryptodev.py Sat Sep 19 18:25:52 2020
(r365909)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2
+#!/usr/local/bin/python3
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # Copyright 2014 John-Mark Gurney
@@ -30,7 +30,7 @@
 # $FreeBSD$
 #
 
-from __future__ import print_function
+
 import array
 import dpkt
 from fcntl import ioctl

Modified: stable/12/tests/sys/opencrypto/cryptotest.py
==
--- stable/12/tests/sys/opencrypto/cryptotest.pySat Sep 19 18:02:55 
2020(r365908)
+++ stable/12/tests/sys/opencrypto/cryptotest.pySat Sep 19 18:25:52 
2020(r365909)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2
+#!/usr/local/bin/python3
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # All rights reserved.
@@ -29,7 +29,9 @@
 # $FreeBSD$
 #
 
-from __future__ import print_function
+
+
+import binascii
 import errno
 import cryptodev
 import itertools

Modified: stable/12/tests/sys/opencrypto/runtests.sh
==
--- stable/12/tests/sys/opencrypto/runtests.sh  Sat Sep 19 18:02:55 2020
(r365908)
+++ stable/12/tests/sys/opencrypto/runtests.sh  Sat Sep 19 18:25:52 2020
(r365909)
@@ -29,7 +29,7 @@
 # $FreeBSD$
 #
 
-: ${PYTHON=python2}
+: ${PYTHON=python3}
 
 if [ ! -d /usr/local/share/nist-kat ]; then
echo "1..0 # SKIP: nist-kat package not installed for test vectors"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365643 - head/bin/cp

2020-09-19 Thread Alan Somers
On Fri, Sep 11, 2020 at 3:52 PM Rick Macklem  wrote:

> Konstantin Belousov wrote:
> >On Fri, Sep 11, 2020 at 08:49:36PM +0000, Alan Somers wrote:
> >> Author: asomers
> >> Date: Fri Sep 11 20:49:36 2020
> >> New Revision: 365643
> >> URL: https://svnweb.freebsd.org/changeset/base/365643
> >>
> >> Log:
> >>   cp: fall back to read/write if copy_file_range fails
> >>
> >>   Even though copy_file_range has a file-system agnostic version, it
> still
> >>   fails on devfs (perhaps because the file descriptor is non-seekable?)
> In
> >>   that case, fallback to old-fashioned read/write. Fixes
> >>   "cp /dev/null /tmp/null"
> >
> >Devices are seekable.
> >
> >The reason for EINVAL is that vn_copy_file_range() checks that both in
> and out
> >vnodes are VREG.  For devfs, they are VCHR.
>
> I coded the syscall to the Linux man page, which states that EINVAL is
> returned
> if either fd does not refer to a regular file.
> Having said that, I do not recall testing the VCHR case under Linux. (ie.
> It might
> actually work and the man page turns out to be incorrect?)
>
> I will test this case under Linux when I get home next week, rick
>

Since there's no standard, I think it's fine for us to support devfs if
possible.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365643 - head/bin/cp

2020-09-11 Thread Alan Somers
Author: asomers
Date: Fri Sep 11 20:49:36 2020
New Revision: 365643
URL: https://svnweb.freebsd.org/changeset/base/365643

Log:
  cp: fall back to read/write if copy_file_range fails
  
  Even though copy_file_range has a file-system agnostic version, it still
  fails on devfs (perhaps because the file descriptor is non-seekable?) In
  that case, fallback to old-fashioned read/write. Fixes
  "cp /dev/null /tmp/null"
  
  PR:   249248
  Reported by:  Michael Butler
  Reviewed by:  mjg
  MFC-With: 365549
  Differential Revision:https://reviews.freebsd.org/D26395

Modified:
  head/bin/cp/utils.c

Modified: head/bin/cp/utils.c
==
--- head/bin/cp/utils.c Fri Sep 11 20:32:40 2020(r365642)
+++ head/bin/cp/utils.c Fri Sep 11 20:49:36 2020(r365643)
@@ -74,6 +74,26 @@ __FBSDID("$FreeBSD$");
  */
 #define BUFSIZE_SMALL (MAXPHYS)
 
+static int
+copy_fallback(int from_fd, int to_fd, char *buf, size_t bufsize)
+{
+   int rcount;
+   ssize_t wresid, wcount = 0;
+   char *bufp;
+
+   rcount = read(from_fd, buf, bufsize);
+   if (rcount <= 0)
+   return (rcount);
+   for (bufp = buf, wresid = rcount; ; bufp += wcount, wresid -= wcount) {
+   wcount = write(to_fd, bufp, wresid);
+   if (wcount <= 0)
+   break;
+   if (wcount >= (ssize_t)wresid)
+   break;
+   }
+   return (wcount < 0 ? wcount : rcount);
+}
+
 int
 copy_file(const FTSENT *entp, int dne)
 {
@@ -88,6 +108,7 @@ copy_file(const FTSENT *entp, int dne)
 #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
char *p;
 #endif
+   int use_copy_file_range = 1;
 
from_fd = to_fd = -1;
if (!lflag && !sflag &&
@@ -212,9 +233,19 @@ copy_file(const FTSENT *entp, int dne)
err(1, "Not enough memory");
}
wtotal = 0;
-   while ((rcount = copy_file_range(from_fd, NULL,
-   to_fd, NULL, bufsize, 0)) > 0)
-   {
+   do {
+   if (use_copy_file_range) {
+   rcount = copy_file_range(from_fd, NULL,
+   to_fd, NULL, bufsize, 0);
+   if (rcount < 0 && errno == EINVAL) {
+   /* Prob a non-seekable FD */
+   use_copy_file_range = 0;
+   }
+   }
+   if (!use_copy_file_range) {
+   rcount = copy_fallback(from_fd, to_fd,
+   buf, bufsize);
+   }
wtotal += rcount;
if (info) {
info = 0;
@@ -223,7 +254,7 @@ copy_file(const FTSENT *entp, int dne)
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
}
-   }
+   } while (rcount > 0);
if (rcount < 0) {
warn("%s", entp->fts_path);
rval = 1;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r365614 - in stable/12: sys/dev/virtio/block usr.sbin/bhyve

2020-09-10 Thread Alan Somers
On Thu, Sep 10, 2020 at 3:01 PM Allan Jude  wrote:

> Author: allanjude
> Date: Thu Sep 10 21:01:22 2020
> New Revision: 365614
> URL: https://svnweb.freebsd.org/changeset/base/365614
>
> Log:
>   MFC r360229, r363255
>
>   r360229:
>   Add VIRTIO_BLK_T_DISCARD (TRIM) support to the bhyve virtio-blk backend
>
>   This will advertise support for TRIM to the guest virtio-blk driver and
>   perform the DIOCGDELETE ioctl on the backing storage if it supports it.
>
>   Thanks to Jason King and others at Joyent and illumos for expanding on
>   my original patch, adding improvements including better error handling
>   and making sure to following the virtio spec.
>
>   r363255:
>   Add VIRTIO_BLK_T_DISCARD support to the virtio-blk driver
>
>   If the hypervisor advertises support for the DISCARD command then the
>   guest can perform TRIM commands, freeing space on the backing store.
>
>   If VIRTIO_BLK_F_DISCARD is enabled, advertise DISKFLAG_CANDELETE
>
>   Tested with FreeBSD guests on bhyve and KVM
>
>   Relnotes: yes
>   Sponsored by: Klara Inc.
>
> Modified:
>   stable/12/sys/dev/virtio/block/virtio_blk.c
>   stable/12/sys/dev/virtio/block/virtio_blk.h
>   stable/12/usr.sbin/bhyve/block_if.c
>   stable/12/usr.sbin/bhyve/pci_virtio_block.c
> Directory Properties:
>   stable/12/   (props changed)
>

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


svn commit: r365549 - head/bin/cp

2020-09-09 Thread Alan Somers
Author: asomers
Date: Thu Sep 10 02:48:55 2020
New Revision: 365549
URL: https://svnweb.freebsd.org/changeset/base/365549

Log:
  cp: use copy_file_range(2)
  
  This has three advantages over write(2)/read(2):
  
  * Fewer context switches and data copies
  * Mostly preserves a file's sparseness
  * On some file systems (currently NFS 4.2) the file system will perform the
copy in an especially efficient way.
  
  Reviewed by:  rmacklem
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26377

Modified:
  head/bin/cp/utils.c

Modified: head/bin/cp/utils.c
==
--- head/bin/cp/utils.c Thu Sep 10 01:49:53 2020(r365548)
+++ head/bin/cp/utils.c Thu Sep 10 02:48:55 2020(r365549)
@@ -212,27 +212,16 @@ copy_file(const FTSENT *entp, int dne)
err(1, "Not enough memory");
}
wtotal = 0;
-   while ((rcount = read(from_fd, buf, bufsize)) > 0) {
-   for (bufp = buf, wresid = rcount; ;
-   bufp += wcount, wresid -= wcount) {
-   wcount = write(to_fd, bufp, wresid);
-   if (wcount <= 0)
-   break;
-   wtotal += wcount;
-   if (info) {
-   info = 0;
-   (void)fprintf(stderr,
-   "%s -> %s %3d%%\n",
-   entp->fts_path, to.p_path,
-   cp_pct(wtotal, 
fs->st_size));
-   }
-   if (wcount >= (ssize_t)wresid)
-   break;
-   }
-   if (wcount != (ssize_t)wresid) {
-   warn("%s", to.p_path);
-   rval = 1;
-   break;
+   while ((rcount = copy_file_range(from_fd, NULL,
+   to_fd, NULL, bufsize, 0)) > 0)
+   {
+   wtotal += rcount;
+   if (info) {
+   info = 0;
+   (void)fprintf(stderr,
+   "%s -> %s %3d%%\n",
+   entp->fts_path, to.p_path,
+   cp_pct(wtotal, fs->st_size));
}
}
if (rcount < 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365503 - stable/12/usr.bin/nfsstat

2020-09-09 Thread Alan Somers
Author: asomers
Date: Wed Sep  9 13:16:20 2020
New Revision: 365503
URL: https://svnweb.freebsd.org/changeset/base/365503

Log:
  MFC r365262:
  
  Fix output of nfsstat -cE in json or xml mode
  
  Due to a copy/paste error, the "getacl" field was duplicated, but only in
  XML or JSON mode, not in txt mode.
  
  Discussed with:   rmacklem
  Sponsored by: Axcient

Modified:
  stable/12/usr.bin/nfsstat/nfsstat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/nfsstat/nfsstat.c
==
--- stable/12/usr.bin/nfsstat/nfsstat.c Wed Sep  9 12:58:19 2020
(r365502)
+++ stable/12/usr.bin/nfsstat/nfsstat.c Wed Sep  9 13:16:20 2020
(r365503)
@@ -731,7 +731,7 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41)
"{T:PutRootFH/%13.13s}{T:DelegRet/%13.13s}"
"{T:GetAcl/%13.13s}{T:SetAcl/%13.13s}\n");
xo_emit("{:rellckown/%13ju}{:freestateid/%13ju}"
-   "{:getacl/%13ju}{:delegret/%13ju}"
+   "{:putrootfh/%13ju}{:delegret/%13ju}"
"{:getacl/%13ju}{:setacl/%13ju}\n",

(uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RELEASELCKOWN],
(uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FREESTATEID],
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365415 - head/share/man/man5

2020-09-07 Thread Alan Somers
Author: asomers
Date: Mon Sep  7 13:44:54 2020
New Revision: 365415
URL: https://svnweb.freebsd.org/changeset/base/365415

Log:
  nsswitch.conf.5: style fixes
  
  Fix some whitespace, and remove the .Tn macro
  
  Reported by:  mandoc, igor
  Reviewed by:  bcr (manpages)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D26345

Modified:
  head/share/man/man5/nsswitch.conf.5

Modified: head/share/man/man5/nsswitch.conf.5
==
--- head/share/man/man5/nsswitch.conf.5 Mon Sep  7 10:51:48 2020
(r365414)
+++ head/share/man/man5/nsswitch.conf.5 Mon Sep  7 13:44:54 2020
(r365415)
@@ -1,4 +1,4 @@
-.\"$NetBSD: nsswitch.conf.5,v 1.14 1999/03/17 20:19:47 garbled Exp $
+.\" $NetBSD: nsswitch.conf.5,v 1.14 1999/03/17 20:19:47 garbled Exp $
 .\"
 .\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -16,7 +16,7 @@
 .\"documentation and/or other materials provided with the distribution.
 .\" 3. All advertising materials mentioning features or use of this software
 .\"must display the following acknowledgement:
-.\"This product includes software developed by Luke Mewburn.
+.\"This product includes software developed by Luke Mewburn.
 .\" 4. The name of the author may not be used to endorse or promote products
 .\"derived from this software without specific prior written permission.
 .\"
@@ -48,8 +48,7 @@ file specifies how the
 .Pp
 The configuration file controls how a process looks up various databases
 containing information regarding hosts, users (passwords), groups, etc.
-Each database comes from a source (such as local files, DNS,
-.Tn NIS ,
+Each database comes from a source (such as local files, DNS, NIS ,
 and cache), and the order to look up the sources is specified in
 .Nm .
 .Pp
@@ -182,9 +181,7 @@ Try the next source
 Return with the current result
 .El
 .Ss Format of file
-A
-.Tn BNF
-description of the syntax of
+A BNF description of the syntax of
 .Nm
 is:
 .Pp
@@ -250,12 +247,10 @@ In historical multi-source implementations, the
 and
 .Sq -
 characters are used to specify the importing of user password and
-group information from
-.Tn NIS .
+group information from NIS .
 Although
 .Nm
-provides alternative methods of accessing distributed sources such as
-.Tn NIS ,
+provides alternative methods of accessing distributed sources such as NIS ,
 specifying a sole source of
 .Dq compat
 will provide the historical behaviour.
@@ -328,9 +323,7 @@ resides in
 To lookup hosts in
 .Pa /etc/hosts
 , then in cache,
-and then from the DNS, and lookup user information from
-.Tn NIS
-then files, use:
+and then from the DNS, and lookup user information from NIS then files, use:
 .Pp
 .Bl -tag -width passwd: -compact
 .It hosts:
@@ -362,9 +355,7 @@ entries.
 .Fx Ns 's
 .Lb libc
 provides stubs for compatibility with NSS modules
-written for the
-.Tn GNU
-C Library
+written for the GNU C Library
 .Nm nsswitch
 interface.
 However, these stubs only support the use of the
@@ -390,10 +381,8 @@ Project, where it appeared first in
 .Sh AUTHORS
 .An Luke Mewburn Aq Mt lu...@netbsd.org
 wrote this freely distributable name-service switch implementation,
-using ideas from the
-.Tn ULTRIX
+using ideas from the ULTRIX
 .Xr svc.conf 5
-and
-.Tn Solaris
+and Solaris
 .Xr nsswitch.conf 4
 manual pages.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364637 - head/sys/kern

2020-09-06 Thread Alan Somers
On Mon, Aug 24, 2020 at 3:01 AM Mateusz Guzik  wrote:

> Author: mjg
> Date: Mon Aug 24 09:00:57 2020
> New Revision: 364637
> URL: https://svnweb.freebsd.org/changeset/base/364637
>
> Log:
>   cache: lockless reverse lookup
>
>   This enables fully scalable operation for getcwd and significantly
> improves
>   realpath.
>
>   For example:
>   PATH_CUSTOM=/usr/src ./getcwd_processes -t 104
>   before:  1550851
>   after: 380135380
>
>   Tested by:pho
>
> Modified:
>   head/sys/kern/vfs_cache.c
>
> Modified: head/sys/kern/vfs_cache.c
>
> ==
> --- head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:07 2020(r364636)
> +++ head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:57 2020(r364637)
> @@ -477,6 +485,8 @@ STATNODE_COUNTER(shrinking_skipped,
>  static void cache_zap_locked(struct namecache *ncp);
>  static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf,
>  char **freebuf, size_t *buflen);
> +static int vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char
> *buf,
> +char **retbuf, size_t *buflen, bool slash_prefixed, size_t addend);
>  static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char
> *buf,
>  char **retbuf, size_t *buflen);
>  static int vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char
> *buf,
> @@ -2476,9 +2486,17 @@ vn_getcwd(char *buf, char **retbuf, size_t *buflen)
>

What does the "smr" stand for?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365391 - head/share/man/man5

2020-09-06 Thread Alan Somers
Author: asomers
Date: Sun Sep  6 20:32:13 2020
New Revision: 365391
URL: https://svnweb.freebsd.org/changeset/base/365391

Log:
  nsswitch.conf(5): recommend placing cache after files
  
  When cache precedes files, and nscd is configured to allow negative caching,
  commands like "pw groupadd" can fail. The sequence of events looks like:
  
  1. A command like pkg(8) looks up the group, and finds it absent.
  2. pkg invokes pw(8) to add the group
  3. pkg queries the group, but nscd says it doesn't exist, since it has a
 negative cache entry for that group.
  
  See also: 
https://lists.freebsd.org/pipermail/freebsd-current/2012-January/031595.html
  
  Reviewed by:  bcr (manpages)
  MFC after:1 week
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26184

Modified:
  head/share/man/man5/nsswitch.conf.5

Modified: head/share/man/man5/nsswitch.conf.5
==
--- head/share/man/man5/nsswitch.conf.5 Sun Sep  6 20:03:13 2020
(r365390)
+++ head/share/man/man5/nsswitch.conf.5 Sun Sep  6 20:32:13 2020
(r365391)
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 10, 2018
+.Dd September 6, 2020
 .Dt NSSWITCH.CONF 5
 .Os
 .Sh NAME
@@ -224,20 +224,24 @@ and continue on anything else (i.e,
 .Ss Cache
 You can enable caching for the particular database by specifying
 .Dq cache
-as the first source in the
+in the
 .Nm
 file.
+It should come after
+.Dq files ,
+but before remote sources like
+.Dq nis .
 You should also enable caching for this database in
 .Xr nscd.conf 5 .
-If for the particular query
+If for a particular query
 .Dq cache
-source returns success, no further sources are queried.
+source returns success, then no further sources are queried.
 On the other hand, if there are no previously cached data, the
 query result will be placed into the cache right after
 all other sources are processed.
-Note, that
+Note that
 .Dq cache
-requires
+requires the
 .Xr nscd 8
 daemon to be running.
 .Ss Compat mode: +/- syntax
@@ -321,15 +325,16 @@ resides in
 .Pa /etc .
 .El
 .Sh EXAMPLES
-To lookup hosts in cache, then in
+To lookup hosts in
 .Pa /etc/hosts
+, then in cache,
 and then from the DNS, and lookup user information from
 .Tn NIS
 then files, use:
 .Pp
 .Bl -tag -width passwd: -compact
 .It hosts:
-cache files dns
+files cache dns
 .It passwd:
 nis [notfound=return] files
 .It group:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365389 - head/sys/crypto/via

2020-09-06 Thread Alan Somers
Author: asomers
Date: Sun Sep  6 19:25:31 2020
New Revision: 365389
URL: https://svnweb.freebsd.org/changeset/base/365389

Log:
  padlock(4): fix instapanics with geli authentication
  
  cryptodev_process implementations are supposed to return 0
  
  PR:   247986
  Submitted by: jhb
  MFC after:1 week

Modified:
  head/sys/crypto/via/padlock.c

Modified: head/sys/crypto/via/padlock.c
==
--- head/sys/crypto/via/padlock.c   Sun Sep  6 19:03:19 2020
(r365388)
+++ head/sys/crypto/via/padlock.c   Sun Sep  6 19:25:31 2020
(r365389)
@@ -275,7 +275,7 @@ out:
 #endif
crp->crp_etype = error;
crypto_done(crp);
-   return (error);
+   return (0);
 }
 
 static device_method_t padlock_methods[] = {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365262 - head/usr.bin/nfsstat

2020-09-02 Thread Alan Somers
Author: asomers
Date: Wed Sep  2 17:36:30 2020
New Revision: 365262
URL: https://svnweb.freebsd.org/changeset/base/365262

Log:
  Fix output of nfsstat -cE in json or xml mode
  
  Due to a copy/paste error, the "getacl" field was duplicated, but only in
  XML or JSON mode, not in txt mode.
  
  Discussed with:   rmacklem
  MFC after:1 week
  Sponsored by: Axcient

Modified:
  head/usr.bin/nfsstat/nfsstat.c

Modified: head/usr.bin/nfsstat/nfsstat.c
==
--- head/usr.bin/nfsstat/nfsstat.c  Wed Sep  2 17:31:06 2020
(r365261)
+++ head/usr.bin/nfsstat/nfsstat.c  Wed Sep  2 17:36:30 2020
(r365262)
@@ -721,7 +721,7 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41)
"{T:PutRootFH/%13.13s}{T:DelegRet/%13.13s}"
"{T:GetAcl/%13.13s}{T:SetAcl/%13.13s}\n");
xo_emit("{:rellckown/%13ju}{:freestateid/%13ju}"
-   "{:getacl/%13ju}{:delegret/%13ju}"
+   "{:putrootfh/%13ju}{:delegret/%13ju}"
"{:getacl/%13ju}{:setacl/%13ju}\n",

(uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RELEASELCKOWN],
(uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FREESTATEID],
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364978 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2020-08-30 Thread Alan Somers
Author: asomers
Date: Sun Aug 30 18:21:54 2020
New Revision: 364978
URL: https://svnweb.freebsd.org/changeset/base/364978

Log:
  MFC r364412:
  
  zfs: fix EIO accessing dataset after resuming interrupted receive
  
  ZFS unmounts a dataset while receiving into it and remounts it afterwards.
  But if ZFS is resuming an incomplete receive, it screws up and ends up with
  a dataset that is mounted, but returns EIO for every access. This commit
  fixes that condition.
  
  While the vulnerable code also exists in OpenZFS, the problem is not
  reproducible there. Apparently OpenZFS doesn't unmount the destination
  dataset during receive, like FreeBSD does.
  
  PR:   248606
  Reviewed by:  mmacy
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26034

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sun Aug 30 17:40:59 2020(r364977)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sun Aug 30 18:21:54 2020(r364978)
@@ -3415,7 +3415,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
}
 
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
-   stream_wantsnewfs) {
+   (stream_wantsnewfs || resuming)) {
/* We can't do online recv in this case */
clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0);
if (clp == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364974 - stable/12/cddl/contrib/opensolaris/lib/libzfs/common

2020-08-30 Thread Alan Somers
Author: asomers
Date: Sun Aug 30 16:27:58 2020
New Revision: 364974
URL: https://svnweb.freebsd.org/changeset/base/364974

Log:
  MFC r364412:
  
  zfs: fix EIO accessing dataset after resuming interrupted receive
  
  ZFS unmounts a dataset while receiving into it and remounts it afterwards.
  But if ZFS is resuming an incomplete receive, it screws up and ends up with
  a dataset that is mounted, but returns EIO for every access. This commit
  fixes that condition.
  
  While the vulnerable code also exists in OpenZFS, the problem is not
  reproducible there. Apparently OpenZFS doesn't unmount the destination
  dataset during receive, like FreeBSD does.
  
  PR:   248606
  Reviewed by:  mmacy
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26034

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sun Aug 30 07:34:32 2020(r364973)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Sun Aug 30 16:27:58 2020(r364974)
@@ -3433,7 +3433,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
}
 
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
-   stream_wantsnewfs) {
+   (stream_wantsnewfs || resuming)) {
/* We can't do online recv in this case */
clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0);
if (clp == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364833 - head/sys/dev/sec

2020-08-26 Thread Alan Somers
On Wed, Aug 26, 2020 at 1:30 PM Brandon Bergren  wrote:

> Author: bdragon
> Date: Wed Aug 26 19:30:42 2020
> New Revision: 364833
> URL: https://svnweb.freebsd.org/changeset/base/364833
>
> Log:
>   [PowerPC] Fix build failure in sec.c
>
>   Fix a typo in r364799 that was breaking powerpc and powerpcspe build.
>
>   MFC with: 364799
>
> Modified:
>   head/sys/dev/sec/sec.c
>

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


Re: svn commit: r364799 - in head: share/man/man9 sys/crypto/ccp sys/dev/cxgbe/crypto sys/dev/sec sys/kern sys/opencrypto

2020-08-26 Thread Alan Somers
On Wed, Aug 26, 2020 at 1:30 PM Ed Maste  wrote:

> On Wed, 26 Aug 2020 at 15:27, Alan Somers  wrote:
> >
> > It probably came copy/pasted from another file :( .  I'll fix it; and
> figure out why my universe build didn't catch this.
>
> IIRC powerpcspe is not included in universe/tinderbox.
>

Oh, it's only for powerpcspe and not for all powerpc?  Now I don't feel so
bad.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364799 - in head: share/man/man9 sys/crypto/ccp sys/dev/cxgbe/crypto sys/dev/sec sys/kern sys/opencrypto

2020-08-26 Thread Alan Somers
On Wed, Aug 26, 2020 at 1:23 PM Brandon Bergren  wrote:

>
> > No, I mean literally. What scope is cb coming from? It's not a variable
> > that is in scope for that function as far as I can tell.
> >
>
> Naturally, about two seconds after I sent this, I realized that you meant
> that it was a powerpc-specific driver and that's why the other platforms
> don't catch it.
>
> Will fix it myself.
>
> --
>   Brandon Bergren
>   bdra...@freebsd.org
>

It probably came copy/pasted from another file :( .  I'll fix it; and
figure out why my universe build didn't catch this.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364800 - head/sys/geom/eli

2020-08-25 Thread Alan Somers
Author: asomers
Date: Wed Aug 26 02:44:35 2020
New Revision: 364800
URL: https://svnweb.freebsd.org/changeset/base/364800

Log:
  geli: use unmapped I/O
  
  Use unmapped I/O for geli. Unlike most geom providers, geli needs to
  manipulate data on every read or write. Previously it would always map bios.
  
  On my 16-core, dual socket server using geli atop md(4) devices, with 512B
  sectors, this change increases geli IOPs by about 3x.
  
  Note that geli still can't use unmapped I/O when data integrity verification
  is enabled (but it could, with a little more work).  And it can't use
  unmapped I/O in combination with ZFS, because ZFS uses mapped bios.
  
  Reviewed by:  markj, kib, jhb, mjg, mat, bcr (manpages)
  MFC after:1 week
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25671

Modified:
  head/sys/geom/eli/g_eli.c
  head/sys/geom/eli/g_eli_privacy.c

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Wed Aug 26 02:37:42 2020(r364799)
+++ head/sys/geom/eli/g_eli.c   Wed Aug 26 02:44:35 2020(r364800)
@@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -972,6 +974,15 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 */
pp = g_new_providerf(gp, "%s%s", bpp->name, G_ELI_SUFFIX);
pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
+   if (CRYPTO_HAS_VMPAGE) {
+   /*
+* On DMAP architectures we can use unmapped I/O.  But don't
+* use it with data integrity verification.  That code hasn't
+* been written yet.
+*/
+if ((sc->sc_flags & G_ELI_FLAG_AUTH) == 0)
+   pp->flags |= G_PF_ACCEPT_UNMAPPED;
+   }
pp->mediasize = sc->sc_mediasize;
pp->sectorsize = sc->sc_sectorsize;
LIST_FOREACH(gap, >aliases, ga_next)

Modified: head/sys/geom/eli/g_eli_privacy.c
==
--- head/sys/geom/eli/g_eli_privacy.c   Wed Aug 26 02:37:42 2020
(r364799)
+++ head/sys/geom/eli/g_eli_privacy.c   Wed Aug 26 02:44:35 2020
(r364800)
@@ -63,6 +63,28 @@ __FBSDID("$FreeBSD$");
 MALLOC_DECLARE(M_ELI);
 
 /*
+ * Copy data from a (potentially unmapped) bio to a kernelspace buffer.
+ *
+ * The buffer must have at least as much room as bp->bio_length.
+ */
+static void
+g_eli_bio_copyin(struct bio *bp, void *kaddr)
+{
+   struct uio uio;
+   struct iovec iov[1];
+
+   iov[0].iov_base = kaddr;
+   iov[0].iov_len = bp->bio_length;
+   uio.uio_iov = iov;
+   uio.uio_iovcnt = 1;
+   uio.uio_offset = 0;
+   uio.uio_resid = bp->bio_length;
+   uio.uio_segflg = UIO_SYSSPACE;
+   uio.uio_rw = UIO_READ;
+   uiomove_fromphys(bp->bio_ma, bp->bio_ma_offset, bp->bio_length, );
+}
+
+/*
  * The function is called after we read and decrypt data.
  *
  * g_eli_start -> g_eli_crypto_read -> g_io_request -> g_eli_read_done -> 
g_eli_crypto_run -> G_ELI_CRYPTO_READ_DONE -> g_io_deliver
@@ -98,8 +120,7 @@ g_eli_crypto_read_done(struct cryptop *crp)
 */
if (bp->bio_inbed < bp->bio_children)
return (0);
-   free(bp->bio_driver2, M_ELI);
-   bp->bio_driver2 = NULL;
+
if (bp->bio_error != 0) {
G_ELI_LOGREQ(0, bp, "Crypto READ request failed (error=%d).",
bp->bio_error);
@@ -167,6 +188,11 @@ g_eli_crypto_write_done(struct cryptop *crp)
return (0);
}
cbp->bio_data = bp->bio_driver2;
+   /* 
+* Clear BIO_UNMAPPED, which was inherited from where we cloned the bio
+* in g_eli_start, because we manually set bio_data
+*/
+   cbp->bio_flags &= ~BIO_UNMAPPED;
cbp->bio_done = g_eli_write_done;
cp = LIST_FIRST(>consumer);
cbp->bio_to = cp->provider;
@@ -236,10 +262,12 @@ g_eli_crypto_run(struct g_eli_worker *wr, struct bio *
 {
struct g_eli_softc *sc;
struct cryptop *crp;
+   vm_page_t *pages;
u_int i, nsec, secsize;
off_t dstoff;
-   u_char *data;
+   u_char *data = NULL;
int error;
+   int pages_offset;
 
G_ELI_LOGREQ(3, bp, "%s", __func__);
 
@@ -258,16 +286,37 @@ g_eli_crypto_run(struct g_eli_worker *wr, struct bio *
if (bp->bio_cmd == BIO_WRITE) {
data = malloc(bp->bio_length, M_ELI, M_WAITOK);
bp->bio_driver2 = data;
-   bcopy(bp->bio_data, data, bp->bio_length);
-   } else
-   data = bp->bio_data;
+   /* 
+* This copy could be eliminated by using crypto's output
+* buffer, instead of using a single overwriting buffer.
+*/
+   if ((bp->bio_flags & BIO_UNMAPPED) != 0)
+   

svn commit: r364799 - in head: share/man/man9 sys/crypto/ccp sys/dev/cxgbe/crypto sys/dev/sec sys/kern sys/opencrypto

2020-08-25 Thread Alan Somers
Author: asomers
Date: Wed Aug 26 02:37:42 2020
New Revision: 364799
URL: https://svnweb.freebsd.org/changeset/base/364799

Log:
  crypto(9): add CRYPTO_BUF_VMPAGE
  
  crypto(9) functions can now be used on buffers composed of an array of
  vm_page_t structures, such as those stored in an unmapped struct bio.  It
  requires the running to kernel to support the direct memory map, so not all
  architectures can use it.
  
  Reviewed by:  markj, kib, jhb, mjg, mat, bcr (manpages)
  MFC after:1 week
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25671

Modified:
  head/share/man/man9/crypto_buffer.9
  head/share/man/man9/crypto_request.9
  head/sys/crypto/ccp/ccp.c
  head/sys/dev/cxgbe/crypto/t4_crypto.c
  head/sys/dev/sec/sec.c
  head/sys/kern/subr_bus_dma.c
  head/sys/opencrypto/criov.c
  head/sys/opencrypto/crypto.c
  head/sys/opencrypto/cryptodev.h
  head/sys/opencrypto/cryptosoft.c

Modified: head/share/man/man9/crypto_buffer.9
==
--- head/share/man/man9/crypto_buffer.9 Wed Aug 26 02:13:27 2020
(r364798)
+++ head/share/man/man9/crypto_buffer.9 Wed Aug 26 02:37:42 2020
(r364799)
@@ -30,7 +30,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 25, 2020
+.Dd August 12, 2020
 .Dt CRYPTO_BUFFER 9
 .Os
 .Sh NAME
@@ -197,10 +197,17 @@ A scatter/gather list of kernel buffers as described i
 .It Dv CRYPTO_BUF_MBUF
 A network memory buffer as described in
 .Xr mbuf 9 .
+.It Dv CRYPTO_BUF_VMPAGE
+A scatter/gather list of 
+.Vt vm_page_t
+structures describing pages in the kernel's address space.
+This buffer type is only available if
+.Dv CRYPTO_HAS_VMPAGE
+is true.
 .El
 .Pp
 The structure also contains the following type-specific fields:
-.Bl -tag -width "  cb_buf_len"
+.Bl -tag -width "  cb_vm_page_offset"
 .It Fa cb_buf
 A pointer to the start of a
 .Dv CRYPTO_BUF_CONTIG
@@ -219,6 +226,19 @@ A pointer to a
 .Vt struct uio
 for
 .Dv CRYPTO_BUF_UIO .
+.It Fa cb_vm_page
+A pointer to an array of
+.Vt struct vm_page
+for
+.Dv CRYPTO_BUF_VMPAGE .
+.It Fa cb_vm_page_len
+The total amount of data included in the
+.Fa cb_vm_page
+array, in bytes.
+.It Fa cb_vm_page_offset
+Offset in bytes in the first page of
+.Fa cb_vm_page
+where valid data begins.
 .El
 .Ss Cursors
 Cursors provide a mechanism for iterating over a data buffer.

Modified: head/share/man/man9/crypto_request.9
==
--- head/share/man/man9/crypto_request.9Wed Aug 26 02:13:27 2020
(r364798)
+++ head/share/man/man9/crypto_request.9Wed Aug 26 02:37:42 2020
(r364799)
@@ -30,7 +30,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 16, 2020
+.Dd August 12, 2020
 .Dt CRYPTO_REQUEST 9
 .Os
 .Sh NAME
@@ -55,11 +55,15 @@
 .Ft void
 .Fn crypto_use_uio "struct cryptop *crp" "struct uio *uio"
 .Ft void
+.Fn crypto_use_vmpage "struct cryptop *crp" "vm_page_t *pages" "int len" "int 
offset"
+.Ft void
 .Fn crypto_use_output_buf "struct cryptop *crp" "void *buf" "int len"
 .Ft void
 .Fn crypto_use_output_mbuf "struct cryptop *crp" "struct mbuf *m"
 .Ft void
 .Fn crypto_use_output_uio "struct cryptop *crp" "struct uio *uio"
+.Ft void
+.Fn crypto_use_output_vmpage "struct cryptop *crp" "vm_page_t *pages" "int 
len" "int offset"
 .Sh DESCRIPTION
 Each symmetric cryptographic operation in the kernel is described by
 an instance of
@@ -141,7 +145,7 @@ mode requests.
 All requests must have a valid
 .Fa crp_buf
 initialized by one of the following functions:
-.Bl -tag -width "Fn crypto_use_mbuf"
+.Bl -tag -width "Fn crypto_use_vmpage"
 .It Fn crypto_use_buf
 Uses an array of
 .Fa len
@@ -156,12 +160,16 @@ as the data buffer.
 Uses the scatter/gather list
 .Fa uio
 as the data buffer.
+.It Fn crypto_use_vmpage
+Uses the array of
+.Vt vm_page_t
+structures as the data buffer.
 .El
 .Pp
 One of the following functions should be used to initialize
 .Fa crp_obuf
 for requests that use separate input and output buffers:
-.Bl -tag -width "Fn crypto_use_output_mbuf"
+.Bl -tag -width "Fn crypto_use_output_vmpage"
 .It Fn crypto_use_output_buf
 Uses an array of
 .Fa len
@@ -176,6 +184,10 @@ as the output buffer.
 Uses the scatter/gather list
 .Fa uio
 as the output buffer.
+.It Fn crypto_use_output_vmpage
+Uses the array of
+.Vt vm_page_t
+structures as the output buffer.
 .El
 .Ss Request Regions
 Each request describes one or more regions in the data buffers.

Modified: head/sys/crypto/ccp/ccp.c
==
--- head/sys/crypto/ccp/ccp.c   Wed Aug 26 02:13:27 2020(r364798)
+++ head/sys/crypto/ccp/ccp.c   Wed Aug 26 02:37:42 2020(r364799)
@@ -107,6 +107,10 @@ ccp_populate_sglist(struct sglist *sg, struct crypto_b
case CRYPTO_BUF_CONTIG:
error = sglist_append(sg, cb->cb_buf, cb->cb_buf_len);
break;
+   case CRYPTO_BUF_VMPAGE:
+   error = 

svn commit: r364412 - head/cddl/contrib/opensolaris/lib/libzfs/common

2020-08-19 Thread Alan Somers
Author: asomers
Date: Thu Aug 20 01:31:21 2020
New Revision: 364412
URL: https://svnweb.freebsd.org/changeset/base/364412

Log:
  zfs: fix EIO accessing dataset after resuming interrupted receive
  
  ZFS unmounts a dataset while receiving into it and remounts it afterwards.
  But if ZFS is resuming an incomplete receive, it screws up and ends up with
  a dataset that is mounted, but returns EIO for every access. This commit
  fixes that condition.
  
  While the vulnerable code also exists in OpenZFS, the problem is not
  reproducible there. Apparently OpenZFS doesn't unmount the destination
  dataset during receive, like FreeBSD does.
  
  PR:   248606
  Reviewed by:  mmacy
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26034

Modified:
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Thu Aug 
20 00:52:53 2020(r364411)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Thu Aug 
20 01:31:21 2020(r364412)
@@ -3434,7 +3434,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const 
}
 
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
-   stream_wantsnewfs) {
+   (stream_wantsnewfs || resuming)) {
/* We can't do online recv in this case */
clp = changelist_gather(zhp, ZFS_PROP_NAME, 0,
flags->forceunmount ? MS_FORCE : 0);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364094 - head/tests/sys/fs/fusefs

2020-08-10 Thread Alan Somers
Author: asomers
Date: Tue Aug 11 01:09:06 2020
New Revision: 364094
URL: https://svnweb.freebsd.org/changeset/base/364094

Log:
  fusefs: fix the FUSE_FORGET unit test after r364064
  
  Thanks to r364064, the name cache now returns a hit where previously it
  would miss.  Adjust the expectations accordingly.
  
  PR:   248583
  Reported by:  lwhsu
  MFC with: r364064

Modified:
  head/tests/sys/fs/fusefs/forget.cc

Modified: head/tests/sys/fs/fusefs/forget.cc
==
--- head/tests/sys/fs/fusefs/forget.cc  Tue Aug 11 00:41:48 2020
(r364093)
+++ head/tests/sys/fs/fusefs/forget.cc  Tue Aug 11 01:09:06 2020
(r364094)
@@ -116,6 +116,7 @@ TEST_F(Forget, invalidate_names)
int err;
 
EXPECT_LOOKUP(FUSE_ROOT_ID, DNAME)
+   .Times(2)
.WillRepeatedly(Invoke(
ReturnImmediate([=](auto in __unused, auto& out) {
SET_OUT_HEADER_LEN(out, entry);
@@ -142,7 +143,7 @@ TEST_F(Forget, invalidate_names)
out.body.entry.attr_valid = UINT64_MAX;
out.body.entry.entry_valid = UINT64_MAX;
})));
-   expect_forget(dir_ino, 2);
+   expect_forget(dir_ino, 1);
 
/* Access the file to cache its name */
ASSERT_EQ(0, access(FULLFPATH, F_OK)) << strerror(errno);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364044 - in head: share/man/man9 sys/compat/linuxkpi/common/src sys/kern sys/security/audit sys/sys

2020-08-07 Thread Alan Somers
So it's just the struct copy, then?  I'm impressed that it made that much
difference to remove it.
-Alan

On Fri, Aug 7, 2020 at 7:40 PM Mateusz Guzik  wrote:

> or to put differently, the difference is disapperance of vn_stat from
> the codepath.
>
> On 8/8/20, Mateusz Guzik  wrote:
> > tmpfs_getattr fills > 100 bytes worth of data into struct vattr, which
> > then has to be converted to struct stat format. The conversion happens
> > to copy some of it as it is and branch on other stuff. tmpfs_stat
> > elides the entire process.
> >
> > On 8/8/20, Alan Somers  wrote:
> >> On Fri, Aug 7, 2020 at 5:06 PM Mateusz Guzik  wrote:
> >>
> >>> Author: mjg
> >>> Date: Fri Aug  7 23:06:40 2020
> >>> New Revision: 364044
> >>> URL: https://svnweb.freebsd.org/changeset/base/364044
> >>>
> >>> Log:
> >>>   vfs: add VOP_STAT
> >>>
> >>>   The current scheme of calling VOP_GETATTR adds avoidable overhead.
> >>>
> >>>   An example with tmpfs doing fstat (ops/s):
> >>>   before: 7488958
> >>>   after:  7913833
> >>>
> >>>   Reviewed by:  kib (previous version)
> >>>   Differential Revision:https://reviews.freebsd.org/D25910
> >>>
> >>> Modified:
> >>>   head/share/man/man9/Makefile
> >>>   head/share/man/man9/VOP_ATTRIB.9
> >>>   head/sys/compat/linuxkpi/common/src/linux_compat.c
> >>>   head/sys/kern/vfs_default.c
> >>>   head/sys/kern/vfs_syscalls.c
> >>>   head/sys/kern/vfs_vnops.c
> >>>   head/sys/kern/vnode_if.src
> >>>   head/sys/security/audit/audit_arg.c
> >>>   head/sys/sys/vnode.h
> >>>
> >>
> >> What avoidable overhead? The tmpfs_stat handler that you added in your
> >> next
> >> commit looks pretty much the same as vop_getattr.  I'm missing where the
> >> performance improvement comes from.  Could you please fill me in?
> >> -Alan
> >>
> >
> >
> > --
> > Mateusz Guzik 
> >
>
>
> --
> Mateusz Guzik 
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r364044 - in head: share/man/man9 sys/compat/linuxkpi/common/src sys/kern sys/security/audit sys/sys

2020-08-07 Thread Alan Somers
On Fri, Aug 7, 2020 at 5:06 PM Mateusz Guzik  wrote:

> Author: mjg
> Date: Fri Aug  7 23:06:40 2020
> New Revision: 364044
> URL: https://svnweb.freebsd.org/changeset/base/364044
>
> Log:
>   vfs: add VOP_STAT
>
>   The current scheme of calling VOP_GETATTR adds avoidable overhead.
>
>   An example with tmpfs doing fstat (ops/s):
>   before: 7488958
>   after:  7913833
>
>   Reviewed by:  kib (previous version)
>   Differential Revision:https://reviews.freebsd.org/D25910
>
> Modified:
>   head/share/man/man9/Makefile
>   head/share/man/man9/VOP_ATTRIB.9
>   head/sys/compat/linuxkpi/common/src/linux_compat.c
>   head/sys/kern/vfs_default.c
>   head/sys/kern/vfs_syscalls.c
>   head/sys/kern/vfs_vnops.c
>   head/sys/kern/vnode_if.src
>   head/sys/security/audit/audit_arg.c
>   head/sys/sys/vnode.h
>

What avoidable overhead? The tmpfs_stat handler that you added in your next
commit looks pretty much the same as vop_getattr.  I'm missing where the
performance improvement comes from.  Could you please fill me in?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363622 - head/sys/sys

2020-07-27 Thread Alan Somers
Author: asomers
Date: Mon Jul 27 18:57:28 2020
New Revision: 363622
URL: https://svnweb.freebsd.org/changeset/base/363622

Log:
  Restrict definition of CTL_P1003_1B_MAXID to the kernel
  
  This constant is only used to size an array within the kernel. There are
  probably no legitimate uses in userland. Worse, since the kernel's array
  could theoretically change size over time, any use of that symbol in
  userland wouldn't be forwards compatible to new kernel versions.
  
  Reviewed by:  jhb
  MFC after:Never
  Differential Revision:https://reviews.freebsd.org/D25816

Modified:
  head/sys/sys/sysctl.h

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Mon Jul 27 18:46:20 2020(r363621)
+++ head/sys/sys/sysctl.h   Mon Jul 27 18:57:28 2020(r363622)
@@ -1096,9 +1096,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #defineCTL_P1003_1B_SIGQUEUE_MAX   24  /* int */
 #defineCTL_P1003_1B_TIMER_MAX  25  /* int */
 
-#defineCTL_P1003_1B_MAXID  26
-
 #ifdef _KERNEL
+
+#defineCTL_P1003_1B_MAXID  26
 
 /*
  * Declare some common oids.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363486 - in stable/12: sys/geom/eli tests/sys/geom/class/eli

2020-07-24 Thread Alan Somers
Author: asomers
Date: Fri Jul 24 18:19:25 2020
New Revision: 363486
URL: https://svnweb.freebsd.org/changeset/base/363486

Log:
  MFC r363014:
  
  geli: enable direct dispatch
  
  geli does all of its crypto operations in a separate thread pool, so
  g_eli_start, g_eli_read_done, and g_eli_write_done don't actually do very
  much work. Enabling direct dispatch eliminates the g_up/g_down bottlenecks,
  doubling IOPs on my system. This change does not affect the thread pool.
  
  Reviewed by:  markj
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25587

Added:
  stable/12/tests/sys/geom/class/eli/reentrancy_test.sh
 - copied unchanged from r363014, 
head/tests/sys/geom/class/eli/reentrancy_test.sh
Modified:
  stable/12/sys/geom/eli/g_eli.c
  stable/12/tests/sys/geom/class/eli/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/eli/g_eli.c
==
--- stable/12/sys/geom/eli/g_eli.c  Fri Jul 24 17:56:17 2020
(r363485)
+++ stable/12/sys/geom/eli/g_eli.c  Fri Jul 24 18:19:25 2020
(r363486)
@@ -642,6 +642,7 @@ g_eli_read_metadata(struct g_class *mp, struct g_provi
gp->orphan = g_eli_orphan_spoil_assert;
gp->spoiled = g_eli_orphan_spoil_assert;
cp = g_new_consumer(gp);
+   cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
if (error != 0)
goto end;
@@ -778,6 +779,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 
pp = NULL;
cp = g_new_consumer(gp);
+   cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, bpp);
if (error != 0) {
if (req != NULL) {
@@ -865,6 +867,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 * Create decrypted provider.
 */
pp = g_new_providerf(gp, "%s%s", bpp->name, G_ELI_SUFFIX);
+   pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
pp->mediasize = sc->sc_mediasize;
pp->sectorsize = sc->sc_sectorsize;
 

Modified: stable/12/tests/sys/geom/class/eli/Makefile
==
--- stable/12/tests/sys/geom/class/eli/Makefile Fri Jul 24 17:56:17 2020
(r363485)
+++ stable/12/tests/sys/geom/class/eli/Makefile Fri Jul 24 18:19:25 2020
(r363486)
@@ -16,6 +16,7 @@ ATF_TESTS_SH+=integrity_test
 ATF_TESTS_SH+= kill_test
 ATF_TESTS_SH+= misc_test
 ATF_TESTS_SH+= onetime_test
+ATF_TESTS_SH+= reentrancy_test
 ATF_TESTS_SH+= resize_test
 ATF_TESTS_SH+= setkey_test
 

Copied: stable/12/tests/sys/geom/class/eli/reentrancy_test.sh (from r363014, 
head/tests/sys/geom/class/eli/reentrancy_test.sh)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/12/tests/sys/geom/class/eli/reentrancy_test.sh   Fri Jul 24 
18:19:25 2020(r363486, copy of r363014, 
head/tests/sys/geom/class/eli/reentrancy_test.sh)
@@ -0,0 +1,69 @@
+# $FreeBSD$
+
+# Test various operations for geli-on-geli providers, to ensure that geli is
+# reentrant.
+
+. $(atf_get_srcdir)/conf.sh
+
+init_test()
+{
+   cipher=$1
+   aalgo=$2
+   secsize=$3
+   ealgo=${cipher%%:*}
+   keylen=${cipher##*:}
+
+   atf_check dd if=/dev/random of=testdata bs=$secsize count=1 status=none
+   atf_check dd if=/dev/random of=keyfile bs=$secsize count=16 status=none
+
+   # Create the lower geli device
+   atf_check -s exit:0 -e ignore \
+   geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
+   -s $secsize ${md}
+   atf_check geli attach -p -k keyfile ${md}
+   # Create the upper geli device
+   atf_check -s exit:0 -e ignore \
+   geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
+   -s $secsize ${md}.eli
+   atf_check geli attach -p -k keyfile ${md}.eli
+   echo ${md} > layered_md_device
+
+   # Ensure we can read and write.
+   atf_check dd if=testdata of=/dev/${md}.eli.eli bs=$secsize count=1 \
+   status=none
+   atf_check dd if=/dev/${md}.eli.eli of=cmpdata bs=$secsize count=1 \
+   status=none
+   atf_check cmp -s testdata cmpdata
+
+   geli detach ${md}.eli 2>/dev/null
+}
+
+atf_test_case init cleanup
+init_head()
+{
+   atf_set "descr" "Initialize a geli provider on top of another"
+   atf_set "require.user" "root"
+   atf_set "timeout" 600
+}
+init_body()
+{
+   sectors=2
+   geli_test_setup
+
+   for_each_geli_config init_test
+}
+init_cleanup()
+{
+   if [ -f layered_md_device ]; then
+   while read provider; do
+   [ -c /dev/${md}.eli.eli ] && \
+   geli detach $md.eli.eli 2>/dev/null
+ 

svn commit: r363485 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-07-24 Thread Alan Somers
Author: asomers
Date: Fri Jul 24 17:56:17 2020
New Revision: 363485
URL: https://svnweb.freebsd.org/changeset/base/363485

Log:
  MFC r362891:
  
  Fix page fault in zfsctl_snapdir_getattr
  
  Must acquire the z_teardown_lock before accessing the zfsvfs_t object. I
  can't reproduce this panic on demand, but this looks like the correct
  solution.
  
  PR:   247668
  Reviewed by:  avg
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25543

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Fri Jul 24 17:45:06 2020(r363484)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Fri Jul 24 17:56:17 2020(r363485)
@@ -1118,12 +1118,13 @@ zfsctl_snapdir_getattr(ap)
vnode_t *vp = ap->a_vp;
vattr_t *vap = ap->a_vap;
zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
-   dsl_dataset_t *ds = dmu_objset_ds(zfsvfs->z_os);
+   dsl_dataset_t *ds;
sfs_node_t *node = vp->v_data;
uint64_t snap_count;
int err;
 
ZFS_ENTER(zfsvfs);
+   ds = dmu_objset_ds(zfsvfs->z_os);
zfsctl_common_getattr(vp, vap);
vap->va_ctime = dmu_objset_snap_cmtime(zfsvfs->z_os);
vap->va_mtime = vap->va_ctime;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363484 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-07-24 Thread Alan Somers
Author: asomers
Date: Fri Jul 24 17:45:06 2020
New Revision: 363484
URL: https://svnweb.freebsd.org/changeset/base/363484

Log:
  MFC r362891:
  
  Fix page fault in zfsctl_snapdir_getattr
  
  Must acquire the z_teardown_lock before accessing the zfsvfs_t object. I
  can't reproduce this panic on demand, but this looks like the correct
  solution.
  
  PR:   247668
  Reviewed by:  avg
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25543

Modified:
  stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Fri Jul 24 17:34:44 2020(r363483)
+++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c   
Fri Jul 24 17:45:06 2020(r363484)
@@ -1120,12 +1120,13 @@ zfsctl_snapdir_getattr(ap)
vnode_t *vp = ap->a_vp;
vattr_t *vap = ap->a_vap;
zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
-   dsl_dataset_t *ds = dmu_objset_ds(zfsvfs->z_os);
+   dsl_dataset_t *ds;
sfs_node_t *node = vp->v_data;
uint64_t snap_count;
int err;
 
ZFS_ENTER(zfsvfs);
+   ds = dmu_objset_ds(zfsvfs->z_os);
zfsctl_common_getattr(vp, vap);
vap->va_ctime = dmu_objset_snap_cmtime(zfsvfs->z_os);
vap->va_mtime = vap->va_ctime;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363402 - in head: sys/geom/eli tests/sys/geom/class/eli

2020-07-21 Thread Alan Somers
Author: asomers
Date: Tue Jul 21 19:18:29 2020
New Revision: 363402
URL: https://svnweb.freebsd.org/changeset/base/363402

Log:
  Fix geli's null cipher, and add a test case
  
  PR:   247954
  Submitted by: jhb (sys), asomers (tests)
  Reviewed by:  jhb (tests), asomers (sys)
  MFC after:2 weeks
  Sponsored by: Axcient

Modified:
  head/sys/geom/eli/g_eli_integrity.c
  head/sys/geom/eli/g_eli_privacy.c
  head/tests/sys/geom/class/eli/onetime_test.sh

Modified: head/sys/geom/eli/g_eli_integrity.c
==
--- head/sys/geom/eli/g_eli_integrity.c Tue Jul 21 17:34:05 2020
(r363401)
+++ head/sys/geom/eli/g_eli_integrity.c Tue Jul 21 19:18:29 2020
(r363402)
@@ -536,13 +536,15 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp
crp->crp_digest_start = 0;
crp->crp_payload_start = sc->sc_alen;
crp->crp_payload_length = data_secsize;
-   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) == 0) {
crp->crp_cipher_key = g_eli_key_hold(sc, dstoff,
encr_secsize);
}
-   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
-   sizeof(crp->crp_iv));
+   if (g_eli_ivlen(sc->sc_ealgo) != 0) {
+   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
+   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
+   sizeof(crp->crp_iv));
+   }
 
g_eli_auth_keygen(sc, dstoff, authkey);
crp->crp_auth_key = authkey;

Modified: head/sys/geom/eli/g_eli_privacy.c
==
--- head/sys/geom/eli/g_eli_privacy.c   Tue Jul 21 17:34:05 2020
(r363401)
+++ head/sys/geom/eli/g_eli_privacy.c   Tue Jul 21 19:18:29 2020
(r363402)
@@ -281,13 +281,15 @@ g_eli_crypto_run(struct g_eli_worker *wr, struct bio *
 
crp->crp_payload_start = 0;
crp->crp_payload_length = secsize;
-   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) == 0) {
crp->crp_cipher_key = g_eli_key_hold(sc, dstoff,
secsize);
}
-   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
-   sizeof(crp->crp_iv));
+   if (g_eli_ivlen(sc->sc_ealgo) != 0) {
+   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
+   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
+   sizeof(crp->crp_iv));
+   }
 
error = crypto_dispatch(crp);
KASSERT(error == 0, ("crypto_dispatch() failed (error=%d)",

Modified: head/tests/sys/geom/class/eli/onetime_test.sh
==
--- head/tests/sys/geom/class/eli/onetime_test.sh   Tue Jul 21 17:34:05 
2020(r363401)
+++ head/tests/sys/geom/class/eli/onetime_test.sh   Tue Jul 21 19:18:29 
2020(r363402)
@@ -130,9 +130,54 @@ onetime_d_cleanup()
geli_test_cleanup
 }
 
+atf_test_case onetime cleanup
+onetime_null_head()
+{
+   atf_set "descr" "geli onetime can use the null cipher"
+   atf_set "require.user" "root"
+}
+onetime_null_body()
+{
+   geli_test_setup
+
+   sectors=100
+
+   dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
+
+   secsize=512
+   ealgo=${cipher%%:*}
+   keylen=${cipher##*:}
+
+   md=$(attach_md -t malloc -s 100k)
+
+   atf_check -s exit:0 -o ignore -e ignore \
+   geli onetime -e null -s ${secsize} ${md}
+
+   atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} 
status=none
+
+   md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5`
+   atf_check_equal 0 $?
+   md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} 
status=none | md5`
+   atf_check_equal 0 $?
+   md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | 
md5`
+   atf_check_equal 0 $?
+
+   if [ ${md_rnd} != ${md_ddev} ]; then
+   atf_fail "geli did not return the original data"
+   fi
+   if [ ${md_rnd} != ${md_edev} ]; then
+   atf_fail "geli encrypted the data even with the null cipher"
+   fi
+}
+onetime_null_cleanup()
+{
+   geli_test_cleanup
+}
+
 atf_init_test_cases()
 {
atf_add_test_case onetime
atf_add_test_case onetime_a
atf_add_test_case onetime_d
+   atf_add_test_case onetime_null
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363398 - head/lib/libc/sys

2020-07-21 Thread Alan Somers
Author: asomers
Date: Tue Jul 21 16:46:40 2020
New Revision: 363398
URL: https://svnweb.freebsd.org/changeset/base/363398

Log:
  [skip ci] document close_range(2) as async-signal-safe
  
  Reviewed by:  bcr (manpages)
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25513

Modified:
  head/lib/libc/sys/sigaction.2

Modified: head/lib/libc/sys/sigaction.2
==
--- head/lib/libc/sys/sigaction.2   Tue Jul 21 16:21:52 2020
(r363397)
+++ head/lib/libc/sys/sigaction.2   Tue Jul 21 16:46:40 2020
(r363398)
@@ -28,7 +28,7 @@
 .\"From: @(#)sigaction.2   8.2 (Berkeley) 4/3/94
 .\" $FreeBSD$
 .\"
-.Dd June 28, 2018
+.Dd June 29, 2020
 .Dt SIGACTION 2
 .Os
 .Sh NAME
@@ -569,6 +569,7 @@ Extension Interfaces:
 .Pp
 .Fn accept4 ,
 .Fn bindat ,
+.Fn close_range ,
 .Fn closefrom ,
 .Fn connectat ,
 .Fn eaccess ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363368 - head/sys/crypto/via

2020-07-20 Thread Alan Somers
Author: asomers
Date: Mon Jul 20 16:12:14 2020
New Revision: 363368
URL: https://svnweb.freebsd.org/changeset/base/363368

Log:
  padlock: fix Via Padlock with 192-bit keys
  
  It's been broken since a typo in r359374
  
  Reviewed by:  jhb
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25710

Modified:
  head/sys/crypto/via/padlock_cipher.c

Modified: head/sys/crypto/via/padlock_cipher.c
==
--- head/sys/crypto/via/padlock_cipher.cMon Jul 20 14:28:26 2020
(r363367)
+++ head/sys/crypto/via/padlock_cipher.cMon Jul 20 16:12:14 2020
(r363368)
@@ -124,7 +124,7 @@ padlock_cipher_setup(struct padlock_session *ses,
 {
union padlock_cw *cw;
 
-   if (csp->csp_cipher_klen != 16 && csp->csp_cipher_klen != 25 &&
+   if (csp->csp_cipher_klen != 16 && csp->csp_cipher_klen != 24 &&
csp->csp_cipher_klen != 32) {
return (EINVAL);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r363361 - head/tests/sys/opencrypto

2020-07-20 Thread Alan Somers
Author: asomers
Date: Mon Jul 20 12:47:15 2020
New Revision: 363361
URL: https://svnweb.freebsd.org/changeset/base/363361

Log:
  tests/sys/opencrypto: use python3
  
  python2 will be EOL soon
  
  Reviewed by:  lwhsu, jmg
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25682

Modified:
  head/tests/sys/opencrypto/Makefile
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py
  head/tests/sys/opencrypto/runtests.sh

Modified: head/tests/sys/opencrypto/Makefile
==
--- head/tests/sys/opencrypto/Makefile  Mon Jul 20 01:55:19 2020
(r363360)
+++ head/tests/sys/opencrypto/Makefile  Mon Jul 20 12:47:15 2020
(r363361)
@@ -14,7 +14,7 @@ ATF_TESTS_C+= blake2_test poly1305_test
 
 TAP_TESTS_SH+= runtests
 
-TEST_METADATA.runtests+= required_programs="python2"
+TEST_METADATA.runtests+= required_programs="python3"
 TEST_METADATA.runtests+= required_user="root"
 
 PYMODULES= cryptodev.py cryptodevh.py cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Mon Jul 20 01:55:19 2020
(r363360)
+++ head/tests/sys/opencrypto/cryptodev.py  Mon Jul 20 12:47:15 2020
(r363361)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2
+#!/usr/local/bin/python3
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # Copyright 2014 John-Mark Gurney
@@ -31,7 +31,7 @@
 # $FreeBSD$
 #
 
-from __future__ import print_function
+
 import array
 import binascii
 from fcntl import ioctl

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Mon Jul 20 01:55:19 2020
(r363360)
+++ head/tests/sys/opencrypto/cryptotest.py Mon Jul 20 12:47:15 2020
(r363361)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2
+#!/usr/local/bin/python3
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # All rights reserved.
@@ -30,7 +30,7 @@
 # $FreeBSD$
 #
 
-from __future__ import print_function
+
 
 import binascii
 import errno

Modified: head/tests/sys/opencrypto/runtests.sh
==
--- head/tests/sys/opencrypto/runtests.sh   Mon Jul 20 01:55:19 2020
(r363360)
+++ head/tests/sys/opencrypto/runtests.sh   Mon Jul 20 12:47:15 2020
(r363361)
@@ -30,7 +30,7 @@
 # $FreeBSD$
 #
 
-: ${PYTHON=python2}
+: ${PYTHON=python3}
 
 if [ ! -d /usr/local/share/nist-kat ]; then
echo "1..0 # SKIP: nist-kat package not installed for test vectors"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r363255 - head/sys/dev/virtio/block

2020-07-16 Thread Alan Somers
On Thu, Jul 16, 2020 at 10:32 AM Allan Jude  wrote:

> Author: allanjude
> Date: Thu Jul 16 16:32:16 2020
> New Revision: 363255
> URL: https://svnweb.freebsd.org/changeset/base/363255
>
> Log:
>   Add VIRTIO_BLK_T_DISCARD support to the virtio-blk driver
>
>   If the hypervisor advertises support for the DISCARD command then the
>   guest can perform TRIM commands, freeing space on the backing store.
>
>   If VIRTIO_BLK_F_DISCARD is enabled, advertise DISKFLAG_CANDELETE
>
>   Tested with FreeBSD guests on bhyve and KVM
>

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


svn commit: r363014 - in head: sys/geom/eli tests/sys/geom/class/eli

2020-07-08 Thread Alan Somers
Author: asomers
Date: Wed Jul  8 17:12:12 2020
New Revision: 363014
URL: https://svnweb.freebsd.org/changeset/base/363014

Log:
  geli: enable direct dispatch
  
  geli does all of its crypto operations in a separate thread pool, so
  g_eli_start, g_eli_read_done, and g_eli_write_done don't actually do very
  much work. Enabling direct dispatch eliminates the g_up/g_down bottlenecks,
  doubling IOPs on my system. This change does not affect the thread pool.
  
  Reviewed by:  markj
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25587

Added:
  head/tests/sys/geom/class/eli/reentrancy_test.sh   (contents, props changed)
Modified:
  head/sys/geom/eli/g_eli.c
  head/tests/sys/geom/class/eli/Makefile

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Wed Jul  8 16:50:47 2020(r363013)
+++ head/sys/geom/eli/g_eli.c   Wed Jul  8 17:12:12 2020(r363014)
@@ -734,6 +734,7 @@ g_eli_read_metadata_offset(struct g_class *mp, struct 
gp->orphan = g_eli_orphan_spoil_assert;
gp->spoiled = g_eli_orphan_spoil_assert;
cp = g_new_consumer(gp);
+   cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
if (error != 0)
goto end;
@@ -882,6 +883,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 
pp = NULL;
cp = g_new_consumer(gp);
+   cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, bpp);
if (error != 0) {
if (req != NULL) {
@@ -969,6 +971,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 * Create decrypted provider.
 */
pp = g_new_providerf(gp, "%s%s", bpp->name, G_ELI_SUFFIX);
+   pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
pp->mediasize = sc->sc_mediasize;
pp->sectorsize = sc->sc_sectorsize;
LIST_FOREACH(gap, >aliases, ga_next)

Modified: head/tests/sys/geom/class/eli/Makefile
==
--- head/tests/sys/geom/class/eli/Makefile  Wed Jul  8 16:50:47 2020
(r363013)
+++ head/tests/sys/geom/class/eli/Makefile  Wed Jul  8 17:12:12 2020
(r363014)
@@ -17,6 +17,7 @@ ATF_TESTS_SH+=kill_test
 ATF_TESTS_SH+= misc_test
 ATF_TESTS_SH+= onetime_test
 ATF_TESTS_SH+= online_resize_test
+ATF_TESTS_SH+= reentrancy_test
 ATF_TESTS_SH+= resize_test
 ATF_TESTS_SH+= setkey_test
 

Added: head/tests/sys/geom/class/eli/reentrancy_test.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/geom/class/eli/reentrancy_test.shWed Jul  8 17:12:12 
2020(r363014)
@@ -0,0 +1,69 @@
+# $FreeBSD$
+
+# Test various operations for geli-on-geli providers, to ensure that geli is
+# reentrant.
+
+. $(atf_get_srcdir)/conf.sh
+
+init_test()
+{
+   cipher=$1
+   aalgo=$2
+   secsize=$3
+   ealgo=${cipher%%:*}
+   keylen=${cipher##*:}
+
+   atf_check dd if=/dev/random of=testdata bs=$secsize count=1 status=none
+   atf_check dd if=/dev/random of=keyfile bs=$secsize count=16 status=none
+
+   # Create the lower geli device
+   atf_check -s exit:0 -e ignore \
+   geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
+   -s $secsize ${md}
+   atf_check geli attach -p -k keyfile ${md}
+   # Create the upper geli device
+   atf_check -s exit:0 -e ignore \
+   geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
+   -s $secsize ${md}.eli
+   atf_check geli attach -p -k keyfile ${md}.eli
+   echo ${md} > layered_md_device
+
+   # Ensure we can read and write.
+   atf_check dd if=testdata of=/dev/${md}.eli.eli bs=$secsize count=1 \
+   status=none
+   atf_check dd if=/dev/${md}.eli.eli of=cmpdata bs=$secsize count=1 \
+   status=none
+   atf_check cmp -s testdata cmpdata
+
+   geli detach ${md}.eli 2>/dev/null
+}
+
+atf_test_case init cleanup
+init_head()
+{
+   atf_set "descr" "Initialize a geli provider on top of another"
+   atf_set "require.user" "root"
+   atf_set "timeout" 600
+}
+init_body()
+{
+   sectors=2
+   geli_test_setup
+
+   for_each_geli_config init_test
+}
+init_cleanup()
+{
+   if [ -f layered_md_device ]; then
+   while read provider; do
+   [ -c /dev/${md}.eli.eli ] && \
+   geli detach $md.eli.eli 2>/dev/null
+   done < layered_md_device
+   fi
+   geli_test_cleanup
+}
+
+atf_init_test_cases()
+{
+   atf_add_test_case init
+}
___
svn-src-all@freebsd.org mailing list

svn commit: r362891 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2020-07-02 Thread Alan Somers
Author: asomers
Date: Thu Jul  2 13:17:31 2020
New Revision: 362891
URL: https://svnweb.freebsd.org/changeset/base/362891

Log:
  Fix page fault in zfsctl_snapdir_getattr
  
  Must acquire the z_teardown_lock before accessing the zfsvfs_t object. I
  can't reproduce this panic on demand, but this looks like the correct
  solution.
  
  PR:   247668
  Reviewed by:  avg
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25543

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cThu Jul 
 2 12:58:07 2020(r362890)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cThu Jul 
 2 13:17:31 2020(r362891)
@@ -1121,12 +1121,13 @@ zfsctl_snapdir_getattr(ap)
vnode_t *vp = ap->a_vp;
vattr_t *vap = ap->a_vap;
zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
-   dsl_dataset_t *ds = dmu_objset_ds(zfsvfs->z_os);
+   dsl_dataset_t *ds;
sfs_node_t *node = vp->v_data;
uint64_t snap_count;
int err;
 
ZFS_ENTER(zfsvfs);
+   ds = dmu_objset_ds(zfsvfs->z_os);
zfsctl_common_getattr(vp, vap);
vap->va_ctime = dmu_objset_snap_cmtime(zfsvfs->z_os);
vap->va_mtime = vap->va_ctime;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r342699 - head/sbin/savecore

2020-06-29 Thread Alan Somers
On Sun, Jun 28, 2020 at 6:55 PM Mark Johnston  wrote:

> On Sun, Jun 28, 2020 at 06:40:59PM -0600, Alan Somers wrote:
> > On Wed, Jan 2, 2019 at 10:09 AM Mark Johnston  wrote:
> >
> > > Author: markj
> > > Date: Wed Jan  2 17:09:35 2019
> > > New Revision: 342699
> > > URL: https://svnweb.freebsd.org/changeset/base/342699
> > >
> > > Log:
> > >   Capsicumize savecore(8).
> > >
> > >   - Use cap_fileargs(3) to open dump devices after entering capability
> > > mode, and use cap_syslog(3) to log messages.
> > >   - Use a relative directory fd to open output files.
> > >   - Use zdopen(3) to compress kernel dumps in capability mode.
> > >
> > >   Reviewed by:  cem, oshogbo
> > >   MFC after:2 months
> > >   Sponsored by: The FreeBSD Foundation
> > >   Differential Revision:https://reviews.freebsd.org/D18458
> > >
> > > Modified:
> > >   head/sbin/savecore/Makefile
> > >   head/sbin/savecore/savecore.c
> > >
> > > Modified: head/sbin/savecore/savecore.c
> > >
> > >
> ==
> > > --- head/sbin/savecore/savecore.c   Wed Jan  2 16:42:07 2019
> > > (r342698)
> > > +++ head/sbin/savecore/savecore.c   Wed Jan  2 17:09:35 2019
> > > (r342699)
> > >
> > > +static char **
> > > +enum_dumpdevs(int *argcp)
> > > +{
> > > +   struct fstab *fsp;
> > > +   char **argv;
> > > +   int argc, n;
> > > +
> > > +   /*
> > > +* We cannot use getfsent(3) in capability mode, so we must
> > > +* scan /etc/fstab and build up a list of candidate devices
> > > +* before proceeding.
> > > +*/
> > > +   argc = 0;
> > > +   n = 8;
> > > +   argv = malloc(n * sizeof(*argv));
> > >
> >
> > It looks like the memory allocated here
> >
> >
> > > +   if (argv == NULL) {
> > > +   logmsg(LOG_ERR, "malloc(): %m");
> > > +   exit(1);
> > > +   }
> > > +   for (;;) {
> > > +   fsp = getfsent();
> > > +   if (fsp == NULL)
> > > +   break;
> > > +   if (strcmp(fsp->fs_vfstype, "swap") != 0 &&
> > > +   strcmp(fsp->fs_vfstype, "dump") != 0)
> > > +   continue;
> > > +   if (argc >= n) {
> > > +   n *= 2;
> > > +   argv = realloc(argv, n * sizeof(*argv));
> > >
> >
> > and here
> >
> >
> > > +   if (argv == NULL) {
> > > +   logmsg(LOG_ERR, "realloc(): %m");
> > > +   exit(1);
> > > +   }
> > > +   }
> > > +   argv[argc] = strdup(fsp->fs_spec);
> > >
> >
> > and here is leaked.  I can't find any corresponding free.  However,
> neither
> > Valgrind nor Coverity complains.  What am I missing?  Does this memory
> > sneakily get freed by a subroutine somewhere, or does Capsicum confuse
> our
> > tools?
>
> I'm not sure why Capsicum would change anything.  It would be worth
> testing devel/valgrind-devel with https://reviews.freebsd.org/D25452
> applied, to see if it's able to detect that bug.
>

Using that new valgrind-devel did not find the leaks.  However, it _did_
print a helpful error message explaining why Capsicum interferes.
Commenting out caph_enter_casper allowed valgrind to find the leaks.  It
also found two more than I didn't know about.  Thanks for the tip.

https://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq

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


svn commit: r362790 - in head: sbin/savecore share/man/man5

2020-06-29 Thread Alan Somers
Author: asomers
Date: Mon Jun 29 22:12:23 2020
New Revision: 362790
URL: https://svnweb.freebsd.org/changeset/base/362790

Log:
  savecore: accept device names without the /dev/ prefix
  
  dumpon has accepted device names without the prefix ever since r291207.
  Since dumpon and savecore are always paired, they ought to accept the same
  arguments. Prior to this change, specifying 'dumpdev="da3"' in
  /etc/rc.conf, for example, would result in dumpon working just fine but
  savecore complaining that "Dump device does not exist".
  
  PR:   247618
  Reviewed by:  cem, bcr
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25500

Modified:
  head/sbin/savecore/savecore.c
  head/share/man/man5/rc.conf.5

Modified: head/sbin/savecore/savecore.c
==
--- head/sbin/savecore/savecore.c   Mon Jun 29 21:35:50 2020
(r362789)
+++ head/sbin/savecore/savecore.c   Mon Jun 29 22:12:23 2020
(r362790)
@@ -973,7 +973,45 @@ closefd:
close(fddev);
 }
 
+/* Prepend "/dev/" to any arguments that don't already have it */
 static char **
+devify(int argc, char **argv)
+{
+   char **devs;
+   int i, l;
+
+   devs = malloc(argc * sizeof(*argv));
+   if (devs == NULL) {
+   logmsg(LOG_ERR, "malloc(): %m");
+   exit(1);
+   }
+   for (i = 0; i < argc; i++) {
+   if (strncmp(argv[i], _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+   devs[i] = strdup(argv[i]);
+   else {
+   char *fullpath;
+
+   fullpath = malloc(PATH_MAX);
+   if (fullpath == NULL) {
+   logmsg(LOG_ERR, "malloc(): %m");
+   exit(1);
+   }
+   l = snprintf(fullpath, PATH_MAX, "%s%s", _PATH_DEV,
+   argv[i]);
+   if (l < 0) {
+   logmsg(LOG_ERR, "snprintf(): %m");
+   exit(1);
+   } else if (l >= PATH_MAX) {
+   logmsg(LOG_ERR, "device name too long");
+   exit(1);
+   }
+   devs[i] = fullpath;
+   }
+   }
+   return (devs);
+}
+
+static char **
 enum_dumpdevs(int *argcp)
 {
struct fstab *fsp;
@@ -1069,6 +1107,7 @@ main(int argc, char **argv)
 {
cap_rights_t rights;
const char *savedir;
+   char **devs;
int i, ch, error, savedirfd;
 
checkfor = compress = clear = force = keep = verbose = 0;
@@ -1132,7 +1171,9 @@ main(int argc, char **argv)
argv++;
}
if (argc == 0)
-   argv = enum_dumpdevs();
+   devs = enum_dumpdevs();
+   else
+   devs = devify(argc, argv);
 
savedirfd = open(savedir, O_RDONLY | O_DIRECTORY);
if (savedirfd < 0) {
@@ -1148,10 +1189,10 @@ main(int argc, char **argv)
}
 
/* Enter capability mode. */
-   init_caps(argc, argv);
+   init_caps(argc, devs);
 
for (i = 0; i < argc; i++)
-   DoFile(savedir, savedirfd, argv[i]);
+   DoFile(savedir, savedirfd, devs[i]);
 
/* Emit minimal output. */
if (nfound == 0) {

Modified: head/share/man/man5/rc.conf.5
==
--- head/share/man/man5/rc.conf.5   Mon Jun 29 21:35:50 2020
(r362789)
+++ head/share/man/man5/rc.conf.5   Mon Jun 29 22:12:23 2020
(r362790)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 23, 2020
+.Dd June 28, 2020
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -3469,7 +3469,9 @@ the first suitable swap device listed in
 .Pa /etc/fstab
 will be used as dump device.
 Otherwise, the value of this variable is passed as the argument to
-.Xr dumpon 8 .
+.Xr dumpon 8
+and
+.Xr savecore 8 .
 To disable crash dumps, set this variable to
 .Dq Li NO .
 .It Va dumpon_flags
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r342699 - head/sbin/savecore

2020-06-28 Thread Alan Somers
On Sun, Jun 28, 2020 at 6:46 PM Warner Losh  wrote:

>
>
> On Sun, Jun 28, 2020, 6:41 PM Alan Somers  wrote:
>
>> On Wed, Jan 2, 2019 at 10:09 AM Mark Johnston  wrote:
>>
>>> Author: markj
>>> Date: Wed Jan  2 17:09:35 2019
>>> New Revision: 342699
>>> URL: https://svnweb.freebsd.org/changeset/base/342699
>>>
>>> Log:
>>>   Capsicumize savecore(8).
>>>
>>>   - Use cap_fileargs(3) to open dump devices after entering capability
>>> mode, and use cap_syslog(3) to log messages.
>>>   - Use a relative directory fd to open output files.
>>>   - Use zdopen(3) to compress kernel dumps in capability mode.
>>>
>>>   Reviewed by:  cem, oshogbo
>>>   MFC after:2 months
>>>   Sponsored by: The FreeBSD Foundation
>>>   Differential Revision:https://reviews.freebsd.org/D18458
>>>
>>> Modified:
>>>   head/sbin/savecore/Makefile
>>>   head/sbin/savecore/savecore.c
>>>
>>> Modified: head/sbin/savecore/savecore.c
>>>
>>> ==
>>> --- head/sbin/savecore/savecore.c   Wed Jan  2 16:42:07 2019
>>> (r342698)
>>> +++ head/sbin/savecore/savecore.c   Wed Jan  2 17:09:35 2019
>>> (r342699)
>>>
>>> +static char **
>>> +enum_dumpdevs(int *argcp)
>>> +{
>>> +   struct fstab *fsp;
>>> +   char **argv;
>>> +   int argc, n;
>>> +
>>> +   /*
>>> +* We cannot use getfsent(3) in capability mode, so we must
>>> +* scan /etc/fstab and build up a list of candidate devices
>>> +* before proceeding.
>>> +*/
>>> +   argc = 0;
>>> +   n = 8;
>>> +   argv = malloc(n * sizeof(*argv));
>>>
>>
>> It looks like the memory allocated here
>>
>>
>>> +   if (argv == NULL) {
>>> +   logmsg(LOG_ERR, "malloc(): %m");
>>> +   exit(1);
>>> +   }
>>> +   for (;;) {
>>> +   fsp = getfsent();
>>> +   if (fsp == NULL)
>>> +   break;
>>> +   if (strcmp(fsp->fs_vfstype, "swap") != 0 &&
>>> +   strcmp(fsp->fs_vfstype, "dump") != 0)
>>> +   continue;
>>> +   if (argc >= n) {
>>> +   n *= 2;
>>> +   argv = realloc(argv, n * sizeof(*argv));
>>>
>>
>> and here
>>
>>
>>> +   if (argv == NULL) {
>>> +   logmsg(LOG_ERR, "realloc(): %m");
>>> +   exit(1);
>>> +   }
>>> +   }
>>> +   argv[argc] = strdup(fsp->fs_spec);
>>>
>>
>> and here is leaked.  I can't find any corresponding free.  However,
>> neither Valgrind nor Coverity complains.  What am I missing?  Does this
>> memory sneakily get freed by a subroutine somewhere, or does Capsicum
>> confuse our tools?
>>
>
> So the other spots adjusted large, but this one sets one of its elements.
> Help me understand how that is a leak? I'm sure I'm just confused.
>

Because strdup itself allocates new memory.  strdup's return value is
always supposed to be freed.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r342699 - head/sbin/savecore

2020-06-28 Thread Alan Somers
On Wed, Jan 2, 2019 at 10:09 AM Mark Johnston  wrote:

> Author: markj
> Date: Wed Jan  2 17:09:35 2019
> New Revision: 342699
> URL: https://svnweb.freebsd.org/changeset/base/342699
>
> Log:
>   Capsicumize savecore(8).
>
>   - Use cap_fileargs(3) to open dump devices after entering capability
> mode, and use cap_syslog(3) to log messages.
>   - Use a relative directory fd to open output files.
>   - Use zdopen(3) to compress kernel dumps in capability mode.
>
>   Reviewed by:  cem, oshogbo
>   MFC after:2 months
>   Sponsored by: The FreeBSD Foundation
>   Differential Revision:https://reviews.freebsd.org/D18458
>
> Modified:
>   head/sbin/savecore/Makefile
>   head/sbin/savecore/savecore.c
>
> Modified: head/sbin/savecore/savecore.c
>
> ==
> --- head/sbin/savecore/savecore.c   Wed Jan  2 16:42:07 2019
> (r342698)
> +++ head/sbin/savecore/savecore.c   Wed Jan  2 17:09:35 2019
> (r342699)
>
> +static char **
> +enum_dumpdevs(int *argcp)
> +{
> +   struct fstab *fsp;
> +   char **argv;
> +   int argc, n;
> +
> +   /*
> +* We cannot use getfsent(3) in capability mode, so we must
> +* scan /etc/fstab and build up a list of candidate devices
> +* before proceeding.
> +*/
> +   argc = 0;
> +   n = 8;
> +   argv = malloc(n * sizeof(*argv));
>

It looks like the memory allocated here


> +   if (argv == NULL) {
> +   logmsg(LOG_ERR, "malloc(): %m");
> +   exit(1);
> +   }
> +   for (;;) {
> +   fsp = getfsent();
> +   if (fsp == NULL)
> +   break;
> +   if (strcmp(fsp->fs_vfstype, "swap") != 0 &&
> +   strcmp(fsp->fs_vfstype, "dump") != 0)
> +   continue;
> +   if (argc >= n) {
> +   n *= 2;
> +   argv = realloc(argv, n * sizeof(*argv));
>

and here


> +   if (argv == NULL) {
> +   logmsg(LOG_ERR, "realloc(): %m");
> +   exit(1);
> +   }
> +   }
> +   argv[argc] = strdup(fsp->fs_spec);
>

and here is leaked.  I can't find any corresponding free.  However, neither
Valgrind nor Coverity complains.  What am I missing?  Does this memory
sneakily get freed by a subroutine somewhere, or does Capsicum confuse our
tools?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362280 - in head/sys/fs: nfs nfsclient nfsserver

2020-06-17 Thread Alan Somers
Author: asomers
Date: Wed Jun 17 16:20:19 2020
New Revision: 362280
URL: https://svnweb.freebsd.org/changeset/base/362280

Log:
  Remove vfs_statfs and vnode_mount macros from NFS
  
  These macro definitions are no longer needed as the NFS OSX port is long
  dead.  The vfs_statfs macro conflicts with the vfsops field of the same
  name.
  
  Submitted by: shivank@
  Reviewed by:  rmacklem
  MFC after:2 weeks
  Sponsored by: Google, Inc. (GSoC 2020)
  Differential Revision:https://reviews.freebsd.org/D25263

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsdport.h
  head/sys/fs/nfs/nfskpiport.h
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsclient/nfs_clbio.c
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clstate.c
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cWed Jun 17 15:57:59 2020
(r362279)
+++ head/sys/fs/nfs/nfs_commonsubs.cWed Jun 17 16:20:19 2020
(r362280)
@@ -1402,9 +1402,9 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
if (compare) {
if (*retcmpp == 0) {
if (thyp != (u_int64_t)
-   vfs_statfs(vnode_mount(vp))->f_fsid.val[0] 
||
+   vp->v_mount->mnt_stat.f_fsid.val[0] ||
thyp2 != (u_int64_t)
-   vfs_statfs(vnode_mount(vp))->f_fsid.val[1])
+   vp->v_mount->mnt_stat.f_fsid.val[1])
*retcmpp = NFSERR_NOTSAME;
}
} else if (nap != NULL) {
@@ -1876,7 +1876,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
 */
savuid = p->p_cred->p_ruid;
p->p_cred->p_ruid = cred->cr_uid;
-   if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,
+   if (!VFS_QUOTACTL(vp->v_mount,QCMD(Q_GETQUOTA,
USRQUOTA), cred->cr_uid, (caddr_t)))
freenum = min(dqb.dqb_bhardlimit, freenum);
p->p_cred->p_ruid = savuid;
@@ -1905,7 +1905,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
 */
savuid = p->p_cred->p_ruid;
p->p_cred->p_ruid = cred->cr_uid;
-   if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,
+   if (!VFS_QUOTACTL(vp->v_mount,QCMD(Q_GETQUOTA,
USRQUOTA), cred->cr_uid, (caddr_t)))
freenum = min(dqb.dqb_bsoftlimit, freenum);
p->p_cred->p_ruid = savuid;
@@ -1931,7 +1931,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
 */
savuid = p->p_cred->p_ruid;
p->p_cred->p_ruid = cred->cr_uid;
-   if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,
+   if (!VFS_QUOTACTL(vp->v_mount,QCMD(Q_GETQUOTA,
USRQUOTA), cred->cr_uid, (caddr_t)))
freenum = dqb.dqb_curblocks;
p->p_cred->p_ruid = savuid;

Modified: head/sys/fs/nfs/nfsdport.h
==
--- head/sys/fs/nfs/nfsdport.h  Wed Jun 17 15:57:59 2020(r362279)
+++ head/sys/fs/nfs/nfsdport.h  Wed Jun 17 16:20:19 2020(r362280)
@@ -101,12 +101,6 @@ struct nfsexstuff {
(n)->cn_flags = (f);\
 } while (0)
 
-/*
- * A little bit of Darwin vfs kpi.
- */
-#definevnode_mount(v)  ((v)->v_mount)
-#definevfs_statfs(m)   (&((m)->mnt_stat))
-
 #defineNFSPATHLEN_Tsize_t
 
 /*

Modified: head/sys/fs/nfs/nfskpiport.h
==
--- head/sys/fs/nfs/nfskpiport.hWed Jun 17 15:57:59 2020
(r362279)
+++ head/sys/fs/nfs/nfskpiport.hWed Jun 17 16:20:19 2020
(r362280)
@@ -36,11 +36,9 @@
  * Darwin8 and hopefully subsequent releases from Apple.)
  */
 typedefstruct mount *  mount_t;
-#definevfs_statfs(m)   (&((m)->mnt_stat))
 #definevfs_flags(m)((m)->mnt_flag)
 
 typedef struct vnode * vnode_t;
-#definevnode_mount(v)  ((v)->v_mount)
 #definevnode_vtype(v)  ((v)->v_type)
 
 #endif /* _NFS_NFSKPIPORT_H */

Modified: head/sys/fs/nfs/nfsport.h

svn commit: r362118 - stable/12/sys/geom/eli

2020-06-12 Thread Alan Somers
Author: asomers
Date: Fri Jun 12 20:39:42 2020
New Revision: 362118
URL: https://svnweb.freebsd.org/changeset/base/362118

Log:
  MFC r361562:
  
  geli: fix a livelock during panic
  
  During any kind of shutdown, kern_reboot calls geli's pre_sync event hook,
  which tries to destroy all unused geli devices. But during a panic, geli
  can't destroy any devices, because the scheduler is stopped, so it can't
  switch threads. A livelock results, and the system never dumps core.
  
  This commit fixes the problem by refusing to destroy any devices during
  panic, used or otherwise.
  
  PR:   246207
  Reviewed by:  jhb
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D24697

Modified:
  stable/12/sys/geom/eli/g_eli.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/eli/g_eli.c
==
--- stable/12/sys/geom/eli/g_eli.c  Fri Jun 12 20:33:00 2020
(r362117)
+++ stable/12/sys/geom/eli/g_eli.c  Fri Jun 12 20:39:42 2020
(r362118)
@@ -1320,11 +1320,13 @@ g_eli_shutdown_pre_sync(void *arg, int howto)
continue;
pp = LIST_FIRST(>provider);
KASSERT(pp != NULL, ("No provider? gp=%p (%s)", gp, gp->name));
-   if (pp->acr + pp->acw + pp->ace == 0)
-   error = g_eli_destroy(sc, TRUE);
-   else {
+   if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0 ||
+   SCHEDULER_STOPPED())
+   {
sc->sc_flags |= G_ELI_FLAG_RW_DETACH;
gp->access = g_eli_access;
+   } else {
+   error = g_eli_destroy(sc, TRUE);
}
}
g_topology_unlock();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362117 - stable/12/share/man/man4

2020-06-12 Thread Alan Somers
Author: asomers
Date: Fri Jun 12 20:33:00 2020
New Revision: 362117
URL: https://svnweb.freebsd.org/changeset/base/362117

Log:
  MFC r361439:
  
  [skip ci] ip.4: fix typos

Modified:
  stable/12/share/man/man4/ip.4
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/ip.4
==
--- stable/12/share/man/man4/ip.4   Fri Jun 12 20:32:26 2020
(r362116)
+++ stable/12/share/man/man4/ip.4   Fri Jun 12 20:33:00 2020
(r362117)
@@ -28,7 +28,7 @@
 .\" @(#)ip.4   8.2 (Berkeley) 11/30/93
 .\" $FreeBSD$
 .\"
-.Dd February 22, 2019
+.Dd May 24, 2020
 .Dt IP 4
 .Os
 .Sh NAME
@@ -144,7 +144,7 @@ the
 .Xr recvmsg 2
 call will return the destination
 .Tn IP
-address and destination port or a
+address and destination port for a
 .Tn UDP
 datagram.
 The
@@ -155,13 +155,13 @@ structure points to a buffer
 that contains a
 .Vt cmsghdr
 structure followed by the
-.Tn in_sockkaddr
-structre.
+.Tn sockaddr_in
+structure.
 The
 .Vt cmsghdr
 fields have the following values:
 .Bd -literal
-cmsg_len = CMSG_LEN(sizeof(struct in_sockaddr))
+cmsg_len = CMSG_LEN(sizeof(struct sockaddr_in))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_ORIGDSTADDR
 .Ed
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362116 - in stable/12: sys/fs/fuse tests/sys/fs/fusefs

2020-06-12 Thread Alan Somers
Author: asomers
Date: Fri Jun 12 20:32:26 2020
New Revision: 362116
URL: https://svnweb.freebsd.org/changeset/base/362116

Log:
  MFC r361401:
  
  Fix issues with FUSE_ACCESS when default_permissions is disabled
  
  This patch fixes two issues relating to FUSE_ACCESS when the
  default_permissions mount option is disabled:
  
  * VOP_ACCESS() calls with VADMIN set should never be sent to a fuse server
in the form of FUSE_ACCESS operations. The FUSE protocol has no equivalent
of VADMIN, so we must evaluate such things kernel-side, regardless of the
default_permissions setting.
  
  * The FUSE protocol only requires FUSE_ACCESS to be sent for two purposes:
for the access(2) syscall and to check directory permissions for
searchability during lookup. FreeBSD sends it much more frequently, due to
differences between our VFS and Linux's, for which FUSE was designed. But
this patch does eliminate several cases not required by the FUSE protocol:
  
* for any FUSE_*XATTR operation
* when creating a new file
* when deleting a file
* when setting timestamps, such as by utimensat(2).
  
  * Additionally, when default_permissions is disabled, this patch removes one
FUSE_GETATTR operation when deleting a file.
  
  PR:   245689
  Reported by:  MooseFS FreeBSD Team 
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D24777

Modified:
  stable/12/sys/fs/fuse/fuse_internal.c
  stable/12/sys/fs/fuse/fuse_vnops.c
  stable/12/tests/sys/fs/fusefs/access.cc
  stable/12/tests/sys/fs/fusefs/rename.cc
  stable/12/tests/sys/fs/fusefs/rmdir.cc
  stable/12/tests/sys/fs/fusefs/unlink.cc
  stable/12/tests/sys/fs/fusefs/utils.cc
  stable/12/tests/sys/fs/fusefs/utils.hh
  stable/12/tests/sys/fs/fusefs/xattr.cc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/fuse/fuse_internal.c
==
--- stable/12/sys/fs/fuse/fuse_internal.c   Fri Jun 12 20:27:37 2020
(r362115)
+++ stable/12/sys/fs/fuse/fuse_internal.c   Fri Jun 12 20:32:26 2020
(r362116)
@@ -158,6 +158,7 @@ fuse_internal_get_cached_vnode(struct mount* mp, ino_t
return 0;
 }
 
+SDT_PROBE_DEFINE0(fusefs, , internal, access_vadmin);
 /* Synchronously send a FUSE_ACCESS operation */
 int
 fuse_internal_access(struct vnode *vp,
@@ -210,10 +211,18 @@ fuse_internal_access(struct vnode *vp,
va.va_gid, mode, cred, NULL);
}
 
+   if (mode & VADMIN) {
+   /*
+* The FUSE protocol doesn't have an equivalent of VADMIN, so
+* it's a bug if we ever reach this point with that bit set.
+*/
+   SDT_PROBE0(fusefs, , internal, access_vadmin);
+   }
+
if (!fsess_isimpl(mp, FUSE_ACCESS))
return 0;
 
-   if ((mode & (VWRITE | VAPPEND | VADMIN)) != 0)
+   if ((mode & (VWRITE | VAPPEND)) != 0)
mask |= W_OK;
if ((mode & VREAD) != 0)
mask |= R_OK;

Modified: stable/12/sys/fs/fuse/fuse_vnops.c
==
--- stable/12/sys/fs/fuse/fuse_vnops.c  Fri Jun 12 20:27:37 2020
(r362115)
+++ stable/12/sys/fs/fuse/fuse_vnops.c  Fri Jun 12 20:32:26 2020
(r362116)
@@ -233,6 +233,7 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, stru
 {
struct mount *mp = vnode_mount(vp);
struct fuse_data *data = fuse_get_mpdata(mp);
+   int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
 
/*
 * Kernel-invoked always succeeds.
@@ -246,13 +247,16 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, stru
 */
switch (ns) {
case EXTATTR_NAMESPACE_SYSTEM:
-   if (data->dataflags & FSESS_DEFAULT_PERMISSIONS) {
+   if (default_permissions) {
return (priv_check_cred(cred, PRIV_VFS_EXTATTR_SYSTEM,
0));
}
-   /* FALLTHROUGH */
+   return (0);
case EXTATTR_NAMESPACE_USER:
-   return (fuse_internal_access(vp, accmode, td, cred));
+   if (default_permissions) {
+   return (fuse_internal_access(vp, accmode, td, cred));
+   }
+   return (0);
default:
return (EPERM);
}
@@ -984,6 +988,8 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
int wantparent = flags & (LOCKPARENT | WANTPARENT);
int islastcn = flags & ISLASTCN;
struct mount *mp = vnode_mount(dvp);
+   struct fuse_data *data = fuse_get_mpdata(mp);
+   int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
 
int err = 0;
int lookup_err = 0;
@@ -1107,7 +1113,11 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
if (lookup_err) {
/* Entry not 

svn commit: r362115 - stable/12/sys/fs/fuse

2020-06-12 Thread Alan Somers
Author: asomers
Date: Fri Jun 12 20:27:37 2020
New Revision: 362115
URL: https://svnweb.freebsd.org/changeset/base/362115

Log:
  MFC r361399:
  
  Disable nullfs cacheing on top of fusefs
  
  Nullfs cacheing can keep a large number of vnodes active.  That results in
  more active FUSE file handles, causing some FUSE servers to use extra
  resources.  Disable nullfs cacheing for fusefs, just like we already do for
  NFSv4.
  
  PR:   245688
  Reported by:  MooseFS FreeBSD Team 

Modified:
  stable/12/sys/fs/fuse/fuse_vfsops.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/fuse/fuse_vfsops.c
==
--- stable/12/sys/fs/fuse/fuse_vfsops.c Fri Jun 12 20:11:25 2020
(r362114)
+++ stable/12/sys/fs/fuse/fuse_vfsops.c Fri Jun 12 20:27:37 2020
(r362115)
@@ -425,6 +425,11 @@ fuse_vfsop_mount(struct mount *mp)
 */
mp->mnt_flag &= ~MNT_LOCAL;
mp->mnt_kern_flag |= MNTK_USES_BCACHE;
+   /* 
+* Disable nullfs cacheing because it can consume too many resources in
+* the FUSE server.
+*/
+   mp->mnt_kern_flag |= MNTK_NULL_NOCACHE;
MNT_IUNLOCK(mp);
/* We need this here as this slot is used by getnewvnode() */
mp->mnt_stat.f_iosize = maxbcachebuf;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r362114 - stable/12/tests/sys/fs/fusefs

2020-06-12 Thread Alan Somers
Author: asomers
Date: Fri Jun 12 20:11:25 2020
New Revision: 362114
URL: https://svnweb.freebsd.org/changeset/base/362114

Log:
  MFC r361223:
  
  fusefs: fix intermittency in some ENOENT tests
  
  When a FUSE operation other than LOOKUP returns ENOENT, the kernel will
  reclaim that vnode, resuling in a FUSE_FORGET being sent a short while
  later.  Many of the ENOENT tests weren't expecting those FUSE_FORGET
  operations.  They usually passed by luck since FUSE_FORGET is often delayed.
  This commit adds appropriate expectations.

Modified:
  stable/12/tests/sys/fs/fusefs/getattr.cc
  stable/12/tests/sys/fs/fusefs/open.cc
  stable/12/tests/sys/fs/fusefs/opendir.cc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/fs/fusefs/getattr.cc
==
--- stable/12/tests/sys/fs/fusefs/getattr.ccFri Jun 12 19:56:19 2020
(r362113)
+++ stable/12/tests/sys/fs/fusefs/getattr.ccFri Jun 12 20:11:25 2020
(r362114)
@@ -32,6 +32,8 @@
 
 extern "C" {
 #include 
+
+#include 
 }
 
 #include "mockfs.hh"
@@ -172,7 +174,10 @@ TEST_F(Getattr, enoent)
const char RELPATH[] = "some_file.txt";
struct stat sb;
const uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([](auto in) {
@@ -181,8 +186,15 @@ TEST_F(Getattr, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_GETATTR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
EXPECT_NE(0, stat(FULLPATH, ));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 TEST_F(Getattr, ok)

Modified: stable/12/tests/sys/fs/fusefs/open.cc
==
--- stable/12/tests/sys/fs/fusefs/open.cc   Fri Jun 12 19:56:19 2020
(r362113)
+++ stable/12/tests/sys/fs/fusefs/open.cc   Fri Jun 12 20:11:25 2020
(r362114)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -105,7 +107,10 @@ TEST_F(Open, enoent)
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
@@ -114,8 +119,15 @@ TEST_F(Open, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_OPEN returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 

Modified: stable/12/tests/sys/fs/fusefs/opendir.cc
==
--- stable/12/tests/sys/fs/fusefs/opendir.ccFri Jun 12 19:56:19 2020
(r362113)
+++ stable/12/tests/sys/fs/fusefs/opendir.ccFri Jun 12 20:11:25 2020
(r362114)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -82,12 +84,21 @@ TEST_F(Opendir, enoent)
const char FULLPATH[] = "mountpoint/some_dir";
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT));
+   // Since FUSE_OPENDIR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
 
ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361562 - head/sys/geom/eli

2020-05-27 Thread Alan Somers
Author: asomers
Date: Wed May 27 19:13:26 2020
New Revision: 361562
URL: https://svnweb.freebsd.org/changeset/base/361562

Log:
  geli: fix a livelock during panic
  
  During any kind of shutdown, kern_reboot calls geli's pre_sync event hook,
  which tries to destroy all unused geli devices. But during a panic, geli
  can't destroy any devices, because the scheduler is stopped, so it can't
  switch threads. A livelock results, and the system never dumps core.
  
  This commit fixes the problem by refusing to destroy any devices during
  panic, used or otherwise.
  
  PR:   246207
  Reviewed by:  jhb
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D24697

Modified:
  head/sys/geom/eli/g_eli.c

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Wed May 27 18:55:24 2020(r361561)
+++ head/sys/geom/eli/g_eli.c   Wed May 27 19:13:26 2020(r361562)
@@ -1416,11 +1416,13 @@ g_eli_shutdown_pre_sync(void *arg, int howto)
continue;
pp = LIST_FIRST(>provider);
KASSERT(pp != NULL, ("No provider? gp=%p (%s)", gp, gp->name));
-   if (pp->acr + pp->acw + pp->ace == 0)
-   error = g_eli_destroy(sc, TRUE);
-   else {
+   if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0 ||
+   SCHEDULER_STOPPED())
+   {
sc->sc_flags |= G_ELI_FLAG_RW_DETACH;
gp->access = g_eli_access;
+   } else {
+   error = g_eli_destroy(sc, TRUE);
}
}
g_topology_unlock();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361439 - head/share/man/man4

2020-05-24 Thread Alan Somers
Author: asomers
Date: Mon May 25 04:17:01 2020
New Revision: 361439
URL: https://svnweb.freebsd.org/changeset/base/361439

Log:
  [skip ci] ip.4: fix typos
  
  MFC after:2 weeks

Modified:
  head/share/man/man4/ip.4

Modified: head/share/man/man4/ip.4
==
--- head/share/man/man4/ip.4Sun May 24 21:42:47 2020(r361438)
+++ head/share/man/man4/ip.4Mon May 25 04:17:01 2020(r361439)
@@ -28,7 +28,7 @@
 .\" @(#)ip.4   8.2 (Berkeley) 11/30/93
 .\" $FreeBSD$
 .\"
-.Dd February 22, 2019
+.Dd May 24, 2020
 .Dt IP 4
 .Os
 .Sh NAME
@@ -144,7 +144,7 @@ the
 .Xr recvmsg 2
 call will return the destination
 .Tn IP
-address and destination port or a
+address and destination port for a
 .Tn UDP
 datagram.
 The
@@ -155,13 +155,13 @@ structure points to a buffer
 that contains a
 .Vt cmsghdr
 structure followed by the
-.Tn in_sockkaddr
-structre.
+.Tn sockaddr_in
+structure.
 The
 .Vt cmsghdr
 fields have the following values:
 .Bd -literal
-cmsg_len = CMSG_LEN(sizeof(struct in_sockaddr))
+cmsg_len = CMSG_LEN(sizeof(struct sockaddr_in))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_ORIGDSTADDR
 .Ed
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361407 - stable/12/tests/sys/geom/class/multipath

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 22:17:44 2020
New Revision: 361407
URL: https://svnweb.freebsd.org/changeset/base/361407

Log:
  Reenable sys.geom.class.multipath.misc.fail_on_error on stable/12
  
  The failing test was fixed by r361403.  Direct commit to stable/12 because
  the test was never disabled on head.
  
  PR:   244158
  Reported by:  lwhsu

Modified:
  stable/12/tests/sys/geom/class/multipath/misc.sh

Modified: stable/12/tests/sys/geom/class/multipath/misc.sh
==
--- stable/12/tests/sys/geom/class/multipath/misc.shFri May 22 22:13:55 
2020(r361406)
+++ stable/12/tests/sys/geom/class/multipath/misc.shFri May 22 22:17:44 
2020(r361407)
@@ -176,10 +176,6 @@ fail_on_error_head()
 }
 fail_on_error_body()
 {
-   if [ "$(atf_config_get ci false)" = "true" ]; then
-   atf_skip "https://bugs.freebsd.org/244158;
-   fi
-
load_gnop
load_gmultipath
md0=$(alloc_md)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361406 - stable/12/tests/sys/fs/fusefs

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 22:13:55 2020
New Revision: 361406
URL: https://svnweb.freebsd.org/changeset/base/361406

Log:
  MFC r360829:
  
  fusefs: fix two small bugs in the tests' expectations
  
  These two errors have been present since the tests' introduction.
  Coincidentally every test (I think there's only one) that cares about that
  field also works when the field's value is 0.

Modified:
  stable/12/tests/sys/fs/fusefs/default_permissions.cc
  stable/12/tests/sys/fs/fusefs/default_permissions_privileged.cc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/fs/fusefs/default_permissions.cc
==
--- stable/12/tests/sys/fs/fusefs/default_permissions.ccFri May 22 
22:12:07 2020(r361405)
+++ stable/12/tests/sys/fs/fusefs/default_permissions.ccFri May 22 
22:13:55 2020(r361406)
@@ -125,7 +125,7 @@ void expect_getattr(uint64_t ino, mode_t mode, uint64_
out.body.attr.attr.mode = mode;
out.body.attr.attr.size = 0;
out.body.attr.attr.uid = uid;
-   out.body.attr.attr.uid = gid;
+   out.body.attr.attr.gid = gid;
out.body.attr.attr_valid = attr_valid;
})));
 }

Modified: stable/12/tests/sys/fs/fusefs/default_permissions_privileged.cc
==
--- stable/12/tests/sys/fs/fusefs/default_permissions_privileged.cc Fri May 
22 22:12:07 2020(r361405)
+++ stable/12/tests/sys/fs/fusefs/default_permissions_privileged.cc Fri May 
22 22:13:55 2020(r361406)
@@ -85,7 +85,7 @@ void expect_getattr(uint64_t ino, mode_t mode, uint64_
out.body.attr.attr.mode = mode;
out.body.attr.attr.size = 0;
out.body.attr.attr.uid = uid;
-   out.body.attr.attr.uid = gid;
+   out.body.attr.attr.gid = gid;
out.body.attr.attr_valid = attr_valid;
})));
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361405 - stable/12/sys/fs/fuse

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 22:12:07 2020
New Revision: 361405
URL: https://svnweb.freebsd.org/changeset/base/361405

Log:
  MFC r360828:
  
  fusefs: better dtrace probes for asynchronous invalidation operations

Modified:
  stable/12/sys/fs/fuse/fuse_internal.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/fuse/fuse_internal.c
==
--- stable/12/sys/fs/fuse/fuse_internal.c   Fri May 22 20:52:36 2020
(r361404)
+++ stable/12/sys/fs/fuse/fuse_internal.c   Fri May 22 22:12:07 2020
(r361405)
@@ -377,8 +377,8 @@ fuse_internal_fsync(struct vnode *vp,
 }
 
 /* Asynchronous invalidation */
-SDT_PROBE_DEFINE2(fusefs, , internal, invalidate_cache_hit,
-   "struct vnode*", "struct vnode*");
+SDT_PROBE_DEFINE3(fusefs, , internal, invalidate_entry,
+   "struct vnode*", "struct fuse_notify_inval_entry_out*", "char*");
 int
 fuse_internal_invalidate_entry(struct mount *mp, struct uio *uio)
 {
@@ -407,6 +407,7 @@ fuse_internal_invalidate_entry(struct mount *mp, struc
else
err = fuse_internal_get_cached_vnode( mp, fnieo.parent,
LK_SHARED, );
+   SDT_PROBE3(fusefs, , internal, invalidate_entry, dvp, , name);
/* 
 * If dvp is not in the cache, then it must've been reclaimed.  And
 * since fuse_vnop_reclaim does a cache_purge, name's entry must've
@@ -435,6 +436,8 @@ fuse_internal_invalidate_entry(struct mount *mp, struc
return (0);
 }
 
+SDT_PROBE_DEFINE2(fusefs, , internal, invalidate_inode,
+   "struct vnode*", "struct fuse_notify_inval_inode_out *");
 int
 fuse_internal_invalidate_inode(struct mount *mp, struct uio *uio)
 {
@@ -450,6 +453,7 @@ fuse_internal_invalidate_inode(struct mount *mp, struc
else
err = fuse_internal_get_cached_vnode(mp, fniio.ino, LK_SHARED,
);
+   SDT_PROBE2(fusefs, , internal, invalidate_inode, vp, );
if (err != 0 || vp == NULL)
return (err);
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361403 - stable/12/tests/sys/geom/class/multipath

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 19:09:43 2020
New Revision: 361403
URL: https://svnweb.freebsd.org/changeset/base/361403

Log:
  MFC r360807:
  
  Fix the sys.geom.class.multipath.misc.fail_on_error test on stable/12
  
  This test uses a gnop feature (delay probability) that isn't available on
  stable/12.  But it's unnecessary; the test works fine without it.  Removing
  it simplifies the test and, once MFCed, will allow it to pass on stable/12.
  
  PR:   244158
  Reported by:  lwhsu

Modified:
  stable/12/tests/sys/geom/class/multipath/misc.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/geom/class/multipath/misc.sh
==
--- stable/12/tests/sys/geom/class/multipath/misc.shFri May 22 18:54:56 
2020(r361402)
+++ stable/12/tests/sys/geom/class/multipath/misc.shFri May 22 19:09:43 
2020(r361403)
@@ -190,7 +190,7 @@ fail_on_error_body()
atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop
# The first I/O to the first path should fail, causing gmultipath to
# fail over to the second path.
-   atf_check gnop configure -q 100 -r 100 -w 100 -x 100 ${md0}.nop
+   atf_check gnop configure -r 100 -w 100 ${md0}.nop
atf_check -s exit:0 -o ignore -e ignore dd if=/dev/zero 
of=/dev/multipath/"$name" bs=4096 count=1
check_multipath_state ${md1}.nop "DEGRADED" "FAIL" "ACTIVE" 
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361401 - in head: sys/fs/fuse tests/sys/fs/fusefs

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 18:11:17 2020
New Revision: 361401
URL: https://svnweb.freebsd.org/changeset/base/361401

Log:
  Fix issues with FUSE_ACCESS when default_permissions is disabled
  
  This patch fixes two issues relating to FUSE_ACCESS when the
  default_permissions mount option is disabled:
  
  * VOP_ACCESS() calls with VADMIN set should never be sent to a fuse server
in the form of FUSE_ACCESS operations. The FUSE protocol has no equivalent
of VADMIN, so we must evaluate such things kernel-side, regardless of the
default_permissions setting.
  
  * The FUSE protocol only requires FUSE_ACCESS to be sent for two purposes:
for the access(2) syscall and to check directory permissions for
searchability during lookup. FreeBSD sends it much more frequently, due to
differences between our VFS and Linux's, for which FUSE was designed. But
this patch does eliminate several cases not required by the FUSE protocol:
  
* for any FUSE_*XATTR operation
* when creating a new file
* when deleting a file
* when setting timestamps, such as by utimensat(2).
  
  * Additionally, when default_permissions is disabled, this patch removes one
FUSE_GETATTR operation when deleting a file.
  
  PR:   245689
  Reported by:  MooseFS FreeBSD Team 
  Reviewed by:  cem
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24777

Modified:
  head/sys/fs/fuse/fuse_internal.c
  head/sys/fs/fuse/fuse_vnops.c
  head/tests/sys/fs/fusefs/access.cc
  head/tests/sys/fs/fusefs/rename.cc
  head/tests/sys/fs/fusefs/rmdir.cc
  head/tests/sys/fs/fusefs/unlink.cc
  head/tests/sys/fs/fusefs/utils.cc
  head/tests/sys/fs/fusefs/utils.hh
  head/tests/sys/fs/fusefs/xattr.cc

Modified: head/sys/fs/fuse/fuse_internal.c
==
--- head/sys/fs/fuse/fuse_internal.cFri May 22 18:10:46 2020
(r361400)
+++ head/sys/fs/fuse/fuse_internal.cFri May 22 18:11:17 2020
(r361401)
@@ -158,6 +158,7 @@ fuse_internal_get_cached_vnode(struct mount* mp, ino_t
return 0;
 }
 
+SDT_PROBE_DEFINE0(fusefs, , internal, access_vadmin);
 /* Synchronously send a FUSE_ACCESS operation */
 int
 fuse_internal_access(struct vnode *vp,
@@ -210,10 +211,18 @@ fuse_internal_access(struct vnode *vp,
va.va_gid, mode, cred, NULL);
}
 
+   if (mode & VADMIN) {
+   /*
+* The FUSE protocol doesn't have an equivalent of VADMIN, so
+* it's a bug if we ever reach this point with that bit set.
+*/
+   SDT_PROBE0(fusefs, , internal, access_vadmin);
+   }
+
if (!fsess_isimpl(mp, FUSE_ACCESS))
return 0;
 
-   if ((mode & (VWRITE | VAPPEND | VADMIN)) != 0)
+   if ((mode & (VWRITE | VAPPEND)) != 0)
mask |= W_OK;
if ((mode & VREAD) != 0)
mask |= R_OK;

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Fri May 22 18:10:46 2020
(r361400)
+++ head/sys/fs/fuse/fuse_vnops.c   Fri May 22 18:11:17 2020
(r361401)
@@ -235,6 +235,7 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, stru
 {
struct mount *mp = vnode_mount(vp);
struct fuse_data *data = fuse_get_mpdata(mp);
+   int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
 
/*
 * Kernel-invoked always succeeds.
@@ -248,12 +249,15 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, stru
 */
switch (ns) {
case EXTATTR_NAMESPACE_SYSTEM:
-   if (data->dataflags & FSESS_DEFAULT_PERMISSIONS) {
+   if (default_permissions) {
return (priv_check_cred(cred, PRIV_VFS_EXTATTR_SYSTEM));
}
-   /* FALLTHROUGH */
+   return (0);
case EXTATTR_NAMESPACE_USER:
-   return (fuse_internal_access(vp, accmode, td, cred));
+   if (default_permissions) {
+   return (fuse_internal_access(vp, accmode, td, cred));
+   }
+   return (0);
default:
return (EPERM);
}
@@ -985,6 +989,8 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
int wantparent = flags & (LOCKPARENT | WANTPARENT);
int islastcn = flags & ISLASTCN;
struct mount *mp = vnode_mount(dvp);
+   struct fuse_data *data = fuse_get_mpdata(mp);
+   int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
 
int err = 0;
int lookup_err = 0;
@@ -1108,7 +1114,11 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
if (lookup_err) {
/* Entry not found */
if ((nameiop == CREATE || nameiop == RENAME) && islastcn) {
-   err = fuse_internal_access(dvp, VWRITE, 

svn commit: r361399 - head/sys/fs/fuse

2020-05-22 Thread Alan Somers
Author: asomers
Date: Fri May 22 18:03:14 2020
New Revision: 361399
URL: https://svnweb.freebsd.org/changeset/base/361399

Log:
  Disable nullfs cacheing on top of fusefs
  
  Nullfs cacheing can keep a large number of vnodes active.  That results in
  more active FUSE file handles, causing some FUSE servers to use extra
  resources.  Disable nullfs cacheing for fusefs, just like we already do for
  NFSv4.
  
  PR:   245688
  Reported by:  MooseFS FreeBSD Team 
  MFC after:2 weeks

Modified:
  head/sys/fs/fuse/fuse_vfsops.c

Modified: head/sys/fs/fuse/fuse_vfsops.c
==
--- head/sys/fs/fuse/fuse_vfsops.c  Fri May 22 17:52:09 2020
(r361398)
+++ head/sys/fs/fuse/fuse_vfsops.c  Fri May 22 18:03:14 2020
(r361399)
@@ -425,6 +425,11 @@ fuse_vfsop_mount(struct mount *mp)
 */
mp->mnt_flag &= ~MNT_LOCAL;
mp->mnt_kern_flag |= MNTK_USES_BCACHE;
+   /* 
+* Disable nullfs cacheing because it can consume too many resources in
+* the FUSE server.
+*/
+   mp->mnt_kern_flag |= MNTK_NULL_NOCACHE;
MNT_IUNLOCK(mp);
/* We need this here as this slot is used by getnewvnode() */
mp->mnt_stat.f_iosize = maxbcachebuf;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361223 - head/tests/sys/fs/fusefs

2020-05-18 Thread Alan Somers
Author: asomers
Date: Mon May 18 18:36:32 2020
New Revision: 361223
URL: https://svnweb.freebsd.org/changeset/base/361223

Log:
  fusefs: fix intermittency in some ENOENT tests
  
  When a FUSE operation other than LOOKUP returns ENOENT, the kernel will
  reclaim that vnode, resuling in a FUSE_FORGET being sent a short while
  later.  Many of the ENOENT tests weren't expecting those FUSE_FORGET
  operations.  They usually passed by luck since FUSE_FORGET is often delayed.
  This commit adds appropriate expectations.
  
  MFC after:2 weeks

Modified:
  head/tests/sys/fs/fusefs/getattr.cc
  head/tests/sys/fs/fusefs/open.cc
  head/tests/sys/fs/fusefs/opendir.cc

Modified: head/tests/sys/fs/fusefs/getattr.cc
==
--- head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/getattr.cc Mon May 18 18:36:32 2020
(r361223)
@@ -32,6 +32,8 @@
 
 extern "C" {
 #include 
+
+#include 
 }
 
 #include "mockfs.hh"
@@ -172,7 +174,10 @@ TEST_F(Getattr, enoent)
const char RELPATH[] = "some_file.txt";
struct stat sb;
const uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([](auto in) {
@@ -181,8 +186,15 @@ TEST_F(Getattr, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_GETATTR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
EXPECT_NE(0, stat(FULLPATH, ));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 TEST_F(Getattr, ok)

Modified: head/tests/sys/fs/fusefs/open.cc
==
--- head/tests/sys/fs/fusefs/open.ccMon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/open.ccMon May 18 18:36:32 2020
(r361223)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -105,7 +107,10 @@ TEST_F(Open, enoent)
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
@@ -114,8 +119,15 @@ TEST_F(Open, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+   // Since FUSE_OPEN returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
+
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 

Modified: head/tests/sys/fs/fusefs/opendir.cc
==
--- head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:32:58 2020
(r361222)
+++ head/tests/sys/fs/fusefs/opendir.cc Mon May 18 18:36:32 2020
(r361223)
@@ -32,7 +32,9 @@
 
 extern "C" {
 #include 
+
 #include 
+#include 
 }
 
 #include "mockfs.hh"
@@ -82,12 +84,21 @@ TEST_F(Opendir, enoent)
const char FULLPATH[] = "mountpoint/some_dir";
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
+   sem_t sem;
 
+   ASSERT_EQ(0, sem_init(, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT));
+   // Since FUSE_OPENDIR returns ENOENT, the kernel will reclaim the vnode
+   // and send a FUSE_FORGET
+   expect_forget(ino, 1, );
 
ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY));
EXPECT_EQ(ENOENT, errno);
+
+   sem_wait();
+   sem_destroy();
 }
 
 /* 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361129 - head/tests/sys/geom/class/gate

2020-05-16 Thread Alan Somers
Author: asomers
Date: Sun May 17 02:41:50 2020
New Revision: 361129
URL: https://svnweb.freebsd.org/changeset/base/361129

Log:
  Reenable sys.geom.class.gate.ggate_test.ggated in CI
  
  Should be fixed by r360613
  
  PR:   244737
  Reported by:  lwhsu

Modified:
  head/tests/sys/geom/class/gate/ggate_test.sh

Modified: head/tests/sys/geom/class/gate/ggate_test.sh
==
--- head/tests/sys/geom/class/gate/ggate_test.shSun May 17 02:40:49 
2020(r361128)
+++ head/tests/sys/geom/class/gate/ggate_test.shSun May 17 02:41:50 
2020(r361129)
@@ -16,10 +16,6 @@ ggated_head()
 
 ggated_body()
 {
-   if [ "$(atf_config_get ci false)" = "true" ]; then
-   atf_skip "https://bugs.freebsd.org/244737;
-   fi
-
load_ggate
 
us=$(alloc_ggate_dev)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r361128 - stable/11/tests/sys/geom/class/gate

2020-05-16 Thread Alan Somers
Author: asomers
Date: Sun May 17 02:40:49 2020
New Revision: 361128
URL: https://svnweb.freebsd.org/changeset/base/361128

Log:
  MFC r360613:
  
  Fix intermittent cleanup failures in the ggated test

Modified:
  stable/11/tests/sys/geom/class/gate/ggate_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/geom/class/gate/ggate_test.sh
==
--- stable/11/tests/sys/geom/class/gate/ggate_test.sh   Sun May 17 02:36:42 
2020(r361127)
+++ stable/11/tests/sys/geom/class/gate/ggate_test.sh   Sun May 17 02:40:49 
2020(r361128)
@@ -194,7 +194,11 @@ common_cleanup()
 
if [ -f "md.devs" ]; then
while read test_md; do
-   mdconfig -d -u $test_md 2>/dev/null
+   # ggatec destroy doesn't release the provider
+   # synchronously, so we may need to retry destroying it.
+   while ! mdconfig -d -u $test_md; do
+   sleep 0.1
+   done
done < md.devs
rm md.devs
fi
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >