From patchwork Fri Feb 2 14:08:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10196861 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 CF73D6037D for ; Fri, 2 Feb 2018 14:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFC9728E61 for ; Fri, 2 Feb 2018 14:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3C9A28E6B; Fri, 2 Feb 2018 14:11:33 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 461A528E61 for ; Fri, 2 Feb 2018 14:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752026AbeBBOLb (ORCPT ); Fri, 2 Feb 2018 09:11:31 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55767 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbeBBOLE (ORCPT ); Fri, 2 Feb 2018 09:11:04 -0500 Received: by mail-wm0-f67.google.com with SMTP id 143so12835167wma.5 for ; Fri, 02 Feb 2018 06:11:03 -0800 (PST) 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=poQyLyC44EFHTJ8UZDG4iZxUWDcz8L5t9qeRWe5Ubyo=; b=yriGFlAOEVgSa2S91Xmms4yNeBZkYzm/Qer6wfvt4kRQOqCXuGVlS9uUyLnZWiGhMr sNmYJcuvwX4pO3X5QO3j39FogMSJ9YZrG77549vdU3sB4LRc8/fl76UfjoFWDeJH1HoN IWfnLLv9kLZffQzEdvfcg4k/YvacFkrzojxsNNnUhkeQd1AUFpUsbN84oOWkG6jeF1yK TJS4Z496yLINVkp6h2Oh+dsyryTBKrl0L7ihcvijKCZzLJZSVERJngwwRIBQGwvUN9lI mg2xPlB7Nol/GDZlWugA7N5ReM8j8vSRNqloGBilmkkRwlMAgj/kO7H54tw6LTDWwPbx FWBg== 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=poQyLyC44EFHTJ8UZDG4iZxUWDcz8L5t9qeRWe5Ubyo=; b=b4XAtMdJm4f/hNEveJ2gzae6ANcfwBCgpUmnFCuZN9umhd1nUxBJ98s87V9gizOFSw ny3l2n9uiFf2OmPQ5zee8E+j+5FUFvavvJVDATYbJnf2nk1G5LwHosEzgghl4Xqgxc8O UXddZudKxnJ5ywwbbM4Pcd1ueOYDT5rFWt4ZYe4hrb9g/zADC87JFyKfjcQqXanAz6im 5X8xDiaj2IQnS1QpVnZ3GomNWE7BtprRAPU9oRsMizoL7mw4OC4XRFaxJKDO6TDVKpAc e29CLYAbCJLDuFrBEC6a2o7NWLSI/0iKAOBFhKMQnQXMQ8FojEZafknpzX8t6Ck/+5i3 4wqQ== X-Gm-Message-State: AKwxytdk0fJfdOAJZ8ugVwW/P1r+aZ0UlqDYzJBJxNsm89dBc0IOxqdM 9VseNO7UkdO5Ergyek1Ahpv9ZCJp X-Google-Smtp-Source: AH8x227pmd9tkiZGIJDgAv+TBwpQD3bEK5hJatCpOwDkSDVYqDupXU6WG7g+C2keP410rurYMkByaA== X-Received: by 10.28.152.74 with SMTP id a71mr32257666wme.76.1517580662921; Fri, 02 Feb 2018 06:11:02 -0800 (PST) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id v186sm798819wmf.17.2018.02.02.06.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 06:11:02 -0800 (PST) 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 , Roman Pen , Danil Kipnis , Jack Wang Subject: [PATCH 18/24] ibnbd: server: private header with server structs and functions Date: Fri, 2 Feb 2018 15:08:58 +0100 Message-Id: <20180202140904.2017-19-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180202140904.2017-1-roman.penyaev@profitbricks.com> References: <20180202140904.2017-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(+) 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 */