tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern.maxlockf for byte range lock limit
Hello
I recently hit a bug where mariadb import failed befause of
maxlocksperuid limit:a
http://mail-index.netbsd.org/netbsd-users/2021/07/09/msg027330.html
Attached is a patch that documents ENOMEM for fcntl() and flock()
and that adds a sysctl kern.maxlockf to make the limit configurable.
Opinions?
--
Emmanuel Dreyfus
manu%netbsd.org@localhost
Index: sys/sys/sysctl.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.233
diff -U4 -r1.233 sysctl.h
--- sys/sys/sysctl.h 13 Apr 2021 01:10:24 -0000 1.233
+++ sys/sys/sysctl.h 9 Jul 2021 14:29:32 -0000
@@ -274,8 +274,9 @@
#define KERN_SYSVIPC 82 /* node: SysV IPC parameters */
#define KERN_BOOTTIME 83 /* struct: time kernel was booted */
#define KERN_EVCNT 84 /* struct: evcnts */
#define KERN_SOFIXEDBUF 85 /* bool: fixed socket buffer sizes */
+#define KERN_MAXLOCKF 86 /* int: max file locks per user */
/*
* KERN_CLOCKRATE structure
*/
Index: sys/kern/init_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_sysctl.c,v
retrieving revision 1.227
diff -U4 -r1.227 init_sysctl.c
--- sys/kern/init_sysctl.c 20 Sep 2020 12:51:57 -0000 1.227
+++ sys/kern/init_sysctl.c 9 Jul 2021 14:29:32 -0000
@@ -146,8 +146,10 @@
{
extern int kern_logsigexit; /* defined in kern/kern_sig.c */
extern fixpt_t ccpu; /* defined in kern/kern_synch.c */
extern int dumponpanic; /* defined in kern/subr_prf.c */
+ extern int maxlocksperuid; /* defined in kern/vfs_lockf.c */
+
const struct sysctlnode *rnode;
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
@@ -587,8 +589,14 @@
CTLTYPE_INT, "messages",
SYSCTL_DESCR("Kernel message verbosity"),
sysctl_kern_messages, 0, NULL, 0,
CTL_KERN, CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "maxlockf",
+ SYSCTL_DESCR("File byte range lock limit per uid"),
+ NULL, 0, &maxlocksperuid, 0,
+ CTL_KERN, KERN_MAXLOCKF, CTL_EOL);
}
SYSCTL_SETUP(sysctl_hw_misc_setup, "sysctl hw subtree misc setup")
{
Index: lib/libc/sys/fcntl.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/fcntl.2,v
retrieving revision 1.45
diff -U4 -r1.45 fcntl.2
--- lib/libc/sys/fcntl.2 27 Sep 2019 07:20:07 -0000 1.45
+++ lib/libc/sys/fcntl.2 9 Jul 2021 14:29:32 -0000
@@ -548,8 +548,19 @@
.Fa cmd
is
.Dv F_GETPATH
and insufficient memory is available.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_GETLK ,
+.Dv F_SETLK ,
+or
+.Dv F_SETLKW ,
+and the file byte range lock limit for the current unprivilegied user
+has been reached. It can be modifed using sysctl
+.Li kern.maxlockf .
.It Bq Er ERANGE
The argument
.Fa cmd
is
Index: lib/libc/sys/flock.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/flock.2,v
retrieving revision 1.22
diff -U4 -r1.22 flock.2
--- lib/libc/sys/flock.2 15 Oct 2011 21:35:50 -0000 1.22
+++ lib/libc/sys/flock.2 9 Jul 2021 14:29:32 -0000
@@ -136,8 +136,12 @@
.Dv LOCK_EX ,
.Dv LOCK_SH ,
or
.Dv LOCK_UN .
+.It Bq Eq ENOMEM
+The file byte range lock limit for the current unprivilegied user
+has been reached. It can be modifed using sysctl
+.Li kern.maxlockf .
.It Bq Er EOPNOTSUPP
The argument
.Fa fd
refers to an object other than a file.
Home |
Main Index |
Thread Index |
Old Index