@@ -300,8 +300,8 @@ int core_free_device_list_for_node(
300
300
lun = deve -> se_lun ;
301
301
302
302
spin_unlock_irq (& nacl -> device_list_lock );
303
- core_update_device_list_for_node (lun , NULL , deve -> mapped_lun ,
304
- TRANSPORT_LUNFLAGS_NO_ACCESS , nacl , tpg , 0 );
303
+ core_disable_device_list_for_node (lun , NULL , deve -> mapped_lun ,
304
+ TRANSPORT_LUNFLAGS_NO_ACCESS , nacl , tpg );
305
305
spin_lock_irq (& nacl -> device_list_lock );
306
306
}
307
307
spin_unlock_irq (& nacl -> device_list_lock );
@@ -342,72 +342,46 @@ void core_update_device_list_access(
342
342
spin_unlock_irq (& nacl -> device_list_lock );
343
343
}
344
344
345
- /* core_update_device_list_for_node ():
345
+ /* core_enable_device_list_for_node ():
346
346
*
347
347
*
348
348
*/
349
- int core_update_device_list_for_node (
349
+ int core_enable_device_list_for_node (
350
350
struct se_lun * lun ,
351
351
struct se_lun_acl * lun_acl ,
352
352
u32 mapped_lun ,
353
353
u32 lun_access ,
354
354
struct se_node_acl * nacl ,
355
- struct se_portal_group * tpg ,
356
- int enable )
355
+ struct se_portal_group * tpg )
357
356
{
358
357
struct se_port * port = lun -> lun_sep ;
359
- struct se_dev_entry * deve = nacl -> device_list [mapped_lun ];
360
- int trans = 0 ;
361
- /*
362
- * If the MappedLUN entry is being disabled, the entry in
363
- * port->sep_alua_list must be removed now before clearing the
364
- * struct se_dev_entry pointers below as logic in
365
- * core_alua_do_transition_tg_pt() depends on these being present.
366
- */
367
- if (!enable ) {
368
- /*
369
- * deve->se_lun_acl will be NULL for demo-mode created LUNs
370
- * that have not been explicitly concerted to MappedLUNs ->
371
- * struct se_lun_acl, but we remove deve->alua_port_list from
372
- * port->sep_alua_list. This also means that active UAs and
373
- * NodeACL context specific PR metadata for demo-mode
374
- * MappedLUN *deve will be released below..
375
- */
376
- spin_lock_bh (& port -> sep_alua_lock );
377
- list_del (& deve -> alua_port_list );
378
- spin_unlock_bh (& port -> sep_alua_lock );
379
- }
358
+ struct se_dev_entry * deve ;
380
359
381
360
spin_lock_irq (& nacl -> device_list_lock );
382
- if (enable ) {
383
- /*
384
- * Check if the call is handling demo mode -> explict LUN ACL
385
- * transition. This transition must be for the same struct se_lun
386
- * + mapped_lun that was setup in demo mode..
387
- */
388
- if (deve -> lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS ) {
389
- if (deve -> se_lun_acl != NULL ) {
390
- pr_err ("struct se_dev_entry->se_lun_acl"
391
- " already set for demo mode -> explict"
392
- " LUN ACL transition\n" );
393
- spin_unlock_irq (& nacl -> device_list_lock );
394
- return - EINVAL ;
395
- }
396
- if (deve -> se_lun != lun ) {
397
- pr_err ("struct se_dev_entry->se_lun does"
398
- " match passed struct se_lun for demo mode"
399
- " -> explict LUN ACL transition\n" );
400
- spin_unlock_irq (& nacl -> device_list_lock );
401
- return - EINVAL ;
402
- }
403
- deve -> se_lun_acl = lun_acl ;
404
- trans = 1 ;
405
- } else {
406
- deve -> se_lun = lun ;
407
- deve -> se_lun_acl = lun_acl ;
408
- deve -> mapped_lun = mapped_lun ;
409
- deve -> lun_flags |= TRANSPORT_LUNFLAGS_INITIATOR_ACCESS ;
361
+
362
+ deve = nacl -> device_list [mapped_lun ];
363
+
364
+ /*
365
+ * Check if the call is handling demo mode -> explict LUN ACL
366
+ * transition. This transition must be for the same struct se_lun
367
+ * + mapped_lun that was setup in demo mode..
368
+ */
369
+ if (deve -> lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS ) {
370
+ if (deve -> se_lun_acl != NULL ) {
371
+ pr_err ("struct se_dev_entry->se_lun_acl"
372
+ " already set for demo mode -> explict"
373
+ " LUN ACL transition\n" );
374
+ spin_unlock_irq (& nacl -> device_list_lock );
375
+ return - EINVAL ;
376
+ }
377
+ if (deve -> se_lun != lun ) {
378
+ pr_err ("struct se_dev_entry->se_lun does"
379
+ " match passed struct se_lun for demo mode"
380
+ " -> explict LUN ACL transition\n" );
381
+ spin_unlock_irq (& nacl -> device_list_lock );
382
+ return - EINVAL ;
410
383
}
384
+ deve -> se_lun_acl = lun_acl ;
411
385
412
386
if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE ) {
413
387
deve -> lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY ;
@@ -417,20 +391,70 @@ int core_update_device_list_for_node(
417
391
deve -> lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY ;
418
392
}
419
393
420
- if (trans ) {
421
- spin_unlock_irq (& nacl -> device_list_lock );
422
- return 0 ;
423
- }
424
- deve -> creation_time = get_jiffies_64 ();
425
- deve -> attach_count ++ ;
426
394
spin_unlock_irq (& nacl -> device_list_lock );
395
+ return 0 ;
396
+ }
427
397
428
- spin_lock_bh (& port -> sep_alua_lock );
429
- list_add_tail (& deve -> alua_port_list , & port -> sep_alua_list );
430
- spin_unlock_bh (& port -> sep_alua_lock );
398
+ deve -> se_lun = lun ;
399
+ deve -> se_lun_acl = lun_acl ;
400
+ deve -> mapped_lun = mapped_lun ;
401
+ deve -> lun_flags |= TRANSPORT_LUNFLAGS_INITIATOR_ACCESS ;
431
402
432
- return 0 ;
403
+ if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE ) {
404
+ deve -> lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY ;
405
+ deve -> lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE ;
406
+ } else {
407
+ deve -> lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE ;
408
+ deve -> lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY ;
433
409
}
410
+
411
+ deve -> creation_time = get_jiffies_64 ();
412
+ deve -> attach_count ++ ;
413
+ spin_unlock_irq (& nacl -> device_list_lock );
414
+
415
+ spin_lock_bh (& port -> sep_alua_lock );
416
+ list_add_tail (& deve -> alua_port_list , & port -> sep_alua_list );
417
+ spin_unlock_bh (& port -> sep_alua_lock );
418
+
419
+ return 0 ;
420
+ }
421
+
422
+ /* core_disable_device_list_for_node():
423
+ *
424
+ *
425
+ */
426
+ int core_disable_device_list_for_node (
427
+ struct se_lun * lun ,
428
+ struct se_lun_acl * lun_acl ,
429
+ u32 mapped_lun ,
430
+ u32 lun_access ,
431
+ struct se_node_acl * nacl ,
432
+ struct se_portal_group * tpg )
433
+ {
434
+ struct se_port * port = lun -> lun_sep ;
435
+ struct se_dev_entry * deve ;
436
+
437
+ spin_lock_irq (& nacl -> device_list_lock );
438
+
439
+ deve = nacl -> device_list [mapped_lun ];
440
+
441
+ /*
442
+ * If the MappedLUN entry is being disabled, the entry in
443
+ * port->sep_alua_list must be removed now before clearing the
444
+ * struct se_dev_entry pointers below as logic in
445
+ * core_alua_do_transition_tg_pt() depends on these being present.
446
+ *
447
+ * deve->se_lun_acl will be NULL for demo-mode created LUNs
448
+ * that have not been explicitly converted to MappedLUNs ->
449
+ * struct se_lun_acl, but we remove deve->alua_port_list from
450
+ * port->sep_alua_list. This also means that active UAs and
451
+ * NodeACL context specific PR metadata for demo-mode
452
+ * MappedLUN *deve will be released below..
453
+ */
454
+ spin_lock_bh (& port -> sep_alua_lock );
455
+ list_del (& deve -> alua_port_list );
456
+ spin_unlock_bh (& port -> sep_alua_lock );
457
+
434
458
/*
435
459
* Wait for any in process SPEC_I_PT=1 or REGISTER_AND_MOVE
436
460
* PR operation to complete.
@@ -475,9 +499,9 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)
475
499
continue ;
476
500
spin_unlock_irq (& nacl -> device_list_lock );
477
501
478
- core_update_device_list_for_node (lun , NULL ,
502
+ core_disable_device_list_for_node (lun , NULL ,
479
503
deve -> mapped_lun , TRANSPORT_LUNFLAGS_NO_ACCESS ,
480
- nacl , tpg , 0 );
504
+ nacl , tpg );
481
505
482
506
spin_lock_irq (& nacl -> device_list_lock );
483
507
}
@@ -1469,8 +1493,8 @@ int core_dev_add_initiator_node_lun_acl(
1469
1493
1470
1494
lacl -> se_lun = lun ;
1471
1495
1472
- if (core_update_device_list_for_node (lun , lacl , lacl -> mapped_lun ,
1473
- lun_access , nacl , tpg , 1 ) < 0 )
1496
+ if (core_enable_device_list_for_node (lun , lacl , lacl -> mapped_lun ,
1497
+ lun_access , nacl , tpg ) < 0 )
1474
1498
return - EINVAL ;
1475
1499
1476
1500
spin_lock (& lun -> lun_acl_lock );
@@ -1513,8 +1537,8 @@ int core_dev_del_initiator_node_lun_acl(
1513
1537
smp_mb__after_atomic_dec ();
1514
1538
spin_unlock (& lun -> lun_acl_lock );
1515
1539
1516
- core_update_device_list_for_node (lun , NULL , lacl -> mapped_lun ,
1517
- TRANSPORT_LUNFLAGS_NO_ACCESS , nacl , tpg , 0 );
1540
+ core_disable_device_list_for_node (lun , NULL , lacl -> mapped_lun ,
1541
+ TRANSPORT_LUNFLAGS_NO_ACCESS , nacl , tpg );
1518
1542
1519
1543
lacl -> se_lun = NULL ;
1520
1544
0 commit comments