diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-28 14:54:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 20:48:15 -0500 |
commit | 517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cf (patch) | |
tree | 573f1e42c269ab32985511788a612ed3d7a99347 /fs/sysfs/dir.c | |
parent | 2b25a62901a1af654c2604f19592b13742ad1601 (diff) |
sysfs, kernfs: revamp sysfs_dirent active_ref lockdep annotation
Currently, sysfs_dirent active_ref lockdep annotation uses
attribute->[s]key as the lockdep key, which forces
kernfs_create_file_ns() to assume that sysfs_dirent->priv is pointing
to a struct attribute which may not be true for non-sysfs users. This
patch restructures the lockdep annotation such that
* kernfs_ops contains lockdep_key which is used by default for files
created kernfs_create_file_ns().
* kernfs_create_file_ns_key() is introduced which takes an extra @key
argument. The created file will use the specified key for
active_ref lockdep annotation. If NULL is specified, lockdep for
the file is disabled.
* sysfs_add_file_mode_ns() is updated to use
kernfs_create_file_ns_key() with the appropriate key from the
attribute or NULL if ignore_lockdep is set.
This makes the lockdep annotation properly contained in kernfs while
allowing sysfs to cleanly keep its current behavior. This patch
doesn't introduce any behavior differences.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r-- | fs/sysfs/dir.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index e88e9a94a083..8f2d577b5f64 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -150,7 +150,7 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd) | |||
150 | if (!atomic_inc_unless_negative(&sd->s_active)) | 150 | if (!atomic_inc_unless_negative(&sd->s_active)) |
151 | return NULL; | 151 | return NULL; |
152 | 152 | ||
153 | if (likely(!sysfs_ignore_lockdep(sd))) | 153 | if (sd->s_flags & SYSFS_FLAG_LOCKDEP) |
154 | rwsem_acquire_read(&sd->dep_map, 0, 1, _RET_IP_); | 154 | rwsem_acquire_read(&sd->dep_map, 0, 1, _RET_IP_); |
155 | return sd; | 155 | return sd; |
156 | } | 156 | } |
@@ -169,7 +169,7 @@ void sysfs_put_active(struct sysfs_dirent *sd) | |||
169 | if (unlikely(!sd)) | 169 | if (unlikely(!sd)) |
170 | return; | 170 | return; |
171 | 171 | ||
172 | if (likely(!sysfs_ignore_lockdep(sd))) | 172 | if (sd->s_flags & SYSFS_FLAG_LOCKDEP) |
173 | rwsem_release(&sd->dep_map, 1, _RET_IP_); | 173 | rwsem_release(&sd->dep_map, 1, _RET_IP_); |
174 | v = atomic_dec_return(&sd->s_active); | 174 | v = atomic_dec_return(&sd->s_active); |
175 | if (likely(v != SD_DEACTIVATED_BIAS)) | 175 | if (likely(v != SD_DEACTIVATED_BIAS)) |