diff options
author | David Teigland <teigland@redhat.com> | 2008-12-09 12:55:46 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2008-12-23 11:16:46 -0500 |
commit | fd22a51bcc0b7b76fc729b02316214fd979f9fe1 (patch) | |
tree | e23326bb9df7cf0ee76b3b6b61c82364ff0aed78 /fs/dlm/ast.c | |
parent | 03339696314fffb95dafb349b84243358e945ce6 (diff) |
dlm: improve how bast mode handling
The lkb bastmode value is set in the context of processing the
lock, and read by the dlm_astd thread. Because it's accessed
in these two separate contexts, the writing/reading ought to
be done under a lock. This is simple to do by setting it and
reading it when the lkb is added to and removed from dlm_astd's
callback list which is properly locked.
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/ast.c')
-rw-r--r-- | fs/dlm/ast.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index 09b167df790e..fbe840d09493 100644 --- a/fs/dlm/ast.c +++ b/fs/dlm/ast.c | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -33,10 +33,10 @@ void dlm_del_ast(struct dlm_lkb *lkb) | |||
33 | spin_unlock(&ast_queue_lock); | 33 | spin_unlock(&ast_queue_lock); |
34 | } | 34 | } |
35 | 35 | ||
36 | void dlm_add_ast(struct dlm_lkb *lkb, int type) | 36 | void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode) |
37 | { | 37 | { |
38 | if (lkb->lkb_flags & DLM_IFL_USER) { | 38 | if (lkb->lkb_flags & DLM_IFL_USER) { |
39 | dlm_user_add_ast(lkb, type); | 39 | dlm_user_add_ast(lkb, type, bastmode); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
@@ -46,6 +46,8 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type) | |||
46 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); | 46 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); |
47 | } | 47 | } |
48 | lkb->lkb_ast_type |= type; | 48 | lkb->lkb_ast_type |= type; |
49 | if (bastmode) | ||
50 | lkb->lkb_bastmode = bastmode; | ||
49 | spin_unlock(&ast_queue_lock); | 51 | spin_unlock(&ast_queue_lock); |
50 | 52 | ||
51 | set_bit(WAKE_ASTS, &astd_wakeflags); | 53 | set_bit(WAKE_ASTS, &astd_wakeflags); |
@@ -59,7 +61,7 @@ static void process_asts(void) | |||
59 | struct dlm_lkb *lkb; | 61 | struct dlm_lkb *lkb; |
60 | void (*cast) (void *astparam); | 62 | void (*cast) (void *astparam); |
61 | void (*bast) (void *astparam, int mode); | 63 | void (*bast) (void *astparam, int mode); |
62 | int type = 0, found, bmode; | 64 | int type = 0, found, bastmode; |
63 | 65 | ||
64 | for (;;) { | 66 | for (;;) { |
65 | found = 0; | 67 | found = 0; |
@@ -74,6 +76,7 @@ static void process_asts(void) | |||
74 | list_del(&lkb->lkb_astqueue); | 76 | list_del(&lkb->lkb_astqueue); |
75 | type = lkb->lkb_ast_type; | 77 | type = lkb->lkb_ast_type; |
76 | lkb->lkb_ast_type = 0; | 78 | lkb->lkb_ast_type = 0; |
79 | bastmode = lkb->lkb_bastmode; | ||
77 | found = 1; | 80 | found = 1; |
78 | break; | 81 | break; |
79 | } | 82 | } |
@@ -84,13 +87,12 @@ static void process_asts(void) | |||
84 | 87 | ||
85 | cast = lkb->lkb_astfn; | 88 | cast = lkb->lkb_astfn; |
86 | bast = lkb->lkb_bastfn; | 89 | bast = lkb->lkb_bastfn; |
87 | bmode = lkb->lkb_bastmode; | ||
88 | 90 | ||
89 | if ((type & AST_COMP) && cast) | 91 | if ((type & AST_COMP) && cast) |
90 | cast(lkb->lkb_astparam); | 92 | cast(lkb->lkb_astparam); |
91 | 93 | ||
92 | if ((type & AST_BAST) && bast) | 94 | if ((type & AST_BAST) && bast) |
93 | bast(lkb->lkb_astparam, bmode); | 95 | bast(lkb->lkb_astparam, bastmode); |
94 | 96 | ||
95 | /* this removes the reference added by dlm_add_ast | 97 | /* this removes the reference added by dlm_add_ast |
96 | and may result in the lkb being freed */ | 98 | and may result in the lkb being freed */ |