From patchwork Tue Jun 30 20:27:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Fuller X-Patchwork-Id: 6698191 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D73FEC05AC for ; Tue, 30 Jun 2015 20:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A592204D3 for ; Tue, 30 Jun 2015 20:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2A76204B5 for ; Tue, 30 Jun 2015 20:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752584AbbF3U36 (ORCPT ); Tue, 30 Jun 2015 16:29:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48463 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbbF3U35 (ORCPT ); Tue, 30 Jun 2015 16:29:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D78EB8F277 for ; Tue, 30 Jun 2015 20:29:56 +0000 (UTC) Received: from rex001.front.sepia.ceph.com ([10.17.112.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5UKTrti018417 for ; Tue, 30 Jun 2015 16:29:56 -0400 From: Douglas Fuller To: ceph-devel@vger.kernel.org Subject: [PATCH RFC 1/6] Add support for userspace ceph DECODE_START. Date: Tue, 30 Jun 2015 13:27:56 -0700 Message-Id: <3f553015bc14a3ed984ba62b5237c05f3f236714.1435695881.git.dfuller@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mike Christie Signed-off-by: Mike Christie --- include/linux/ceph/decode.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h index a6ef9cc..b55c7fd 100644 --- a/include/linux/ceph/decode.h +++ b/include/linux/ceph/decode.h @@ -255,5 +255,28 @@ static inline void ceph_encode_string(void **p, void *end, ceph_encode_string(p, end, s, n); \ } while (0) +/** + * ceph_start_decoding - start a decoding block + * @p: buffer to decode + * @end: end of buffer + * @curr_ver: current version of the encoding that the code supports/encode + * @len: buffer to return len of data in buffer + */ +static inline int ceph_start_decoding(void **p, void *end, u8 curr_ver, + u32 *len) +{ + u8 struct_ver, struct_compat; + + ceph_decode_8_safe(p, end, struct_ver, fail); + ceph_decode_8_safe(p, end, struct_compat, fail); + + if (curr_ver < struct_compat) + return -EINVAL; + + ceph_decode_32_safe(p, end, *len, fail); + return 0; +fail: + return -ERANGE; +} #endif