From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D7411E9906; Mon, 23 Feb 2026 23:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771890046; cv=none; b=U7QHgKuYb0/BTCp1/Em0tH+8euHEQ1OxLKsd2mWzUAgwZikx1oKKWelx6expw8jxaYvcvHPz+bml8AeZt+X+GGBD1cH8GsUCVyPhhGO6qfn81WlDeFL5Py0sTuYOZ7LfhhP82X/eyvZGaDrvAp0N3YiISRk+fzdcr4G2lUR5dJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771890046; c=relaxed/simple; bh=/9YrKbT1Yll5lu37hT9MwYJOVGra563eoWxULLsgGW4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RoZ46/IGBQlFsQ7T1mWaOCP71gEqoH7GAQuYJiE2DJdbWgfAGFNM0WvqjfVgqRQxYOJJ+oV7KuK6SsK/lvuLmcEbE0+Y1eoYRSXL0xPiw+sjLjdXV0EBr4ZAnhnFGenXBs3YD1ZSRQxFhngKiWcaY2GkxxIVwCONzOAH+ZeVNVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FH1q2z7S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FH1q2z7S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21255C19421; Mon, 23 Feb 2026 23:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771890046; bh=/9YrKbT1Yll5lu37hT9MwYJOVGra563eoWxULLsgGW4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=FH1q2z7Sx5HpENT1Ie4/STOJ1hSDOF9l/0vIdiqDws+fT1IsY7iQtSskouKV4+sOX f/855jljKXccEaF/y6VGzgsgbQnf6mft7k2jKLEk+3OdZv1LuWAlpC+9m+U8JatizR OPg5hmDS33bT7TpjUl8LPvm2i40f4bHMmysB5m0c/ECKxtBWrRw539cLopwj8b5SvL z5C4cbq9iajqk1YchD/d6NpBRSwDmrWjEEZC4tJjKnjG7SVgmKMblTy7UWxV0wgP3a c5duPIrFlPE0Re1QyUghVEwmKkxSLflNG/4qXDR5v2N+UtSFTmPob8IxykWUYZVseE pOtIFaD7TRk+Q== Date: Mon, 23 Feb 2026 15:40:45 -0800 Subject: [PATCH 18/19] fuse4fs: disable fs reclaim and write throttling From: "Darrick J. Wong" To: tytso@mit.edu Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, miklos@szeredi.hu, bernd@bsbernd.com, joannelkoong@gmail.com, neal@gompa.dev Message-ID: <177188744804.3943178.14306714883633979460.stgit@frogsfrogsfrogs> In-Reply-To: <177188744403.3943178.7675407203918355137.stgit@frogsfrogsfrogs> References: <177188744403.3943178.7675407203918355137.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Darrick J. Wong Ask the kernel if we can disable fs reclaim and write throttling. Disabling fs reclaim prevents livelocks where the fuse server can allocate memory, fault into the kernel, and then the allocation tries to initiate writeback by calling back into the same fuse server. Disabling BDI write throttling means that writeback won't be throttled by metadata writes to the filesystem. Signed-off-by: "Darrick J. Wong" --- fuse4fs/fuse4fs.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c index 77207bae19e544..4499f4083f85dd 100644 --- a/fuse4fs/fuse4fs.c +++ b/fuse4fs/fuse4fs.c @@ -7737,6 +7737,19 @@ static void try_set_io_flusher(struct fuse4fs *ff) #endif } +/* Undo try_set_io_flusher */ +static void try_clear_io_flusher(struct fuse4fs *ff) +{ +#ifdef HAVE_PR_SET_IO_FLUSHER + /* + * zero ret means it's already set, negative means we can't even + * look at the value so don't bother clearing it + */ + if (prctl(PR_GET_IO_FLUSHER, 0, 0, 0, 0) > 0) + prctl(PR_SET_IO_FLUSHER, 0, 0, 0, 0); +#endif +} + /* Try to adjust the OOM score so that we don't get killed */ static void try_adjust_oom_score(struct fuse4fs *ff) { @@ -7842,12 +7855,27 @@ static int fuse4fs_main(struct fuse_args *args, struct fuse4fs *ff) fuse_loop_cfg_set_idle_threads(loop_config, opts.max_idle_threads); fuse_loop_cfg_set_max_threads(loop_config, 4); + /* + * Try to set ourselves up with fs reclaim disabled to prevent + * recursive reclaim and throttling. This must be done before starting + * the worker threads so that they inherit the process flags. + */ + ret = fuse_lowlevel_disable_fsreclaim(ff->fuse, 1); + if (ret) { + err_printf(ff, "%s: %s.\n", + _("Could not register as FS flusher thread"), + strerror(errno)); + try_set_io_flusher(ff); + ret = 0; + } + if (fuse_session_loop_mt(se, loop_config) != 0) { ret = 8; - goto out_loopcfg; + goto out_flusher; } -out_loopcfg: +out_flusher: + try_clear_io_flusher(ff); fuse_loop_cfg_destroy(loop_config); out_remove_signal_handlers: fuse_remove_signal_handlers(se); @@ -7925,7 +7953,6 @@ int main(int argc, char *argv[]) goto out; } - try_set_io_flusher(&fctx); try_adjust_oom_score(&fctx); /* Will we allow users to allocate every last block? */