Whamcloud - gitweb
LU-2031 obdclass: check if client is connected to the target
authorJinshan Xiong <jinshan.xiong@intel.com>
Tue, 13 Nov 2012 19:56:17 +0000 (11:56 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 21 Nov 2012 05:35:09 +0000 (00:35 -0500)
When the client is notified by IR, it may not connect to the OST
yet, verify it before writing the new NID to the import.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Ia144b695443a9850ecccd0c8946de029492b4446
Reviewed-on: http://review.whamcloud.com/4525
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mgc/mgc_request.c

index bf02e4e..e293fa0 100644 (file)
@@ -1371,11 +1371,20 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
                 pos += sprintf(params, "%s.import=%s", cname, "connection=");
                 uuid = buf + pos;
 
+               cfs_down_read(&obd->u.cli.cl_sem);
+               if (obd->u.cli.cl_import == NULL) {
+                       /* client does not connect to the OST yet */
+                       cfs_up_read(&obd->u.cli.cl_sem);
+                       rc = 0;
+                       continue;
+               }
+
                 /* TODO: iterate all nids to find one */
                 /* find uuid by nid */
                 rc = client_import_find_conn(obd->u.cli.cl_import,
                                              entry->u.nids[0],
                                              (struct obd_uuid *)uuid);
+               cfs_up_read(&obd->u.cli.cl_sem);
                 if (rc < 0) {
                         CERROR("mgc: cannot find uuid by nid %s\n",
                                libcfs_nid2str(entry->u.nids[0]));