From: Danil Kipnis <danil.kipnis@cloud.ionos.com>
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,
jgg@ziepe.ca, danil.kipnis@cloud.ionos.com,
jinpu.wang@cloud.ionos.com, pankaj.gupta@cloud.ionos.com
Subject: [PATCH v12 16/25] block/rnbd: client: private header with client structs and functions
Date: Wed, 15 Apr 2020 11:20:36 +0200 [thread overview]
Message-ID: <20200415092045.4729-17-danil.kipnis@cloud.ionos.com> (raw)
In-Reply-To: <20200415092045.4729-1-danil.kipnis@cloud.ionos.com>
From: Jack Wang <jinpu.wang@cloud.ionos.com>
This header describes main structs and functions used by rnbd-client
module, mainly for managing RNBD sessions and mapped block devices,
creating and destroying sysfs entries.
Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/block/rnbd/rnbd-clt.h | 156 ++++++++++++++++++++++++++++++++++
1 file changed, 156 insertions(+)
create mode 100644 drivers/block/rnbd/rnbd-clt.h
diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h
new file mode 100644
index 000000000000..c3807a8bbcec
--- /dev/null
+++ b/drivers/block/rnbd/rnbd-clt.h
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * RDMA Network Block Driver
+ *
+ * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
+ * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
+ * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
+ */
+
+#ifndef RNBD_CLT_H
+#define RNBD_CLT_H
+
+#include <linux/wait.h>
+#include <linux/in.h>
+#include <linux/inet.h>
+#include <linux/blk-mq.h>
+#include <linux/refcount.h>
+
+#include "rtrs.h"
+#include "rnbd-proto.h"
+#include "rnbd-log.h"
+
+/* Max. number of segments per IO request, Mellanox Connect X ~ Connect X5,
+ * choose minimial 30 for all, minus 1 for internal protocol, so 29.
+ */
+#define BMAX_SEGMENTS 29
+/* time in seconds between reconnect tries, default to 30 s */
+#define RECONNECT_DELAY 30
+/*
+ * Number of times to reconnect on error before giving up, 0 for * disabled,
+ * -1 for forever
+ */
+#define MAX_RECONNECTS -1
+
+enum rnbd_clt_dev_state {
+ DEV_STATE_INIT,
+ DEV_STATE_MAPPED,
+ DEV_STATE_MAPPED_DISCONNECTED,
+ DEV_STATE_UNMAPPED,
+};
+
+struct rnbd_iu_comp {
+ wait_queue_head_t wait;
+ int errno;
+};
+
+struct rnbd_iu {
+ union {
+ struct request *rq; /* for block io */
+ void *buf; /* for user messages */
+ };
+ struct rtrs_permit *permit;
+ union {
+ /* use to send msg associated with a dev */
+ struct rnbd_clt_dev *dev;
+ /* use to send msg associated with a sess */
+ struct rnbd_clt_session *sess;
+ };
+ struct scatterlist sglist[BMAX_SEGMENTS];
+ struct work_struct work;
+ int errno;
+ struct rnbd_iu_comp comp;
+ atomic_t refcount;
+};
+
+struct rnbd_cpu_qlist {
+ struct list_head requeue_list;
+ spinlock_t requeue_lock;
+ unsigned int cpu;
+};
+
+struct rnbd_clt_session {
+ struct list_head list;
+ struct rtrs_clt *rtrs;
+ wait_queue_head_t rtrs_waitq;
+ bool rtrs_ready;
+ struct rnbd_cpu_qlist __percpu
+ *cpu_queues;
+ DECLARE_BITMAP(cpu_queues_bm, NR_CPUS);
+ int __percpu *cpu_rr; /* per-cpu var for CPU round-robin */
+ atomic_t busy;
+ int queue_depth;
+ u32 max_io_size;
+ struct blk_mq_tag_set tag_set;
+ struct mutex lock; /* protects state and devs_list */
+ struct list_head devs_list; /* list of struct rnbd_clt_dev */
+ refcount_t refcount;
+ char sessname[NAME_MAX];
+ u8 ver; /* protocol version */
+};
+
+/**
+ * Submission queues.
+ */
+struct rnbd_queue {
+ struct list_head requeue_list;
+ unsigned long in_list;
+ struct rnbd_clt_dev *dev;
+ struct blk_mq_hw_ctx *hctx;
+};
+
+struct rnbd_clt_dev {
+ struct rnbd_clt_session *sess;
+ struct request_queue *queue;
+ struct rnbd_queue *hw_queues;
+ u32 device_id;
+ /* local Idr index - used to track minor number allocations. */
+ u32 clt_device_id;
+ struct mutex lock;
+ enum rnbd_clt_dev_state dev_state;
+ char pathname[NAME_MAX];
+ enum rnbd_access_mode access_mode;
+ bool read_only;
+ bool rotational;
+ u32 max_hw_sectors;
+ u32 max_write_same_sectors;
+ u32 max_discard_sectors;
+ u32 discard_granularity;
+ u32 discard_alignment;
+ u16 secure_discard;
+ u16 physical_block_size;
+ u16 logical_block_size;
+ u16 max_segments;
+ size_t nsectors;
+ u64 size; /* device size in bytes */
+ struct list_head list;
+ struct gendisk *gd;
+ struct kobject kobj;
+ char blk_symlink_name[NAME_MAX];
+ refcount_t refcount;
+ struct work_struct unmap_on_rmmod_work;
+};
+
+/* rnbd-clt.c */
+
+struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
+ struct rtrs_addr *paths,
+ size_t path_cnt, u16 port_nr,
+ const char *pathname,
+ enum rnbd_access_mode access_mode);
+int rnbd_clt_unmap_device(struct rnbd_clt_dev *dev, bool force,
+ const struct attribute *sysfs_self);
+
+int rnbd_clt_remap_device(struct rnbd_clt_dev *dev);
+int rnbd_clt_resize_disk(struct rnbd_clt_dev *dev, size_t newsize);
+
+/* rnbd-clt-sysfs.c */
+
+int rnbd_clt_create_sysfs_files(void);
+
+void rnbd_clt_destroy_sysfs_files(void);
+void rnbd_clt_destroy_default_group(void);
+
+void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev);
+
+#endif /* RNBD_CLT_H */
--
2.20.1
next prev parent reply other threads:[~2020-04-15 9:24 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 9:20 [PATCH v12 00/25] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 01/25] sysfs: export sysfs_remove_file_self() Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 02/25] RDMA/rtrs: public interface header to establish RDMA connections Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 03/25] RDMA/rtrs: private headers with rtrs protocol structs and helpers Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 04/25] RDMA/rtrs: core: lib functions shared between client and server modules Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 05/25] RDMA/rtrs: client: private header with client structs and functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 06/25] RDMA/rtrs: client: main functionality Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 07/25] RDMA/rtrs: client: statistics functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 08/25] RDMA/rtrs: client: sysfs interface functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 09/25] RDMA/rtrs: server: private header with server structs and functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 10/25] RDMA/rtrs: server: main functionality Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 11/25] RDMA/rtrs: server: statistics functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 12/25] RDMA/rtrs: server: sysfs interface functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 13/25] RDMA/rtrs: include client and server modules into kernel compilation Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 14/25] RDMA/rtrs: a bit of documentation Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 15/25] block/rnbd: private headers with rnbd protocol structs and helpers Danil Kipnis
2020-04-18 23:01 ` Bart Van Assche
2020-04-20 6:51 ` Jinpu Wang
2020-04-15 9:20 ` Danil Kipnis [this message]
2020-04-18 23:02 ` [PATCH v12 16/25] block/rnbd: client: private header with client structs and functions Bart Van Assche
2020-04-20 6:51 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 17/25] block/rnbd: client: main functionality Danil Kipnis
2020-04-18 23:17 ` Bart Van Assche
2020-04-20 7:01 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 18/25] block/rnbd: client: sysfs interface functions Danil Kipnis
2020-04-18 23:18 ` Bart Van Assche
2020-04-20 7:02 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 19/25] block/rnbd: server: private header with server structs and functions Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 20/25] block/rnbd: server: main functionality Danil Kipnis
2020-04-18 23:34 ` Bart Van Assche
2020-04-20 6:52 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 21/25] block/rnbd: server: functionality for IO submission to block dev Danil Kipnis
2020-04-18 23:38 ` Bart Van Assche
2020-04-20 6:59 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 22/25] block/rnbd: server: sysfs interface functions Danil Kipnis
2020-04-18 23:39 ` Bart Van Assche
2020-04-20 7:00 ` Jinpu Wang
2020-04-15 9:20 ` [PATCH v12 23/25] block/rnbd: include client and server modules into kernel compilation Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 24/25] block/rnbd: a bit of documentation Danil Kipnis
2020-04-15 9:20 ` [PATCH v12 25/25] MAINTAINERS: Add maintainers for RNBD/RTRS modules Danil Kipnis
2020-04-25 8:31 ` [PATCH v12 00/25] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jinpu Wang
2020-04-28 12:31 ` Jason Gunthorpe
2020-04-28 12:41 ` Jinpu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200415092045.4729-17-danil.kipnis@cloud.ionos.com \
--to=danil.kipnis@cloud.ionos.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dledford@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@cloud.ionos.com \
--cc=leon@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=pankaj.gupta@cloud.ionos.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).