[Ocfs2-devel] [PATCH 4/4] ocfs2: introduce ext4 MMP feature

heming.zhao at suse.com heming.zhao at suse.com
Sun Jul 31 09:13:56 UTC 2022


On 7/30/22 09:14, Heming Zhao wrote:
> MMP (multiple mount protection) gives filesystem ability to prevent
> from being mounted multiple times.
> 
> For avoiding data corruption when non-clustered and/or clustered mount
> are happening at same time, this commit introduced MMP feature. MMP
> idea is from ext4 MMP (fs/ext4/mmp.c) code. For ocfs2 is a clustered
> fs and also for compatible with existing slotmap feature, I did some
> optimization and modification when porting from ext4 to ocfs2.
> 
> For optimization:
> mmp has a kthread kmmpd-<dev>, which is only created in non-clustered
> mode.
> 
> We set a rule:
> If last mount didn't do unmount, (eg: crash), the next mount MUST be
> same mount type.
> 
> At last, this commit also fix commit c80af0c250c8 ("Revert "ocfs2:
> mount shared volume without ha stack") mentioned issue.
> 
> Signed-off-by: Heming Zhao <heming.zhao at suse.com>
> ---
>   fs/ocfs2/ocfs2.h    |   2 +
>   fs/ocfs2/ocfs2_fs.h |  13 +-
>   fs/ocfs2/slot_map.c | 459 ++++++++++++++++++++++++++++++++++++++++++--
>   fs/ocfs2/slot_map.h |   3 +
>   fs/ocfs2/super.c    |  23 ++-
>   5 files changed, 479 insertions(+), 21 deletions(-)
> ... ...
>   /*C0*/  __le64 s_reserved2[15];		/* Fill out superblock */
> diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
> index 0b0ae3ebb0cf..86a21140ead6 100644
> --- a/fs/ocfs2/slot_map.c
> +++ b/fs/ocfs2/slot_map.c
> ... ...
> +void ocfs2_stop_mmpd(struct ocfs2_super *osb)
> +{
> +	if (osb->mmp_task) {
> +		kthread_stop(osb->mmp_task);
> +		osb->mmp_task = NULL;
> +	}
> +}
> +
> +/*
> + * Protect the filesystem from being mounted more than once.
> + *
> + * This function was inspired by ext4 MMP feature. Because HA stack
> + * helps ocfs2 to manage nodes join/leave, so we only focus on MMP
> + * under nocluster mode.
> + * Another info is ocfs2 only uses slot 0 on nocuster mode.
> + *
> + * es_valid:
> + *  0: not available
> + *  1: valid, cluster mode
> + *  2: valid, nocluster mod> + *
> + * parameters:
> + *  osb: the struct ocfs2_super
> + *  noclustered: under noclustered mount
> + *  slot: prefer slot number

Sorry, above es_valid & parameters comments are outdated. I will remove them on next version.

> + */
> +int ocfs2_multi_mount_protect(struct ocfs2_super *osb, int noclustered)


I forgot to run checkpatch.pl for all 4 patches. And checkpatch.pl reported many
format warning. I prefer these patches as draft version, let's discuss the mmp+noncluster
idea is workable/acceptable. If no one reject these code, I will file v1.

(For test cases, I put them in cover letter.)

Thanks,
Heming



More information about the Ocfs2-devel mailing list