Skip to content

Commit 76246c9

Browse files
a-darwishPeter Zijlstra
authored andcommitted
NFSv4: 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]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 67b7b64 commit 76246c9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/nfs/nfs4_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct nfs4_state_owner {
117117
unsigned long so_flags;
118118
struct list_head so_states;
119119
struct nfs_seqid_counter so_seqid;
120-
seqcount_t so_reclaim_seqcount;
120+
seqcount_spinlock_t so_reclaim_seqcount;
121121
struct mutex so_delegreturn_mutex;
122122
};
123123

fs/nfs/nfs4state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ nfs4_alloc_state_owner(struct nfs_server *server,
509509
nfs4_init_seqid_counter(&sp->so_seqid);
510510
atomic_set(&sp->so_count, 1);
511511
INIT_LIST_HEAD(&sp->so_lru);
512-
seqcount_init(&sp->so_reclaim_seqcount);
512+
seqcount_spinlock_init(&sp->so_reclaim_seqcount, &sp->so_lock);
513513
mutex_init(&sp->so_delegreturn_mutex);
514514
return sp;
515515
}

0 commit comments

Comments
 (0)