Skip to contentSkip to conversation

Add suspend change flag into dm-ioctl.

PATCH In review Milan Broz 2 participants 2 messages Mar 18, 2010 Device mapper

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Add suspend change flag into dm-ioctl.

For some node operation is userspace we need to know if previous suspend state of device really changed.

Patch add new flag to indicate suspend state change.

---
 drivers/md/dm-ioctl.c    |   25 ++++++++++++++++++-------
 include/linux/dm-ioctl.h |   11 ++++++++---
 2 files changed, 26 insertions(+), 10 deletions(-)
drivers/md/dm-ioctl.c +18 -7
index b670922..5d33492 100644
@@ -596,7 +596,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
 	struct dm_table *table;
 
 	param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG |
-			  DM_ACTIVE_PRESENT_FLAG);
+			  DM_SUSPEND_CHANGE_FLAG | DM_ACTIVE_PRESENT_FLAG);
 
 	if (dm_suspended_md(md))
 		param->flags |= DM_SUSPEND_FLAG;
@@ -846,7 +846,7 @@ out:
 
 static int do_suspend(struct dm_ioctl *param)
 {
-	int r = 0;
+	int r = 0, suspended = 0;
 	unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG;
 	struct mapped_device *md;
 
@@ -859,11 +859,17 @@ static int do_suspend(struct dm_ioctl *param)
 	if (param->flags & DM_NOFLUSH_FLAG)
 		suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
 
-	if (!dm_suspended_md(md))
+	if (!dm_suspended_md(md)) {
 		r = dm_suspend(md, suspend_flags);
+		if (!r)
+			suspended = 1;
+	}
 
-	if (!r)
+	if (!r) {
 		r = __dev_status(md, param);
+		if (suspended)
+			param->flags |= DM_SUSPEND_CHANGE_FLAG;
+	}
 
 	dm_put(md);
 	return r;
@@ -871,7 +877,7 @@ static int do_suspend(struct dm_ioctl *param)
 
 static int do_resume(struct dm_ioctl *param)
 {
-	int r = 0;
+	int r = 0, resumed = 0;
 	unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG;
 	struct hash_cell *hc;
 	struct mapped_device *md;
@@ -919,16 +925,21 @@ static int do_resume(struct dm_ioctl *param)
 
 	if (dm_suspended_md(md)) {
 		r = dm_resume(md);
-		if (!r)
+		if (!r) {
 			dm_ioctl_uevent(md, KOBJ_CHANGE, param->event_nr,
 					&param->flags);
+			resumed = 1;
+		}
 	}
 
 	if (old_map)
 		dm_table_destroy(old_map);
 
-	if (!r)
+	if (!r) {
 		r = __dev_status(md, param);
+		if (resumed)
+			param->flags |= DM_SUSPEND_CHANGE_FLAG;
+	}
 
 	dm_put(md);
 	return r;
include/linux/dm-ioctl.h +8 -3
index 2c445e1..ae957a3 100644
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
- * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004 - 2010 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -266,9 +266,9 @@ enum {
 #define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR	4
-#define DM_VERSION_MINOR	17
+#define DM_VERSION_MINOR	18
 #define DM_VERSION_PATCHLEVEL	0
-#define DM_VERSION_EXTRA	"-ioctl (2010-03-05)"
+#define DM_VERSION_EXTRA	"-ioctl (2010-03-10)"
 
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */
@@ -321,4 +321,9 @@ enum {
  */
 #define DM_UEVENT_GENERATED_FLAG	(1 << 13) /* Out */
 
+/*
+ * If set, suspend state of device changed from previous state.
+ */
+#define DM_SUSPEND_CHANGE_FLAG		(1 << 14) /* Out */
+
 #endif				/* _LINUX_DM_IOCTL_H */
Signature · 1 line
1.7.0
#1 lore raw
Quoted 3 lines · Milan Broz

For some node operation is userspace we need to know if previous suspend state of device really changed. Patch add new flag to indicate suspend state change.

I'd like more discussion of this one.

(a) Why userspace needs it and the alternatives.
- Is it just an optimisation to save an info ioctl?

(b) A precise definition of the flag in the header file, mentioning 'corner cases' explicitly, and consideration of alternative ways of getting the information out of the kernel. (E.g. Different flag definitions, alternative or generic ways of returning 'previous' state if that is what's needed.)

Alasdair