1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * RDMA Network Block Driver
5 * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
6 * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
7 * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
12 #include <linux/types.h>
13 #include <linux/idr.h>
14 #include <linux/kref.h>
17 #include "rnbd-proto.h"
20 struct rnbd_srv_session
{
21 /* Entry inside global sess_list */
22 struct list_head list
;
23 struct rtrs_srv_sess
*rtrs
;
24 char sessname
[NAME_MAX
];
27 struct xarray index_idr
;
33 /* Entry inside global dev_list */
34 struct list_head list
;
35 struct kobject dev_kobj
;
36 struct kobject
*dev_sessions_kobj
;
39 /* List of rnbd_srv_sess_dev structs */
40 struct list_head sess_dev_list
;
45 /* Structure which binds N devices and N sessions */
46 struct rnbd_srv_sess_dev
{
47 /* Entry inside rnbd_srv_dev struct */
48 struct list_head dev_list
;
49 struct file
*bdev_file
;
50 struct rnbd_srv_session
*sess
;
51 struct rnbd_srv_dev
*dev
;
57 struct completion
*destroy_comp
;
58 char pathname
[NAME_MAX
];
59 enum rnbd_access_mode access_mode
;
62 void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev
*sess_dev
,
63 struct kobj_attribute
*attr
);
64 /* rnbd-srv-sysfs.c */
66 int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev
*dev
,
67 struct block_device
*bdev
);
68 void rnbd_srv_destroy_dev_sysfs(struct rnbd_srv_dev
*dev
);
69 int rnbd_srv_create_dev_session_sysfs(struct rnbd_srv_sess_dev
*sess_dev
);
70 void rnbd_srv_destroy_dev_session_sysfs(struct rnbd_srv_sess_dev
*sess_dev
);
71 int rnbd_srv_create_sysfs_files(void);
72 void rnbd_srv_destroy_sysfs_files(void);
73 void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev
*sess_dev
, bool keep_id
);
75 #endif /* RNBD_SRV_H */