Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1748552rwb; Fri, 13 Jan 2023 17:28:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKfxz4d0gF6axI2zh2s6XH44P/9RkczUcNYlIsoHj/OBEFQih+lmHAD5vsytahy4xwG/2d X-Received: by 2002:a05:6402:408:b0:482:74a:c3d9 with SMTP id q8-20020a056402040800b00482074ac3d9mr63141849edv.23.1673659708359; Fri, 13 Jan 2023 17:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673659708; cv=none; d=google.com; s=arc-20160816; b=SB9kcDcy/c1Hpaq+TQ0W5AYFY8J28jRGtF7WeAnCB0A++J9juBiethuG80x6wRgNqs SONJMWQ1PHeIbuAsapYOalKV4qDtBjLBeB+cGZM9yr6PzUH+p2Nc5Lb4U+FCeOUIyODt iQHpVnEtFp5LpdbZDFG48U4uBB+nHPRLyWfmPfX5LZ6nZDONRrAIM0K+XVsXzNYOLEsE xNKtUiIepknO3xc6SoN7UNuhMrXAZVggmPJfV0/6imhevvZw1zrPQj9Gi9lkOzy+pRxo ZyORL5JXyAGCa96Msmh+CXiU2xXfcwnVVaMBUzd48lL9ASAihUk84M6f6i8dymi9ogRJ fj9A== 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=IWJAcTlsi8ryaxDVWH2nmdINNVfn/iAaGN3EvUk7iBg=; b=rroAlqpsD30Bhxf8EYNY32IjRW8jrzSFR7x3vLgIroCvqg0X25iWoQWGeAxkDodOQq hnUz05EN8dAfvQ+TbIDq1JXbbIFsqIpUrCvXzLuZec5RGOBAJDDRnBVoEfFZ3aGy+jRB t5wGCkxLmD4jo0KdLLyZKcKXw+Hzc0XsU9ztWiCzk8OipdkakjQTiFj25Q0/8jFRyYg9 1wn6EtiqIifIzXl0ARpg122DYGnopU4ebXzQzpfSWwZdrzcSZF+LVTo2MPj8UletH6Of bWlB2scyzwBal/TbqDjAUxzvOwnxzTjf/KpEDJYn0Z6qnLKfuoKIeb7TuCBr3Ng3bDjN MJvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Mi22gS6o; 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 u1-20020a50a401000000b0048ee37983a0si22227134edb.178.2023.01.13.17.28.15; Fri, 13 Jan 2023 17:28:28 -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=Mi22gS6o; 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 S231419AbjANAfw (ORCPT + 53 others); Fri, 13 Jan 2023 19:35:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjANAe1 (ORCPT ); Fri, 13 Jan 2023 19:34:27 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 996398B503; 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=IWJAcTlsi8ryaxDVWH2nmdINNVfn/iAaGN3EvUk7iBg=; b=Mi22gS6oqSXUxRA13EGgc4HHnX wNkKl8VX84iIEA+HoUigSGJt/l+lI9YkT4xw6705TcIpQ7E5XXNd7twIh+ckKu9FkUfVcxijCARzR qbVix/oxCjaCbx1fmZ9TqrsR+x+4nz5ZYwMy9aslYiS/6qEHETxFL5ne2dmERvM55J4hKwPWKJc5N 63ofvf3XA2EZyaoaYUsIWyTs+tEdFytDNflZQ297SjjxCTIILiWfcPmsjgHsy0OZHqbbRTyrPp5Cl xOTgUeo2zftx63wEntVhGL9kLPKEXjTSOMsnli/ql7JfEAQpU/tK1tqP7Lvh7gwSOmfzJq3lFx7/F cQ4MdSlA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGUUt-004twN-Gz; 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 14/24] nfs: replace kthread freezing with auto fs freezing Date: Fri, 13 Jan 2023 16:33:59 -0800 Message-Id: <20230114003409.1168311-15-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/nfs --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/nfs/callback.c | 4 ---- fs/nfs/fs_context.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 456af7d230cf..f5ba4d6bf2a7 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -77,8 +77,6 @@ nfs4_callback_svc(void *vrqstp) int err; struct svc_rqst *rqstp = vrqstp; - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) @@ -109,8 +107,6 @@ nfs41_callback_svc(void *vrqstp) int error; DEFINE_WAIT(wq); - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 9bcd53d5c7d4..04753962db9a 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1583,7 +1583,7 @@ struct file_system_type nfs_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs"); EXPORT_SYMBOL_GPL(nfs_fs_type); @@ -1595,7 +1595,7 @@ struct file_system_type nfs4_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs4"); MODULE_ALIAS("nfs4"); -- 2.35.1