From: Christoph Hellwig <hch@infradead.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: rafael@kernel.org, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org,
jeyu@kernel.org, ebiederm@xmission.com, mchehab@kernel.org,
keescook@chromium.org, linux-fsdevel@vger.kernel.org,
kernel@tuxforce.de, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC v2 6/6] fs: add automatic kernel fs freeze / thaw and remove kthread freezing
Date: Tue, 20 Apr 2021 13:59:03 +0100 [thread overview]
Message-ID: <20210420125903.GC3604224@infradead.org> (raw)
In-Reply-To: <20210417001026.23858-7-mcgrof@kernel.org>
> This also removes all the superflous freezer calls on all filesystems
> as they are no longer needed as the VFS now performs filesystem
> freezing/thaw if the filesystem has support for it. The filesystem
> therefore is in charge of properly dealing with quiescing of the
> filesystem through its callbacks.
Can you split that out from the main logic change? Maybe even into one
patch per file system?
> +#ifdef CONFIG_PM_SLEEP
> +static bool super_should_freeze(struct super_block *sb)
> +{
> + if (!sb->s_root)
> + return false;
> + if (!(sb->s_flags & MS_BORN))
> + return false;
This is already done in the iterate_supers_excl and
iterate_supers_reverse_excl helpers that this helper is always called
through.
> + /*
> + * We don't freeze virtual filesystems, we skip those filesystems with
> + * no backing device.
> + */
> + if (sb->s_bdi == &noop_backing_dev_info)
> + return false;
Why?
> + /* No need to freeze read-only filesystems */
> + if (sb_rdonly(sb))
> + return false;
freeze_super/thaw_super already takes care of read-only file systems,
and IMHO in a better way.
> + int error = 0;
> +
> + spin_lock(&sb_lock);
> + if (!super_should_freeze(sb))
> + goto out;
> +
> + pr_info("%s (%s): freezing\n", sb->s_type->name, sb->s_id);
> +
> + spin_unlock(&sb_lock);
I don't see how super_should_freeze needs sb_lock. But if it does
the lock should be taken in the function.
> + atomic_inc(&sb->s_active);
Doesn't this need a atomic_inc_not_zero if we're racing with a delayed
unmount?
> + error = freeze_locked_super(sb, false);
> + if (error)
> + atomic_dec(&sb->s_active);
And this really needs something like deactivate_locked_super.
> + spin_lock(&sb_lock);
> + if (error && error != -EBUSY)
> + pr_notice("%s (%s): Unable to freeze, error=%d",
> + sb->s_type->name, sb->s_id, error);
> +
> +out:
> + spin_unlock(&sb_lock);
Huh, what is the point of sb_lock here?
> +int fs_suspend_freeze(void)
> +{
> + return iterate_supers_reverse_excl(fs_suspend_freeze_sb, NULL);
> +}
I'd just fold this helper into its only caller.
> + error = __thaw_super_locked(sb, false);
> + if (!error)
> + atomic_dec(&sb->s_active);
> +
> + spin_lock(&sb_lock);
> + if (error && error != -EBUSY)
> + pr_notice("%s (%s): Unable to unfreeze, error=%d",
> + sb->s_type->name, sb->s_id, error);
> +
> +out:
> + spin_unlock(&sb_lock);
> + return error;
> +}
> +
> +int fs_resume_unfreeze(void)
> +{
> + return iterate_supers_excl(fs_suspend_thaw_sb, NULL);
> +}
Same comments as on the freeze side.
next prev parent reply other threads:[~2021-04-20 13:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-17 0:10 [RFC v2 0/6] vfs: provide automatic kernel freeze / resume Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 1/6] fs: provide unlocked helper for freeze_super() Luis Chamberlain
2021-04-20 12:03 ` Christoph Hellwig
2021-04-17 0:10 ` [RFC v2 2/6] fs: add frozen sb state helpers Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 3/6] fs: add a helper for thaw_super_locked() which does not unlock Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 4/6] fs: distinguish between user initiated freeze and kernel initiated freeze Luis Chamberlain
2021-04-20 12:46 ` Christoph Hellwig
2021-04-17 0:10 ` [RFC v2 5/6] fs: add iterate_supers_excl() and iterate_supers_reverse_excl() Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 6/6] fs: add automatic kernel fs freeze / thaw and remove kthread freezing Luis Chamberlain
2021-04-20 12:59 ` Christoph Hellwig [this message]
2021-04-20 18:47 ` Luis Chamberlain
2023-01-10 2:11 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210420125903.GC3604224@infradead.org \
--to=hch@infradead.org \
--cc=bvanassche@acm.org \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=kernel@tuxforce.de \
--cc=kexec@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mchehab@kernel.org \
--cc=rafael@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).