Skip to content

Commit 0a87b25

Browse files
a-darwishPeter Zijlstra
authored andcommitted
raid5: Use sequence counter with associated spinlock
A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2647537 commit 0a87b25

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6935,7 +6935,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
69356935
} else
69366936
goto abort;
69376937
spin_lock_init(&conf->device_lock);
6938-
seqcount_init(&conf->gen_lock);
6938+
seqcount_spinlock_init(&conf->gen_lock, &conf->device_lock);
69396939
mutex_init(&conf->cache_size_mutex);
69406940
init_waitqueue_head(&conf->wait_for_quiescent);
69416941
init_waitqueue_head(&conf->wait_for_stripe);

drivers/md/raid5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ struct r5conf {
589589
int prev_chunk_sectors;
590590
int prev_algo;
591591
short generation; /* increments with every reshape */
592-
seqcount_t gen_lock; /* lock against generation changes */
592+
seqcount_spinlock_t gen_lock; /* lock against generation changes */
593593
unsigned long reshape_checkpoint; /* Time we last updated
594594
* metadata */
595595
long long min_offset_diff; /* minimum difference between

0 commit comments

Comments
 (0)