Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [Drbd-dev] [DRBD8.0 PATCH] Updated fix to ensure stale state is not sent if a cluster wide state change is in progress
@ 2008-02-23 20:44 Graham, Simon
  2008-02-25 15:22 ` Philipp Reisner
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Graham, Simon @ 2008-02-23 20:44 UTC (permalink / raw)
  To: drbd-dev


[-- Attachment #1.1: Type: text/plain, Size: 424 bytes --]

This is an addendum to a patch I previously submitted (applied to the
8.0 tree as ID 6e9fdc92) that blocks sending state information if a
cluster wide state change is in progress - there was a hole in this
because the code in drbd_request_state() actually released the drbd
state lock BEFORE updating the state locally leaving a small window
where a request to send state can send the old stale state.

 

Simon


[-- Attachment #1.2: Type: text/html, Size: 3699 bytes --]

[-- Attachment #2: 0001-Close-window-where-old-state-can-be-sent-by-drbd_sen.patch --]
[-- Type: application/octet-stream, Size: 1392 bytes --]

From 1b4149bc5e0775e3f4d8680cffc5a90654467f62 Mon Sep 17 00:00:00 2001
From: Simon P. Graham <Simon.Graham@stratus.com>
Date: Sat, 23 Feb 2008 15:06:42 -0500
Subject: [PATCH] Close window where old state can be sent by drbd_send_state()

A previous change made this routine acquire the drbd_state_lock() to
ensure that it wont be sent when there is a cluster wide state change
in progress. Unfortunately, the code in drbd_request_state released
the lock before updating the local state which means that it was still
possible for drbd_send_state() to send stale data.

This fix sets the local state whilst still holding the state lock.
---
 drbd/drbd_main.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c
index d03ed70..1d717cc 100644
--- a/drbd/drbd_main.c
+++ b/drbd/drbd_main.c
@@ -496,14 +496,18 @@ int _drbd_request_state(drbd_dev* mdev, drbd_state_t mask, drbd_state_t val,
 			if( f & ChgStateVerbose ) print_st_err(mdev,os,ns,rv);
 			return rv;
 		}
+
 		spin_lock_irqsave(&mdev->req_lock,flags);
 		os = mdev->state;
 		ns.i = (os.i & ~mask.i) | val.i;
+		rv = _drbd_set_state(mdev, ns, f);
+
 		drbd_state_unlock(mdev);
 	}
+	else {
+		rv = _drbd_set_state(mdev, ns, f);
+	}
 
-	rv = _drbd_set_state(mdev, ns, f);
-	ns = mdev->state;
 	spin_unlock_irqrestore(&mdev->req_lock,flags);
 
 	return rv;
-- 
1.5.4.rc1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-26 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-23 20:44 [Drbd-dev] [DRBD8.0 PATCH] Updated fix to ensure stale state is not sent if a cluster wide state change is in progress Graham, Simon
2008-02-25 15:22 ` Philipp Reisner
2008-02-25 20:31 ` [Drbd-dev] I/O can hang on primary synctarget after an io error Montrose, Ernest
2008-02-25 21:06   ` Lars Ellenberg
     [not found] ` <BD7042533C2F8943A6A4257A9E31C454F47ACB@EXNA.corp.str atus.com>
2008-02-25 21:53   ` Montrose, Ernest
2008-02-26 12:49     ` Lars Ellenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox