Skip to contentSkip to conversation

ocfs2:freeze-thaw: add freeze cluster lock

PATCH New Wengang Wang 2 participants 3 messages Jan 9, 2010 – Jan 15, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ocfs2:freeze-thaw: add freeze cluster lock

add cluster lock for freeze/thaw.
change dlm version from 1.0 to 1.1

---
 fs/ocfs2/dlm/dlmdomain.c |    6 +++++-
 fs/ocfs2/dlmglue.c       |   28 ++++++++++++++++++++++++++++
 fs/ocfs2/dlmglue.h       |    2 ++
 fs/ocfs2/ocfs2.h         |    1 +
 fs/ocfs2/ocfs2_lockid.h  |    5 +++++
 5 files changed, 41 insertions(+), 1 deletions(-)
fs/ocfs2/dlm/dlmdomain.c +5 -1
index 0334000..6e8bcb6 100644
@@ -128,10 +128,14 @@ static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events);
  * will have a negotiated version with the same major number and a minor
  * number equal or smaller.  The dlm_ctxt->dlm_locking_proto field should
  * be used to determine what a running domain is actually using.
+ *
+ * dlm protocal history:
+ * 1.0:	base
+ * 1.1:	freeze lock support added
  */
 static const struct dlm_protocol_version dlm_protocol = {
 	.pv_major = 1,
-	.pv_minor = 0,
+	.pv_minor = 1,
 };
 
 #define DLM_DOMAIN_BACKOFF_MS 200
fs/ocfs2/dlmglue.c +28 -0
index c5e4a49..0caa69e 100644
@@ -2894,6 +2894,34 @@ static const struct file_operations ocfs2_dlm_debug_fops = {
 	.llseek =	seq_lseek,
 };
 
+int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex)
+{
+	int ret;
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (ocfs2_is_hard_readonly(osb))
+		return -EROFS;
+
+	if (ocfs2_mount_local(osb))
+		return 0;
+
+	ret = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
+	if (ret < 0)
+		mlog_errno(ret);
+
+	return ret;
+}
+
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex)
+{
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (!ocfs2_mount_local(osb))
+		ocfs2_cluster_unlock(osb, lockres, level);
+}
+
 static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
 {
 	int ret = 0;
fs/ocfs2/dlmglue.h +2 -0
index d1ce48e..8687b81 100644
@@ -155,6 +155,8 @@ struct ocfs2_refcount_tree;
 int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex);
 void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex);
 
+int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex);
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex);
 
 void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres);
 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
fs/ocfs2/ocfs2.h +1 -0
index d963d86..bf66978 100644
@@ -355,6 +355,7 @@ struct ocfs2_super
 	struct ocfs2_lock_res osb_super_lockres;
 	struct ocfs2_lock_res osb_rename_lockres;
 	struct ocfs2_lock_res osb_nfs_sync_lockres;
+	struct ocfs2_lock_res osb_freeze_lockres;
 	struct ocfs2_dlm_debug *osb_dlm_debug;
 
 	struct dentry *osb_debug_root;
fs/ocfs2/ocfs2_lockid.h +5 -0
index d277aab..3c29924 100644
@@ -50,6 +50,7 @@ enum ocfs2_lock_type {
 	OCFS2_LOCK_TYPE_NFS_SYNC,
 	OCFS2_LOCK_TYPE_ORPHAN_SCAN,
 	OCFS2_LOCK_TYPE_REFCOUNT,
+	OCFS2_LOCK_TYPE_FREEZE,
 	OCFS2_NUM_LOCK_TYPES
 };
 
@@ -93,6 +94,9 @@ static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type)
 		case OCFS2_LOCK_TYPE_REFCOUNT:
 			c = 'T';
 			break;
+		case OCFS2_LOCK_TYPE_FREEZE:
+			c = 'Z';
+			break;
 		default:
 			c = '\0';
 	}
@@ -115,6 +119,7 @@ static char *ocfs2_lock_type_strings[] = {
 	[OCFS2_LOCK_TYPE_NFS_SYNC] = "NFSSync",
 	[OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan",
 	[OCFS2_LOCK_TYPE_REFCOUNT] = "Refcount",
+	[OCFS2_LOCK_TYPE_FREEZE] = "Freeze",
 };
 
 static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type)
Signature · 1 line
1.6.5.2
#1 lore raw

PATCH 1/3 ocfs2:freeze-thaw: add freeze cluster lock

Quoted 7 lines · Wengang Wang

add cluster lock for freeze/thaw.
change dlm version from 1.0 to 1.1

Removed Authored by tags. Just note that these patches were originally authored by Tiger.

Quoted 9 lines
fs/ocfs2/dlm/dlmdomain.c +1 -0
index 0334000..6e8bcb6 100644
@@ -128,10 +128,14 @@ static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events);
  * will have a negotiated version with the same major number and a minor
  * number equal or smaller.  The dlm_ctxt->dlm_locking_proto field should
  * be used to determine what a running domain is actually using.
+ *

fs/ocfs2/dlm/dlmdomain.c static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events); · line 140

Quoted 10 lines
fs/ocfs2/dlm/dlmdomain.c +4 -1
+ * dlm protocal history:
+ * 1.0:	base
+ * 1.1:	freeze lock support added
  */
 static const struct dlm_protocol_version dlm_protocol = {
 	.pv_major = 1,
-	.pv_minor = 0,
+	.pv_minor = 1,
 };
 

Sorry. I told you to change the dlm protocol. But it should be the fs protocol as we are adding a new lock type. We would change the dlm protocol if were were adding a new dlm message type, etc.

Same change. Up the minor by one.

Quoted 71 lines
fs/ocfs2/dlm/dlmdomain.c +0 -0
 #define DLM_DOMAIN_BACKOFF_MS 200
fs/ocfs2/dlmglue.c +28 -0
index c5e4a49..0caa69e 100644
@@ -2894,6 +2894,34 @@ static const struct file_operations ocfs2_dlm_debug_fops = {
 	.llseek =	seq_lseek,
 };
 
+int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex)
+{
+	int ret;
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (ocfs2_is_hard_readonly(osb))
+		return -EROFS;
+
+	if (ocfs2_mount_local(osb))
+		return 0;
+
+	ret = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
+	if (ret < 0)
+		mlog_errno(ret);
+
+	return ret;
+}
+
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex)
+{
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (!ocfs2_mount_local(osb))
+		ocfs2_cluster_unlock(osb, lockres, level);
+}
+
 static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
 {
 	int ret = 0;
fs/ocfs2/dlmglue.h +2 -0
index d1ce48e..8687b81 100644
@@ -155,6 +155,8 @@ struct ocfs2_refcount_tree;
 int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex);
 void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex);
 
+int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex);
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex);
 
 void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres);
 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
fs/ocfs2/ocfs2.h +1 -0
index d963d86..bf66978 100644
@@ -355,6 +355,7 @@ struct ocfs2_super
 	struct ocfs2_lock_res osb_super_lockres;
 	struct ocfs2_lock_res osb_rename_lockres;
 	struct ocfs2_lock_res osb_nfs_sync_lockres;
+	struct ocfs2_lock_res osb_freeze_lockres;
 	struct ocfs2_dlm_debug *osb_dlm_debug;
 
 	struct dentry *osb_debug_root;
fs/ocfs2/ocfs2_lockid.h +0 -0
index d277aab..3c29924 100644

fs/ocfs2/ocfs2_lockid.h enum ocfs2_lock_type { · line 56

Quoted 7 lines
fs/ocfs2/ocfs2_lockid.h +1 -0
@@ -50,6 +50,7 @@ enum ocfs2_lock_type {
 	OCFS2_LOCK_TYPE_NFS_SYNC,
 	OCFS2_LOCK_TYPE_ORPHAN_SCAN,
 	OCFS2_LOCK_TYPE_REFCOUNT,
+	OCFS2_LOCK_TYPE_FREEZE,
 	OCFS2_NUM_LOCK_TYPES
 };
 

OCFS2_LOCK_TYPE_FREEZEFS sounds better.

Quoted 19 lines
fs/ocfs2/ocfs2_lockid.h +4 -0
@@ -93,6 +94,9 @@ static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type)
 		case OCFS2_LOCK_TYPE_REFCOUNT:
 			c = 'T';
 			break;
+		case OCFS2_LOCK_TYPE_FREEZE:
+			c = 'Z';
+			break;
 		default:
 			c = '\0';
 	}
@@ -115,6 +119,7 @@ static char *ocfs2_lock_type_strings[] = {
 	[OCFS2_LOCK_TYPE_NFS_SYNC] = "NFSSync",
 	[OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan",
 	[OCFS2_LOCK_TYPE_REFCOUNT] = "Refcount",
+	[OCFS2_LOCK_TYPE_FREEZE] = "Freeze",
 };
 
 static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type)
#2 lore raw

PATCH 1/3 ocfs2:freeze-thaw: add freeze cluster lock

Hi Sunil,

Quoted 11 lines · Sunil Mushran
Quoted 7 lines · Wengang Wang

add cluster lock for freeze/thaw.
change dlm version from 1.0 to 1.1

Removed Authored by tags. Just note that these patches were originally authored by Tiger.

Ok, sure.

Quoted 26 lines
Quoted 10 lines
fs/ocfs2/dlm/dlmdomain.c +1 -0
index 0334000..6e8bcb6 100644
@@ -128,10 +128,14 @@ static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events);
  * will have a negotiated version with the same major number and a minor
  * number equal or smaller.  The dlm_ctxt->dlm_locking_proto field should
  * be used to determine what a running domain is actually using.
+ *

fs/ocfs2/dlm/dlmdomain.c static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events); · line 140

Quoted 10 lines
fs/ocfs2/dlm/dlmdomain.c +4 -1
+ * dlm protocal history:
+ * 1.0:	base
+ * 1.1:	freeze lock support added
  */
 static const struct dlm_protocol_version dlm_protocol = {
 	.pv_major = 1,
-	.pv_minor = 0,
+	.pv_minor = 1,
 };
 

Sorry. I told you to change the dlm protocol. But it should be the fs protocol as we are adding a new lock type. We would change the dlm protocol if were were adding a new dlm message type, etc.

Quoted 1 line

Same change. Up the minor by one.

Ok.

Quoted 67 lines
Quoted 67 lines
fs/ocfs2/dlm/dlmdomain.c +0 -0
  #define DLM_DOMAIN_BACKOFF_MS 200
fs/ocfs2/dlmglue.c +27 -0
index c5e4a49..0caa69e 100644
@@ -2894,6 +2894,34 @@ static const struct file_operations ocfs2_dlm_debug_fops = {
 	.llseek =	seq_lseek,
 };
 +int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex)
+{
+	int ret;
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (ocfs2_is_hard_readonly(osb))
+		return -EROFS;
+
+	if (ocfs2_mount_local(osb))
+		return 0;
+
+	ret = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
+	if (ret < 0)
+		mlog_errno(ret);
+
+	return ret;
+}
+
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex)
+{
+	int level = ex ? LKM_EXMODE : LKM_PRMODE;
+	struct ocfs2_lock_res *lockres = &osb->osb_freeze_lockres;
+
+	if (!ocfs2_mount_local(osb))
+		ocfs2_cluster_unlock(osb, lockres, level);
+}
+
 static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
 {
 	int ret = 0;
fs/ocfs2/dlmglue.h +1 -0
index d1ce48e..8687b81 100644
@@ -155,6 +155,8 @@ struct ocfs2_refcount_tree;
 int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex);
 void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex);
 +int ocfs2_freeze_lock(struct ocfs2_super *osb, int ex);
+void ocfs2_freeze_unlock(struct ocfs2_super *osb, int ex);
  void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres);
 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
fs/ocfs2/ocfs2.h +1 -0
index d963d86..bf66978 100644
@@ -355,6 +355,7 @@ struct ocfs2_super
 	struct ocfs2_lock_res osb_super_lockres;
 	struct ocfs2_lock_res osb_rename_lockres;
 	struct ocfs2_lock_res osb_nfs_sync_lockres;
+	struct ocfs2_lock_res osb_freeze_lockres;
 	struct ocfs2_dlm_debug *osb_dlm_debug;
  	struct dentry *osb_debug_root;
fs/ocfs2/ocfs2_lockid.h +0 -0
index d277aab..3c29924 100644
@@ -50,6 +50,7 @@ enum ocfs2_lock_type {
 	OCFS2_LOCK_TYPE_NFS_SYNC,
Quoted 8 lines

fs/ocfs2/ocfs2_lockid.h enum ocfs2_lock_type { · line 56

Quoted 6 lines
fs/ocfs2/ocfs2_lockid.h +1 -0
 	OCFS2_LOCK_TYPE_ORPHAN_SCAN,
 	OCFS2_LOCK_TYPE_REFCOUNT,
+	OCFS2_LOCK_TYPE_FREEZE,
 	OCFS2_NUM_LOCK_TYPES
 };
 

OCFS2_LOCK_TYPE_FREEZEFS sounds better.

Ok.

Quoted 11 lines
Quoted 11 lines
fs/ocfs2/ocfs2_lockid.h +3 -0
@@ -93,6 +94,9 @@ static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type)
 		case OCFS2_LOCK_TYPE_REFCOUNT:
 			c = 'T';
 			break;
+		case OCFS2_LOCK_TYPE_FREEZE:
+			c = 'Z';
+			break;
 		default:
 			c = '\0';
 	}
@@ -115,6 +119,7 @@ static char *ocfs2_lock_type_strings[] = {
Quoted 9 lines

fs/ocfs2/ocfs2_lockid.h static char *ocfs2_lock_type_strings[] = {

Quoted 8 lines
fs/ocfs2/ocfs2_lockid.h +1 -0
 	[OCFS2_LOCK_TYPE_NFS_SYNC] = "NFSSync",
 	[OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan",
 	[OCFS2_LOCK_TYPE_REFCOUNT] = "Refcount",
+	[OCFS2_LOCK_TYPE_FREEZE] = "Freeze",
 };
  static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type 
 type)

I will post the version 2 after all v1 patches commented.

regards,
wengang.