Commit 1c520dfbf391e1617ef61553f815b8006a066c44

Authored by Joel Becker
1 parent 3fe0344faf

ocfs2: Provide the ocfs2_dlm_lvb_valid() stack API.

The Lock Value Block (LVB) of a DLM lock can be lost when nodes die and
the DLM cannot reconstruct its state.  Clients of the DLM need to know
this.

ocfs2's internal DLM, o2dlm, explicitly zeroes out the LVB when it loses
track of the state.  This is not a standard behavior, but ocfs2 has
always relied on it.  Thus, an o2dlm LVB is always "valid".

ocfs2 now supports both o2dlm and fs/dlm via the stack glue.  When
fs/dlm loses track of an LVBs state, it sets a flag
(DLM_SBF_VALNOTVALID) on the Lock Status Block (LKSB).  The contents of
the LVB may be garbage or merely stale.

ocfs2 doesn't want to try to guess at the validity of the stale LVB.
Instead, it should be checking the VALNOTVALID flag.  As this is the
'standard' way of treating LVBs, we will promote this behavior.

We add a stack glue API ocfs2_dlm_lvb_valid().  It returns non-zero when
the LVB is valid.  o2dlm will always return valid, while fs/dlm will
check VALNOTVALID.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Acked-by: Mark Fasheh <mfasheh@suse.com>

Showing 5 changed files with 38 additions and 9 deletions Side-by-side Diff

... ... @@ -1989,7 +1989,8 @@
1989 1989 {
1990 1990 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
1991 1991  
1992   - if (lvb->lvb_version == OCFS2_LVB_VERSION
  1992 + if (ocfs2_dlm_lvb_valid(&lockres->l_lksb)
  1993 + && lvb->lvb_version == OCFS2_LVB_VERSION
1993 1994 && be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation)
1994 1995 return 1;
1995 1996 return 0;
... ... @@ -2382,7 +2383,8 @@
2382 2383 return status;
2383 2384  
2384 2385 lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
2385   - if (lvb->lvb_version == OCFS2_ORPHAN_LVB_VERSION)
  2386 + if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) &&
  2387 + lvb->lvb_version == OCFS2_ORPHAN_LVB_VERSION)
2386 2388 *seqno = be32_to_cpu(lvb->lvb_os_seqno);
2387 2389 return status;
2388 2390 }
... ... @@ -3627,7 +3629,8 @@
3627 3629 struct ocfs2_global_disk_dqinfo *gdinfo;
3628 3630 int status = 0;
3629 3631  
3630   - if (lvb->lvb_version == OCFS2_QINFO_LVB_VERSION) {
  3632 + if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) &&
  3633 + lvb->lvb_version == OCFS2_QINFO_LVB_VERSION) {
3631 3634 info->dqi_bgrace = be32_to_cpu(lvb->lvb_bgrace);
3632 3635 info->dqi_igrace = be32_to_cpu(lvb->lvb_igrace);
3633 3636 oinfo->dqi_syncms = be32_to_cpu(lvb->lvb_syncms);
fs/ocfs2/stack_o2cb.c
... ... @@ -236,6 +236,16 @@
236 236 return dlm_status_to_errno(lksb->lksb_o2dlm.status);
237 237 }
238 238  
  239 +/*
  240 + * o2dlm aways has a "valid" LVB. If the dlm loses track of the LVB
  241 + * contents, it will zero out the LVB. Thus the caller can always trust
  242 + * the contents.
  243 + */
  244 +static int o2cb_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
  245 +{
  246 + return 1;
  247 +}
  248 +
239 249 static void *o2cb_dlm_lvb(union ocfs2_dlm_lksb *lksb)
240 250 {
241 251 return (void *)(lksb->lksb_o2dlm.lvb);
... ... @@ -354,6 +364,7 @@
354 364 .dlm_lock = o2cb_dlm_lock,
355 365 .dlm_unlock = o2cb_dlm_unlock,
356 366 .lock_status = o2cb_dlm_lock_status,
  367 + .lvb_valid = o2cb_dlm_lvb_valid,
357 368 .lock_lvb = o2cb_dlm_lvb,
358 369 .dump_lksb = o2cb_dump_lksb,
359 370 };
fs/ocfs2/stack_user.c
... ... @@ -738,6 +738,13 @@
738 738 return lksb->lksb_fsdlm.sb_status;
739 739 }
740 740  
  741 +static int user_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
  742 +{
  743 + int invalid = lksb->lksb_fsdlm.sb_flags & DLM_SBF_VALNOTVALID;
  744 +
  745 + return !invalid;
  746 +}
  747 +
741 748 static void *user_dlm_lvb(union ocfs2_dlm_lksb *lksb)
742 749 {
743 750 if (!lksb->lksb_fsdlm.sb_lvbptr)
... ... @@ -873,6 +880,7 @@
873 880 .dlm_lock = user_dlm_lock,
874 881 .dlm_unlock = user_dlm_unlock,
875 882 .lock_status = user_dlm_lock_status,
  883 + .lvb_valid = user_dlm_lvb_valid,
876 884 .lock_lvb = user_dlm_lvb,
877 885 .plock = user_plock,
878 886 .dump_lksb = user_dlm_dump_lksb,
fs/ocfs2/stackglue.c
... ... @@ -6,7 +6,7 @@
6 6 * Code which implements an OCFS2 specific interface to underlying
7 7 * cluster stacks.
8 8 *
9   - * Copyright (C) 2007 Oracle. All rights reserved.
  9 + * Copyright (C) 2007, 2009 Oracle. All rights reserved.
10 10 *
11 11 * This program is free software; you can redistribute it and/or
12 12 * modify it under the terms of the GNU General Public
... ... @@ -271,11 +271,12 @@
271 271 }
272 272 EXPORT_SYMBOL_GPL(ocfs2_dlm_lock_status);
273 273  
274   -/*
275   - * Why don't we cast to ocfs2_meta_lvb? The "clean" answer is that we
276   - * don't cast at the glue level. The real answer is that the header
277   - * ordering is nigh impossible.
278   - */
  274 +int ocfs2_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
  275 +{
  276 + return active_stack->sp_ops->lvb_valid(lksb);
  277 +}
  278 +EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb_valid);
  279 +
279 280 void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb)
280 281 {
281 282 return active_stack->sp_ops->lock_lvb(lksb);
fs/ocfs2/stackglue.h
... ... @@ -186,6 +186,11 @@
186 186 int (*lock_status)(union ocfs2_dlm_lksb *lksb);
187 187  
188 188 /*
  189 + * Return non-zero if the LVB is valid.
  190 + */
  191 + int (*lvb_valid)(union ocfs2_dlm_lksb *lksb);
  192 +
  193 + /*
189 194 * Pull the lvb pointer off of the stack-specific lksb.
190 195 */
191 196 void *(*lock_lvb)(union ocfs2_dlm_lksb *lksb);
... ... @@ -252,6 +257,7 @@
252 257 struct ocfs2_lock_res *astarg);
253 258  
254 259 int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb);
  260 +int ocfs2_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb);
255 261 void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb);
256 262 void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb);
257 263