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/sysfs.h | |
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/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index c86456c9b19e..e93f8b845611 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -92,43 +92,13 @@ struct sysfs_dirent { | |||
92 | #define SYSFS_FLAG_NS 0x0020 | 92 | #define SYSFS_FLAG_NS 0x0020 |
93 | #define SYSFS_FLAG_HAS_SEQ_SHOW 0x0040 | 93 | #define SYSFS_FLAG_HAS_SEQ_SHOW 0x0040 |
94 | #define SYSFS_FLAG_HAS_MMAP 0x0080 | 94 | #define SYSFS_FLAG_HAS_MMAP 0x0080 |
95 | #define SYSFS_FLAG_LOCKDEP 0x0100 | ||
95 | 96 | ||
96 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) | 97 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) |
97 | { | 98 | { |
98 | return sd->s_flags & SYSFS_TYPE_MASK; | 99 | return sd->s_flags & SYSFS_TYPE_MASK; |
99 | } | 100 | } |
100 | 101 | ||
101 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
102 | |||
103 | #define sysfs_dirent_init_lockdep(sd) \ | ||
104 | do { \ | ||
105 | struct attribute *attr = sd->priv; \ | ||
106 | struct lock_class_key *key = attr->key; \ | ||
107 | if (!key) \ | ||
108 | key = &attr->skey; \ | ||
109 | \ | ||
110 | lockdep_init_map(&sd->dep_map, "s_active", key, 0); \ | ||
111 | } while (0) | ||
112 | |||
113 | /* Test for attributes that want to ignore lockdep for read-locking */ | ||
114 | static inline bool sysfs_ignore_lockdep(struct sysfs_dirent *sd) | ||
115 | { | ||
116 | struct attribute *attr = sd->priv; | ||
117 | |||
118 | return sysfs_type(sd) == SYSFS_KOBJ_ATTR && attr->ignore_lockdep; | ||
119 | } | ||
120 | |||
121 | #else | ||
122 | |||
123 | #define sysfs_dirent_init_lockdep(sd) do {} while (0) | ||
124 | |||
125 | static inline bool sysfs_ignore_lockdep(struct sysfs_dirent *sd) | ||
126 | { | ||
127 | return true; | ||
128 | } | ||
129 | |||
130 | #endif | ||
131 | |||
132 | /* | 102 | /* |
133 | * Context structure to be used while adding/removing nodes. | 103 | * Context structure to be used while adding/removing nodes. |
134 | */ | 104 | */ |