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>

+17 -15
+8 -6
fs/dlm/ast.c
··· 2 2 ******************************************************************************* 3 3 ** 4 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 7 ** This copyrighted material is made available to anyone wishing to use, 8 8 ** modify, copy, or redistribute it subject to the terms and conditions ··· 33 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 38 if (lkb->lkb_flags & DLM_IFL_USER) { 39 - dlm_user_add_ast(lkb, type); 39 + dlm_user_add_ast(lkb, type, bastmode); 40 40 return; 41 41 } 42 42 ··· 46 46 list_add_tail(&lkb->lkb_astqueue, &ast_queue); 47 47 } 48 48 lkb->lkb_ast_type |= type; 49 + if (bastmode) 50 + lkb->lkb_bastmode = bastmode; 49 51 spin_unlock(&ast_queue_lock); 50 52 51 53 set_bit(WAKE_ASTS, &astd_wakeflags); ··· 61 59 struct dlm_lkb *lkb; 62 60 void (*cast) (void *astparam); 63 61 void (*bast) (void *astparam, int mode); 64 - int type = 0, found, bmode; 62 + int type = 0, found, bastmode; 65 63 66 64 for (;;) { 67 65 found = 0; ··· 76 74 list_del(&lkb->lkb_astqueue); 77 75 type = lkb->lkb_ast_type; 78 76 lkb->lkb_ast_type = 0; 77 + bastmode = lkb->lkb_bastmode; 79 78 found = 1; 80 79 break; 81 80 } ··· 87 84 88 85 cast = lkb->lkb_astfn; 89 86 bast = lkb->lkb_bastfn; 90 - bmode = lkb->lkb_bastmode; 91 87 92 88 if ((type & AST_COMP) && cast) 93 89 cast(lkb->lkb_astparam); 94 90 95 91 if ((type & AST_BAST) && bast) 96 - bast(lkb->lkb_astparam, bmode); 92 + bast(lkb->lkb_astparam, bastmode); 97 93 98 94 /* this removes the reference added by dlm_add_ast 99 95 and may result in the lkb being freed */
+2 -2
fs/dlm/ast.h
··· 1 1 /****************************************************************************** 2 2 ******************************************************************************* 3 3 ** 4 - ** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 4 + ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5 5 ** 6 6 ** This copyrighted material is made available to anyone wishing to use, 7 7 ** modify, copy, or redistribute it subject to the terms and conditions ··· 13 13 #ifndef __ASTD_DOT_H__ 14 14 #define __ASTD_DOT_H__ 15 15 16 - void dlm_add_ast(struct dlm_lkb *lkb, int type); 16 + void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 17 17 void dlm_del_ast(struct dlm_lkb *lkb); 18 18 19 19 void dlm_astd_wake(void);
+3 -5
fs/dlm/lock.c
··· 307 307 lkb->lkb_lksb->sb_status = rv; 308 308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; 309 309 310 - dlm_add_ast(lkb, AST_COMP); 310 + dlm_add_ast(lkb, AST_COMP, 0); 311 311 } 312 312 313 313 static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) ··· 320 320 { 321 321 if (is_master_copy(lkb)) 322 322 send_bast(r, lkb, rqmode); 323 - else { 324 - lkb->lkb_bastmode = rqmode; 325 - dlm_add_ast(lkb, AST_BAST); 326 - } 323 + else 324 + dlm_add_ast(lkb, AST_BAST, rqmode); 327 325 } 328 326 329 327 /*
+3 -1
fs/dlm/user.c
··· 175 175 /* we could possibly check if the cancel of an orphan has resulted in the lkb 176 176 being removed and then remove that lkb from the orphans list and free it */ 177 177 178 - void dlm_user_add_ast(struct dlm_lkb *lkb, int type) 178 + void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode) 179 179 { 180 180 struct dlm_ls *ls; 181 181 struct dlm_user_args *ua; ··· 208 208 209 209 ast_type = lkb->lkb_ast_type; 210 210 lkb->lkb_ast_type |= type; 211 + if (bastmode) 212 + lkb->lkb_bastmode = bastmode; 211 213 212 214 if (!ast_type) { 213 215 kref_get(&lkb->lkb_ref);
+1 -1
fs/dlm/user.h
··· 9 9 #ifndef __USER_DOT_H__ 10 10 #define __USER_DOT_H__ 11 11 12 - void dlm_user_add_ast(struct dlm_lkb *lkb, int type); 12 + void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 13 13 int dlm_user_init(void); 14 14 void dlm_user_exit(void); 15 15 int dlm_device_deregister(struct dlm_ls *ls);