From patchwork Wed Jun 6 15:25:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10450501 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 E0E0D60375 for ; Wed, 6 Jun 2018 15:26:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D09D729776 for ; Wed, 6 Jun 2018 15:26:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C34682979F; Wed, 6 Jun 2018 15:26:29 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 502F429776 for ; Wed, 6 Jun 2018 15:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932101AbeFFP01 (ORCPT ); Wed, 6 Jun 2018 11:26:27 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36074 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426AbeFFPZx (ORCPT ); Wed, 6 Jun 2018 11:25:53 -0400 Received: by mail-wm0-f66.google.com with SMTP id v131-v6so12828075wma.1 for ; Wed, 06 Jun 2018 08:25:52 -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=r+sp0C8hItjrs+CfstR5cmMBYEPWVhKNfl+PNquhNrc=; b=YUdwPNTbXxjiryYU8dxqBEGywNPs1s+/CifNbw1hSMhq7Jb85lJsRREBWkhe/5dlBN Nt9gdWpYEFzLUdwdRDSMsTFqBrThj0qXdre2YtLeo6wjJUyz48E4+rPfPV74nVecfBhB TtX1jEnPwdmj8ABUz2GlTY+NI+aujKctENcYZymSnHtBl+ZSa1DuyPHNCCihpH/xYR55 4MPc68w8pUAnKLmO5Sa2hOSw070+1k/9riA/f/p1foeptXlkALRLVmUOZYkPeFuu70ud aGu+Jo/Ss6uCWtURkYWk5qDXkB9UZgM0eNNlE3E7MmR5B92GIUcEAp6OwouKZ0aq5USe f63A== 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=r+sp0C8hItjrs+CfstR5cmMBYEPWVhKNfl+PNquhNrc=; b=JCB4ivnhno2gFsdZJJImbIJS+troCX45aUhTkLghgyGcXAVhoLWMTVgNt+Z9MTle89 sjzgHQYLILITMDlN29zkUF1jCMMGkm5nxXYHc4hnO7ITA5mYELIG/mQ1tOizAmr61EMb z2lcbqCwNDyRCDfNiGSsGB+lZ0QQQb3fQX9fG3Hu48TN20v3eP4gPhj90OhmLhCef7lj +EVPmzaQTue3O5VXp0TH6LhyBtu/bq4QJiNA75loUIVqtDe21M5tU/vbRRng1AFi6Rru o/6zctICA3ikGBlCngmzfWvqNm9bM7bGvxtxHHB06ibBOLzsQc9szcbZ3si8N5fYHjIK y/3g== X-Gm-Message-State: APt69E3FmG0IWqG5pl6bSZcikAdGN6LdXdFYcSgzYXwO2OwaJoXFpZUq khEzeJPNLUpzwopVMoAjl+7vcSJdFms= X-Google-Smtp-Source: ADUXVKLbumlsbf0LIX50pAyW3FU0iPCnsTkhMmaq7oWaAN8vSXx0O6rNLbKJ26OzdESAJZZweYi4lw== X-Received: by 2002:a1c:928c:: with SMTP id u134-v6mr2047637wmd.106.1528298751995; Wed, 06 Jun 2018 08:25:51 -0700 (PDT) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id n11-v6sm18645834wro.13.2018.06.06.08.25.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 08:25:51 -0700 (PDT) From: Roman Pen To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Jens Axboe , Christoph Hellwig , Sagi Grimberg , Bart Van Assche , Or Gerlitz , Doug Ledford , Danil Kipnis , Jack Wang , Roman Pen Subject: [PATCH v3 19/25] ibnbd: server: private header with server structs and functions Date: Wed, 6 Jun 2018 17:25:09 +0200 Message-Id: <20180606152515.25807-20-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180606152515.25807-1-roman.penyaev@profitbricks.com> References: <20180606152515.25807-1-roman.penyaev@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 This header describes main structs and functions used by ibnbd-server module, namely structs for managing sessions from different clients and mapped (opened) devices. Signed-off-by: Roman Pen Signed-off-by: Danil Kipnis Cc: Jack Wang --- drivers/block/ibnbd/ibnbd-srv.h | 100 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 drivers/block/ibnbd/ibnbd-srv.h diff --git a/drivers/block/ibnbd/ibnbd-srv.h b/drivers/block/ibnbd/ibnbd-srv.h new file mode 100644 index 000000000000..191a1650bc1d --- /dev/null +++ b/drivers/block/ibnbd/ibnbd-srv.h @@ -0,0 +1,100 @@ +/* + * InfiniBand Network Block Driver + * + * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved. + * Authors: Fabian Holler + * Jack Wang + * Kleber Souza + * Danil Kipnis + * Roman Penyaev + * Milind Dumbare + * + * Copyright (c) 2017 - 2018 ProfitBricks GmbH. All rights reserved. + * Authors: Danil Kipnis + * Roman Penyaev + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef IBNBD_SRV_H +#define IBNBD_SRV_H + +#include +#include +#include + +#include "ibtrs.h" +#include "ibnbd-proto.h" +#include "ibnbd-log.h" + +struct ibnbd_srv_session { + /* Entry inside global sess_list */ + struct list_head list; + struct ibtrs_srv *ibtrs; + char sessname[NAME_MAX]; + int queue_depth; + struct bio_set *sess_bio_set; + + rwlock_t index_lock ____cacheline_aligned; + struct idr index_idr; + /* List of struct ibnbd_srv_sess_dev */ + struct list_head sess_dev_list; + struct mutex lock; + u8 ver; +}; + +struct ibnbd_srv_dev { + /* Entry inside global dev_list */ + struct list_head list; + struct kobject dev_kobj; + struct kobject dev_sessions_kobj; + struct kref kref; + char id[NAME_MAX]; + /* List of ibnbd_srv_sess_dev structs */ + struct list_head sess_dev_list; + struct mutex lock; + int open_write_cnt; + enum ibnbd_io_mode mode; +}; + +/* Structure which binds N devices and N sessions */ +struct ibnbd_srv_sess_dev { + /* Entry inside ibnbd_srv_dev struct */ + struct list_head dev_list; + /* Entry inside ibnbd_srv_session struct */ + struct list_head sess_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; + fmode_t open_flags; + struct kref kref; + struct completion *destroy_comp; + char pathname[NAME_MAX]; +}; + +/* ibnbd-srv-sysfs.c */ + +int ibnbd_srv_create_dev_sysfs(struct ibnbd_srv_dev *dev, + struct block_device *bdev, + const char *dir_name); +void ibnbd_srv_destroy_dev_sysfs(struct ibnbd_srv_dev *dev); +int ibnbd_srv_create_dev_session_sysfs(struct ibnbd_srv_sess_dev *sess_dev); +void ibnbd_srv_destroy_dev_session_sysfs(struct ibnbd_srv_sess_dev *sess_dev); +int ibnbd_srv_create_sysfs_files(void); +void ibnbd_srv_destroy_sysfs_files(void); + +#endif /* IBNBD_SRV_H */