Whamcloud - gitweb
3310c34ae1ef5e92dabed74b09366e1edf6be0ca
[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                                 spin_lock(&imp->imp_lock);
39                                 imp->imp_level = LUSTRE_CONN_RECOVD;
40                                 spin_unlock(&imp->imp_lock);
41                         }
42                         imp->imp_recover(imp, phase);
43                 }
44                 
45                 if (phase == PTLRPC_RECOVD_PHASE_PREPARE)
46                         RETURN(ptlrpc_run_recovery_upcall(conn));
47                 RETURN(0);
48                         
49             case PTLRPC_RECOVD_PHASE_FAILURE:
50                 RETURN(ll_retry_recovery(conn));
51         }
52
53         LBUG();
54         RETURN(-ENOSYS);
55 }