Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3650334rdb; Wed, 13 Sep 2023 20:29:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7Aql8zZvrY2bh9j/nnyeIAJ1mlBR4eKJLFj9hivUqnu1zS9ia3wi470Xr4EZybkP9yAbe X-Received: by 2002:a05:6a00:d9e:b0:68f:c1e0:a2c4 with SMTP id bf30-20020a056a000d9e00b0068fc1e0a2c4mr865593pfb.3.1694662153501; Wed, 13 Sep 2023 20:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694662153; cv=none; d=google.com; s=arc-20160816; b=upPTQKesRL5dgDMt9fTlHMvDSpFtT0e4umgcwjX90R+YqJ5hkh88FUSlIX7WWEibnb tK+guUqidU8FkpX9C6MdimK5iI2waXjKl9Sma5Zww5bMD+2Sa/8F1ZUnk/dv5WKTMzXJ jLIln2Oug3xOIv/A+Lq+AYxh6W2gtY20YcYiVniC/dJW60Pm17ecOQxIfnuSkVOvEvNl H6wbJbhrZKVZ1C0AA3KKu7eHEeYWKzKzJi3mCAAEN5zYQKQQ1AYD3Ydj7M/tgQ7wbCdS jLENj1yahE8JiJFm3phxGyIHzLr8XTt25byuArdhFb2UVA/X1SklHVod68LLFbq6lWWd c8Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=aZ73ErKfFCudA76NUgANoybnniVAPS5S8E3lXnfEKpQ=; fh=nydpFg/uexEzSby3I3G7yhhGN6BZS6EqME0szqY+Izg=; b=TQCmQOPjLRanN0+RsDUdpL8Jrg2hWj1/RyTFtXGTlonChp+UwaBxZPS8CRX1YorUoU A2KBQdLJxTAtFPsi3kb575vWKq3Hipli32MbSTMObkTQpRT0kouNn4xGcg7WCBzh6oMJ e8iCgrs15bnb6sCaaPJaifyPvt2jdhfIvUeCmiw8O3U2OL+TDY9sFMDU1xCJ1PAbVgbA aQkjPYKvFkVBy9DrRzKL9vBC/rSnOQWWhfWYOfXX0K3QdDzTEFrWW6SsnMrUsHjFGgru 939xTOfb5u11PjdIgGt+RyfD9u+N6aZA8e7MfJmcnZAqGewqkFbM237Xb6toWg89Fw+g 7Grg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=uxLI8kbo; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=hZvcFXmq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o124-20020a62cd82000000b006871178848csi640558pfg.208.2023.09.13.20.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 20:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=uxLI8kbo; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=hZvcFXmq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B77D68313583; Wed, 13 Sep 2023 08:05:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241011AbjIMPFL (ORCPT + 99 others); Wed, 13 Sep 2023 11:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237004AbjIMPFK (ORCPT ); Wed, 13 Sep 2023 11:05:10 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEDD5C6 for ; Wed, 13 Sep 2023 08:05:06 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8C063218E5; Wed, 13 Sep 2023 15:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1694617505; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aZ73ErKfFCudA76NUgANoybnniVAPS5S8E3lXnfEKpQ=; b=uxLI8kbovKukDi4rufe1shjDfGGIHvTpq5PDHhu/RSHrZVHLJsE7WlOxTC1JkFhszeJ8eR MEzBFZkf+yOVjuIp6zjkPWXhIryCQfB/8iAqcxcDpwcjtZelRn3Ae+0bc5t6JB0hBDerih Ma+1CrSMUZr6pwkkKGi+0kjmsJMq3DQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1694617505; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aZ73ErKfFCudA76NUgANoybnniVAPS5S8E3lXnfEKpQ=; b=hZvcFXmq85wRR7AncqJhr4l+pTETKSFXqRCLbNWaXNeNA5mkW+W7p/faytjqdQqZZd0L4U nvUvA+V37tcn0CCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 70E4913440; Wed, 13 Sep 2023 15:05:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hGsaG6HPAWUJdQAAMHmgww (envelope-from ); Wed, 13 Sep 2023 15:05:05 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id E2DF0A07C6; Wed, 13 Sep 2023 17:05:04 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , todd.e.brandt@intel.com, lenb@kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 2/2] ext4: Do not let fstrim block system suspend Date: Wed, 13 Sep 2023 17:04:55 +0200 Message-Id: <20230913150504.9054-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230913145649.3595-1-jack@suse.cz> References: <20230913145649.3595-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2106; i=jack@suse.cz; h=from:subject; bh=wzbr2qr/xOIYXhTC6cdxWrFNVRdnfwRURCn2vRs8oQc=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBlAc+WfAaguV1yLF++A3pQWHh0PT/yqwe92ypKrU6f cgPqcfWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZQHPlgAKCRCcnaoHP2RA2U08B/ 9NVlOi/FTKkfwV4s0ZvWpnxZ+POqu5X3QAmySDviXmWV7PskYNSQ2Pzl8LhVJyMWBUYvIFxyJqQCYh O0CWNDxaxjtP4JjfHWMGn4fQROvSLLFTLLt8jbpVl354lI8Y3i3xCumnnZKu5MPGMuGNcSf2SY8fSV omVCm19JIHC/F0JceW2RoUjLwQlA0N8Xt6fsbf91sMuBpRGkFIVu2/ogyon6U6/l4ykREm0ckZqJA3 EEKyv1ibXdBRQV/1O/owySZCT5FsIAntivepavOMRsGqSHCUoMrafCMOxlJ9yOO7w+6gpnl1HkWN0Z T6f575F+Sb41DU9MWmtFRMIstz0IK0 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:05:09 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Len Brown has reported that system suspend sometimes fail due to inability to freeze a task working in ext4_trim_fs() for one minute. Trimming a large filesystem on a disk that slowly processes discard requests can indeed take a long time. Since discard is just an advisory call, it is perfectly fine to interrupt it at any time and the return number of discarded blocks until that moment. Do that when we detect the task is being frozen. Reported-by: Len Brown Suggested-by: Dave Chinner References: https://bugzilla.kernel.org/show_bug.cgi?id=216322 Signed-off-by: Jan Kara --- fs/ext4/mballoc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 09091adfde64..1e599305d85f 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include /* @@ -6916,6 +6917,11 @@ static ext4_grpblk_t ext4_last_grp_cluster(struct super_block *sb, EXT4_CLUSTER_BITS(sb); } +static bool ext4_trim_interrupted(void) +{ + return fatal_signal_pending(current) || freezing(current); +} + static int ext4_try_to_trim_range(struct super_block *sb, struct ext4_buddy *e4b, ext4_grpblk_t start, ext4_grpblk_t max, ext4_grpblk_t minblocks) @@ -6949,8 +6955,8 @@ __releases(ext4_group_lock_ptr(sb, e4b->bd_group)) free_count += next - start; start = next + 1; - if (fatal_signal_pending(current)) - return -ERESTARTSYS; + if (ext4_trim_interrupted()) + return count; if (need_resched()) { ext4_unlock_group(sb, e4b->bd_group); @@ -7072,6 +7078,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) end = EXT4_CLUSTERS_PER_GROUP(sb) - 1; for (group = first_group; group <= last_group; group++) { + if (ext4_trim_interrupted()) + break; grp = ext4_get_group_info(sb, group); if (!grp) continue; -- 2.35.3