1 From: David Teigland <teigland@redhat.com>
2 commit fd22a51bcc0b7b76fc729b02316214fd979f9fe1
3 Author: David Teigland <teigland@redhat.com>
4 Date: Tue Dec 9 11:55:46 2008 -0600
5 Subject: dlm: improve how bast mode handling
7 The lkb bastmode value is set in the context of processing the
8 lock, and read by the dlm_astd thread. Because it's accessed
9 in these two separate contexts, the writing/reading ought to
10 be done under a lock. This is simple to do by setting it and
11 reading it when the lkb is added to and removed from dlm_astd's
12 callback list which is properly locked.
14 Signed-off-by: David Teigland <teigland@redhat.com>
15 Signed-off-by: Coly Li <coly.li@suse.de>
17 diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
18 index 09b167d..fbe840d 100644
22 *******************************************************************************
24 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
25 -** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
26 +** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
28 ** This copyrighted material is made available to anyone wishing to use,
29 ** modify, copy, or redistribute it subject to the terms and conditions
30 @@ -33,10 +33,10 @@ void dlm_del_ast(struct dlm_lkb *lkb)
31 spin_unlock(&ast_queue_lock);
34 -void dlm_add_ast(struct dlm_lkb *lkb, int type)
35 +void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
37 if (lkb->lkb_flags & DLM_IFL_USER) {
38 - dlm_user_add_ast(lkb, type);
39 + dlm_user_add_ast(lkb, type, bastmode);
43 @@ -46,6 +46,8 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type)
44 list_add_tail(&lkb->lkb_astqueue, &ast_queue);
46 lkb->lkb_ast_type |= type;
48 + lkb->lkb_bastmode = bastmode;
49 spin_unlock(&ast_queue_lock);
51 set_bit(WAKE_ASTS, &astd_wakeflags);
52 @@ -59,7 +61,7 @@ static void process_asts(void)
54 void (*cast) (void *astparam);
55 void (*bast) (void *astparam, int mode);
56 - int type = 0, found, bmode;
57 + int type = 0, found, bastmode;
61 @@ -74,6 +76,7 @@ static void process_asts(void)
62 list_del(&lkb->lkb_astqueue);
63 type = lkb->lkb_ast_type;
64 lkb->lkb_ast_type = 0;
65 + bastmode = lkb->lkb_bastmode;
69 @@ -84,13 +87,12 @@ static void process_asts(void)
71 cast = lkb->lkb_astfn;
72 bast = lkb->lkb_bastfn;
73 - bmode = lkb->lkb_bastmode;
75 if ((type & AST_COMP) && cast)
76 cast(lkb->lkb_astparam);
78 if ((type & AST_BAST) && bast)
79 - bast(lkb->lkb_astparam, bmode);
80 + bast(lkb->lkb_astparam, bastmode);
82 /* this removes the reference added by dlm_add_ast
83 and may result in the lkb being freed */
84 diff --git a/fs/dlm/ast.h b/fs/dlm/ast.h
85 index 6ee276c..1b5fc5f 100644
89 /******************************************************************************
90 *******************************************************************************
92 -** Copyright (C) 2005 Red Hat, Inc. All rights reserved.
93 +** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
95 ** This copyrighted material is made available to anyone wishing to use,
96 ** modify, copy, or redistribute it subject to the terms and conditions
98 #ifndef __ASTD_DOT_H__
99 #define __ASTD_DOT_H__
101 -void dlm_add_ast(struct dlm_lkb *lkb, int type);
102 +void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode);
103 void dlm_del_ast(struct dlm_lkb *lkb);
105 void dlm_astd_wake(void);
106 diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
107 index 724ddac..7b758da 100644
110 @@ -307,7 +307,7 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv)
111 lkb->lkb_lksb->sb_status = rv;
112 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags;
114 - dlm_add_ast(lkb, AST_COMP);
115 + dlm_add_ast(lkb, AST_COMP, 0);
118 static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb)
119 @@ -320,10 +320,8 @@ static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode)
121 if (is_master_copy(lkb))
122 send_bast(r, lkb, rqmode);
124 - lkb->lkb_bastmode = rqmode;
125 - dlm_add_ast(lkb, AST_BAST);
128 + dlm_add_ast(lkb, AST_BAST, rqmode);
132 diff --git a/fs/dlm/user.c b/fs/dlm/user.c
133 index b3832c6..065149e 100644
136 @@ -175,7 +175,7 @@ static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type)
137 /* we could possibly check if the cancel of an orphan has resulted in the lkb
138 being removed and then remove that lkb from the orphans list and free it */
140 -void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
141 +void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
144 struct dlm_user_args *ua;
145 @@ -208,6 +208,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
147 ast_type = lkb->lkb_ast_type;
148 lkb->lkb_ast_type |= type;
150 + lkb->lkb_bastmode = bastmode;
153 kref_get(&lkb->lkb_ref);
154 diff --git a/fs/dlm/user.h b/fs/dlm/user.h
155 index 35eb6a1..1c96864 100644
159 #ifndef __USER_DOT_H__
160 #define __USER_DOT_H__
162 -void dlm_user_add_ast(struct dlm_lkb *lkb, int type);
163 +void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode);
164 int dlm_user_init(void);
165 void dlm_user_exit(void);
166 int dlm_device_deregister(struct dlm_ls *ls);