From nobody Fri Dec 29 15:43:17 2023 X-Original-To: fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T1qQx6h3gz56KPv for ; Fri, 29 Dec 2023 15:43:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T1qQx34Stz4Pp4 for ; Fri, 29 Dec 2023 15:43:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5945fef58caso2804451eaf.2 for ; Fri, 29 Dec 2023 07:43:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703864600; x=1704469400; darn=freebsd.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=R3mN0pq0FYXodIgdBVLc6jL0cwm12nUSILMCTZVdKeI=; b=AjrPKXu/DjntTxucYwxvYZNqmmJr/qwBggYMAJULCSCWLN3PS5x9qwdn92R+jdAHh9 1f34uV1shPmzvWhOsCYfW8Q1zarmvoYrBgrvVb7acDE/GxmpUMYFLk7/uQBSPnKUfHFg S74SVIFcPAJykDjV5IqJt+3+Gm6uqdNMHX6hmu7GfMfRZspq9ig90NXGx1aoYQPxC4gv 6hBbmkzloTdzOC3fwyLhoxUqK6OfHMN/JJCEhyKyu3unh0XxhczSc8wUzptVx65zajUt 0oGYYB9BG9XO0vryp8kDPIhJtBE+Nas8mC/94e3ro6Jh4du6Vh8z2UrQPAmRqTrik8h5 sbhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703864600; x=1704469400; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R3mN0pq0FYXodIgdBVLc6jL0cwm12nUSILMCTZVdKeI=; b=pdJEGkgxU5rfM0P3uIBFtqAlf7PwOBf4+iLYw7SlhECb8Qu7mNrPd/M8+YBLLZFssr h76s/+yCDldKfNo1gImeMwGKugsOmdRn2jDS/KT7joj/w05e8hFiS8hyD4YnYCJw2PPP KH3C3WfXrDyYPv4ksuElWr+vfh3LhES7/2JW6jiEJktIY9wn2gVZ34M5+WYIZeRGPrAZ PfQNszr4rn7Oh/b7H2qiPLcPrzv8fSbNzneRScT6URCJN+rL+3t72hjfxkfen9YiL4Tc DDzI3ioL5nhIghRvNDOqTWFC1RnrtpnSF2at/Oolhl2M1iFDbjNtpbFI9nNOdpLKVheI WXVQ== X-Gm-Message-State: AOJu0YxmFLBfLU7PhDhYEbFwM23vrLq3lRtLtiPMvOWtsnPTxFeNRxR6 XMzpUu/kFN1H40Pc1k8Z4CRYVguXuGO7Bg== X-Google-Smtp-Source: AGHT+IEkTr36Rr5Q0wyHf7VnG/gH/Xbeaqn+r/k8FjncNei2zKhOR1vunsE/U6PwBLvb2n8/roHP0w== X-Received: by 2002:a05:6358:9213:b0:174:cf3a:749 with SMTP id d19-20020a056358921300b00174cf3a0749mr13214233rwb.36.1703864600302; Fri, 29 Dec 2023 07:43:20 -0800 (PST) Received: from nuc (192-0-220-237.cpe.teksavvy.com. [192.0.220.237]) by smtp.gmail.com with ESMTPSA id fw11-20020a05622a4a8b00b00419801b1094sm2513688qtb.13.2023.12.29.07.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 07:43:19 -0800 (PST) Date: Fri, 29 Dec 2023 10:43:17 -0500 From: Mark Johnston To: Peter Holm Cc: fs@freebsd.org Subject: Re: panic: sbuf_clear makes no sense on sbuf 0xfffff80004234000 with drain Message-ID: References: List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Spamd-Bar: ---- X-Rspamd-Queue-Id: 4T1qQx34Stz4Pp4 On Fri, Dec 29, 2023 at 10:29:57AM +0100, Peter Holm wrote: > root@mercat1:/tmp # cat sysctl.sh > #!/bin/sh > > kldstat | grep -q zfs.ko || kldload zfs.ko > start=`date +%s` > while [ $((`date +%s` - start)) -lt 180 ]; do > for i in `jot 3`; do > sysctl -a > /dev/null 2>&1 & > done > wait > done > kldstat | grep -q zfs.ko && kldunload zfs.ko > exit 0 > root@mercat1:/tmp # ./sysctl.sh > ZFS filesystem version: 5 > ZFS storage pool version: features support (5000) > panic: sbuf_clear makes no sense on sbuf 0xfffff80004234000 with drain > cpuid = 0 > time = 1703841857 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe016a270960 > vpanic() at vpanic+0x131/frame 0xfffffe016a270a90 > panic() at panic+0x43/frame 0xfffffe016a270af0 > sbuf_clear() at sbuf_clear+0xa8/frame 0xfffffe016a270b00 > sbuf_cpy() at sbuf_cpy+0x56/frame 0xfffffe016a270b20 > spa_taskq_write_param() at spa_taskq_write_param+0x85/frame 0xfffffe016a270bd0 (src/sys/contrib/openzfs/module/zfs/spa.c:1486) > sysctl_root_handler_locked() at sysctl_root_handler_locked+0x9c/frame 0xfffffe016a270c20 > sysctl_root() at sysctl_root+0x21e/frame 0xfffffe016a270ca0 > userland_sysctl() at userland_sysctl+0x184/frame 0xfffffe016a270d50 > sys___sysctl() at sys___sysctl+0x60/frame 0xfffffe016a270e00 > amd64_syscall() at amd64_syscall+0x153/frame 0xfffffe016a270f30 > fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe016a270f30 > --- syscall (202, FreeBSD ELF64, __sysctl), rip = 0x116eb469819a, rsp = 0x116eb273c6e8, rbp = 0x116eb273c720 --- > KDB: enter: panic > [ thread pid 3697 tid 100308 ] > Stopped at kdb_enter+0x33: movq $0,0xe38ff2(%rip) > db> x/s version > FreeBSD 15.0-CURRENT #0 main-n267275-4b817fc1f02c: Thu Dec 28 07:42:48 CET 2023 > pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO > db> The patch below fixes the problem for me. I submitted it upstream here: https://github.com/openzfs/zfs/pull/15719 diff --git a/sys/contrib/openzfs/module/zfs/spa.c b/sys/contrib/openzfs/module/zfs/spa.c index a21b0decf6a3..b489266e0556 100644 --- a/sys/contrib/openzfs/module/zfs/spa.c +++ b/sys/contrib/openzfs/module/zfs/spa.c @@ -1460,11 +1460,12 @@ spa_taskq_read_param(ZFS_MODULE_PARAM_ARGS) int err = 0; if (req->newptr == NULL) { + struct sbuf s; int len = spa_taskq_param_get(ZIO_TYPE_READ, buf); - struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req); - sbuf_cpy(s, buf); - err = sbuf_finish(s); - sbuf_delete(s); + + (void) sbuf_new_for_sysctl(&s, buf, len + 1, req); + err = sbuf_finish(&s); + sbuf_delete(&s); return (err); } @@ -1481,11 +1482,12 @@ spa_taskq_write_param(ZFS_MODULE_PARAM_ARGS) int err = 0; if (req->newptr == NULL) { + struct sbuf s; int len = spa_taskq_param_get(ZIO_TYPE_WRITE, buf); - struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req); - sbuf_cpy(s, buf); - err = sbuf_finish(s); - sbuf_delete(s); + + (void) sbuf_new_for_sysctl(&s, buf, len + 1, req); + err = sbuf_finish(&s); + sbuf_delete(&s); return (err); }