From 53fc622b9e829c8e632e45ef8c14f054388759c1 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 20 Dec 2007 16:49:04 -0800 Subject: [PATCH 2/2] ocfs2: cluster aware flock() Hook up ocfs2_flock(), using the new flock lock type in dlmglue.c. A new mount option, "localflocks" is added so that users can revert to old functionality as need be. Signed-off-by: Mark Fasheh --- fs/ocfs2/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'fs/ocfs2/super.c') diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 1104f14c318..4a091f58664 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -153,6 +153,7 @@ enum { Opt_slot, Opt_commit, Opt_localalloc, + Opt_localflocks, Opt_err, }; @@ -170,6 +171,7 @@ static match_table_t tokens = { {Opt_slot, "preferred_slot=%u"}, {Opt_commit, "commit=%u"}, {Opt_localalloc, "localalloc=%d"}, + {Opt_localflocks, "localflocks"}, {Opt_err, NULL} }; @@ -848,6 +850,20 @@ static int ocfs2_parse_options(struct super_block *sb, if (option >= 0 && (option <= ocfs2_local_alloc_size(sb) * 8)) mopt->localalloc_opt = option; break; + case Opt_localflocks: + /* + * Changing this during remount could race + * flock() requests, or "unbalance" existing + * ones (e.g., a lock is taken in one mode but + * dropped in the other). If users care enough + * to flip locking modes during remount, we + * could add a "local" flag to individual + * flock structures for proper tracking of + * state. + */ + if (!is_remount) + mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS; + break; default: mlog(ML_ERROR, "Unrecognized mount option \"%s\" " @@ -903,6 +919,9 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) if (osb->local_alloc_size != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE) seq_printf(s, ",localalloc=%d", osb->local_alloc_size); + if (opts & OCFS2_MOUNT_LOCALFLOCKS) + seq_printf(s, ",localflocks,"); + return 0; } -- cgit v1.2.3