From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE3BCCE79AF for ; Wed, 20 Sep 2023 10:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234325AbjITKAH (ORCPT ); Wed, 20 Sep 2023 06:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234331AbjITKAG (ORCPT ); Wed, 20 Sep 2023 06:00:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3052AD for ; Wed, 20 Sep 2023 02:59:59 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C1EC433C7; Wed, 20 Sep 2023 09:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695203999; bh=YuwRJp5ZA6RnHYK/5S9ygHIh2UI4aoYNN34wPInzeo8=; h=Subject:To:Cc:From:Date:From; b=cTwME3jX30OGQ+jZh+uYEdE5+7BDxObD+St/37vjqZreBsBObJz/BJ+LkD3SpaUuP R/TwFX5hefWQYLGD7NaMrIFR8yYcGSTwehG88zFLlZ20frmm2aOOIVyhhC39CjX+DU GTp/bWATjzWmsSEfZPrnfWUqSGsKODw9W8RJ2vI8= Subject: FAILED: patch "[PATCH] ext4: do not let fstrim block system suspend" failed to apply to 4.19-stable tree To: jack@suse.cz, david@fromorbit.com, lenb@kernel.org, tytso@mit.edu Cc: From: Date: Wed, 20 Sep 2023 11:59:37 +0200 Message-ID: <2023092037-underpaid-casing-6ccf@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y git checkout FETCH_HEAD git cherry-pick -x 5229a658f6453362fbb9da6bf96872ef25a7097e # git commit -s git send-email --to '' --in-reply-to '2023092037-underpaid-casing-6ccf@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^.. Possible dependencies: 5229a658f645 ("ext4: do not let fstrim block system suspend") 45e4ab320c9b ("ext4: move setting of trimmed bit into ext4_try_to_trim_range()") de8bf0e5ee74 ("ext4: replace the traditional ternary conditional operator with with max()/min()") d63c00ea435a ("ext4: mark group as trimmed only if it was fully scanned") 2327fb2e2341 ("ext4: change s_last_trim_minblks type to unsigned long") 173b6e383d2a ("ext4: avoid trim error on fs with small groups") afcc4e32f606 ("ext4: scope ret locally in ext4_try_to_trim_range()") 6920b3913235 ("ext4: add new helper interface ext4_try_to_trim_range()") bd2eea8d0a6b ("ext4: remove the 'group' parameter of ext4_trim_extent") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 5229a658f6453362fbb9da6bf96872ef25a7097e Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 13 Sep 2023 17:04:55 +0200 Subject: [PATCH] ext4: do not let fstrim block system suspend 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. Cc: stable@kernel.org Reported-by: Len Brown Suggested-by: Dave Chinner References: https://bugzilla.kernel.org/show_bug.cgi?id=216322 Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20230913150504.9054-2-jack@suse.cz Signed-off-by: Theodore Ts'o 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;