From 4b3981d2c9b4cafa24398765b3d0c8a4d45d43b1 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Fri, 16 Jan 2015 14:26:45 +0530 Subject: cluster/dht: Fix incorrect updates to parent times Backport of: http://review.gluster.org/9457 In directory write FOPs, as far as updates to timestamps associated with parent by DHT is concerned, there are three possibilities: a) time (in sec) gotten from child of DHT < time (in sec) in inode ctx b) time (in sec) gotten from child of DHT = time (in sec) in inode ctx c) time (in sec) gotten from child of DHT > time (in sec) in inode ctx In case (c), for time in nsecs, it is the value returned by DHT's child that must be selected. But what DHT_UPDATE_TIME ends up doing is to choose the maximum of (time in nsec gotten from DHT's child, time in nsec in inode ctx). Change-Id: I1388e374c8a2029f3b8919380e68620e7591bde6 BUG: 1186121 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/9496 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Shyamsundar Ranganathan Reviewed-by: Niels de Vos --- xlators/cluster/dht/src/dht-common.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'xlators/cluster/dht/src/dht-common.h') diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index b9a696bb628..d421f29314d 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -417,15 +417,14 @@ typedef enum { } while (0) #define DHT_UPDATE_TIME(ctx_sec, ctx_nsec, new_sec, new_nsec, inode, post) do {\ - int32_t sec = 0; \ - sec = new_sec; \ LOCK (&inode->lock); \ { \ - new_sec = max(new_sec, ctx_sec); \ - if (sec < new_sec) \ - new_nsec = ctx_nsec; \ - if (sec == new_sec) \ + if (ctx_sec == new_sec) \ new_nsec = max (new_nsec, ctx_nsec); \ + else if (ctx_sec > new_sec) { \ + new_sec = ctx_sec; \ + new_nsec = ctx_nsec; \ + } \ if (post) { \ ctx_sec = new_sec; \ ctx_nsec = new_nsec; \ -- cgit