]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add tunables for channel programs
authorJohn Gallagher <jgallag88@gmail.com>
Fri, 15 Jun 2018 22:10:42 +0000 (15:10 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 15 Jun 2018 22:10:42 +0000 (15:10 -0700)
This patch adds tunables for modifying the maximum memory limit and
maximum instruction limit that can be specified when running a channel
program.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov
Reviewed-by: Sara Hartse <sara.hartse@delphix.com>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
External-issue: LX-1085
Closes #7618

cmd/zfs/zfs_main.c
include/sys/zcp.h
man/man5/zfs-module-parameters.5
module/zfs/zcp.c
tests/zfs-tests/tests/functional/channel_program/lua_core/tst.memory_limit.ksh

index b45e93c3fb92a87c037483f717a5d905f2c761c5..e60ac514d2652897437bf5559824a8f9c88eb353 100644 (file)
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  * Copyright 2012 Milan Jurik. All rights reserved.
  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  * Copyright (c) 2013 Steven Hartland.  All rights reserved.
@@ -7308,24 +7308,10 @@ zfs_do_channel_program(int argc, char **argv)
                        }
 
                        if (c == 't') {
-                               if (arg > ZCP_MAX_INSTRLIMIT || arg == 0) {
-                                       (void) fprintf(stderr, gettext(
-                                           "Invalid instruction limit: "
-                                           "%s\n"), optarg);
-                                       return (1);
-                               } else {
-                                       instrlimit = arg;
-                               }
+                               instrlimit = arg;
                        } else {
                                ASSERT3U(c, ==, 'm');
-                               if (arg > ZCP_MAX_MEMLIMIT || arg == 0) {
-                                       (void) fprintf(stderr, gettext(
-                                           "Invalid memory limit: "
-                                           "%s\n"), optarg);
-                                       return (1);
-                               } else {
-                                       memlimit = arg;
-                               }
+                               memlimit = arg;
                        }
                        break;
                }
index b56eda552e1749c3bfc0d405c045121490756f32..b9c8ef0069f1552d4f51ec9d42729aad12e78d5a 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 /*
- * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2016, 2018 by Delphix. All rights reserved.
  */
 
 #ifndef _SYS_ZCP_H
@@ -33,8 +33,8 @@ extern "C" {
 
 #define        ZCP_RUN_INFO_KEY "runinfo"
 
-extern uint64_t zfs_lua_max_instrlimit;
-extern uint64_t zfs_lua_max_memlimit;
+extern unsigned long zfs_lua_max_instrlimit;
+extern unsigned long zfs_lua_max_memlimit;
 
 int zcp_argerror(lua_State *, int, const char *, ...);
 
index dbfa8806a8af5e24ef320bc1ba868a5a382f51bf..7a195ab1263344ee9ca7257e48e4643c33e485f1 100644 (file)
@@ -1,6 +1,7 @@
 '\" te
 .\" Copyright (c) 2013 by Turbo Fredriksson <turbo@bayour.com>. All rights reserved.
 .\" Copyright (c) 2017 Datto Inc.
+.\" Copyright (c) 2018 by Delphix. All rights reserved.
 .\" The contents of this file are subject to the terms of the Common Development
 .\" and Distribution License (the "License").  You may not use this file except
 .\" in compliance with the License. You can obtain a copy of the license at
@@ -1560,6 +1561,30 @@ dataset being written to had the property setting \fBlogbias=throughput\fR.
 Default value: \fB32,768\fR.
 .RE
 
+.sp
+.ne 2
+.na
+\fBzfs_lua_max_instrlimit\fR (ulong)
+.ad
+.RS 12n
+The maximum execution time limit that can be set for a ZFS channel program,
+specified as a number of Lua instructions.
+.sp
+Default value: \fB100,000,000\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fBzfs_lua_max_memlimit\fR (ulong)
+.ad
+.RS 12n
+The maximum memory limit that can be set for a ZFS channel program, specified
+in bytes.
+.sp
+Default value: \fB104,857,600\fR.
+.RE
+
 .sp
 .ne 2
 .na
index e7194344b7d8c2ce03ad713eabb80cb2fd08985a..dad09da50d2abbd72bf91a697136a258b62bba3a 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 /*
- * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2016, 2018 by Delphix. All rights reserved.
  */
 
 /*
 #define        ZCP_NVLIST_MAX_DEPTH 20
 
 uint64_t zfs_lua_check_instrlimit_interval = 100;
-uint64_t zfs_lua_max_instrlimit = ZCP_MAX_INSTRLIMIT;
-uint64_t zfs_lua_max_memlimit = ZCP_MAX_MEMLIMIT;
+unsigned long zfs_lua_max_instrlimit = ZCP_MAX_INSTRLIMIT;
+unsigned long zfs_lua_max_memlimit = ZCP_MAX_MEMLIMIT;
 
 /*
  * Forward declarations for mutually recursive functions
@@ -1417,3 +1417,15 @@ zcp_parse_args(lua_State *state, const char *fname, const zcp_arg_t *pargs,
                zcp_parse_pos_args(state, fname, pargs, kwargs);
        }
 }
+
+#if defined(_KERNEL)
+/* BEGIN CSTYLED */
+module_param(zfs_lua_max_instrlimit, ulong, 0644);
+MODULE_PARM_DESC(zfs_lua_max_instrlimit,
+       "Max instruction limit that can be specified for a channel program");
+
+module_param(zfs_lua_max_memlimit, ulong, 0644);
+MODULE_PARM_DESC(zfs_lua_max_memlimit,
+       "Max memory limit that can be specified for a channel program");
+/* END CSTYLED */
+#endif
index dbac583872465fbd2dc67dfb8fcb982e3b0bac49..288577568673667c9ac14959faffdf6ae96a6819 100755 (executable)
@@ -61,12 +61,12 @@ log_mustnot_checkerror_program "Memory limit exhausted" -m 1 $TESTPOOL - <<-EOF
        return s
 EOF
 
-log_mustnot_checkerror_program "Invalid memory limit" \
-    -m 1000000000000 $TESTPOOL - <<-EOF
+log_mustnot_checkerror_program "Invalid instruction or memory limit" \
+    -m 200000000 $TESTPOOL - <<-EOF
        return 1;
 EOF
 
-log_mustnot_checkerror_program "Invalid memory limit" \
+log_mustnot_checkerror_program "Return value too large" \
     -m 9223372036854775808 $TESTPOOL - <<-EOF
        return 1;
 EOF