Skip to contentSkip to conversation

Fix udev synchronization for no-locking mode

PATCH New Zdenek Kabelac 4 participants 4 messages Jan 31, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Fix udev synchronization for no-locking mode

Instead of implicitly syncing udev operation in clustered and file locking code - call syncing directly in lock_vol when the operation unlocks VG

Currently problem is missing implicit fs_unlock() in the no_locking code. This is used with --sysinit on read-only filesystem. In this case vgchange -ay could exit before all udev nodes are properly synchronised and may cause problems with accessing such node right after vgchange --sysinint command is finished.

---
 daemons/clvmd/clvmd-command.c |    1 -
 lib/locking/file_locking.c    |    1 -
 lib/locking/locking.c         |    4 ++++
 3 files changed, 4 insertions(+), 2 deletions(-)
daemons/clvmd/clvmd-command.c +0 -1
index 3872702..6d0dee4 100644
@@ -217,7 +217,6 @@ static int lock_vg(struct local_client *client)
 	if (lkid == 0)
 	    return EINVAL;
 
-	lvm_do_fs_unlock(); /* Wait for devices */
 	status = sync_unlock(lockname, lkid);
 	if (status)
 	    status = errno;
lib/locking/file_locking.c +0 -1
index 0c8bbed..68b0420 100644
@@ -215,7 +215,6 @@ static int _lock_file(const char *file, uint32_t flags)
 		state = 'W';
 		break;
 	case LCK_UNLOCK:
-		fs_unlock(); /* Wait until devices are available */
 		return _release_lock(file, 1);
 	default:
 		log_error("Unrecognised lock type: %d", flags & LCK_TYPE_MASK);
lib/locking/locking.c +4 -0
index 645f25d..c923610 100644
@@ -442,6 +442,10 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
 		/* If LVM1 driver knows about the VG, it can't be accessed. */
 		if (!check_lvm1_vg_inactive(cmd, vol))
 			return_0;
+
+		/* Before unlocking VG wait until devices are available. */
+		if ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)
+			sync_local_dev_names(cmd);
 		break;
 	case LCK_LV:
 		/* All LV locks are non-blocking. */
Signature · 1 line
1.7.3.5
#2 lore raw

PATCH 1/1 Fix udev synchronization for no-locking mode

Hi,

looks OK, although one thing is definitely puzzling: the udev wait is mentioned in 3 places (2 removals and 1 addition) in the patch:
nevertheless, no two places agree on which function to use for that. It'd be good to know why is that? (I can sort of understand that clvmd has a wrapper, but the removed functions still don't agree with the added one.)

Other than that, ack.

On a second thought: are we sure this is not going to break clvmd? Please double-check that. There was trouble with that recently, IIRC.

Quoted 1 line · Zdenek Kabelac
Quoted 39 lines
daemons/clvmd/clvmd-command.c +0 -1
index 3872702..6d0dee4 100644
@@ -217,7 +217,6 @@ static int lock_vg(struct local_client *client)
 	if (lkid == 0)
 	    return EINVAL;
 
-	lvm_do_fs_unlock(); /* Wait for devices */
 	status = sync_unlock(lockname, lkid);
 	if (status)
 	    status = errno;
lib/locking/file_locking.c +0 -1
index 0c8bbed..68b0420 100644
@@ -215,7 +215,6 @@ static int _lock_file(const char *file, uint32_t flags)
 		state = 'W';
 		break;
 	case LCK_UNLOCK:
-		fs_unlock(); /* Wait until devices are available */
 		return _release_lock(file, 1);
 	default:
 		log_error("Unrecognised lock type: %d", flags & LCK_TYPE_MASK);
lib/locking/locking.c +4 -0
index 645f25d..c923610 100644
@@ -442,6 +442,10 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
 		/* If LVM1 driver knows about the VG, it can't be accessed. */
 		if (!check_lvm1_vg_inactive(cmd, vol))
 			return_0;
+
+		/* Before unlocking VG wait until devices are available. */
+		if ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)
+			sync_local_dev_names(cmd);
 		break;
 	case LCK_LV:
 		/* All LV locks are non-blocking. */
#3 lore raw

PATCH 1/1 Fix udev synchronization for no-locking mode

Quoted 2 lines · Petr Rockai

On a second thought: are we sure this is not going to break clvmd? Please double-check that. There was trouble with that recently, IIRC.

...seems it's working fine (no locking/file locking/cluster locking). The nodes are always synced now.

Quoted 2 lines
Quoted 1 line
#4 lore raw

PATCH 1/1 Fix udev synchronization for no-locking mode

In reply to Petr Rockai
Quoted 2 lines · Peter Rockai

nevertheless, no two places agree on which function to use for that.

Indeed - can this be fixed without a recursive lock_vol call?

Alasdair