Skip to content

Commit d1bff07

Browse files
KAGA-KOKOmartinkpetersen
authored andcommitted
scsi: target: Introduce transport_init_session()
Other than initializing xcopy_pt_sess.sess_wait_list, this patch does not change any functionality. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Mike Christie <mchristi@redhat.com> Cc: Mike Christie <mchristi@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 317f897 commit d1bff07

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎drivers/target/target_core_transport.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,22 @@ void transport_subsystem_check_init(void)
224224
sub_api_initialized = 1;
225225
}
226226

227+
/**
228+
* transport_init_session - initialize a session object
229+
* @se_sess: Session object pointer.
230+
*
231+
* The caller must have zero-initialized @se_sess before calling this function.
232+
*/
233+
void transport_init_session(struct se_session *se_sess)
234+
{
235+
INIT_LIST_HEAD(&se_sess->sess_list);
236+
INIT_LIST_HEAD(&se_sess->sess_acl_list);
237+
INIT_LIST_HEAD(&se_sess->sess_cmd_list);
238+
INIT_LIST_HEAD(&se_sess->sess_wait_list);
239+
spin_lock_init(&se_sess->sess_cmd_lock);
240+
}
241+
EXPORT_SYMBOL(transport_init_session);
242+
227243
/**
228244
* transport_alloc_session - allocate a session object and initialize it
229245
* @sup_prot_ops: bitmask that defines which T10-PI modes are supported.
@@ -238,11 +254,7 @@ struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops)
238254
" se_sess_cache\n");
239255
return ERR_PTR(-ENOMEM);
240256
}
241-
INIT_LIST_HEAD(&se_sess->sess_list);
242-
INIT_LIST_HEAD(&se_sess->sess_acl_list);
243-
INIT_LIST_HEAD(&se_sess->sess_cmd_list);
244-
INIT_LIST_HEAD(&se_sess->sess_wait_list);
245-
spin_lock_init(&se_sess->sess_cmd_lock);
257+
transport_init_session(se_sess);
246258
se_sess->sup_prot_ops = sup_prot_ops;
247259

248260
return se_sess;

‎drivers/target/target_core_xcopy.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,7 @@ int target_xcopy_setup_pt(void)
497497
INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list);
498498
INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list);
499499
memset(&xcopy_pt_sess, 0, sizeof(struct se_session));
500-
INIT_LIST_HEAD(&xcopy_pt_sess.sess_list);
501-
INIT_LIST_HEAD(&xcopy_pt_sess.sess_acl_list);
502-
INIT_LIST_HEAD(&xcopy_pt_sess.sess_cmd_list);
503-
spin_lock_init(&xcopy_pt_sess.sess_cmd_lock);
500+
transport_init_session(&xcopy_pt_sess);
504501

505502
xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg;
506503
xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess;

‎include/target/target_core_fabric.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct se_session *target_alloc_session(struct se_portal_group *,
115115
int (*callback)(struct se_portal_group *,
116116
struct se_session *, void *));
117117

118+
void transport_init_session(struct se_session *);
118119
struct se_session *transport_alloc_session(enum target_prot_op);
119120
int transport_alloc_session_tags(struct se_session *, unsigned int,
120121
unsigned int);

0 commit comments

Comments
 (0)