From patchwork Fri Dec 20 15:51:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11305911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0709A13A4 for ; Fri, 20 Dec 2019 15:51:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D909D24679 for ; Fri, 20 Dec 2019 15:51:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GC9ZOzDa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727593AbfLTPvl (ORCPT ); Fri, 20 Dec 2019 10:51:41 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37786 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfLTPvk (ORCPT ); Fri, 20 Dec 2019 10:51:40 -0500 Received: by mail-wm1-f65.google.com with SMTP id f129so9721920wmf.2; Fri, 20 Dec 2019 07:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uczIf8wl7NtPkUeKJLOllYreCbtFd4vfgmCVdW8TWc8=; b=GC9ZOzDago+wV+X0UVwyKiBizEVsTq6Ch+prIaIF1NpQeXerGVTnAtWC7UhMzYPY2V Ad8FT7qI4J8c+GgHyj93xwbC/vsAc5qLK0klUVtiXco4w1Xclvoq79Cm/l3EI/VGKYRd WifLcnGqVGhv66+Qnjhip7aoOUeDX7+5z1Jyub0hG1AndiS2/y0deklLkCJ+gGJdxJCp jRDbyA99HAkGblN0UE0EWmRhnE/eRpeamTxl9hysWFpwd48g5utNSvg9UmaMAaN4qbn8 yBPJRWTfhYtYS2oDqCWtBeW2VNCrlI4BRCTXh69JM65hLz71u0xIXvjHvd7JMTRMO5hi 4Xew== 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=uczIf8wl7NtPkUeKJLOllYreCbtFd4vfgmCVdW8TWc8=; b=QnNQ3XBN4buOtKwJ05QLyA8jsu6yBHUbZkYMX78gcR6lK4qleigxqsRtUVuWSiHezq K12LQtMElH5+vxDqUQery23ClrV+zVCByOdrWAz6wrjdEGPNvCBW6CwzvTgxTekKTf85 tH1FfHxs9jPS1hDjrknNhfQKEpYT1jn/T0Me1pHecDu8uqzXaE8YIXrPXpYJtnyOjm6Z YEd5bqmzaNVuv295ISzk25cVx4OhbD5bhKsTZ3XVrbUl9xDHfBwbYZ/j2nAqlCNtJtPG MJPIHI6TyoFQoUTDpSRX5AuIktxVC5xfh04KGKgStpq5adPV91IUiLzj9s7AM3JhJxIS 2Qsw== X-Gm-Message-State: APjAAAUlXGlhAytm/18tApRo3BJ4LetMJgdxmDZNAKgj8feWSKU+YviC 6L5Tgt04JswyRUMOhTXw7MAvvn8k X-Google-Smtp-Source: APXvYqxFyyqDBnHsWQR/CAteTwJMJqRTIJRGsYtwDQK6f1Ev5j5C7dNrTb1mZtGSCt1UbYq90m8pQA== X-Received: by 2002:a7b:c847:: with SMTP id c7mr17158504wml.3.1576857098155; Fri, 20 Dec 2019 07:51:38 -0800 (PST) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4972:cc00:b9e0:6ef7:286d:4897]) by smtp.gmail.com with ESMTPSA id u14sm10372139wrm.51.2019.12.20.07.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 07:51:37 -0800 (PST) From: Jack Wang To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, rpenyaev@suse.de Subject: [PATCH v5 19/25] rnbd: server: private header with server structs and functions Date: Fri, 20 Dec 2019 16:51:03 +0100 Message-Id: <20191220155109.8959-20-jinpuwang@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191220155109.8959-1-jinpuwang@gmail.com> References: <20191220155109.8959-1-jinpuwang@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Jack Wang This header describes main structs and functions used by rnbd-server module, namely structs for managing sessions from different clients and mapped (opened) devices. Signed-off-by: Danil Kipnis Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-srv.h | 99 +++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 drivers/block/rnbd/rnbd-srv.h diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h new file mode 100644 index 000000000000..770181e36f15 --- /dev/null +++ b/drivers/block/rnbd/rnbd-srv.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * 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 + * + * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. + * Authors: Roman Penyaev + * Jack Wang + * Danil Kipnis + */ + +/* Copyright (c) 2019 1&1 IONOS SE. All rights reserved. + * Authors: Jack Wang + * Danil Kipnis + * Guoqing Jiang + * Lutz Pogrell + */ +#ifndef RNBD_SRV_H +#define RNBD_SRV_H + +#include +#include +#include + +#include "rtrs.h" +#include "rnbd-proto.h" +#include "rnbd-log.h" + +struct rnbd_srv_session { + /* Entry inside global sess_list */ + struct list_head list; + struct rtrs_srv *rtrs; + 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 rnbd_srv_sess_dev */ + struct list_head sess_dev_list; + struct mutex lock; + u8 ver; +}; + +struct rnbd_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 rnbd_srv_sess_dev structs */ + struct list_head sess_dev_list; + struct mutex lock; + int open_write_cnt; +}; + +/* Structure which binds N devices and N sessions */ +struct rnbd_srv_sess_dev { + /* Entry inside rnbd_srv_dev struct */ + struct list_head dev_list; + /* Entry inside rnbd_srv_session struct */ + struct list_head sess_list; + struct rnbd_dev *rnbd_dev; + struct rnbd_srv_session *sess; + struct rnbd_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]; + enum rnbd_access_mode access_mode; +}; + +/* rnbd-srv-sysfs.c */ + +int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev, + struct block_device *bdev, + const char *dir_name); +void rnbd_srv_destroy_dev_sysfs(struct rnbd_srv_dev *dev); +int rnbd_srv_create_dev_session_sysfs(struct rnbd_srv_sess_dev *sess_dev); +void rnbd_srv_destroy_dev_session_sysfs(struct rnbd_srv_sess_dev *sess_dev); +int rnbd_srv_create_sysfs_files(void); +void rnbd_srv_destroy_sysfs_files(void); + +#endif /* RNBD_SRV_H */