]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: add osd sync that will flush all open osd requests
authorSage Weil <sage@newdream.net>
Tue, 17 Mar 2009 18:30:33 +0000 (11:30 -0700)
committerSage Weil <sage@newdream.net>
Tue, 17 Mar 2009 18:30:41 +0000 (11:30 -0700)
Important for flushing sync write uncommitted requests on syncfs
(or shutdown).

src/kernel/osd_client.c
src/kernel/osd_client.h
src/kernel/super.c

index 144359a9446711e25d76754454483e74ddd7d64c..affe37993cc9dae6e878df2999eeb1a05f0fb89b 100644 (file)
@@ -784,6 +784,38 @@ void ceph_osdc_abort_request(struct ceph_osd_client *osdc,
        }
 }
 
+void ceph_osdc_sync(struct ceph_osd_client *osdc)
+{
+       struct ceph_osd_request *req;
+       u64 last_tid, next_tid = 0;
+       int got;
+
+       mutex_lock(&osdc->request_mutex);
+       last_tid = osdc->last_tid;
+       while (1) {
+              got = radix_tree_gang_lookup(&osdc->request_tree, (void **)&req,
+                                           next_tid, 1);
+              if (!got)
+                      break;
+              if (req->r_tid > last_tid)
+                      break;
+
+              next_tid = req->r_tid + 1;
+              if ((req->r_flags & CEPH_OSD_OP_MODIFY) == 0)
+                      continue;
+
+              ceph_osdc_get_request(req);
+              mutex_unlock(&osdc->request_mutex);
+              dout(10, "sync waiting on tid %llu (last is %llu)\n",
+                   req->r_tid, last_tid);
+              wait_for_completion(&req->r_safe_completion);
+              mutex_lock(&osdc->request_mutex);
+              ceph_osdc_put_request(req);
+       }
+       mutex_unlock(&osdc->request_mutex);
+       dout(10, "sync done (thru tid %llu)\n", last_tid);
+}
+
 /*
  * init, shutdown
  */
index 1ffebab69b0b96c2d629c552cac0991d2bb67741..75d94aa0a7f95ce1071c1c3470cae22579c8885b 100644 (file)
@@ -128,7 +128,7 @@ extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
                                  struct ceph_osd_request *req);
 extern void ceph_osdc_abort_request(struct ceph_osd_client *osdc,
                                    struct ceph_osd_request *req);
-
+extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
 
 extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
                               struct ceph_vino vino,
index a161c46740f28dd88a5f1e513518ed5f8c331434..2fb731c33c6f53e183ec90647df97b51dda95a69 100644 (file)
@@ -117,6 +117,7 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 static int ceph_syncfs(struct super_block *sb, int wait)
 {
        dout(10, "sync_fs %d\n", wait);
+       ceph_osdc_sync(&ceph_client(sb)->osdc);
        return 0;
 }