Re: [PATCH v3 1/2] fs/super: function to prevent super re-use

Christoph Hellwig
2022-05-31T07:24:48Z

On Mon, May 30, 2022 at 11:39:57AM +1000, Daniil Lunev wrote:
> +void retire_super(struct super_block *sb)
> +{
> + down_write(&sb->s_umount);
> + if (sb->s_bdi != &noop_backing_dev_info) {
> + if (sb->s_iflags & SB_I_PERSB_BDI && !(sb->s_iflags & SB_I_RETIRED))

SB_I_PERSB_BDI can't be set for noop_backing_dev_info, so that check
should not be needed. Which also conveniently fixes the overly long
line.

Also this should clear SB_I_PERSB_BDI as the only place that checks
it is the unregistration.

> spin_lock(&sb_lock);
> - /* should be initialized for __put_super_and_need_restart() */

This is a completely unrelated change. While the function is gone
it might be worth to check what it got renamed to or folded in, or
if the initialization is still needed. But all that is for a separate
patch.

> up_write(&sb->s_umount);
> if (sb->s_bdi != &noop_backing_dev_info) {
> - if (sb->s_iflags & SB_I_PERSB_BDI)
> + /* retire should have already unregistered bdi */
> + if (sb->s_iflags & SB_I_PERSB_BDI && !(sb->s_iflags & SB_I_RETIRED))
> bdi_unregister(sb->s_bdi);
> bdi_put(sb->s_bdi);

And once SB_I_PERSB_BDI is dropped when retiring we don't need this
change.