diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2009-12-07 19:34:43 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-12-14 23:46:31 -0500 |
commit | fdb8ebb729bbb640e64028a4f579a02ebc405727 (patch) | |
tree | 9dfca7422cb858cd05208734affab31d980030fe /security/tomoyo/common.h | |
parent | 86fc80f16e8a2449d5827bf1a9838b7fd9f70097 (diff) |
TOMOYO: Use RCU primitives for list operation
Replace list operation with RCU primitives and replace
down_read()/up_read() with srcu_read_lock()/srcu_read_unlock().
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/common.h')
-rw-r--r-- | security/tomoyo/common.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h index bd10f9fa3511..c6f13925472a 100644 --- a/security/tomoyo/common.h +++ b/security/tomoyo/common.h | |||
@@ -269,6 +269,8 @@ struct tomoyo_io_buffer { | |||
269 | int (*write) (struct tomoyo_io_buffer *); | 269 | int (*write) (struct tomoyo_io_buffer *); |
270 | /* Exclusive lock for this structure. */ | 270 | /* Exclusive lock for this structure. */ |
271 | struct mutex io_sem; | 271 | struct mutex io_sem; |
272 | /* Index returned by tomoyo_read_lock(). */ | ||
273 | int reader_idx; | ||
272 | /* The position currently reading from. */ | 274 | /* The position currently reading from. */ |
273 | struct list_head *read_var1; | 275 | struct list_head *read_var1; |
274 | /* Extra variables for reading. */ | 276 | /* Extra variables for reading. */ |
@@ -446,16 +448,28 @@ extern struct tomoyo_domain_info tomoyo_kernel_domain; | |||
446 | * @cookie: the &struct list_head to use as a cookie. | 448 | * @cookie: the &struct list_head to use as a cookie. |
447 | * @head: the head for your list. | 449 | * @head: the head for your list. |
448 | * | 450 | * |
449 | * Same with list_for_each() except that this primitive uses @cookie | 451 | * Same with list_for_each_rcu() except that this primitive uses @cookie |
450 | * so that we can continue iteration. | 452 | * so that we can continue iteration. |
451 | * @cookie must be NULL when iteration starts, and @cookie will become | 453 | * @cookie must be NULL when iteration starts, and @cookie will become |
452 | * NULL when iteration finishes. | 454 | * NULL when iteration finishes. |
453 | */ | 455 | */ |
454 | #define list_for_each_cookie(pos, cookie, head) \ | 456 | #define list_for_each_cookie(pos, cookie, head) \ |
455 | for (({ if (!cookie) \ | 457 | for (({ if (!cookie) \ |
456 | cookie = head; }), \ | 458 | cookie = head; }), \ |
457 | pos = (cookie)->next; \ | 459 | pos = rcu_dereference((cookie)->next); \ |
458 | prefetch(pos->next), pos != (head) || ((cookie) = NULL); \ | 460 | prefetch(pos->next), pos != (head) || ((cookie) = NULL); \ |
459 | (cookie) = pos, pos = pos->next) | 461 | (cookie) = pos, pos = rcu_dereference(pos->next)) |
462 | |||
463 | extern struct srcu_struct tomoyo_ss; | ||
464 | |||
465 | static inline int tomoyo_read_lock(void) | ||
466 | { | ||
467 | return srcu_read_lock(&tomoyo_ss); | ||
468 | } | ||
469 | |||
470 | static inline void tomoyo_read_unlock(int idx) | ||
471 | { | ||
472 | srcu_read_unlock(&tomoyo_ss, idx); | ||
473 | } | ||
460 | 474 | ||
461 | #endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */ | 475 | #endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */ |