snap.c (a105f00cf17d711e876b3dc67e15f9a89b7de5a3) snap.c (2600d2dd5085ab6fb09540226138a60055abf335)
1#include "ceph_debug.h"
2
3#include <linux/sort.h>
4
5#include "super.h"
6#include "decode.h"
7
8/*

--- 699 unchanged lines hidden (view full) ---

708 * or deletion notification on an existing realm. This should update the
709 * realm and its children.
710 *
711 * The more difficult case is realm creation, due to snap creation at a
712 * new point in the file hierarchy, or due to a rename that moves a file or
713 * directory into another realm.
714 */
715void ceph_handle_snap(struct ceph_mds_client *mdsc,
1#include "ceph_debug.h"
2
3#include <linux/sort.h>
4
5#include "super.h"
6#include "decode.h"
7
8/*

--- 699 unchanged lines hidden (view full) ---

708 * or deletion notification on an existing realm. This should update the
709 * realm and its children.
710 *
711 * The more difficult case is realm creation, due to snap creation at a
712 * new point in the file hierarchy, or due to a rename that moves a file or
713 * directory into another realm.
714 */
715void ceph_handle_snap(struct ceph_mds_client *mdsc,
716 struct ceph_mds_session *session,
716 struct ceph_msg *msg)
717{
718 struct super_block *sb = mdsc->client->sb;
717 struct ceph_msg *msg)
718{
719 struct super_block *sb = mdsc->client->sb;
719 struct ceph_mds_session *session;
720 int mds;
720 int mds = session->s_mds;
721 u64 split;
722 int op;
723 int trace_len;
724 struct ceph_snap_realm *realm = NULL;
725 void *p = msg->front.iov_base;
726 void *e = p + msg->front.iov_len;
727 struct ceph_mds_snap_head *h;
728 int num_split_inos, num_split_realms;
729 __le64 *split_inos = NULL, *split_realms = NULL;
730 int i;
731 int locked_rwsem = 0;
732
721 u64 split;
722 int op;
723 int trace_len;
724 struct ceph_snap_realm *realm = NULL;
725 void *p = msg->front.iov_base;
726 void *e = p + msg->front.iov_len;
727 struct ceph_mds_snap_head *h;
728 int num_split_inos, num_split_realms;
729 __le64 *split_inos = NULL, *split_realms = NULL;
730 int i;
731 int locked_rwsem = 0;
732
733 if (msg->hdr.src.name.type != CEPH_ENTITY_TYPE_MDS)
734 return;
735 mds = le64_to_cpu(msg->hdr.src.name.num);
736
737 /* decode */
738 if (msg->front.iov_len < sizeof(*h))
739 goto bad;
740 h = p;
741 op = le32_to_cpu(h->op);
742 split = le64_to_cpu(h->split); /* non-zero if we are splitting an
743 * existing realm */
744 num_split_inos = le32_to_cpu(h->num_split_inos);
745 num_split_realms = le32_to_cpu(h->num_split_realms);
746 trace_len = le32_to_cpu(h->trace_len);
747 p += sizeof(*h);
748
749 dout("handle_snap from mds%d op %s split %llx tracelen %d\n", mds,
750 ceph_snap_op_name(op), split, trace_len);
751
733 /* decode */
734 if (msg->front.iov_len < sizeof(*h))
735 goto bad;
736 h = p;
737 op = le32_to_cpu(h->op);
738 split = le64_to_cpu(h->split); /* non-zero if we are splitting an
739 * existing realm */
740 num_split_inos = le32_to_cpu(h->num_split_inos);
741 num_split_realms = le32_to_cpu(h->num_split_realms);
742 trace_len = le32_to_cpu(h->trace_len);
743 p += sizeof(*h);
744
745 dout("handle_snap from mds%d op %s split %llx tracelen %d\n", mds,
746 ceph_snap_op_name(op), split, trace_len);
747
752 /* find session */
753 mutex_lock(&mdsc->mutex);
754 session = __ceph_lookup_mds_session(mdsc, mds);
755 mutex_unlock(&mdsc->mutex);
756 if (!session) {
757 dout("WTF, got snap but no session for mds%d\n", mds);
758 return;
759 }
760
761 mutex_lock(&session->s_mutex);
762 session->s_seq++;
763 mutex_unlock(&session->s_mutex);
764
765 down_write(&mdsc->snap_rwsem);
766 locked_rwsem = 1;
767
768 if (op == CEPH_SNAP_OP_SPLIT) {

--- 149 unchanged lines hidden ---
748 mutex_lock(&session->s_mutex);
749 session->s_seq++;
750 mutex_unlock(&session->s_mutex);
751
752 down_write(&mdsc->snap_rwsem);
753 locked_rwsem = 1;
754
755 if (op == CEPH_SNAP_OP_SPLIT) {

--- 149 unchanged lines hidden ---