From nobody Mon Nov 07 22:01:27 2022 X-Original-To: bugs@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 4N5lYg5MrYz4gVkh for ; Mon, 7 Nov 2022 22:01:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N5lYg3WtXz5dp8 for ; Mon, 7 Nov 2022 22:01:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N5lYg2M5bzHdP for ; Mon, 7 Nov 2022 22:01:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2A7M1Rr6013870 for ; Mon, 7 Nov 2022 22:01:27 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2A7M1R5Q013869 for bugs@FreeBSD.org; Mon, 7 Nov 2022 22:01:27 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 267628] growfs deadlocks if output is redirected to the filesystem being grown Date: Mon, 07 Nov 2022 22:01:27 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: cgull@glup.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667858487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gpA3AfCq9KhK9HgzNnlo2NBnm5aJNchK2hVVkP6K5wI=; b=ZeGwrR33HvBA9KDEC7kUAd96sYEPDMJgSY4zsGbq/k2EO9dbcj9l0RgrsCzrY1ity2mckg DLtomNUy0ZfPRNbh9zu8lkdp9qdBQo0xhhL4iPGsKUaNI0JAK4N0UszA4iqR6rFt5GrhKd kE7MmQZtHDs7Kl6wYQ6phZEkteJq3LmvT8B2LAwLPv+xi/Y7+NUJEDxrMI0a05Gsb0hpK8 TZ8Yz2qwj4bwZPAgysCsBNLO5c90nWTETHsWBmKJgBaw2V1chHlkYQUyU9Tey2bkPO1qn5 bbn03j6wDh2mXRxJg8NxP2Obecwf3Cz5bw5qGaGqc0PeD5nhoviJTDH1ERh+wA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667858487; a=rsa-sha256; cv=none; b=iHfnKJEBYv3bbLssJKQgP2/2p2Lxm6P89uibPlp1+rpPij4WBytw/t4AdYcdzflCgMwOVI thP1KnQtEs6kXRjZE3ZHkdMW7ldsnsY7fCuhjo6XV4M5phZOr9EdtSNKuK9qmyX+LwdECk Pdt7zx7jh+uGGJLwsBtAKFGFuA/r+AeV9T0Tz1MOG26F+8WCTEZdVHJDGF09If702qQmN+ 2MR3yrd9PxTFaK0TbwfRDA559QfBu9kaZBpLwoeLfXx69GQd++Ey/r+IXVv8SjlC26wWdk UY42iM2dP4aT+J7So7EHbYDvkKNaaNH4SEiHYQ+Eoi51ZFOfwiClyp8NNYck5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D267628 Bug ID: 267628 Summary: growfs deadlocks if output is redirected to the filesystem being grown Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: cgull@glup.org growfs deadlocks in disk wait on 'suspfs' if its stdout/stderr is redirecte= d to a file on the filesystem being grown. This appears to be because it suspen= ds the filesystem with the UFSSUSPEND ioctl, and then writes disk block number= s as a progress indicator as it writes new cylinder groups. The reproduction is easy: mdconfig -s 20m gpart create -s gpt md0 gpart add -t freebsd-ufs -s 10m -i 1 md0 newfs md0p1 mount /dev/md0p1 /mnt gpart resize -i 1 md0 growfs -y md0p1 > /mnt/growfs.log Reproduced in 13.1p2 and a -CURRENT snapshot dated Nov 3 07:57 with identif= ier 'main-n259005-5cc5c9254da'. Also, if the system is shutdown with a growfs in this state, disk syncing h= angs and the system never halts/reboots. I'll open a separate bug for that. Ideas for fixes (some are not complete fixes): * fstat() stdout/stderr and compare their fsids against the filesystem we're growing. If either is found to match, exit with an error message. I think that may be a complete solution for growfs (it can no longer uninterruptibly deadlock). 'growfs | tee /growing-fs/growfs.log' will still hang if growfs produces enough output, but growfs will be interruptible, and tee will make progress after the ufssuspend state is exited. * Write new cylinder groups first, before doing UFSSUSPEND and writing the formerly-last cg and superblock. This is not a complete fix for this particular issue (if growfs reports errors it will still deadlock), but is = 90%, and has the added benefits of doing most of the I/O (and encountering most possible errors) before making irreversible changes to the existing filesys= tem, and also reducing the amount of time the filesystem is suspended. * Don't report progress or errors while in ufssuspend state. * On non-ttys, set stdio buffers so that progress indicators are not written until completion. I'll try and come up with patches for this. --=20 You are receiving this mail because: You are the assignee for the bug.=