Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/kern Pull up following revision(s) (requested by manu...



details:   https://anonhg.NetBSD.org/src/rev/77b7de99132f
branches:  netbsd-9
changeset: 985790:77b7de99132f
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Sep 07 17:12:21 2021 +0000

description:
Pull up following revision(s) (requested by manu in ticket #1343):

        share/man/man7/sysctl.7: revision 1.153
        sys/kern/vfs_lockf.c: revision 1.74
        lib/libc/sys/fcntl.2: revision 1.46
        lib/libc/sys/flock.2: revision 1.23

Tie the maximum file lock per unprivilegied uid to kern.maxfiles

This makes the limit simple to raise at run time. While there, document
that fcntl(2) and flock(2) may return ENOMEM when this limit is reached.

diffstat:

 lib/libc/sys/fcntl.2    |  6 +++++-
 lib/libc/sys/flock.2    |  6 +++++-
 share/man/man7/sysctl.7 |  7 ++++++-
 sys/kern/vfs_lockf.c    |  8 ++++----
 4 files changed, 20 insertions(+), 7 deletions(-)

diffs (97 lines):

diff -r bee04a82e465 -r 77b7de99132f lib/libc/sys/fcntl.2
--- a/lib/libc/sys/fcntl.2      Sun Sep 05 10:49:51 2021 +0000
+++ b/lib/libc/sys/fcntl.2      Tue Sep 07 17:12:21 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: fcntl.2,v 1.41 2013/12/28 20:03:22 dholland Exp $
+.\"    $NetBSD: fcntl.2,v 1.41.28.1 2021/09/07 17:12:21 martin Exp $
 .\"
 .\" Copyright (c) 1983, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -501,6 +501,10 @@
 .Dv F_SETLKW ,
 and satisfying the lock or unlock request would result in the
 number of locked regions in the system exceeding a system-imposed limit.
+.It Bq Er ENOMEM
+The file lock limit for the current unprivilegied user 
+has been reached. It can be modified using sysctl
+.Li kern.maxfiles .
 .It Bq Er ESRCH
 .Fa cmd
 is
diff -r bee04a82e465 -r 77b7de99132f lib/libc/sys/flock.2
--- a/lib/libc/sys/flock.2      Sun Sep 05 10:49:51 2021 +0000
+++ b/lib/libc/sys/flock.2      Tue Sep 07 17:12:21 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: flock.2,v 1.22 2011/10/15 21:35:50 rmind Exp $
+.\"    $NetBSD: flock.2,v 1.22.44.1 2021/09/07 17:12:21 martin Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -137,6 +137,10 @@
 .Dv LOCK_SH ,
 or
 .Dv LOCK_UN .
+.It Bq Eq ENOMEM
+The file lock limit for the current unprivilegied user 
+has been reached. It can be modifed using sysctl
+.Li kern.maxfiles .
 .It Bq Er EOPNOTSUPP
 The argument
 .Fa fd
diff -r bee04a82e465 -r 77b7de99132f share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7   Sun Sep 05 10:49:51 2021 +0000
+++ b/share/man/man7/sysctl.7   Tue Sep 07 17:12:21 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sysctl.7,v 1.139.2.1 2019/11/18 19:45:00 martin Exp $
+.\"    $NetBSD: sysctl.7,v 1.139.2.2 2021/09/07 17:12:21 martin Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -736,6 +736,11 @@
 otherwise\ 0.
 .It Li kern.maxfiles ( Dv KERN_MAXFILES )
 The maximum number of open files that may be open in the system.
+This also controls the maximum file locks per unprivilegied user 
+enforced by
+.Xr fnctl 2
+and 
+.Xr flock 2 .
 .It Li kern.maxpartitions ( Dv KERN_MAXPARTITIONS )
 The maximum number of partitions allowed per disk.
 .It Li kern.maxlwp
diff -r bee04a82e465 -r 77b7de99132f sys/kern/vfs_lockf.c
--- a/sys/kern/vfs_lockf.c      Sun Sep 05 10:49:51 2021 +0000
+++ b/sys/kern/vfs_lockf.c      Tue Sep 07 17:12:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $  */
+/*     $NetBSD: vfs_lockf.c,v 1.73.60.1 2021/09/07 17:12:21 martin Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.73.60.1 2021/09/07 17:12:21 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -123,7 +123,7 @@
  * so that the unlock can succeed.  If the unlocking causes too many splits,
  * however, you're totally cutoff.
  */
-int maxlocksperuid = 1024;
+#define MAXLOCKSPERUID (2 * maxfiles)
 
 #ifdef LOCKF_DEBUG
 /*
@@ -200,7 +200,7 @@
        uip = uid_find(uid);
        lcnt = atomic_inc_ulong_nv(&uip->ui_lockcnt);
        if (uid && allowfail && lcnt >
-           (allowfail == 1 ? maxlocksperuid : (maxlocksperuid * 2))) {
+           (allowfail == 1 ? MAXLOCKSPERUID : (MAXLOCKSPERUID * 2))) {
                atomic_dec_ulong(&uip->ui_lockcnt);
                return NULL;
        }



Home | Main Index | Thread Index | Old Index