From patchwork Wed Jul 29 09:23:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 6891311 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 C0B0FC05AD for ; Wed, 29 Jul 2015 09:24:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E26AD207D8 for ; Wed, 29 Jul 2015 09:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B30A207B1 for ; Wed, 29 Jul 2015 09:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbbG2JYF (ORCPT ); Wed, 29 Jul 2015 05:24:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49887 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbbG2JYB (ORCPT ); Wed, 29 Jul 2015 05:24:01 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 531C574; Wed, 29 Jul 2015 09:24:01 +0000 (UTC) Received: from rh2.redhat.com (vpn-60-109.rdu2.redhat.com [10.10.60.109]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6T9Ntmk011149; Wed, 29 Jul 2015 05:24:00 -0400 From: mchristi@redhat.com To: ceph-devel@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 07/18] rbd: add num ops calculator helper Date: Wed, 29 Jul 2015 04:23:44 -0500 Message-Id: <1438161835-27960-7-git-send-email-mchristi@redhat.com> In-Reply-To: <1438161835-27960-1-git-send-email-mchristi@redhat.com> References: <1438161835-27960-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-8.3 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 The next patches add new commands that have different number of ops, so this adds a helper. Signed-off-by: Mike Christie --- drivers/block/rbd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8d0b30a..425c3d8 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -813,6 +813,16 @@ static int parse_rbd_opts_token(char *c, void *private) return 0; } +static int obj_num_ops(enum obj_operation_type op_type) +{ + switch (op_type) { + case OBJ_OP_WRITE: + return 2; + default: + return 1; + } +} + static char* obj_op_name(enum obj_operation_type op_type) { switch (op_type) { @@ -1987,7 +1997,7 @@ static struct ceph_osd_request *rbd_osd_req_create( snapc = img_request->snapc; } - rbd_assert(num_ops == 1 || ((op_type == OBJ_OP_WRITE) && num_ops == 2)); + rbd_assert(num_ops == 1 || obj_num_ops(op_type) == num_ops); /* Allocate and initialize the request, for the num_ops ops */ @@ -2589,8 +2599,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, } osd_req = rbd_osd_req_create(rbd_dev, op_type, - (op_type == OBJ_OP_WRITE) ? 2 : 1, - obj_request); + obj_num_ops(op_type), obj_request); if (!osd_req) goto out_unwind;