From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBDA63FE357 for ; Wed, 29 Apr 2026 18:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777485676; cv=none; b=uJlwtZ4YwJzS5OAx9R9GmK+cEOGyYIizinucl+5HHh16sSDg+NNISdHtKwsqj4qD6C9/ej13qXq95hj1HlKXbzh8MT9I3V9MLr/9EmAp+gg/Pks637UsruC/HqyU9ybOW2yK8F11t2Odcu3XiOtn8S2nIRzE2O8OUsQZ6P6tpJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777485676; c=relaxed/simple; bh=mzpKH1ZB3Qh3QKLqTq5A8f4/hEciqaohMILgVC0QH+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dh4nDEgNUM51htmmgGiOVS0+6/2gkUPcjFx7fgeAQPwHa8C8i6J/UMYQ4rhTRwfSr+LQUQo5ZnA2ZkFfg5wk2tJRKx8/KkdKKwJ/j+6VuKUZKNIqFG9N6LUjUUDD4zaP38XNJqZ3EiYXfau40LX7YJnA2XLNiJhPG1TO2y1igGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 263476A814; Wed, 29 Apr 2026 18:01:13 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 14292593B4; Wed, 29 Apr 2026 18:01:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SGvmBGlH8mnaOwAAD6G6ig (envelope-from ); Wed, 29 Apr 2026 18:01:13 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C9075A0B79; Wed, 29 Apr 2026 20:01:04 +0200 (CEST) From: Jan Kara To: Cc: , Matthew Wilcox , Jan Kara Subject: [PATCH 4/4] ext4: Defer inode reclaim if it has preallocations Date: Wed, 29 Apr 2026 20:00:54 +0200 Message-ID: <20260429180056.29598-8-jack@suse.cz> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260429174850.18223-1-jack@suse.cz> References: <20260429174850.18223-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1087; i=jack@suse.cz; h=from:subject; bh=mzpKH1ZB3Qh3QKLqTq5A8f4/hEciqaohMILgVC0QH+A=; b=kA0DAAgBnJ2qBz9kQNkByyZiAGnyR1qgiHH9eRNVeK9FTxZcxGOSjM3n0qP/bIUSdV0vN1SUq YkBMwQAAQgAHRYhBKtZ0SvWnjKKtVUoHJydqgc/ZEDZBQJp8kdaAAoJEJydqgc/ZEDZGX0H/iFk 4CSpD4Rr7/0/SHiPEtHqczHLQ32NLfDTbdDiekMaIsfCup32NxFJX93uPoUlku7SixlLBhbWUN9 pfxN3CV0G7UonsQw3/tMeJ72ILPPGrNVN95JAlBz8YqUM0bbbS9JSX7Bsl7w+WK2XUkNaknbx1D v9h6w3RBHE3QeNtox3omQK0QA7eAo6JxLp725+2BRaMjtTRQkU5oYotWJzC1Fa9SkoQvI9LQy6D GjZjqq0bEWuCudzYeVRPoMVOG4jktvaJ2aXYvpPACf0oIREEfeZrxdtWhW0pO2UhPzC4Dc2x3ui 8FIEmXr+ictBMOcfAqv/LqpS07sqSt4NTky+YfQ= X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 263476A814 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: When we have to free preallocations during inode eviction, we need to load block bitmaps and run transaction to modify them. This takes time and also requires GFP_NOFAIL allocations. Mark inodes with preallocated blocks as needing offloading of inode reclaim to a workqueue so that we don't block reclaim for long and potentially deadlock MM subsystem. Signed-off-by: Jan Kara --- fs/ext4/mballoc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ed1bd00e11cd..4de3cfa4e648 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3114,6 +3114,13 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) if (ac->ac_prefetch_nr) ext4_mb_prefetch_fini(sb, ac->ac_prefetch_grp, ac->ac_prefetch_nr); + /* + * Freeing preallocations requires loading bitmaps and running + * transactions. Defer inode reclaim to a workqueue. + */ + if (!RB_EMPTY_ROOT(&EXT4_I(ac->ac_inode)->i_prealloc_node)) + mark_inode_reclaim_deferred(ac->ac_inode); + return err; } -- 2.51.0