Skip to content

Commit 2647537

Browse files
a-darwishPeter Zijlstra
authored andcommitted
vfs: 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 025e82b commit 2647537

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

fs/dcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
17461746
dentry->d_lockref.count = 1;
17471747
dentry->d_flags = 0;
17481748
spin_lock_init(&dentry->d_lock);
1749-
seqcount_init(&dentry->d_seq);
1749+
seqcount_spinlock_init(&dentry->d_seq, &dentry->d_lock);
17501750
dentry->d_inode = NULL;
17511751
dentry->d_parent = dentry;
17521752
dentry->d_sb = sb;

fs/fs_struct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
117117
fs->users = 1;
118118
fs->in_exec = 0;
119119
spin_lock_init(&fs->lock);
120-
seqcount_init(&fs->seq);
120+
seqcount_spinlock_init(&fs->seq, &fs->lock);
121121
fs->umask = old->umask;
122122

123123
spin_lock(&old->lock);
@@ -163,6 +163,6 @@ EXPORT_SYMBOL(current_umask);
163163
struct fs_struct init_fs = {
164164
.users = 1,
165165
.lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
166-
.seq = SEQCNT_ZERO(init_fs.seq),
166+
.seq = SEQCNT_SPINLOCK_ZERO(init_fs.seq, &init_fs.lock),
167167
.umask = 0022,
168168
};

include/linux/dcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extern struct dentry_stat_t dentry_stat;
8989
struct dentry {
9090
/* RCU lookup touched fields */
9191
unsigned int d_flags; /* protected by d_lock */
92-
seqcount_t d_seq; /* per dentry seqlock */
92+
seqcount_spinlock_t d_seq; /* per dentry seqlock */
9393
struct hlist_bl_node d_hash; /* lookup hash list */
9494
struct dentry *d_parent; /* parent directory */
9595
struct qstr d_name;

include/linux/fs_struct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
struct fs_struct {
1010
int users;
1111
spinlock_t lock;
12-
seqcount_t seq;
12+
seqcount_spinlock_t seq;
1313
int umask;
1414
int in_exec;
1515
struct path root, pwd;

0 commit comments

Comments
 (0)