|
14 | 14 |
|
15 | 15 | #include "msgr.h" |
16 | 16 | #include "rados.h" |
17 | | -#include "include/encoding.h" |
18 | | -#include "include/denc.h" |
| 17 | +#include "include/buffer.h" // for ceph::buffer::list |
19 | 18 |
|
20 | 19 | /* |
21 | 20 | * The data structures defined here are shared between Linux kernel and |
@@ -686,107 +685,8 @@ struct ceph_mds_request_head { |
686 | 685 | __le32 owner_uid, owner_gid; /* used for OPs which create inodes */ |
687 | 686 | } __attribute__ ((packed)); |
688 | 687 |
|
689 | | -void inline encode(const struct ceph_mds_request_head& h, ceph::buffer::list& bl) { |
690 | | - using ceph::encode; |
691 | | - encode(h.version, bl); |
692 | | - encode(h.oldest_client_tid, bl); |
693 | | - encode(h.mdsmap_epoch, bl); |
694 | | - encode(h.flags, bl); |
695 | | - |
696 | | - // For old MDS daemons |
697 | | - __u8 num_retry = __u32(h.ext_num_retry); |
698 | | - __u8 num_fwd = __u32(h.ext_num_fwd); |
699 | | - encode(num_retry, bl); |
700 | | - encode(num_fwd, bl); |
701 | | - |
702 | | - encode(h.num_releases, bl); |
703 | | - encode(h.op, bl); |
704 | | - encode(h.caller_uid, bl); |
705 | | - encode(h.caller_gid, bl); |
706 | | - encode(h.ino, bl); |
707 | | - bl.append((char*)&h.args, sizeof(h.args)); |
708 | | - |
709 | | - if (h.version >= 2) { |
710 | | - encode(h.ext_num_retry, bl); |
711 | | - encode(h.ext_num_fwd, bl); |
712 | | - } |
713 | | - |
714 | | - if (h.version >= 3) { |
715 | | - __u32 struct_len = sizeof(struct ceph_mds_request_head); |
716 | | - encode(struct_len, bl); |
717 | | - encode(h.owner_uid, bl); |
718 | | - encode(h.owner_gid, bl); |
719 | | - |
720 | | - /* |
721 | | - * Please, add new fields handling here. |
722 | | - * You don't need to check h.version as we do it |
723 | | - * in decode(), because decode can properly skip |
724 | | - * all unsupported fields if h.version >= 3. |
725 | | - */ |
726 | | - } |
727 | | -} |
728 | | - |
729 | | -void inline decode(struct ceph_mds_request_head& h, ceph::buffer::list::const_iterator& bl) { |
730 | | - using ceph::decode; |
731 | | - unsigned struct_end = bl.get_off(); |
732 | | - |
733 | | - decode(h.version, bl); |
734 | | - decode(h.oldest_client_tid, bl); |
735 | | - decode(h.mdsmap_epoch, bl); |
736 | | - decode(h.flags, bl); |
737 | | - decode(h.num_retry, bl); |
738 | | - decode(h.num_fwd, bl); |
739 | | - decode(h.num_releases, bl); |
740 | | - decode(h.op, bl); |
741 | | - decode(h.caller_uid, bl); |
742 | | - decode(h.caller_gid, bl); |
743 | | - decode(h.ino, bl); |
744 | | - bl.copy(sizeof(h.args), (char*)&(h.args)); |
745 | | - |
746 | | - if (h.version >= 2) { |
747 | | - decode(h.ext_num_retry, bl); |
748 | | - decode(h.ext_num_fwd, bl); |
749 | | - } else { |
750 | | - h.ext_num_retry = h.num_retry; |
751 | | - h.ext_num_fwd = h.num_fwd; |
752 | | - } |
753 | | - |
754 | | - if (h.version >= 3) { |
755 | | - decode(h.struct_len, bl); |
756 | | - struct_end += h.struct_len; |
757 | | - |
758 | | - decode(h.owner_uid, bl); |
759 | | - decode(h.owner_gid, bl); |
760 | | - } else { |
761 | | - /* |
762 | | - * client is old: let's take caller_{u,g}id as owner_{u,g}id |
763 | | - * this is how it worked before adding of owner_{u,g}id fields. |
764 | | - */ |
765 | | - h.owner_uid = h.caller_uid; |
766 | | - h.owner_gid = h.caller_gid; |
767 | | - } |
768 | | - |
769 | | - /* add new fields handling here */ |
770 | | - |
771 | | - /* |
772 | | - * From version 3 we have struct_len field. |
773 | | - * It allows us to properly handle a case |
774 | | - * when client send struct ceph_mds_request_head |
775 | | - * bigger in size than MDS supports. In this |
776 | | - * case we just want to skip all remaining bytes |
777 | | - * at the end. |
778 | | - * |
779 | | - * See also DECODE_FINISH macro. Unfortunately, |
780 | | - * we can't start using it right now as it will be |
781 | | - * an incompatible protocol change. |
782 | | - */ |
783 | | - if (h.version >= 3) { |
784 | | - if (bl.get_off() > struct_end) |
785 | | - throw ::ceph::buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); |
786 | | - if (bl.get_off() < struct_end) |
787 | | - bl += struct_end - bl.get_off(); |
788 | | - } |
789 | | -} |
| 688 | +void encode(const struct ceph_mds_request_head& h, ceph::buffer::list& bl); |
| 689 | +void decode(struct ceph_mds_request_head& h, ceph::buffer::list::const_iterator& bl); |
790 | 690 |
|
791 | 691 | /* cap/lease release record */ |
792 | 692 | struct ceph_mds_request_release { |
|
0 commit comments