From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: 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> In-Reply-To: <20180518130413.16997-1-roman.penyaev@profitbricks.com> References: <20180518130413.16997-1-roman.penyaev@profitbricks.com> List-ID: 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 */ -- 2.13.1