Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1718763rwb; Fri, 13 Jan 2023 16:58:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXtiefZIM6VTM5oK6iWkuMYveiYw4zKwB5oP33vEqgU+74yVA4lWIHutAxnTdD6E0jIaMWiy X-Received: by 2002:a05:6a20:3d84:b0:b0:1abd:8604 with SMTP id s4-20020a056a203d8400b000b01abd8604mr130675706pzi.41.1673657886413; Fri, 13 Jan 2023 16:58:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673657886; cv=none; d=google.com; s=arc-20160816; b=X4goZx5TmE1XSu6yYGbaInGSij5pMT2/J/0RjC22Qt+bhyp3ftDjm9y0LqzFf4bp6b 2T9pUsgMLtFDir4Ef//AVAMixpC4dRiBIPrDE4xxWjxf9SoCJj5MtXqOAPUTZUsboGYE yUoZMVcnmTPFaD44v5S3ktAA8FwiFd1V+coUctApARFpPqY2EvBC8qYCbjKFF0BBItNO acuo8+3MHtKJhCtB6sR5AJHUVtIoyzBfZX4/IQHGlC+OlE6ut/eAFXfNuLbNbUEnWDgw WuLyXlynDg0pqszK90HaNKZIy9ZzkznAz7BmKf5m/XXPoBPwg8ZmOEK/VktIpNy+YKpY r2tQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pZPvdTNpHFNfezOeGlLRl8Ac0qskj02eRl+ESGUnqKc=; b=FAlQ+v2cuYoorA6hBJk9QpDsATbA/jjsTxQNnfrG07HUxUOkFm+ZBhIzAl/bjKyZiA a1Ebl59yurDeS4zI2FjfqwsjgZXhbmK7VxWx+p6YJVq1QaFlLF5Ymj/ZjwXrxwIqEhGl ut6kkjYj1Ri1N+WVC7vUU1wVWxZdMY/vgZzSYA6SSsEHzPa6t2OAEIbYr03E8FWUmQ3I L4HuPqCLo3p4sKmDWztXzGIvtJIkeaG3cIh52pKzv9vWY0ADAVIRhb7rnkqU8LtlEFD1 EKGUzt4MXZqOXv4psUQ1W39QsKzyo3MZmIznkEfrjj8lkQxDrHf7BNPrKSleZ1i3pFjI y2Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=WuP56jBI; 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 e26-20020a63545a000000b0049b37046fbcsi20961835pgm.391.2023.01.13.16.58.00; Fri, 13 Jan 2023 16:58:06 -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=WuP56jBI; 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 S231201AbjANAep (ORCPT + 54 others); Fri, 13 Jan 2023 19:34:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230192AbjANAeZ (ORCPT ); Fri, 13 Jan 2023 19:34:25 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBC288DFA; Fri, 13 Jan 2023 16:34:24 -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:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=pZPvdTNpHFNfezOeGlLRl8Ac0qskj02eRl+ESGUnqKc=; b=WuP56jBI/edfwGTjNluugGTW4L aksvsiv9QKCI7E70JreIECaE6XW0+t8D9NNGARJwOmv//6CjmfpLFDzDwoOQjZgO+PVz3LKHxMnRT VAkh39+qVCRycy05wwMfe441svrjnPgYj2gUDLadeHx/BW2zSb4QP9SwiRO2xHf9gq5k/juKPOY6v Qywy55Jm5KvR5KpgT9aKtC9im8xYumctTO5VjbwwQHy4N3W7RxDickaYNOlvLv6gG58uGc6/FJawM 4pA+1g+CC3F/UEpq2q2rdjDbCQiaFDLWCU2fo+rfN1w4eL+UCpuVXBzF+0F4RwVZyXAT010Csml0A Ep+uRmgA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGUUs-004tvv-Pm; Sat, 14 Jan 2023 00:34:10 +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 00/24] vfs: provide automatic kernel freeze / resume Date: Fri, 13 Jan 2023 16:33:45 -0800 Message-Id: <20230114003409.1168311-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 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 Darrick J. Wong poked me about the status of the fs freez work, he's right, it's been too long since the last spin. The last v2 attempt happened in April 2021 [0], this just takes the feedback from Christoph and spins it again. I've only done basic build tests on x86_64, and haven't yet run time tested the stuff, but given the size of this set its better to review early before getting stuck on details. So this is what I've ended up with so far. Please help me paint the bike shed, and figure out the stuff perhaps I had not considered yet. The locking stuff is really the important thing here. I'd like to re-iterate that tons of areas of the kernel are using the kthread freezer stuff for things it probably has no reason to use it, so once we remove this from the fs, it should be easy to start trimming this from other parts of the kernel. The kthread freezer stuff was put in place originally stop IO in flight for fs. Other parts of the kernels should have no business using this stuff after all this work is done. [0] https://lore.kernel.org/all/20210417001026.23858-1-mcgrof@kernel.org/ Changes since the last v2: * instead of having different semantics for lock / unlocked freeze and thaw calls, this unifies the semantics by requiring the lock prior to freeze / thaw * uses grab_active_super() now in all all places which need to freeze or thaw, this includes filesystems, this is to match the locking requirements, and so to not add new heuristics over defining if the superblock might be in a good state for freeze/thaw. * drops SB_FREEZE_COMPLETE_AUTO in favor of just checking for a flag to be able to determine if userspace initiated the freeze or if its auto (by the kernel pm) * folded the pm calls for the VFS so that instead of one call which has a one-liner with two routines, we use the same one-liner on the pm side of things. * split the FS stuff by using a enw temporary flag, so to enable easier review of the FS changes * more filesystems use the freezer API now so this also converts them over * adjusted the coccinelle rule to use the new flag and in the end removes it This is all here too: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20231010-fs-freeze-v5 Luis Chamberlain (24): fs: unify locking semantics for fs freeze / thaw fs: add frozen sb state helpers fs: distinguish between user initiated freeze and kernel initiated freeze fs: add iterate_supers_excl() and iterate_supers_reverse_excl() fs: add automatic kernel fs freeze / thaw and remove kthread freezing xfs: replace kthread freezing with auto fs freezing btrfs: replace kthread freezing with auto fs freezing ext4: replace kthread freezing with auto fs freezing f2fs: replace kthread freezing with auto fs freezing cifs: replace kthread freezing with auto fs freezing gfs2: replace kthread freezing with auto fs freezing jfs: replace kthread freezing with auto fs freezing nilfs2: replace kthread freezing with auto fs freezing nfs: replace kthread freezing with auto fs freezing nfsd: replace kthread freezing with auto fs freezing ubifs: replace kthread freezing with auto fs freezing ksmbd: replace kthread freezing with auto fs freezing jffs2: replace kthread freezing with auto fs freezing jbd2: replace kthread freezing with auto fs freezing coredump: drop freezer usage ecryptfs: replace kthread freezing with auto fs freezing fscache: replace kthread freezing with auto fs freezing lockd: replace kthread freezing with auto fs freezing fs: remove FS_AUTOFREEZE block/bdev.c | 9 +- fs/btrfs/disk-io.c | 4 +- fs/btrfs/scrub.c | 2 +- fs/cifs/cifsfs.c | 10 +- fs/cifs/connect.c | 8 -- fs/cifs/dfs_cache.c | 2 +- fs/coredump.c | 2 +- fs/ecryptfs/kthread.c | 1 - fs/ext4/ext4_jbd2.c | 2 +- fs/ext4/super.c | 3 - fs/f2fs/gc.c | 12 +- fs/f2fs/segment.c | 6 +- fs/fscache/main.c | 2 +- fs/gfs2/glock.c | 6 +- fs/gfs2/glops.c | 2 +- fs/gfs2/log.c | 2 - fs/gfs2/main.c | 4 +- fs/gfs2/quota.c | 2 - fs/gfs2/super.c | 11 +- fs/gfs2/sys.c | 12 +- fs/gfs2/util.c | 7 +- fs/ioctl.c | 14 ++- fs/jbd2/journal.c | 54 ++++----- fs/jffs2/background.c | 3 +- fs/jfs/jfs_logmgr.c | 11 +- fs/jfs/jfs_txnmgr.c | 31 ++---- fs/ksmbd/connection.c | 3 - fs/ksmbd/transport_tcp.c | 2 - fs/lockd/clntproc.c | 1 - fs/lockd/svc.c | 3 - fs/nfs/callback.c | 4 - fs/nfsd/nfssvc.c | 2 - fs/nilfs2/segment.c | 48 ++++---- fs/quota/quota.c | 4 +- fs/super.c | 232 ++++++++++++++++++++++++++++++++------- fs/ubifs/commit.c | 4 - fs/xfs/xfs_log.c | 3 +- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_mru_cache.c | 2 +- fs/xfs/xfs_pwork.c | 2 +- fs/xfs/xfs_super.c | 14 +-- fs/xfs/xfs_trans.c | 3 +- fs/xfs/xfs_trans_ail.c | 3 - include/linux/fs.h | 53 ++++++++- kernel/power/process.c | 15 ++- 45 files changed, 393 insertions(+), 229 deletions(-) -- 2.35.1