From patchwork Fri May 18 13:04:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10410631 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 48FD56037E for ; Fri, 18 May 2018 13:06:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3883F28980 for ; Fri, 18 May 2018 13:06:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D59328984; Fri, 18 May 2018 13:06:41 +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=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 B395328985 for ; Fri, 18 May 2018 13:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbeERNGh (ORCPT ); Fri, 18 May 2018 09:06:37 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33727 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752661AbeERNFv (ORCPT ); Fri, 18 May 2018 09:05:51 -0400 Received: by mail-wm0-f67.google.com with SMTP id x12-v6so3435475wmc.0 for ; Fri, 18 May 2018 06:05:51 -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=wQkSSoXSWP3W02rk5LuAC1I8LsWEsNcQ3aVAnmwUX7oYEuYfznTvMIxVd4k8KjuMy8 JLFmW/lQJEPFJoKZoOE5LIgtCcds+Stzj41QlK7ojc5Mpearm4h632EiNl4ct5KyNEQR V52IB8T7/OMdFv/Hfwbto5djY1GxX4yawrXlj5++1K8sydpZch5gIOiw9fFuhmQNQWFv ecaZA1SCj4mm826iudpvfA/FvSLtQPr6+dUtpEelYQEVFF6rchg3QVpkVkwSrdgYP4V4 1GlFReZ/L31EB5yUhla/vOhVtgWcMDpHhBZbslpW3+8pz1ZPQiSO8gjkv1L+Lm0o7wd3 1UtQ== 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=CzpvK0pagkzrWqzsDfC2jkvaJMW1Edsof++Ej5+v1QDk9yzzEK+68nRI1mlcli7gWc 9B43qzTPr5l1ouwfr/dqJEVYXHxwL+BEfji2oit+FJ1joXKZ1ODTiytWz9g+CGFEBqso OHfNuwWtFYBZ4Zo2hBYZwaZiidQ78t2cUenmfl/zw0Cq3rYJ1P0dYVx5fChWpwYt8WQ1 4EH+Vfsg+92RdpINwJ0F+BnVwor/caT9SCyyPkbcqiNka9CsdNaLioIAvtqblSfyxffC QnbpJO5BfaHJfbSc309A6Pq+ZoLkMQIcMPaEcWUj7v6Nc2TkAHiLH88flCxeAW9qaYUG q3lA== X-Gm-Message-State: ALKqPwemwbDmzJ0sM0RW+z32+QKzRgRM5/1hNYVJZTvNMeWY/CR3rAnU mUvf2Nzl6zIIAbyTqu0txXdDXHBH X-Google-Smtp-Source: AB8JxZrh2pNUe7nvmVZQg41lj3b17C3REPD5YlKPWRg2gXtMrMlGJtvMboZxb6BppF2WXlXo+c+NRw== X-Received: by 2002:a1c:512:: with SMTP id 18-v6mr4368325wmf.47.1526648750291; Fri, 18 May 2018 06:05:50 -0700 (PDT) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id m35-v6sm7639980wrm.51.2018.05.18.06.05.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 06:05:49 -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 , Swapnil Ingle , Danil Kipnis , Jack Wang , Roman Pen Subject: [PATCH v2 20/26] ibnbd: server: private header with server structs and functions Date: Fri, 18 May 2018 15:04:07 +0200 Message-Id: <20180518130413.16997-21-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180518130413.16997-1-roman.penyaev@profitbricks.com> References: <20180518130413.16997-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 */