From patchwork Fri Mar 24 10:45:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9642659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40B5F6020B for ; Fri, 24 Mar 2017 10:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5725E28236 for ; Fri, 24 Mar 2017 10:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A5CE26E81; Fri, 24 Mar 2017 10:48:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D908026E81 for ; Fri, 24 Mar 2017 10:48:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964908AbdCXKsX (ORCPT ); Fri, 24 Mar 2017 06:48:23 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38145 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935738AbdCXKsD (ORCPT ); Fri, 24 Mar 2017 06:48:03 -0400 Received: by mail-wm0-f46.google.com with SMTP id t189so9908874wmt.1 for ; Fri, 24 Mar 2017 03:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nKSuFyDqLty1jiS/nrzZhRdS0qCf5BBtajqOg7xR2nI=; b=Hl9fYW+LMNa/213wjI77VkIcuSBdvEUx1iiG0UQMDnuBMU+iWHUaOUen6SgQTFdVCs NY8M6DK4EWwKJg63KGLU+GCZD6ruveBoTE5ixDOb7lI/0FdRfH+u0QXveMfgWwQMHoU3 aNWV/Ki2rX0lzfK8CsAOQ5V4/YLy2RGHtU1jc/eAaHNKPC36wN1AqYR0aGry8QtLNEtU x0hOBNOpz8gnkIcvJOqe6spzKJPtQaM1EfZxBgN57g0+jV6JRIqke9RdXCMYi23P/X4c YRLK7p2R7gTtCg4Yk2yJne6xDw085nGY+1jLqiGT4uq3hesHWyXk4KFrNSAKULQTRRqb cMgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nKSuFyDqLty1jiS/nrzZhRdS0qCf5BBtajqOg7xR2nI=; b=pADjLwZfjOPiHxCVs3lpciZ3HfktGKtnWoV8eit2nmBrYrAVByQY4g50Ywg+uvDk/8 Iwg2nrvoyUkSfR5ynC7+OOsGICavgNc/hX4G7TkU/E+OOTPl6ymj5slwNq6byt2xb09e l+6MXj8due1f0Vp+aQijVBb6h9j4mDUgSjkp5Ye05pigAmDWq4N94088GYsP2gDBgsny AfFYKcH9sdVU5bKsnFtgeHatBtjm/7DlYpFwTwi9u8KT3CgI5RLRr9HAfPediT7tMeFC j3QBrRtakH3ETufuyTZLY/WYy0Ye8gsNBS9QmljupLeS6scmLyHH8wvpJQjSpK2716ZV 27Cw== X-Gm-Message-State: AFeK/H0Qb4ZFWyKB67VTH5z0IKeoNOk5uJRQT/7GYN/w9cyQa5vny3KUHvFMEddAqyCuvRWY X-Received: by 10.28.107.14 with SMTP id g14mr2399707wmc.106.1490352470979; Fri, 24 Mar 2017 03:47:50 -0700 (PDT) Received: from jinpu-GA-870A-USB3.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id s17sm2404458wrc.25.2017.03.24.03.47.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Mar 2017 03:47:50 -0700 (PDT) From: Jack Wang X-Google-Original-From: Jack Wang To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: dledford@redhat.com, axboe@kernel.dk, hch@lst.de, mail@fholler.de, Milind.dumbare@gmail.com, yun.wang@profitbricks.com, Jack Wang , Kleber Souza , Danil Kipnis , Roman Pen Subject: [PATCH 21/28] ibnbd_srv: add header shared in ibnbd_server Date: Fri, 24 Mar 2017 11:45:36 +0100 Message-Id: <1490352343-20075-22-git-send-email-jinpu.wangl@profitbricks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490352343-20075-1-git-send-email-jinpu.wangl@profitbricks.com> References: <1490352343-20075-1-git-send-email-jinpu.wangl@profitbricks.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jack Wang Signed-off-by: Jack Wang Signed-off-by: Kleber Souza Signed-off-by: Danil Kipnis Signed-off-by: Roman Pen --- drivers/block/ibnbd_server/ibnbd_srv.h | 115 +++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 drivers/block/ibnbd_server/ibnbd_srv.h diff --git a/drivers/block/ibnbd_server/ibnbd_srv.h b/drivers/block/ibnbd_server/ibnbd_srv.h new file mode 100644 index 0000000..764a31f --- /dev/null +++ b/drivers/block/ibnbd_server/ibnbd_srv.h @@ -0,0 +1,115 @@ +/* + * InfiniBand Network Block Driver + * + * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved. + * Authors: Fabian Holler < mail@fholler.de> + * Jack Wang + * Kleber Souza + * Danil Kipnis + * Roman Pen + * Milind Dumbare + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + */ + +#ifndef _IBNBD_SRV_H +#define _IBNBD_SRV_H + +#include +#include +#include +#include "../ibnbd_inc/ibnbd.h" +#include "../ibnbd_inc/ibnbd-proto.h" +#include + +enum sess_state { + SESS_STATE_CONNECTED, + SESS_STATE_DISCONNECTED +}; + +struct ibnbd_srv_session { + struct list_head list; /* for the global sess_list */ + struct ibtrs_session *ibtrs_sess; + char str_addr[IBTRS_ADDRLEN]; + char hostname[MAXHOSTNAMELEN]; + int queue_depth; + enum sess_state state; + struct bio_set *sess_bio_set; + + rwlock_t index_lock ____cacheline_aligned; + struct idr index_idr; + struct mutex lock; /* protects sess_dev_list */ + struct list_head sess_dev_list; /* list of struct ibnbd_srv_sess_dev */ + u8 ver; /* IBNBD protocol version */ +}; + +struct ibnbd_srv_dev { + struct list_head list; /* global dev_list */ + + struct kobject dev_kobj; + struct kobject dev_clients_kobj; + + struct kref kref; + char id[NAME_MAX]; + + struct mutex lock; /* protects sess_dev_list and open_write_cnt */ + struct list_head sess_dev_list; /* list of struct ibnbd_srv_sess_dev */ + int open_write_cnt; + enum ibnbd_io_mode mode; +}; + +struct ibnbd_srv_sess_dev { + struct list_head dev_list; /* for struct ibnbd_srv_dev->sess_dev_list */ + struct list_head sess_list; /* for struct ibnbd_srv_session->sess_dev_list */ + + struct ibnbd_dev *ibnbd_dev; + struct ibnbd_srv_session *sess; + struct ibnbd_srv_dev *dev; + struct kobject kobj; + struct completion *sysfs_release_compl; + + u32 device_id; + u32 clt_device_id; + fmode_t open_flags; + struct kref kref; + struct completion *destroy_comp; + char pathname[NAME_MAX]; + size_t nsectors; + bool is_visible; +}; + +int ibnbd_srv_revalidate_dev(struct ibnbd_srv_dev *dev); + +#endif