Lines Matching defs:realm

31  * of the files contained by each realm share the same set of
32 * snapshots. An individual realm's snap set contains snapshots
33 * explicitly created on that realm, as well as any snaps in its
40 * realm relationship, and for each realm has an explicit list of snaps
44 * with an open cap in the system. (The needed snap realm information is
46 * version number is used to ensure that as realm parameters change (new
47 * snapshot, new parent, etc.) the client's realm hierarchy is updated.
49 * The realm hierarchy drives the generation of a 'snap context' for each
50 * realm, which simply lists the resulting set of snaps for the realm. This
55 * update, but don't have enough memory to update our realm hierarchy,
62 * increase ref count for the realm
67 struct ceph_snap_realm *realm)
77 if (atomic_inc_not_zero(&realm->nref))
81 if (atomic_inc_return(&realm->nref) == 1)
82 list_del_init(&realm->empty_item);
109 * create and get the realm rooted at @ino and bump its ref count.
117 struct ceph_snap_realm *realm;
121 realm = kzalloc(sizeof(*realm), GFP_NOFS);
122 if (!realm)
127 atomic_set(&realm->nref, 2);
129 atomic_set(&realm->nref, 1);
130 realm->ino = ino;
131 INIT_LIST_HEAD(&realm->children);
132 INIT_LIST_HEAD(&realm->child_item);
133 INIT_LIST_HEAD(&realm->empty_item);
134 INIT_LIST_HEAD(&realm->dirty_item);
135 INIT_LIST_HEAD(&realm->rebuild_item);
136 INIT_LIST_HEAD(&realm->inodes_with_caps);
137 spin_lock_init(&realm->inodes_with_caps_lock);
138 __insert_snap_realm(&mdsc->snap_realms, realm);
141 doutc(mdsc->fsc->client, "%llx %p\n", realm->ino, realm);
142 return realm;
146 * lookup the realm rooted at @ino.
184 struct ceph_snap_realm *realm);
190 struct ceph_snap_realm *realm)
195 doutc(cl, "%p %llx\n", realm, realm->ino);
197 rb_erase(&realm->node, &mdsc->snap_realms);
200 if (realm->parent) {
201 list_del_init(&realm->child_item);
202 __put_snap_realm(mdsc, realm->parent);
205 kfree(realm->prior_parent_snaps);
206 kfree(realm->snaps);
207 ceph_put_snap_context(realm->cached_context);
208 kfree(realm);
215 struct ceph_snap_realm *realm)
223 if (atomic_dec_and_test(&realm->nref))
224 __destroy_snap_realm(mdsc, realm);
231 struct ceph_snap_realm *realm)
233 if (!atomic_dec_and_lock(&realm->nref, &mdsc->snap_empty_lock))
238 __destroy_snap_realm(mdsc, realm);
241 list_add(&realm->empty_item, &mdsc->snap_empty);
255 struct ceph_snap_realm *realm;
261 realm = list_first_entry(&mdsc->snap_empty,
263 list_del(&realm->empty_item);
265 __destroy_snap_realm(mdsc, realm);
284 * adjust the parent realm of a given @realm. adjust child list, and parent
292 struct ceph_snap_realm *realm,
300 if (realm->parent_ino == parentino)
309 doutc(cl, "%llx %p: %llx %p -> %llx %p\n", realm->ino, realm,
310 realm->parent_ino, realm->parent, parentino, parent);
311 if (realm->parent) {
312 list_del_init(&realm->child_item);
313 ceph_put_snap_realm(mdsc, realm->parent);
315 realm->parent_ino = parentino;
316 realm->parent = parent;
317 list_add(&realm->child_item, &parent->children);
333 * build the snap context for a given realm.
336 struct ceph_snap_realm *realm,
341 struct ceph_snap_realm *parent = realm->parent;
344 u32 num = realm->num_prior_parent_snaps + realm->num_snaps;
361 matches realm seq, and my parents' does to. (this works
364 if (realm->cached_context &&
365 realm->cached_context->seq == realm->seq &&
367 realm->cached_context->seq >= parent->cached_context->seq)) {
369 realm->ino, realm, realm->cached_context,
370 realm->cached_context->seq,
371 (unsigned int)realm->cached_context->num_snaps);
385 snapc->seq = realm->seq;
393 realm->parent_since)
399 memcpy(snapc->snaps + num, realm->snaps,
400 sizeof(u64)*realm->num_snaps);
401 num += realm->num_snaps;
402 memcpy(snapc->snaps + num, realm->prior_parent_snaps,
403 sizeof(u64)*realm->num_prior_parent_snaps);
404 num += realm->num_prior_parent_snaps;
408 doutc(cl, "%llx %p: %p seq %lld (%u snaps)\n", realm->ino, realm,
411 ceph_put_snap_context(realm->cached_context);
412 realm->cached_context = snapc;
413 /* queue realm for cap_snap creation */
414 list_add_tail(&realm->dirty_item, dirty_realms);
422 if (realm->cached_context) {
423 ceph_put_snap_context(realm->cached_context);
424 realm->cached_context = NULL;
426 pr_err_client(cl, "%llx %p fail %d\n", realm->ino, realm, err);
431 * rebuild snap context for the given realm and all of its children.
434 struct ceph_snap_realm *realm,
442 list_add_tail(&realm->rebuild_item, &realm_queue);
463 doutc(cl, "%llx %p, %s\n", realm->ino, realm,
527 * Caller must hold snap_rwsem for read (i.e., the realm topology won't
719 * Queue cap_snaps for snap writeback for this realm and its children.
720 * Called under snap_rwsem, so realm topology won't change.
723 struct ceph_snap_realm *realm)
730 doutc(cl, "%p %llx inode\n", realm, realm->ino);
732 spin_lock(&realm->inodes_with_caps_lock);
733 list_for_each_entry(ci, &realm->inodes_with_caps, i_snap_realm_item) {
737 spin_unlock(&realm->inodes_with_caps_lock);
762 spin_lock(&realm->inodes_with_caps_lock);
764 spin_unlock(&realm->inodes_with_caps_lock);
769 doutc(cl, "%p %llx done\n", realm, realm->ino);
774 * the snap realm parameters from a given realm and all of its ancestors,
787 struct ceph_snap_realm *realm;
800 realm = NULL;
812 realm = ceph_lookup_snap_realm(mdsc, le64_to_cpu(ri->ino));
813 if (!realm) {
814 realm = ceph_create_snap_realm(mdsc, le64_to_cpu(ri->ino));
815 if (IS_ERR(realm)) {
816 err = PTR_ERR(realm);
822 err = adjust_snap_realm_parent(mdsc, realm, le64_to_cpu(ri->parent));
827 if (le64_to_cpu(ri->seq) > realm->seq) {
828 doutc(cl, "updating %llx %p %lld -> %lld\n", realm->ino,
829 realm, realm->seq, le64_to_cpu(ri->seq));
830 /* update realm parameters, snap lists */
831 realm->seq = le64_to_cpu(ri->seq);
832 realm->created = le64_to_cpu(ri->created);
833 realm->parent_since = le64_to_cpu(ri->parent_since);
835 realm->num_snaps = le32_to_cpu(ri->num_snaps);
836 err = dup_array(&realm->snaps, snaps, realm->num_snaps);
840 realm->num_prior_parent_snaps =
842 err = dup_array(&realm->prior_parent_snaps, prior_parent_snaps,
843 realm->num_prior_parent_snaps);
847 if (realm->seq > mdsc->last_snap_seq)
848 mdsc->last_snap_seq = realm->seq;
851 } else if (!realm->cached_context) {
852 doutc(cl, "%llx %p seq %lld new\n", realm->ino, realm,
853 realm->seq);
856 doutc(cl, "%llx %p seq %lld unchanged\n", realm->ino, realm,
857 realm->seq);
860 doutc(cl, "done with %llx %p, rebuild_snapcs=%d, %p %p\n", realm->ino,
861 realm, rebuild_snapcs, p, e);
864 * this will always track the uppest parent realm from which
869 realm_to_rebuild = realm;
876 first_realm = realm;
878 ceph_put_snap_realm(mdsc, realm);
888 realm = list_first_entry(&dirty_realms, struct ceph_snap_realm,
890 list_del_init(&realm->dirty_item);
891 queue_realm_cap_snaps(mdsc, realm);
905 if (realm && !IS_ERR(realm))
906 ceph_put_snap_realm(mdsc, realm);
969 * @inode: inode to move to new snap realm
970 * @realm: new realm to move inode into (may be NULL)
973 * the new snaprealm (if any). The old snap realm reference held by
974 * the inode is put. If realm is non-NULL, then the caller's reference
977 void ceph_change_snap_realm(struct inode *inode, struct ceph_snap_realm *realm)
994 ci->i_snap_realm = realm;
996 if (realm) {
997 spin_lock(&realm->inodes_with_caps_lock);
998 list_add(&ci->i_snap_realm_item, &realm->inodes_with_caps);
999 if (realm->ino == ci->i_vino.ino)
1000 realm->inode = inode;
1001 spin_unlock(&realm->inodes_with_caps_lock);
1009 * or deletion notification on an existing realm. This should update the
1010 * realm and its children.
1012 * The more difficult case is realm creation, due to snap creation at a
1014 * directory into another realm.
1026 struct ceph_snap_realm *realm = NULL;
1045 * existing realm */
1061 * A "split" breaks part of an existing realm off into
1062 * a new realm. The MDS provides a list of inodes
1071 /* we will peek at realm info here, but will _not_
1072 * advance p, as the realm update will occur below in
1076 realm = ceph_lookup_snap_realm(mdsc, split);
1077 if (!realm) {
1078 realm = ceph_create_snap_realm(mdsc, split);
1079 if (IS_ERR(realm))
1083 doutc(cl, "splitting snap_realm %llx %p\n", realm->ino, realm);
1100 * If this inode belongs to a realm that was
1101 * created after our new realm, we experienced
1108 doutc(cl, " leaving %p %llx.%llx in newer realm %llx %p\n",
1113 doutc(cl, " will move %p %llx.%llx to split realm %llx %p\n",
1114 inode, ceph_vinop(inode), realm->ino, realm);
1116 ceph_get_snap_realm(mdsc, realm);
1117 ceph_change_snap_realm(inode, realm);
1127 /* we may have taken some of the old realm's children. */
1134 adjust_snap_realm_parent(mdsc, child, realm->ino);
1144 * positioned at the start of realm info, as expected by
1163 /* we took a reference when we created the realm, above */
1164 ceph_put_snap_realm(mdsc, realm);