Skip to contentSkip to conversation

use atomic_dec_return() instead of atomic_dec() and atomic_read()

PATCH New kedacomkernel 1 participant 1 message Feb 29, 2012 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use atomic_dec_return() instead of atomic_dec() and atomic_read()

From ebdcb976dc5c7aa992f8bd682babffbbb143de18 Mon Sep 17 00:00:00 2001
From: majianpeng <[email protected]>
Date: Wed, 29 Feb 2012 15:05:17 +0800
Subject: [PATCH] md:use atomic_dec_return() instead of atomic_dec() and
atomic_read().

---
 drivers/md/raid5.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/md/raid5.c +3 -5
index 360f2b9..9b58d05 100644
@@ -208,11 +208,9 @@ static void __release_stripe(struct r5conf *conf, struct stripe_head *sh)
 			md_wakeup_thread(conf->mddev->thread);
 		} else {
 			BUG_ON(stripe_operations_active(sh));
-			if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) {
-				atomic_dec(&conf->preread_active_stripes);
-				if (atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD)
-					md_wakeup_thread(conf->mddev->thread);
-			}
+			if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state) &&
+				(atomic_dec_return(&conf->preread_active_stripes) < IO_THRESHOLD))
+				md_wakeup_thread(conf->mddev->thread);
 			atomic_dec(&conf->active_stripes);
 			if (!test_bit(STRIPE_EXPANDING, &sh->state)) {
 				list_add_tail(&sh->lru, &conf->inactive_list);
Signature · 6 lines
1.7.5.4

 				
--------------
kedacomkernel
2012-02-29