From 12f901b7afe81dfd212407bc77c1b5793b8fa04e Mon Sep 17 00:00:00 2001
From: komaln <komaln>
Date: Tue, 13 Nov 2007 20:43:24 +0000
Subject: [PATCH] b=13299 r=Nathan, Wangdi, Andreas

	To change /proc/fs/lustre/devices to reflect active/inactive state
---
 lustre/include/obd.h                 |  4 +++-
 lustre/lov/lov_obd.c                 | 12 ++++++++++--
 lustre/obdclass/linux/linux-module.c |  2 ++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lustre/include/obd.h b/lustre/include/obd.h
index d24bc35139..d58905e8ce 100644
--- a/lustre/include/obd.h
+++ b/lustre/include/obd.h
@@ -725,7 +725,9 @@ struct obd_device {
                      obd_force:1,         /* cleanup with > 0 obd refcount */
                      obd_fail:1,          /* cleanup with failover */
                      obd_async_recov:1,   /* allow asyncronous orphan cleanup */
-                     obd_no_conn:1;       /* deny new connections */
+                     obd_no_conn:1,       /* deny new connections */
+                     obd_inactive:1;      /* device active/inactive
+                                           * (for /proc/status only!!) */
         /* uuid-export hash body */
         struct lustre_class_hash_body *obd_uuid_hash_body;
         /* nid-export hash body */
diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c
index c6c7832e48..99e0ff70e1 100644
--- a/lustre/lov/lov_obd.c
+++ b/lustre/lov/lov_obd.c
@@ -97,6 +97,7 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
         struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
         struct lustre_handle conn = {0, };
         struct obd_import *imp;
+
 #ifdef __KERNEL__
         cfs_proc_dir_entry_t *lov_proc_dir;
 #endif
@@ -172,6 +173,7 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
         if (activate) {
                 lov->lov_tgts[index]->ltd_active = 1;
                 lov->desc.ld_active_tgt_count++;
+                lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
         }
         CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
                obd_uuid2str(&tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
@@ -257,6 +259,7 @@ static int lov_disconnect_obd(struct obd_device *obd, __u32 index)
         struct obd_device *osc_obd =
                 class_exp2obd(lov->lov_tgts[index]->ltd_exp);
         int rc;
+
         ENTRY;
 
         CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", 
@@ -265,6 +268,7 @@ static int lov_disconnect_obd(struct obd_device *obd, __u32 index)
         if (lov->lov_tgts[index]->ltd_active) {
                 lov->lov_tgts[index]->ltd_active = 0;
                 lov->desc.ld_active_tgt_count--;
+                lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
         }
 
         lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
@@ -385,10 +389,14 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
                activate ? "" : "in");
 
         lov->lov_tgts[i]->ltd_active = activate;
-        if (activate)
+
+        if (activate) {
                 lov->desc.ld_active_tgt_count++;
-        else
+                lov->lov_tgts[i]->ltd_exp->exp_obd->obd_inactive = 0;
+        } else {
                 lov->desc.ld_active_tgt_count--;
+                lov->lov_tgts[i]->ltd_exp->exp_obd->obd_inactive = 1;
+        }
         /* remove any old qos penalty */
         lov->lov_tgts[i]->ltd_qos.ltq_penalty = 0;
 
diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c
index d90b5113f6..c9807f521c 100644
--- a/lustre/obdclass/linux/linux-module.c
+++ b/lustre/obdclass/linux/linux-module.c
@@ -333,6 +333,8 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v)
         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
         if (obd->obd_stopping)
                 status = "ST";
+        else if (obd->obd_inactive)
+                status = "IN";
         else if (obd->obd_set_up)
                 status = "UP";
         else if (obd->obd_attached)
-- 
GitLab