]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: snap type cleanup
authorSage Weil <sage@newdream.net>
Wed, 20 Aug 2008 16:43:24 +0000 (09:43 -0700)
committerSage Weil <sage@newdream.net>
Wed, 20 Aug 2008 16:43:24 +0000 (09:43 -0700)
src/kernel/addr.c
src/kernel/caps.c
src/kernel/file.c
src/kernel/mds_client.c
src/kernel/mds_client.h
src/kernel/snap.c
src/kernel/super.c
src/kernel/super.h

index 8426326c1935edd3fbea008c17e8a87810180981..ae35d1262293de60fa8ec68d7ef5c00514ee10a5 100644 (file)
@@ -55,7 +55,7 @@ static int ceph_set_page_dirty(struct page *page)
                 * on truncate for dirty page accounting for mmap.
                 */
                ceph_put_snap_context((void *)page->private);
-               snapc = ceph_get_snap_context(ci->i_snaprealm->cached_context);
+               snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
                page->private = (unsigned long)snapc;
                SetPagePrivate(page);
                dout(20, "%p set_page_dirty %p %d -> %d (?)\n",
@@ -572,11 +572,11 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
             inode, page, (int)pos, (int)len);
 
        /* check snap context */
-       BUG_ON(!ci->i_snaprealm);
-       BUG_ON(!ci->i_snaprealm->cached_context);
+       BUG_ON(!ci->i_snap_realm);
+       BUG_ON(!ci->i_snap_realm->cached_context);
        down_read(&mdsc->snap_rwsem);
        if (page->private &&
-           (void *)page->private != ci->i_snaprealm->cached_context) {
+           (void *)page->private != ci->i_snap_realm->cached_context) {
                /* force early writeback of snapped page */
                r = writepage_nounlock(page, 0);
                if (r < 0)
index c977b443f96535291b1b4224c530ef3355256427..eed3877b7b4f3ae71f4daae430d6f752a5ed4dbf 100644 (file)
@@ -87,7 +87,7 @@ int ceph_add_cap(struct inode *inode,
        struct ceph_cap *cap, *new_cap = 0;
        int i;
        int is_first = 0;
-       struct ceph_snaprealm *realm = 0;
+       struct ceph_snap_realm *realm = 0;
        struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
 
        if (snapblob_len)
@@ -140,11 +140,11 @@ retry:
                        ci->i_cap_exporting_mds = -1;
                }
        }
-       if (!ci->i_snaprealm) {
-               ci->i_snaprealm = realm;
-               list_add(&ci->i_snaprealm_item, &realm->inodes_with_caps);
+       if (!ci->i_snap_realm) {
+               ci->i_snap_realm = realm;
+               list_add(&ci->i_snap_realm_item, &realm->inodes_with_caps);
        } else
-               ceph_put_snaprealm(realm);
+               ceph_put_snap_realm(realm);
 
        dout(10, "add_cap inode %p (%llx.%llx) cap %xh now %xh seq %d mds%d\n",
             inode, ceph_vinop(inode), issued, issued|cap->issued, seq, mds);
@@ -219,7 +219,7 @@ int __ceph_remove_cap(struct ceph_cap *cap)
                kfree(cap);
 
        if (RB_EMPTY_ROOT(&ci->i_caps)) {
-               list_del_init(&ci->i_snaprealm_item);
+               list_del_init(&ci->i_snap_realm_item);
                return 1;
        }
        return 0;
@@ -321,11 +321,11 @@ retry:
                if (flush_snap &&
                    (cap->issued & (CEPH_CAP_WR|CEPH_CAP_WRBUFFER))) {
                        if (cap->flushed_snap >=
-                           ci->i_snaprealm->cached_context->seq) {
+                           ci->i_snap_realm->cached_context->seq) {
                                dout(10, "flushed_snap %llu >= seq %lld, "
                                     "not flushing mds%d\n",
                                     cap->flushed_snap,
-                                    ci->i_snaprealm->cached_context->seq,
+                                    ci->i_snap_realm->cached_context->seq,
                                     cap->session->s_mds);
                                continue;  /* already flushed for this snap */
                        }
@@ -649,7 +649,7 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
                        ceph_encode_timespec(&grant->atime, &inode->i_atime);
                        grant->time_warp_seq = cpu_to_le64(ci->i_time_warp_seq);
                        grant->snap_follows =
-                            cpu_to_le64(ci->i_snaprealm->cached_context->seq);
+                            cpu_to_le64(ci->i_snap_realm->cached_context->seq);
                        reply = 1;
                        wake = 1;
                }
@@ -1023,7 +1023,7 @@ int __ceph_send_cap(struct ceph_mds_client *mdsc,
        mtime = inode->i_mtime;
        atime = inode->i_atime;
        time_warp_seq = ci->i_time_warp_seq;
-       follows = ci->i_snaprealm->cached_context->seq;
+       follows = ci->i_snap_realm->cached_context->seq;
        if (flush_snap)
                cap->flushed_snap = follows; /* so we only flush it once */
        spin_unlock(&inode->i_lock);
index 334017ad518316f54076ec00d2baeafacd8dd547..251d13d804b58b4b9ce2154f72dac7149feea1db 100644 (file)
@@ -243,7 +243,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
 
        ret = ceph_osdc_sync_write(&client->osdc, ceph_vino(inode),
                                   &ci->i_layout,
-                                  ci->i_snaprealm->cached_context,
+                                  ci->i_snap_realm->cached_context,
                                   pos, count, data);
        if (ret > 0) {
                pos += ret;
index c4ba343b8fd6a65e68b38b75729a25c6e4743987..b8cf09449354b248c852509fe539b83a359e72d1 100644 (file)
@@ -1468,161 +1468,6 @@ static void check_new_map(struct ceph_mds_client *mdsc,
 
 
 
-/*
- * snap
- */
-
-void ceph_mdsc_handle_snap(struct ceph_mds_client *mdsc,
-                          struct ceph_msg *msg)
-{
-       struct super_block *sb = mdsc->client->sb;
-       struct ceph_mds_session *session;
-       int mds = le32_to_cpu(msg->hdr.src.name.num);
-       u64 split;
-       int op;
-       int trace_len;
-       struct ceph_snaprealm *realm = 0;
-       void *p = msg->front.iov_base;
-       void *e = p + msg->front.iov_len;
-       struct ceph_mds_snap_head *h;
-       int num_split_inos, num_split_realms;
-       __le64 *split_inos = 0, *split_realms = 0;
-       int i;
-
-       /* decode */
-       if (msg->front.iov_len < sizeof(*h))
-               goto bad;
-       h = p;
-       op = le32_to_cpu(h->op);
-       split = le64_to_cpu(h->split);
-       trace_len = le32_to_cpu(h->trace_len);
-       num_split_inos = le32_to_cpu(h->num_split_inos);
-       num_split_realms = le32_to_cpu(h->num_split_realms);
-       p += sizeof(*h);
-
-       dout(10, "handle_snap from mds%d op %s split %llx tracelen %d\n", mds,
-            ceph_snap_op_name(op), split, trace_len);
-
-       /* find session */
-       mutex_lock(&mdsc->mutex);
-       session = __ceph_get_mds_session(mdsc, mds);
-       if (session)
-               down_write(&mdsc->snap_rwsem);
-       mutex_unlock(&mdsc->mutex);
-       if (!session) {
-               dout(10, "WTF, got snap but no session for mds%d\n", mds);
-               return;
-       }
-
-       mutex_lock(&session->s_mutex);
-       session->s_seq++;
-       mutex_unlock(&session->s_mutex);
-
-       if (op == CEPH_SNAP_OP_SPLIT) {
-               struct ceph_mds_snap_realm *ri;
-
-               split_inos = p;
-               p += sizeof(u64) * num_split_inos;
-               split_realms = p;
-               p += sizeof(u64) * num_split_realms;
-               ceph_decode_need(&p, e, sizeof(*ri), bad);
-               ri = p;
-
-               realm = ceph_get_snaprealm(mdsc, split);
-               if (IS_ERR(realm))
-                       goto out;
-               dout(10, "splitting snaprealm %llx %p\n", realm->ino, realm);
-
-               for (i = 0; i < num_split_inos; i++) {
-                       struct ceph_vino vino = {
-                               .ino = le64_to_cpu(split_inos[i]),
-                               .snap = CEPH_NOSNAP,
-                       };
-                       struct inode *inode = ceph_find_inode(sb, vino);
-                       struct ceph_inode_info *ci;
-                       if (!inode)
-                               continue;
-                       ci = ceph_inode(inode);
-                       spin_lock(&inode->i_lock);
-                       if (!ci->i_snaprealm)
-                               goto skip_inode;
-                       if (ci->i_snaprealm->created > le64_to_cpu(ri->created)) {
-                               dout(15, " leaving %p in newer realm %llx %p\n",
-                                    inode, ci->i_snaprealm->ino,
-                                    ci->i_snaprealm);
-                               goto skip_inode;
-                       }
-                       dout(15, " will move %p to split realm %llx %p\n",
-                            inode, realm->ino, realm);
-                       /*
-                        * remove from list, but don't re-add yet.  we
-                        * don't want the caps to be flushed (again) by
-                        * ceph_update_snap_trace below.
-                        */
-                       list_del_init(&ci->i_snaprealm_item);
-                       spin_unlock(&inode->i_lock);
-
-                       ceph_check_caps(ci, 0, 1);
-
-                       iput(inode);
-                       continue;
-
-               skip_inode:
-                       spin_unlock(&inode->i_lock);
-                       iput(inode);
-               }
-
-               for (i = 0; i < num_split_realms; i++) {
-                       struct ceph_snaprealm *child =
-                               ceph_get_snaprealm(mdsc,
-                                          le64_to_cpu(split_realms[i]));
-                       if (!child)
-                               continue;
-                       ceph_adjust_snaprealm_parent(mdsc, child, realm->ino);
-                       ceph_put_snaprealm(child);
-               }
-
-               ceph_put_snaprealm(realm);
-       }
-
-       realm = ceph_update_snap_trace(mdsc, p, e,
-                                      op != CEPH_SNAP_OP_DESTROY);
-       if (IS_ERR(realm))
-               goto bad;
-
-       if (op == CEPH_SNAP_OP_SPLIT) {
-               for (i = 0; i < num_split_inos; i++) {
-                       struct ceph_vino vino = {
-                               .ino = le64_to_cpu(split_inos[i]),
-                               .snap = CEPH_NOSNAP,
-                       };
-                       struct inode *inode = ceph_find_inode(sb, vino);
-                       struct ceph_inode_info *ci;
-                       if (!inode)
-                               continue;
-                       ci = ceph_inode(inode);
-                       spin_lock(&inode->i_lock);
-                       /* _now_ add to newly split realm */
-                       ceph_put_snaprealm(ci->i_snaprealm);
-                       list_add(&ci->i_snaprealm_item,
-                                &realm->inodes_with_caps);
-                       ci->i_snaprealm = realm;
-                       realm->nref++;
-                       spin_unlock(&inode->i_lock);
-               }
-       }
-
-       ceph_put_snaprealm(realm);
-       up_write(&mdsc->snap_rwsem);
-       return;
-
-bad:
-       derr(10, "corrupt snap message from mds%d\n", mds);
-out:
-       return;
-}
-
-
 static int request_close_session(struct ceph_mds_client *mdsc,
                                 struct ceph_mds_session *session)
 {
@@ -1906,7 +1751,7 @@ void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client)
        mdsc->max_sessions = 0;
        mdsc->last_tid = 0;
        mdsc->stopping = 0;
-       INIT_RADIX_TREE(&mdsc->snaprealms, GFP_NOFS);
+       INIT_RADIX_TREE(&mdsc->snap_realms, GFP_NOFS);
        INIT_RADIX_TREE(&mdsc->request_tree, GFP_NOFS);
        init_completion(&mdsc->map_waiters);
        init_completion(&mdsc->session_close_waiters);
index 9610f88a4ac9a86c680218c0bc11fe5c8022ba5f..064e5a456542a64a2f701974167af5b04c4db6df 100644 (file)
@@ -135,7 +135,7 @@ struct ceph_mds_client {
         * snap contexts.  (later, we can do per-realm snap contexts locks..)
         */
        struct rw_semaphore     snap_rwsem;
-       struct radix_tree_root  snaprealms;
+       struct radix_tree_root  snap_realms;
 
        __u64                   last_tid;      /* most recent mds request */
        struct radix_tree_root  request_tree;  /* pending mds requests */
@@ -167,9 +167,6 @@ extern void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc,
 extern void ceph_mdsc_handle_forward(struct ceph_mds_client *mdsc,
                                     struct ceph_msg *msg);
 
-extern void ceph_mdsc_handle_snap(struct ceph_mds_client *mdsc,
-                                 struct ceph_msg *msg);
-
 extern void ceph_mdsc_handle_lease(struct ceph_mds_client *mdsc,
                                   struct ceph_msg *msg);
 
index 049c5126d6bad0938512562d2d404946c6815b49..c55d36307c3210e20be37508002a3f6ef9f36812 100644 (file)
@@ -10,36 +10,30 @@ int ceph_debug_snap = -1;
 #include "decode.h"
 
 
-struct ceph_snaprealm *ceph_get_snaprealm(struct ceph_mds_client *mdsc, u64 ino)
+struct ceph_snap_realm *ceph_get_snap_realm(struct ceph_mds_client *mdsc, u64 ino)
 {
-       struct ceph_snaprealm *realm;
+       struct ceph_snap_realm *realm;
 
-       realm = radix_tree_lookup(&mdsc->snaprealms, ino);
+       realm = radix_tree_lookup(&mdsc->snap_realms, ino);
        if (!realm) {
                realm = kzalloc(sizeof(*realm), GFP_NOFS);
-               radix_tree_insert(&mdsc->snaprealms, ino, realm);
+               radix_tree_insert(&mdsc->snap_realms, ino, realm);
                realm->nref = 1;    /* in tree */
                realm->ino = ino;
                INIT_LIST_HEAD(&realm->children);
                INIT_LIST_HEAD(&realm->child_item);
                INIT_LIST_HEAD(&realm->inodes_with_caps);
-               dout(20, "get_snaprealm created %llx %p\n", realm->ino, realm);
+               dout(20, "get_snap_realm created %llx %p\n", realm->ino, realm);
        }
-       dout(20, "get_snaprealm %llx %p %d -> %d\n", realm->ino, realm,
+       dout(20, "get_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
             realm->nref, realm->nref+1);
        realm->nref++;
        return realm;
 }
 
-struct ceph_snaprealm *ceph_find_snaprealm(struct ceph_mds_client *mdsc,
-                                          u64 ino)
+void ceph_put_snap_realm(struct ceph_snap_realm *realm)
 {
-       return radix_tree_lookup(&mdsc->snaprealms, ino);
-}
-
-void ceph_put_snaprealm(struct ceph_snaprealm *realm)
-{
-       dout(20, "put_snaprealm %llx %p %d -> %d\n", realm->ino, realm,
+       dout(20, "put_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
             realm->nref, realm->nref-1);
        realm->nref--;
        if (realm->nref == 0) {
@@ -50,23 +44,24 @@ void ceph_put_snaprealm(struct ceph_snaprealm *realm)
        }
 }
 
-int ceph_adjust_snaprealm_parent(struct ceph_mds_client *mdsc,
-                                struct ceph_snaprealm *realm, u64 parentino)
+static int adjust_snap_realm_parent(struct ceph_mds_client *mdsc,
+                                       struct ceph_snap_realm *realm,
+                                       u64 parentino)
 {
-       struct ceph_snaprealm *parent;
+       struct ceph_snap_realm *parent;
 
        if (realm->parent_ino == parentino)
                return 0;
 
-       parent = ceph_get_snaprealm(mdsc, parentino);
+       parent = ceph_get_snap_realm(mdsc, parentino);
        if (!parent)
                return -ENOMEM;
-       dout(20, "adjust_snaprealm_parent %llx %p: %llx %p -> %llx %p\n",
+       dout(20, "adjust_snap_realm_parent %llx %p: %llx %p -> %llx %p\n",
             realm->ino, realm, realm->parent_ino, realm->parent,
             parentino, parent);
        if (realm->parent) {
                list_del_init(&realm->child_item);
-               ceph_put_snaprealm(realm->parent);
+               ceph_put_snap_realm(realm->parent);
        }
        realm->parent_ino = parentino;
        realm->parent = parent;
@@ -84,9 +79,9 @@ static int cmpu64_rev(const void *a, const void *b)
        return 0;
 }
 
-int ceph_build_snap_context(struct ceph_snaprealm *realm)
+static int build_snap_context(struct ceph_snap_realm *realm)
 {
-       struct ceph_snaprealm *parent = realm->parent;
+       struct ceph_snap_realm *parent = realm->parent;
        struct ceph_snap_context *sc;
        int err = 0;
        int i;
@@ -94,7 +89,7 @@ int ceph_build_snap_context(struct ceph_snaprealm *realm)
 
        if (parent) {
                if (!parent->cached_context) {
-                       err = ceph_build_snap_context(parent);
+                       err = build_snap_context(parent);
                        if (err)
                                goto fail;
                }
@@ -159,17 +154,17 @@ fail:
        return err;
 }
 
-void ceph_rebuild_snaprealms(struct ceph_snaprealm *realm)
+static void rebuild_snap_realms(struct ceph_snap_realm *realm)
 {
        struct list_head *p;
-       struct ceph_snaprealm *child;
+       struct ceph_snap_realm *child;
 
-       dout(10, "rebuild_snaprealms %llx %p\n", realm->ino, realm);
-       ceph_build_snap_context(realm);
+       dout(10, "rebuild_snap_realms %llx %p\n", realm->ino, realm);
+       build_snap_context(realm);
 
        list_for_each(p, &realm->children) {
-               child = list_entry(p, struct ceph_snaprealm, child_item);
-               ceph_rebuild_snaprealms(child);
+               child = list_entry(p, struct ceph_snap_realm, child_item);
+               rebuild_snap_realms(child);
        }
 }
 
@@ -191,14 +186,14 @@ static int dup_array(u64 **dst, u64 *src, int num)
        return 0;
 }
 
-struct ceph_snaprealm *ceph_update_snap_trace(struct ceph_mds_client *mdsc,
+struct ceph_snap_realm *ceph_update_snap_trace(struct ceph_mds_client *mdsc,
                                              void *p, void *e, int must_flush)
 {
        struct ceph_mds_snap_realm *ri;
        int err = -ENOMEM;
        u64 *snaps;
        u64 *prior_parent_snaps;
-       struct ceph_snaprealm *realm, *first = 0;
+       struct ceph_snap_realm *realm, *first = 0;
        int invalidate = 0;
 
        dout(10, "update_snap_trace must_flush=%d\n", must_flush);
@@ -213,7 +208,7 @@ more:
        prior_parent_snaps = p;
        p += sizeof(u64) * le32_to_cpu(ri->num_prior_parent_snaps);
 
-       realm = ceph_get_snaprealm(mdsc, le64_to_cpu(ri->ino));
+       realm = ceph_get_snap_realm(mdsc, le64_to_cpu(ri->ino));
        if (!realm)
                goto fail;
        if (!first) {
@@ -229,7 +224,7 @@ more:
                list_for_each(p, &realm->inodes_with_caps) {
                        struct ceph_inode_info *ci =
                                list_entry(p, struct ceph_inode_info,
-                                          i_snaprealm_item);
+                                          i_snap_realm_item);
                        ceph_check_caps(ci, 0, 1);
                }
                dout(20, "update_snap_trace cap flush done\n");
@@ -238,8 +233,8 @@ more:
                dout(10, "update_snap_trace %llx %p seq %lld unchanged\n",
                     realm->ino, realm, realm->seq);
 
-       invalidate += ceph_adjust_snaprealm_parent(mdsc, realm,
-                                                  le64_to_cpu(ri->parent));
+       invalidate += adjust_snap_realm_parent(mdsc, realm,
+                                             le64_to_cpu(ri->parent));
        
        if (le64_to_cpu(ri->seq) > realm->seq) {
                realm->seq = le64_to_cpu(ri->seq);
@@ -263,9 +258,9 @@ more:
             realm, invalidate, p, e);
 
        if (p >= e && invalidate)
-               ceph_rebuild_snaprealms(realm);
+               rebuild_snap_realms(realm);
 
-       ceph_put_snaprealm(realm);
+       ceph_put_snap_realm(realm);
        if (p < e)
                goto more;
 
@@ -280,3 +275,159 @@ fail:
 
 
 
+/*
+ * snap
+ */
+
+void ceph_handle_snap(struct ceph_mds_client *mdsc,
+                     struct ceph_msg *msg)
+{
+       struct super_block *sb = mdsc->client->sb;
+       struct ceph_mds_session *session;
+       int mds = le32_to_cpu(msg->hdr.src.name.num);
+       u64 split;
+       int op;
+       int trace_len;
+       struct ceph_snap_realm *realm = 0;
+       void *p = msg->front.iov_base;
+       void *e = p + msg->front.iov_len;
+       struct ceph_mds_snap_head *h;
+       int num_split_inos, num_split_realms;
+       __le64 *split_inos = 0, *split_realms = 0;
+       int i;
+
+       /* decode */
+       if (msg->front.iov_len < sizeof(*h))
+               goto bad;
+       h = p;
+       op = le32_to_cpu(h->op);
+       split = le64_to_cpu(h->split);
+       trace_len = le32_to_cpu(h->trace_len);
+       num_split_inos = le32_to_cpu(h->num_split_inos);
+       num_split_realms = le32_to_cpu(h->num_split_realms);
+       p += sizeof(*h);
+
+       dout(10, "handle_snap from mds%d op %s split %llx tracelen %d\n", mds,
+            ceph_snap_op_name(op), split, trace_len);
+
+       /* find session */
+       mutex_lock(&mdsc->mutex);
+       session = __ceph_get_mds_session(mdsc, mds);
+       if (session)
+               down_write(&mdsc->snap_rwsem);
+       mutex_unlock(&mdsc->mutex);
+       if (!session) {
+               dout(10, "WTF, got snap but no session for mds%d\n", mds);
+               return;
+       }
+
+       mutex_lock(&session->s_mutex);
+       session->s_seq++;
+       mutex_unlock(&session->s_mutex);
+
+       if (op == CEPH_SNAP_OP_SPLIT) {
+               struct ceph_mds_snap_realm *ri;
+
+               split_inos = p;
+               p += sizeof(u64) * num_split_inos;
+               split_realms = p;
+               p += sizeof(u64) * num_split_realms;
+               ceph_decode_need(&p, e, sizeof(*ri), bad);
+               ri = p;
+
+               realm = ceph_get_snap_realm(mdsc, split);
+               if (IS_ERR(realm))
+                       goto out;
+               dout(10, "splitting snap_realm %llx %p\n", realm->ino, realm);
+
+               for (i = 0; i < num_split_inos; i++) {
+                       struct ceph_vino vino = {
+                               .ino = le64_to_cpu(split_inos[i]),
+                               .snap = CEPH_NOSNAP,
+                       };
+                       struct inode *inode = ceph_find_inode(sb, vino);
+                       struct ceph_inode_info *ci;
+                       if (!inode)
+                               continue;
+                       ci = ceph_inode(inode);
+                       spin_lock(&inode->i_lock);
+                       if (!ci->i_snap_realm)
+                               goto skip_inode;
+                       if (ci->i_snap_realm->created > le64_to_cpu(ri->created)) {
+                               dout(15, " leaving %p in newer realm %llx %p\n",
+                                    inode, ci->i_snap_realm->ino,
+                                    ci->i_snap_realm);
+                               goto skip_inode;
+                       }
+                       dout(15, " will move %p to split realm %llx %p\n",
+                            inode, realm->ino, realm);
+                       /*
+                        * remove from list, but don't re-add yet.  we
+                        * don't want the caps to be flushed (again) by
+                        * ceph_update_snap_trace below.
+                        */
+                       list_del_init(&ci->i_snap_realm_item);
+                       spin_unlock(&inode->i_lock);
+
+                       ceph_check_caps(ci, 0, 1);
+
+                       iput(inode);
+                       continue;
+
+               skip_inode:
+                       spin_unlock(&inode->i_lock);
+                       iput(inode);
+               }
+
+               for (i = 0; i < num_split_realms; i++) {
+                       struct ceph_snap_realm *child =
+                               ceph_get_snap_realm(mdsc,
+                                          le64_to_cpu(split_realms[i]));
+                       if (!child)
+                               continue;
+                       adjust_snap_realm_parent(mdsc, child, realm->ino);
+                       ceph_put_snap_realm(child);
+               }
+
+               ceph_put_snap_realm(realm);
+       }
+
+       realm = ceph_update_snap_trace(mdsc, p, e,
+                                      op != CEPH_SNAP_OP_DESTROY);
+       if (IS_ERR(realm))
+               goto bad;
+
+       if (op == CEPH_SNAP_OP_SPLIT) {
+               for (i = 0; i < num_split_inos; i++) {
+                       struct ceph_vino vino = {
+                               .ino = le64_to_cpu(split_inos[i]),
+                               .snap = CEPH_NOSNAP,
+                       };
+                       struct inode *inode = ceph_find_inode(sb, vino);
+                       struct ceph_inode_info *ci;
+                       if (!inode)
+                               continue;
+                       ci = ceph_inode(inode);
+                       spin_lock(&inode->i_lock);
+                       /* _now_ add to newly split realm */
+                       ceph_put_snap_realm(ci->i_snap_realm);
+                       list_add(&ci->i_snap_realm_item,
+                                &realm->inodes_with_caps);
+                       ci->i_snap_realm = realm;
+                       realm->nref++;
+                       spin_unlock(&inode->i_lock);
+               }
+       }
+
+       ceph_put_snap_realm(realm);
+       up_write(&mdsc->snap_rwsem);
+       return;
+
+bad:
+       derr(10, "corrupt snap message from mds%d\n", mds);
+out:
+       return;
+}
+
+
+
index 5318ff43f15ce71c445dbecffed366b5581267e0..bb4396f5c8a3a7ecb40e1c7bf057ae59ee5e0621 100644 (file)
@@ -189,7 +189,7 @@ static struct inode *ceph_alloc_inode(struct super_block *sb)
        ci->i_hold_caps_until = 0;
        INIT_LIST_HEAD(&ci->i_cap_delay_list);
 
-       ci->i_snaprealm = 0;
+       ci->i_snap_realm = 0;
 
        INIT_WORK(&ci->i_wb_work, ceph_inode_writeback);
 
@@ -825,7 +825,7 @@ void ceph_dispatch(void *p, struct ceph_msg *msg)
                ceph_handle_caps(&client->mdsc, msg);
                break;
        case CEPH_MSG_CLIENT_SNAP:
-               ceph_mdsc_handle_snap(&client->mdsc, msg);
+               ceph_handle_snap(&client->mdsc, msg);
                break;
        case CEPH_MSG_CLIENT_LEASE:
                ceph_mdsc_handle_lease(&client->mdsc, msg);
index 78d83bccf9007d650bf2c41341ecee762b922c50..22021e02bb2d91fccdcadcd5d8156b512b2d31af 100644 (file)
@@ -266,8 +266,8 @@ struct ceph_inode_info {
        int i_rd_ref, i_rdcache_ref, i_wr_ref;
        atomic_t i_wrbuffer_ref;
 
-       struct ceph_snaprealm *i_snaprealm;
-       struct list_head i_snaprealm_item;
+       struct ceph_snap_realm *i_snap_realm;
+       struct list_head i_snap_realm_item;
 
        struct work_struct i_wb_work;  /* writeback work */
 
@@ -483,7 +483,7 @@ static inline void ceph_put_snap_context(struct ceph_snap_context *sc)
        }
 }
 
-struct ceph_snaprealm {
+struct ceph_snap_realm {
        u64 ino;
        int nref;
        u64 created, seq;
@@ -495,7 +495,7 @@ struct ceph_snaprealm {
        u64 *snaps;
        int num_snaps;
        
-       struct ceph_snaprealm *parent;
+       struct ceph_snap_realm *parent;
        struct list_head child_item;
        struct list_head children;
 
@@ -505,18 +505,12 @@ struct ceph_snaprealm {
 };
 
 /* snap.c */
-extern struct ceph_snaprealm *ceph_get_snaprealm(struct ceph_mds_client *mdsc,
-                                                u64 ino);
-extern struct ceph_snaprealm *ceph_find_snaprealm(struct ceph_mds_client *mdsc,
-                                                 u64 ino);
-extern void ceph_put_snaprealm(struct ceph_snaprealm *realm);
-extern int ceph_adjust_snaprealm_parent(struct ceph_mds_client *mdsc,
-                                       struct ceph_snaprealm *realm, u64 p);
-extern struct ceph_snaprealm *ceph_update_snap_trace(struct ceph_mds_client *mc,
-                                                    void *p, void *e,
-                                                    int must_flush);
-extern int ceph_build_snap_context(struct ceph_snaprealm *realm);
-extern void ceph_invalidate_snaprealm(struct ceph_snaprealm *realm);
+extern void ceph_put_snap_realm(struct ceph_snap_realm *realm);
+extern struct ceph_snap_realm *ceph_update_snap_trace(struct ceph_mds_client *m,
+                                                     void *p, void *e,
+                                                     int must_flush);
+extern void ceph_handle_snap(struct ceph_mds_client *mdsc,
+                            struct ceph_msg *msg);
 
 
 /*