ceph: connect to export targets on cap export
authorSage Weil <sage@newdream.net>
Mon, 21 Jun 2010 20:45:04 +0000 (13:45 -0700)
committerSage Weil <sage@newdream.net>
Mon, 2 Aug 2010 03:11:41 +0000 (20:11 -0700)
When we get a cap EXPORT message, make sure we are connected to all export
targets to ensure we can handle the matching IMPORT.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/caps.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h

index 47068b10baf833a1cc70c256a937bcc9128e8998..52befa65fbf7f9a2aaf040f680f9e1ed8c7c8040 100644 (file)
@@ -2573,7 +2573,8 @@ static void handle_cap_trunc(struct inode *inode,
  * caller holds s_mutex
  */
 static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
-                             struct ceph_mds_session *session)
+                             struct ceph_mds_session *session,
+                             int *open_target_sessions)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        int mds = session->s_mds;
@@ -2605,6 +2606,12 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
                        ci->i_cap_exporting_mds = mds;
                        ci->i_cap_exporting_mseq = mseq;
                        ci->i_cap_exporting_issued = cap->issued;
+
+                       /*
+                        * make sure we have open sessions with all possible
+                        * export targets, so that we get the matching IMPORT
+                        */
+                       *open_target_sessions = 1;
                }
                __ceph_remove_cap(cap);
        }
@@ -2680,6 +2687,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        u64 size, max_size;
        u64 tid;
        void *snaptrace;
+       int open_target_sessions = 0;
 
        dout("handle_caps from mds%d\n", mds);
 
@@ -2731,7 +2739,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                goto done;
 
        case CEPH_CAP_OP_EXPORT:
-               handle_cap_export(inode, h, session);
+               handle_cap_export(inode, h, session, &open_target_sessions);
                goto done;
 
        case CEPH_CAP_OP_IMPORT:
@@ -2778,6 +2786,8 @@ done:
 done_unlocked:
        if (inode)
                iput(inode);
+       if (open_target_sessions)
+               ceph_mdsc_open_export_target_sessions(mdsc, session);
        return;
 
 bad:
index 552b934c9cd0f655a5ee40f9e70e1dc26faa6f02..a546e0ddb8e3d7d10a56e76597143ae0e27024dd 100644 (file)
@@ -741,6 +741,14 @@ static void __open_export_target_sessions(struct ceph_mds_client *mdsc,
        }
 }
 
+void ceph_mdsc_open_export_target_sessions(struct ceph_mds_client *mdsc,
+                                          struct ceph_mds_session *session)
+{
+       mutex_lock(&mdsc->mutex);
+       __open_export_target_sessions(mdsc, session);
+       mutex_unlock(&mdsc->mutex);
+}
+
 /*
  * session caps
  */
index 8f2126321f2d2ab6d5baac7a81b46537a7a615b8..c86be30e8707f26f851e5b286dc471a16126aa58 100644 (file)
@@ -364,4 +364,7 @@ extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
 extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc,
                                 struct ceph_msg *msg);
 
+extern void ceph_mdsc_open_export_target_sessions(struct ceph_mds_client *mdsc,
+                                         struct ceph_mds_session *session);
+
 #endif