Lines Matching defs:realm
30 * of the files contained by each realm share the same set of
31 * snapshots. An individual realm's snap set contains snapshots
32 * explicitly created on that realm, as well as any snaps in its
39 * realm relationship, and for each realm has an explicit list of snaps
43 * with an open cap in the system. (The needed snap realm information is
45 * version number is used to ensure that as realm parameters change (new
46 * snapshot, new parent, etc.) the client's realm hierarchy is updated.
48 * The realm hierarchy drives the generation of a 'snap context' for each
49 * realm, which simply lists the resulting set of snaps for the realm. This
54 * update, but don't have enough memory to update our realm hierarchy,
61 * increase ref count for the realm
66 struct ceph_snap_realm *realm)
76 if (atomic_inc_not_zero(&realm->nref))
80 if (atomic_inc_return(&realm->nref) == 1)
81 list_del_init(&realm->empty_item);
108 * create and get the realm rooted at @ino and bump its ref count.
116 struct ceph_snap_realm *realm;
120 realm = kzalloc(sizeof(*realm), GFP_NOFS);
121 if (!realm)
124 atomic_set(&realm->nref, 1); /* for caller */
125 realm->ino = ino;
126 INIT_LIST_HEAD(&realm->children);
127 INIT_LIST_HEAD(&realm->child_item);
128 INIT_LIST_HEAD(&realm->empty_item);
129 INIT_LIST_HEAD(&realm->dirty_item);
130 INIT_LIST_HEAD(&realm->inodes_with_caps);
131 spin_lock_init(&realm->inodes_with_caps_lock);
132 __insert_snap_realm(&mdsc->snap_realms, realm);
135 dout("create_snap_realm %llx %p\n", realm->ino, realm);
136 return realm;
140 * lookup the realm rooted at @ino.
177 struct ceph_snap_realm *realm);
183 struct ceph_snap_realm *realm)
187 dout("__destroy_snap_realm %p %llx\n", realm, realm->ino);
189 rb_erase(&realm->node, &mdsc->snap_realms);
192 if (realm->parent) {
193 list_del_init(&realm->child_item);
194 __put_snap_realm(mdsc, realm->parent);
197 kfree(realm->prior_parent_snaps);
198 kfree(realm->snaps);
199 ceph_put_snap_context(realm->cached_context);
200 kfree(realm);
207 struct ceph_snap_realm *realm)
215 if (atomic_dec_and_test(&realm->nref))
216 __destroy_snap_realm(mdsc, realm);
223 struct ceph_snap_realm *realm)
225 if (!atomic_dec_and_lock(&realm->nref, &mdsc->snap_empty_lock))
230 __destroy_snap_realm(mdsc, realm);
233 list_add(&realm->empty_item, &mdsc->snap_empty);
247 struct ceph_snap_realm *realm;
253 realm = list_first_entry(&mdsc->snap_empty,
255 list_del(&realm->empty_item);
257 __destroy_snap_realm(mdsc, realm);
271 * adjust the parent realm of a given @realm. adjust child list, and parent
279 struct ceph_snap_realm *realm,
286 if (realm->parent_ino == parentino)
296 realm->ino, realm, realm->parent_ino, realm->parent,
298 if (realm->parent) {
299 list_del_init(&realm->child_item);
300 ceph_put_snap_realm(mdsc, realm->parent);
302 realm->parent_ino = parentino;
303 realm->parent = parent;
304 list_add(&realm->child_item, &parent->children);
320 * build the snap context for a given realm.
322 static int build_snap_context(struct ceph_snap_realm *realm,
325 struct ceph_snap_realm *parent = realm->parent;
328 u32 num = realm->num_prior_parent_snaps + realm->num_snaps;
345 matches realm seq, and my parents' does to. (this works
348 if (realm->cached_context &&
349 realm->cached_context->seq == realm->seq &&
351 realm->cached_context->seq >= parent->cached_context->seq)) {
354 realm->ino, realm, realm->cached_context,
355 realm->cached_context->seq,
356 (unsigned int)realm->cached_context->num_snaps);
370 snapc->seq = realm->seq;
378 realm->parent_since)
384 memcpy(snapc->snaps + num, realm->snaps,
385 sizeof(u64)*realm->num_snaps);
386 num += realm->num_snaps;
387 memcpy(snapc->snaps + num, realm->prior_parent_snaps,
388 sizeof(u64)*realm->num_prior_parent_snaps);
389 num += realm->num_prior_parent_snaps;
394 realm->ino, realm, snapc, snapc->seq,
397 ceph_put_snap_context(realm->cached_context);
398 realm->cached_context = snapc;
399 /* queue realm for cap_snap creation */
400 list_add_tail(&realm->dirty_item, dirty_realms);
408 if (realm->cached_context) {
409 ceph_put_snap_context(realm->cached_context);
410 realm->cached_context = NULL;
412 pr_err("build_snap_context %llx %p fail %d\n", realm->ino,
413 realm, err);
418 * rebuild snap context for the given realm and all of its children.
420 static void rebuild_snap_realms(struct ceph_snap_realm *realm,
425 dout("rebuild_snap_realms %llx %p\n", realm->ino, realm);
426 build_snap_context(realm, dirty_realms);
428 list_for_each_entry(child, &realm->children, child_item)
474 * Caller must hold snap_rwsem for read (i.e., the realm topology won't
659 * Queue cap_snaps for snap writeback for this realm and its children.
660 * Called under snap_rwsem, so realm topology won't change.
662 static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)
667 dout("queue_realm_cap_snaps %p %llx inodes\n", realm, realm->ino);
669 spin_lock(&realm->inodes_with_caps_lock);
670 list_for_each_entry(ci, &realm->inodes_with_caps, i_snap_realm_item) {
674 spin_unlock(&realm->inodes_with_caps_lock);
680 spin_lock(&realm->inodes_with_caps_lock);
682 spin_unlock(&realm->inodes_with_caps_lock);
685 dout("queue_realm_cap_snaps %p %llx done\n", realm, realm->ino);
690 * the snap realm parameters from a given realm and all of its ancestors,
702 struct ceph_snap_realm *realm;
713 realm = NULL;
725 realm = ceph_lookup_snap_realm(mdsc, le64_to_cpu(ri->ino));
726 if (!realm) {
727 realm = ceph_create_snap_realm(mdsc, le64_to_cpu(ri->ino));
728 if (IS_ERR(realm)) {
729 err = PTR_ERR(realm);
735 err = adjust_snap_realm_parent(mdsc, realm, le64_to_cpu(ri->parent));
740 if (le64_to_cpu(ri->seq) > realm->seq) {
742 realm->ino, realm, realm->seq, le64_to_cpu(ri->seq));
743 /* update realm parameters, snap lists */
744 realm->seq = le64_to_cpu(ri->seq);
745 realm->created = le64_to_cpu(ri->created);
746 realm->parent_since = le64_to_cpu(ri->parent_since);
748 realm->num_snaps = le32_to_cpu(ri->num_snaps);
749 err = dup_array(&realm->snaps, snaps, realm->num_snaps);
753 realm->num_prior_parent_snaps =
755 err = dup_array(&realm->prior_parent_snaps, prior_parent_snaps,
756 realm->num_prior_parent_snaps);
760 if (realm->seq > mdsc->last_snap_seq)
761 mdsc->last_snap_seq = realm->seq;
764 } else if (!realm->cached_context) {
766 realm->ino, realm, realm->seq);
770 realm->ino, realm, realm->seq);
773 dout("done with %llx %p, rebuild_snapcs=%d, %p %p\n", realm->ino,
774 realm, rebuild_snapcs, p, e);
777 * this will always track the uppest parent realm from which
782 realm_to_rebuild = realm;
789 first_realm = realm;
791 ceph_put_snap_realm(mdsc, realm);
801 realm = list_first_entry(&dirty_realms, struct ceph_snap_realm,
803 list_del_init(&realm->dirty_item);
804 queue_realm_cap_snaps(realm);
818 if (realm && !IS_ERR(realm))
819 ceph_put_snap_realm(mdsc, realm);
867 * or deletion notification on an existing realm. This should update the
868 * realm and its children.
870 * The more difficult case is realm creation, due to snap creation at a
872 * directory into another realm.
883 struct ceph_snap_realm *realm = NULL;
898 * existing realm */
918 * A "split" breaks part of an existing realm off into
919 * a new realm. The MDS provides a list of inodes
928 /* we will peek at realm info here, but will _not_
929 * advance p, as the realm update will occur below in
933 realm = ceph_lookup_snap_realm(mdsc, split);
934 if (!realm) {
935 realm = ceph_create_snap_realm(mdsc, split);
936 if (IS_ERR(realm))
940 dout("splitting snap_realm %llx %p\n", realm->ino, realm);
958 * If this inode belongs to a realm that was
959 * created after our new realm, we experienced
966 dout(" leaving %p in newer realm %llx %p\n",
971 dout(" will move %p to split realm %llx %p\n",
972 inode, realm->ino, realm);
974 * Move the inode to the new realm
981 spin_lock(&realm->inodes_with_caps_lock);
983 &realm->inodes_with_caps);
984 ci->i_snap_realm = realm;
985 if (realm->ino == ci->i_vino.ino)
986 realm->inode = inode;
987 spin_unlock(&realm->inodes_with_caps_lock);
991 ceph_get_snap_realm(mdsc, realm);
1004 /* we may have taken some of the old realm's children. */
1011 adjust_snap_realm_parent(mdsc, child, realm->ino);
1021 * positioned at the start of realm info, as expected by
1036 /* we took a reference when we created the realm, above */
1037 ceph_put_snap_realm(mdsc, realm);