From a2146d6548ff1bf02cf6adc9856e8ed7da1da0c9 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 21 Jul 2011 13:23:48 +0000
Subject: [PATCH] Compare also file size to detect changed config file

Clvmd detects modifed config file before it takes lv_lock.
If the config file is changed rapidly - the change was ignored within
a seocnd ranged.  This patch adds also compare of file size.
So change like some flag for 0 to 1 would pass unnoticed - but
it's quick fix for failing test suite.

FIXME: Implement inotify solution.
---
 WHATS_NEW           | 1 +
 lib/config/config.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index fb261322c..c5ab74430 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Compare also file size to detect changed config file.
 
 Version 2.02.86 - 8th July 2011
 ===============================
diff --git a/lib/config/config.c b/lib/config/config.c
index f6c758959..d7b704259 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -62,6 +62,7 @@ struct cs {
 	struct config_tree cft;
 	struct dm_pool *mem;
 	time_t timestamp;
+	off_t st_size;
 	char *filename;
 	int exists;
 	int keep_open;
@@ -309,6 +310,7 @@ int read_config_file(struct config_tree *cft)
 	}
 
 	c->timestamp = info.st_ctime;
+	c->st_size = info.st_size;
 
 	return r;
 }
@@ -352,7 +354,7 @@ int config_file_changed(struct config_tree *cft)
 	}
 
 	/* Unchanged? */
-	if (c->timestamp == info.st_ctime)
+	if (c->timestamp == info.st_ctime && c->st_size == info.st_size)
 		return 0;
 
       reload: