Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

super: use higher-level helper for {freeze,thaw}

It's not necessary to use low-level locking helpers here. Use the
higher-level locking helpers and log if the superblock is dying. Since
the caller is assumed to already hold an active reference it isn't
possible to observe a dying superblock.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+12 -3
+12 -3
fs/super.c
··· 1873 1873 { 1874 1874 int ret; 1875 1875 1876 + /* Since the caller must already have an active reference... */ 1876 1877 atomic_inc(&sb->s_active); 1877 - __super_lock_excl(sb); 1878 + 1879 + /* ...@sb definitely can't be dying. */ 1880 + if (!super_lock_excl(sb)) 1881 + WARN(1, "Dying superblock while freezing!"); 1882 + 1878 1883 if (sb->s_writers.frozen != SB_UNFROZEN) { 1879 1884 deactivate_locked_super(sb); 1880 1885 return -EBUSY; ··· 1901 1896 /* Release s_umount to preserve sb_start_write -> s_umount ordering */ 1902 1897 super_unlock_excl(sb); 1903 1898 sb_wait_write(sb, SB_FREEZE_WRITE); 1904 - __super_lock_excl(sb); 1899 + 1900 + /* We're still holding an active reference. */ 1901 + if (!super_lock_excl(sb)) 1902 + WARN(1, "Dying superblock while freezing!"); 1905 1903 1906 1904 /* Now we go and block page faults... */ 1907 1905 sb->s_writers.frozen = SB_FREEZE_PAGEFAULT; ··· 1987 1979 */ 1988 1980 int thaw_super(struct super_block *sb) 1989 1981 { 1990 - __super_lock_excl(sb); 1982 + if (!super_lock_excl(sb)) 1983 + WARN(1, "Dying superblock while thawing!"); 1991 1984 return thaw_super_locked(sb); 1992 1985 } 1993 1986 EXPORT_SYMBOL(thaw_super);