Whamcloud - gitweb
Merge b_md to HEAD for 0.5.19 release.
[fs/lustre-release.git] / lustre / llite / recover.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Lustre Lite recovery infrastructure.
5  *
6  * Copyright (C) 2002 Cluster File Systems Inc.
7  */
8
9 #define DEBUG_SUBSYSTEM S_LLITE
10
11 #include <linux/lustre_lite.h>
12 #include <linux/lustre_ha.h>
13 #include <linux/lustre_dlm.h>
14 #include <linux/lustre_idl.h>
15
16 static int ll_retry_recovery(struct ptlrpc_connection *conn)
17 {
18         ENTRY;
19         RETURN(0);
20 }
21
22 int ll_recover(struct recovd_data *rd, int phase)
23 {
24         struct ptlrpc_connection *conn = class_rd2conn(rd);
25         struct list_head *tmp;
26
27         LASSERT(conn);
28         ENTRY;
29
30         switch (phase) {
31             case PTLRPC_RECOVD_PHASE_PREPARE:
32             case PTLRPC_RECOVD_PHASE_RECOVER:
33                 list_for_each(tmp, &conn->c_imports) {
34                         struct obd_import *imp = 
35                                 list_entry(tmp, struct obd_import, imp_chain);
36
37                         if (phase == PTLRPC_RECOVD_PHASE_PREPARE) {
38                                 unsigned long flags;
39                                 spin_lock_irqsave(&imp->imp_lock, flags);
40                                 imp->imp_level = LUSTRE_CONN_RECOVD;
41                                 spin_unlock_irqrestore(&imp->imp_lock, flags);
42                         }
43                         imp->imp_recover(imp, phase);
44                 }
45                 
46                 if (phase == PTLRPC_RECOVD_PHASE_PREPARE)
47                         RETURN(ptlrpc_run_recovery_upcall(conn));
48                 RETURN(0);
49                         
50             case PTLRPC_RECOVD_PHASE_FAILURE:
51                 RETURN(ll_retry_recovery(conn));
52         }
53
54         LBUG();
55         RETURN(-ENOSYS);
56 }