aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2011-02-21 07:20:55 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-10-14 10:47:42 -0400
commit4738fa16907a933d72bbcae1b8922dc9330fde92 (patch)
treed0a48980a5269758ba01545b4200c548b30b0909
parent61610420f764acb835af4a450251dbab2ab6d621 (diff)
drbd: use clear_bit_unlock() where appropriate
Some open-coded clear_bit(); smp_mb__after_clear_bit(); should in fact have been smp_mb__before_clear_bit(); clear_bit(); Instead, use clear_bit_unlock() to annotate the intention, and have it do the right thing. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r--drivers/block/drbd/drbd_bitmap.c3
-rw-r--r--drivers/block/drbd/drbd_main.c3
-rw-r--r--include/linux/lru_cache.h3
-rw-r--r--lib/lru_cache.c10
4 files changed, 7 insertions, 12 deletions
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index e8d652f197c3..4be737055718 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -219,8 +219,7 @@ static void bm_page_unlock_io(struct drbd_conf *mdev, int page_nr)
219{ 219{
220 struct drbd_bitmap *b = mdev->bitmap; 220 struct drbd_bitmap *b = mdev->bitmap;
221 void *addr = &page_private(b->bm_pages[page_nr]); 221 void *addr = &page_private(b->bm_pages[page_nr]);
222 clear_bit(BM_PAGE_IO_LOCK, addr); 222 clear_bit_unlock(BM_PAGE_IO_LOCK, addr);
223 smp_mb__after_clear_bit();
224 wake_up(&mdev->bitmap->bm_io_wait); 223 wake_up(&mdev->bitmap->bm_io_wait);
225} 224}
226 225
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 592f0c949fd0..c77e51a40926 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2818,8 +2818,7 @@ static int w_bitmap_io(struct drbd_work *w, int unused)
2818 put_ldev(mdev); 2818 put_ldev(mdev);
2819 } 2819 }
2820 2820
2821 clear_bit(BITMAP_IO, &mdev->flags); 2821 clear_bit_unlock(BITMAP_IO, &mdev->flags);
2822 smp_mb__after_clear_bit();
2823 wake_up(&mdev->misc_wait); 2822 wake_up(&mdev->misc_wait);
2824 2823
2825 if (work->done) 2824 if (work->done)
diff --git a/include/linux/lru_cache.h b/include/linux/lru_cache.h
index 7a71ffad037c..4cceafb0732d 100644
--- a/include/linux/lru_cache.h
+++ b/include/linux/lru_cache.h
@@ -275,8 +275,7 @@ static inline int lc_try_lock(struct lru_cache *lc)
275 */ 275 */
276static inline void lc_unlock(struct lru_cache *lc) 276static inline void lc_unlock(struct lru_cache *lc)
277{ 277{
278 clear_bit(__LC_DIRTY, &lc->flags); 278 clear_bit_unlock(__LC_DIRTY, &lc->flags);
279 smp_mb__after_clear_bit();
280} 279}
281 280
282static inline int lc_is_used(struct lru_cache *lc, unsigned int enr) 281static inline int lc_is_used(struct lru_cache *lc, unsigned int enr)
diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index a07e7268d7ed..9f353f7f41ca 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -44,8 +44,8 @@ MODULE_LICENSE("GPL");
44} while (0) 44} while (0)
45 45
46#define RETURN(x...) do { \ 46#define RETURN(x...) do { \
47 clear_bit(__LC_PARANOIA, &lc->flags); \ 47 clear_bit_unlock(__LC_PARANOIA, &lc->flags); \
48 smp_mb__after_clear_bit(); return x ; } while (0) 48 return x ; } while (0)
49 49
50/* BUG() if e is not one of the elements tracked by lc */ 50/* BUG() if e is not one of the elements tracked by lc */
51#define PARANOIA_LC_ELEMENT(lc, e) do { \ 51#define PARANOIA_LC_ELEMENT(lc, e) do { \
@@ -438,8 +438,7 @@ void lc_changed(struct lru_cache *lc, struct lc_element *e)
438 hlist_add_head(&e->colision, lc_hash_slot(lc, lc->new_number)); 438 hlist_add_head(&e->colision, lc_hash_slot(lc, lc->new_number));
439 lc->changing_element = NULL; 439 lc->changing_element = NULL;
440 lc->new_number = LC_FREE; 440 lc->new_number = LC_FREE;
441 clear_bit(__LC_DIRTY, &lc->flags); 441 clear_bit_unlock(__LC_DIRTY, &lc->flags);
442 smp_mb__after_clear_bit();
443 RETURN(); 442 RETURN();
444} 443}
445 444
@@ -463,8 +462,7 @@ unsigned int lc_put(struct lru_cache *lc, struct lc_element *e)
463 /* move it to the front of LRU. */ 462 /* move it to the front of LRU. */
464 list_move(&e->list, &lc->lru); 463 list_move(&e->list, &lc->lru);
465 lc->used--; 464 lc->used--;
466 clear_bit(__LC_STARVING, &lc->flags); 465 clear_bit_unlock(__LC_STARVING, &lc->flags);
467 smp_mb__after_clear_bit();
468 } 466 }
469 RETURN(e->refcnt); 467 RETURN(e->refcnt);
470} 468}