Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1719993rwb; Fri, 13 Jan 2023 16:59:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXueKrG1Lp9zNyQqrVCM7mUhPstEkRl2K0IhTjrzYiSpOOUQSuzpG72qZCmH0XVBk89dP1Hb X-Received: by 2002:a17:907:1110:b0:78d:f455:3118 with SMTP id qu16-20020a170907111000b0078df4553118mr68584621ejb.64.1673657990936; Fri, 13 Jan 2023 16:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673657990; cv=none; d=google.com; s=arc-20160816; b=RP/8KdzJW4uT7kgTiFIPHQ0+cpUr7lq83V4/9Mxe+ebEep3FNZjActxvb4YH0UcydU Rct7VCvjSd8uI4lzwA81EMy5bRqhUqEncqHGc9dw5l5YDFoqYlIkvbrSK4LIczytZ/aa 602SCdmVSOOknF7veVuu1fObmI6MzJXc3sgvyvc7chXziYPZ+nteWlPVgMQ73O9Zq1o1 d20Sv7NMrEJG98SZSlUNn3rPyR151Wm7WqLI0z9MffQbvNEExwff2ilpoWkXT415wC2L e4HfN66wmMwzLYJH4lLtRJxVOEL6T4XALC/bIVHBbgWydFPQUQ+RYPqdkRi3vbYFUxed AObg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0cr6flZbmbUm6BnDVrPQ805DdqVakOcMQUvo0Dk/7Bk=; b=1Fmc6XblbReVCxB+83dd+BzAsElmywA2DICvkfgShw60xz3MJGVaC1WmsEc2jILI6t ntSPtgz6N5a6I/i/S2C158l/z86j/LzZMwq9uibwBaeX5dI1rIuoGejiqvzIAEyBpOLZ tG7qQ5SA83IT2B/qqM+jac5Sfx165ggCyy1hCT7fsYXhrRQSZHkfSTsc5EbpL0H6iPAI Lizlq5b6HqdueoKDXzzCXZZm8j/5iZzPzUV1pcM+xDrecx8daOrcolKjREP2ApvLDeO3 /wQAdOkf1oXT8aVbibAlNPK5PWFBMo20e+tCGmm4cKk2Xe6F1GVIvlRSw1tHR17aoEtY NBQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=OcUfmFkm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg3-20020a170907320300b007c4fe4301basi22347411ejb.983.2023.01.13.16.59.37; Fri, 13 Jan 2023 16:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=OcUfmFkm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjANAfc (ORCPT + 53 others); Fri, 13 Jan 2023 19:35:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231279AbjANAe0 (ORCPT ); Fri, 13 Jan 2023 19:34:26 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366318A23B; Fri, 13 Jan 2023 16:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=0cr6flZbmbUm6BnDVrPQ805DdqVakOcMQUvo0Dk/7Bk=; b=OcUfmFkmRmElPTZk5KTMUQK441 r9Ec6i6sYTW8pRj0cYqA9kZqb1Tnea+rqFqhKbfuT3cMiAJEN/FLJUNQE2zowWVuWTBbJN1QuiI9s kKzaDbErKlT553gpgn/ntZ5K9MMPX6zaBLE9LrCe+C99lg1fNgK4FGJFs9XdCQnstNZAnYBEAMEJk wOrNz6nj9vN29tXtzwbCLZrlysmsTg8duHpJvnfmQpOBhlIL/emOC66Mu7i5+60bAdsP4M3yJo71a 6tinKETwlIeXYwTuRtmL2i7Aq4ZUj76xra0Zrs+f6MHurr1IezAvXJ7y6IHvMa7+cvuNjL+97zDix YzOMO8Zg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGUUt-004twV-Ml; Sat, 14 Jan 2023 00:34:11 +0000 From: Luis Chamberlain To: hch@infradead.org, djwong@kernel.org, song@kernel.org, rafael@kernel.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org, ebiederm@xmission.com Cc: mchehab@kernel.org, keescook@chromium.org, p.raghav@samsung.com, linux-fsdevel@vger.kernel.org, kernel@tuxforce.de, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [RFC v3 18/24] jffs2: replace kthread freezing with auto fs freezing Date: Fri, 13 Jan 2023 16:34:03 -0800 Message-Id: <20230114003409.1168311-19-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230114003409.1168311-1-mcgrof@kernel.org> References: <20230114003409.1168311-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel power management now supports allowing the VFS to handle filesystem freezing freezes and thawing. Take advantage of that and remove the kthread freezing. This is needed so that we properly really stop IO in flight without races after userspace has been frozen. Without this we rely on kthread freezing and its semantics are loose and error prone. The filesystem therefore is in charge of properly dealing with quiescing of the filesystem through its callbacks if it thinks it knows better than how the VFS handles it. The following Coccinelle rule was used as to remove the now superflous freezer calls: spatch --sp-file fs-freeze-cleanup.cocci --in-place --timeout 120 --dir fs/jffs2 --jobs 12 --use-gitgrep @ remove_set_freezable @ expression time; statement S, S2; expression task, current; @@ ( - set_freezable(); | - if (try_to_freeze()) - continue; | - try_to_freeze(); | - freezable_schedule(); + schedule(); | - freezable_schedule_timeout(time); + schedule_timeout(time); | - if (freezing(task)) { S } | - if (freezing(task)) { S } - else { S2 } | - freezing(current) ) @ remove_wq_freezable @ expression WQ_E, WQ_ARG1, WQ_ARG2, WQ_ARG3, WQ_ARG4; identifier fs_wq_fn; @@ ( WQ_E = alloc_workqueue(WQ_ARG1, - WQ_ARG2 | WQ_FREEZABLE, + WQ_ARG2, ...); | WQ_E = alloc_workqueue(WQ_ARG1, - WQ_ARG2 | WQ_FREEZABLE | WQ_ARG3, + WQ_ARG2 | WQ_ARG3, ...); | WQ_E = alloc_workqueue(WQ_ARG1, - WQ_ARG2 | WQ_ARG3 | WQ_FREEZABLE, + WQ_ARG2 | WQ_ARG3, ...); | WQ_E = alloc_workqueue(WQ_ARG1, - WQ_ARG2 | WQ_ARG3 | WQ_FREEZABLE | WQ_ARG4, + WQ_ARG2 | WQ_ARG3 | WQ_ARG4, ...); | WQ_E = - WQ_ARG1 | WQ_FREEZABLE + WQ_ARG1 | WQ_E = - WQ_ARG1 | WQ_FREEZABLE | WQ_ARG3 + WQ_ARG1 | WQ_ARG3 | fs_wq_fn( - WQ_FREEZABLE | WQ_ARG2 | WQ_ARG3 + WQ_ARG2 | WQ_ARG3 ) | fs_wq_fn( - WQ_FREEZABLE | WQ_ARG2 + WQ_ARG2 ) | fs_wq_fn( - WQ_FREEZABLE + 0 ) ) @ add_auto_flag @ expression E1; identifier fs_type; @@ struct file_system_type fs_type = { .fs_flags = E1 + | FS_AUTOFREEZE , }; Generated-by: Coccinelle SmPL Signed-off-by: Luis Chamberlain --- fs/jffs2/background.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 6da92ecaf66d..e29fdf1ed878 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c @@ -87,7 +87,6 @@ static int jffs2_garbage_collect_thread(void *_c) set_user_nice(current, 10); - set_freezable(); for (;;) { sigprocmask(SIG_UNBLOCK, &hupmask, NULL); again: @@ -119,7 +118,7 @@ static int jffs2_garbage_collect_thread(void *_c) /* Put_super will send a SIGKILL and then wait on the sem. */ - while (signal_pending(current) || freezing(current)) { + while (signal_pending(current) ||) { unsigned long signr; if (try_to_freeze()) -- 2.35.1