Lines Matching refs:sess_dev
71 struct rnbd_srv_sess_dev *sess_dev; member
76 struct rnbd_srv_sess_dev *sess_dev; in rnbd_sess_dev_release() local
78 sess_dev = container_of(kref, struct rnbd_srv_sess_dev, kref); in rnbd_sess_dev_release()
79 complete(sess_dev->destroy_comp); in rnbd_sess_dev_release()
82 static inline void rnbd_put_sess_dev(struct rnbd_srv_sess_dev *sess_dev) in rnbd_put_sess_dev() argument
84 kref_put(&sess_dev->kref, rnbd_sess_dev_release); in rnbd_put_sess_dev()
90 struct rnbd_srv_sess_dev *sess_dev; in rnbd_get_sess_dev() local
94 sess_dev = xa_load(&srv_sess->index_idr, dev_id); in rnbd_get_sess_dev()
95 if (sess_dev) in rnbd_get_sess_dev()
96 ret = kref_get_unless_zero(&sess_dev->kref); in rnbd_get_sess_dev()
102 return sess_dev; in rnbd_get_sess_dev()
108 struct rnbd_srv_sess_dev *sess_dev = rnbd_priv->sess_dev; in rnbd_dev_bi_end_io() local
110 rnbd_put_sess_dev(sess_dev); in rnbd_dev_bi_end_io()
123 struct rnbd_srv_sess_dev *sess_dev; in process_rdma() local
137 sess_dev = rnbd_get_sess_dev(dev_id, srv_sess); in process_rdma()
138 if (IS_ERR(sess_dev)) { in process_rdma()
145 priv->sess_dev = sess_dev; in process_rdma()
148 bio = bio_alloc(sess_dev->bdev, 1, in process_rdma()
152 rnbd_srv_err(sess_dev, "Failed to map data to bio\n"); in process_rdma()
171 rnbd_put_sess_dev(sess_dev); in process_rdma()
204 void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id) in rnbd_destroy_sess_dev() argument
212 xa_cmpxchg(&sess_dev->sess->index_idr, sess_dev->device_id, in rnbd_destroy_sess_dev()
213 sess_dev, NULL, 0); in rnbd_destroy_sess_dev()
215 xa_erase(&sess_dev->sess->index_idr, sess_dev->device_id); in rnbd_destroy_sess_dev()
218 sess_dev->destroy_comp = &dc; in rnbd_destroy_sess_dev()
219 rnbd_put_sess_dev(sess_dev); in rnbd_destroy_sess_dev()
222 blkdev_put(sess_dev->bdev, NULL); in rnbd_destroy_sess_dev()
223 mutex_lock(&sess_dev->dev->lock); in rnbd_destroy_sess_dev()
224 list_del(&sess_dev->dev_list); in rnbd_destroy_sess_dev()
225 if (!sess_dev->readonly) in rnbd_destroy_sess_dev()
226 sess_dev->dev->open_write_cnt--; in rnbd_destroy_sess_dev()
227 mutex_unlock(&sess_dev->dev->lock); in rnbd_destroy_sess_dev()
229 rnbd_put_srv_dev(sess_dev->dev); in rnbd_destroy_sess_dev()
231 rnbd_srv_info(sess_dev, "Device closed\n"); in rnbd_destroy_sess_dev()
232 kfree(sess_dev); in rnbd_destroy_sess_dev()
237 struct rnbd_srv_sess_dev *sess_dev; in destroy_sess() local
246 xa_for_each(&srv_sess->index_idr, index, sess_dev) in destroy_sess()
247 rnbd_srv_destroy_dev_session_sysfs(sess_dev); in destroy_sess()
319 void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, in rnbd_srv_sess_dev_force_close() argument
322 struct rnbd_srv_session *sess = sess_dev->sess; in rnbd_srv_sess_dev_force_close()
328 sess_dev->keep_id = true; in rnbd_srv_sess_dev_force_close()
330 sysfs_remove_file_self(&sess_dev->kobj, &attr->attr); in rnbd_srv_sess_dev_force_close()
331 rnbd_srv_destroy_dev_session_sysfs(sess_dev); in rnbd_srv_sess_dev_force_close()
340 struct rnbd_srv_sess_dev *sess_dev; in process_msg_close() local
344 sess_dev = rnbd_get_sess_dev(le32_to_cpu(close_msg->device_id), in process_msg_close()
346 if (IS_ERR(sess_dev)) in process_msg_close()
349 rnbd_put_sess_dev(sess_dev); in process_msg_close()
351 rnbd_srv_destroy_dev_session_sysfs(sess_dev); in process_msg_close()
407 struct rnbd_srv_sess_dev *sess_dev; in rnbd_sess_dev_alloc() local
410 sess_dev = kzalloc(sizeof(*sess_dev), GFP_KERNEL); in rnbd_sess_dev_alloc()
411 if (!sess_dev) in rnbd_sess_dev_alloc()
414 error = xa_alloc(&srv_sess->index_idr, &sess_dev->device_id, sess_dev, in rnbd_sess_dev_alloc()
418 kfree(sess_dev); in rnbd_sess_dev_alloc()
422 return sess_dev; in rnbd_sess_dev_alloc()
535 struct rnbd_srv_sess_dev *sess_dev) in rnbd_srv_fill_msg_open_rsp() argument
537 struct block_device *bdev = sess_dev->bdev; in rnbd_srv_fill_msg_open_rsp()
540 rsp->device_id = cpu_to_le32(sess_dev->device_id); in rnbd_srv_fill_msg_open_rsp()
659 struct rnbd_srv_sess_dev *sess_dev; in find_srv_sess_dev() local
665 xa_for_each(&srv_sess->index_idr, index, sess_dev) in find_srv_sess_dev()
666 if (!strcmp(sess_dev->pathname, dev_name)) in find_srv_sess_dev()
667 return sess_dev; in find_srv_sess_dev()