diff options
author | David Teigland <teigland@redhat.com> | 2010-02-24 12:08:18 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2010-02-24 12:46:53 -0500 |
commit | 7fe2b3190b8b299409f13cf3a6f85c2bd371f8bb (patch) | |
tree | 36af13880f834cd1c7fd92200ebcc33c64d9edf0 /fs/dlm/ast.c | |
parent | b0483e78e5c4c9871fc5541875b3bc006846d46b (diff) |
dlm: fix ordering of bast and cast
When both blocking and completion callbacks are queued for lock,
the dlm would always deliver the completion callback (cast) first.
In some cases the blocking callback (bast) is queued before the
cast, though, and should be delivered first. This patch keeps
track of the order in which they were queued and delivers them
in that order.
This patch also keeps track of the granted mode in the last cast
and eliminates the following bast if the bast mode is compatible
with the preceding cast mode. This happens when a remotely mastered
lock is demoted, e.g. EX->NL, in which case the local node queues
a cast immediately after sending the demote message. In this way
a cast can be queued for a mode, e.g. NL, that makes an in-transit
bast extraneous.
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/ast.c')
-rw-r--r-- | fs/dlm/ast.c | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index dc2ad6008b2d..4314f0d48d85 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-2008 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2010 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, int bastmode) | 36 | void dlm_add_ast(struct dlm_lkb *lkb, int type, int mode) |
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, bastmode); | 39 | dlm_user_add_ast(lkb, type, mode); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
@@ -44,10 +44,21 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode) | |||
44 | if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { | 44 | if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { |
45 | kref_get(&lkb->lkb_ref); | 45 | kref_get(&lkb->lkb_ref); |
46 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); | 46 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); |
47 | lkb->lkb_ast_first = type; | ||
47 | } | 48 | } |
49 | |||
50 | /* sanity check, this should not happen */ | ||
51 | |||
52 | if ((type == AST_COMP) && (lkb->lkb_ast_type & AST_COMP)) | ||
53 | log_print("repeat cast %d castmode %d lock %x %s", | ||
54 | mode, lkb->lkb_castmode, | ||
55 | lkb->lkb_id, lkb->lkb_resource->res_name); | ||
56 | |||
48 | lkb->lkb_ast_type |= type; | 57 | lkb->lkb_ast_type |= type; |
49 | if (bastmode) | 58 | if (type == AST_BAST) |
50 | lkb->lkb_bastmode = bastmode; | 59 | lkb->lkb_bastmode = mode; |
60 | else | ||
61 | lkb->lkb_castmode = mode; | ||
51 | spin_unlock(&ast_queue_lock); | 62 | spin_unlock(&ast_queue_lock); |
52 | 63 | ||
53 | set_bit(WAKE_ASTS, &astd_wakeflags); | 64 | set_bit(WAKE_ASTS, &astd_wakeflags); |
@@ -59,9 +70,9 @@ static void process_asts(void) | |||
59 | struct dlm_ls *ls = NULL; | 70 | struct dlm_ls *ls = NULL; |
60 | struct dlm_rsb *r = NULL; | 71 | struct dlm_rsb *r = NULL; |
61 | struct dlm_lkb *lkb; | 72 | struct dlm_lkb *lkb; |
62 | void (*cast) (void *astparam); | 73 | void (*castfn) (void *astparam); |
63 | void (*bast) (void *astparam, int mode); | 74 | void (*bastfn) (void *astparam, int mode); |
64 | int type = 0, bastmode; | 75 | int type, first, bastmode, castmode, do_bast, do_cast, last_castmode; |
65 | 76 | ||
66 | repeat: | 77 | repeat: |
67 | spin_lock(&ast_queue_lock); | 78 | spin_lock(&ast_queue_lock); |
@@ -75,17 +86,48 @@ repeat: | |||
75 | list_del(&lkb->lkb_astqueue); | 86 | list_del(&lkb->lkb_astqueue); |
76 | type = lkb->lkb_ast_type; | 87 | type = lkb->lkb_ast_type; |
77 | lkb->lkb_ast_type = 0; | 88 | lkb->lkb_ast_type = 0; |
89 | first = lkb->lkb_ast_first; | ||
90 | lkb->lkb_ast_first = 0; | ||
78 | bastmode = lkb->lkb_bastmode; | 91 | bastmode = lkb->lkb_bastmode; |
79 | 92 | castmode = lkb->lkb_castmode; | |
93 | castfn = lkb->lkb_astfn; | ||
94 | bastfn = lkb->lkb_bastfn; | ||
80 | spin_unlock(&ast_queue_lock); | 95 | spin_unlock(&ast_queue_lock); |
81 | cast = lkb->lkb_astfn; | ||
82 | bast = lkb->lkb_bastfn; | ||
83 | |||
84 | if ((type & AST_COMP) && cast) | ||
85 | cast(lkb->lkb_astparam); | ||
86 | 96 | ||
87 | if ((type & AST_BAST) && bast) | 97 | do_cast = (type & AST_COMP) && castfn; |
88 | bast(lkb->lkb_astparam, bastmode); | 98 | do_bast = (type & AST_BAST) && bastfn; |
99 | |||
100 | /* Skip a bast if its blocking mode is compatible with the | ||
101 | granted mode of the preceding cast. */ | ||
102 | |||
103 | if (do_bast) { | ||
104 | if (first == AST_COMP) | ||
105 | last_castmode = castmode; | ||
106 | else | ||
107 | last_castmode = lkb->lkb_castmode_done; | ||
108 | if (dlm_modes_compat(bastmode, last_castmode)) | ||
109 | do_bast = 0; | ||
110 | } | ||
111 | |||
112 | if (first == AST_COMP) { | ||
113 | if (do_cast) | ||
114 | castfn(lkb->lkb_astparam); | ||
115 | if (do_bast) | ||
116 | bastfn(lkb->lkb_astparam, bastmode); | ||
117 | } else if (first == AST_BAST) { | ||
118 | if (do_bast) | ||
119 | bastfn(lkb->lkb_astparam, bastmode); | ||
120 | if (do_cast) | ||
121 | castfn(lkb->lkb_astparam); | ||
122 | } else { | ||
123 | log_error(ls, "bad ast_first %d ast_type %d", | ||
124 | first, type); | ||
125 | } | ||
126 | |||
127 | if (do_cast) | ||
128 | lkb->lkb_castmode_done = castmode; | ||
129 | if (do_bast) | ||
130 | lkb->lkb_bastmode_done = bastmode; | ||
89 | 131 | ||
90 | /* this removes the reference added by dlm_add_ast | 132 | /* this removes the reference added by dlm_add_ast |
91 | and may result in the lkb being freed */ | 133 | and may result in the lkb being freed */ |