Skip to contentSkip to conversation

jfs: serialize remount option snapshots

PATCH New Cen Zhang 1 participant 1 message May 5 JFS filesystem

lore
Share & tools
lore

Cen Zhang

author
#0 lore raw

PATCH 1/1 jfs: serialize remount option snapshots

JFS initializes a reconfigure fs_context by copying the current superblock mount-option state before the VFS takes sb->s_umount for the actual reconfigure operation. Another remount can therefore update the JFS option fields in jfs_reconfigure() while jfs_init_options() is copying them.

The affected fields are copied as a group so that unspecified remount options inherit the current state. Reading them concurrently with the publisher can create a mixed snapshot that never existed as a complete JFS option state, for example combining a discard flag from one remount with a minblks_trim value from another.

Add a small JFS-private mutex and use it only around the remount option snapshot and publication of the scalar option fields. The existing VFS superblock lock continues to serialize the reconfigure operation itself; this mutex covers the earlier context-initialization gap without taking sb->s_umount recursively.

---
 fs/jfs/jfs_incore.h |  1 +
 fs/jfs/super.c      | 53 +++++++++++++++++++++++++++++----------------
 2 files changed, 35 insertions(+), 19 deletions(-)
fs/jfs/jfs_incore.h +1 -0
index 5aaafed..b222468 100644
@@ -189,6 +189,7 @@ struct jfs_sb_info {
 	/* Formerly in ipbmap */
 	struct bmap	*bmap;		/* incore bmap descriptor	*/
 	struct nls_table *nls_tab;	/* current codepage		*/
+	struct mutex	remount_mutex;	/* serializes scalar option copy/update */
 	struct inode *direct_inode;	/* metadata inode */
 	uint		state;		/* mount/recovery state	*/
 	unsigned long	flag;		/* mount time flags */
fs/jfs/super.c +34 -19

111 lines not on this page · raw message