Skip to content

Commit b4d1656

Browse files
committed
tcmur_device: rename the state_lock to rdev_lock
Signed-off-by: Xiubo Li <[email protected]>
1 parent 793346e commit b4d1656

File tree

6 files changed

+74
-73
lines changed

6 files changed

+74
-73
lines changed

alua.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,12 @@ static int alua_sync_state(struct tcmu_device *dev,
432432
* the first command sent to us so clear
433433
* lock state to avoid later blacklist errors.
434434
*/
435-
pthread_mutex_lock(&rdev->state_lock);
435+
pthread_mutex_lock(&rdev->rdev_lock);
436436
if (rdev->lock_state == TCMUR_DEV_LOCK_WRITE_LOCKED) {
437437
tcmu_dev_dbg(dev, "Dropping lock\n");
438438
rdev->lock_state = TCMUR_DEV_LOCK_UNLOCKED;
439439
}
440-
pthread_mutex_unlock(&rdev->state_lock);
440+
pthread_mutex_unlock(&rdev->rdev_lock);
441441
}
442442
}
443443

@@ -560,7 +560,7 @@ int alua_implicit_transition(struct tcmu_device *dev, struct tcmulib_cmd *cmd,
560560
if (!lock_is_required(dev))
561561
return ret;
562562

563-
pthread_mutex_lock(&rdev->state_lock);
563+
pthread_mutex_lock(&rdev->rdev_lock);
564564
if (rdev->lock_state == TCMUR_DEV_LOCK_WRITE_LOCKED) {
565565
/* For both read/write cases in this state is good */
566566
goto done;
@@ -617,7 +617,7 @@ int alua_implicit_transition(struct tcmu_device *dev, struct tcmulib_cmd *cmd,
617617
}
618618

619619
done:
620-
pthread_mutex_unlock(&rdev->state_lock);
620+
pthread_mutex_unlock(&rdev->rdev_lock);
621621
return ret;
622622
}
623623

main.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,14 @@ static void tcmur_stop_device(void *arg)
615615
struct tcmur_device *rdev = tcmu_dev_get_private(dev);
616616
bool is_open = false;
617617

618-
pthread_mutex_lock(&rdev->state_lock);
618+
pthread_mutex_lock(&rdev->rdev_lock);
619619
/* check if this was already called due to thread cancelation */
620620
if (rdev->flags & TCMUR_DEV_FLAG_STOPPED) {
621-
pthread_mutex_unlock(&rdev->state_lock);
621+
pthread_mutex_unlock(&rdev->rdev_lock);
622622
return;
623623
}
624624
rdev->flags |= TCMUR_DEV_FLAG_STOPPING;
625-
pthread_mutex_unlock(&rdev->state_lock);
625+
pthread_mutex_unlock(&rdev->rdev_lock);
626626

627627
/*
628628
* The lock thread can fire off the recovery thread, so make sure
@@ -633,19 +633,19 @@ static void tcmur_stop_device(void *arg)
633633

634634
tcmu_release_dev_lock(dev);
635635

636-
pthread_mutex_lock(&rdev->state_lock);
636+
pthread_mutex_lock(&rdev->rdev_lock);
637637
if (rdev->flags & TCMUR_DEV_FLAG_IS_OPEN) {
638638
rdev->flags &= ~TCMUR_DEV_FLAG_IS_OPEN;
639639
is_open = true;
640640
}
641-
pthread_mutex_unlock(&rdev->state_lock);
641+
pthread_mutex_unlock(&rdev->rdev_lock);
642642

643643
if (is_open)
644644
rhandler->close(dev);
645645

646-
pthread_mutex_lock(&rdev->state_lock);
646+
pthread_mutex_lock(&rdev->rdev_lock);
647647
rdev->flags |= TCMUR_DEV_FLAG_STOPPED;
648-
pthread_mutex_unlock(&rdev->state_lock);
648+
pthread_mutex_unlock(&rdev->rdev_lock);
649649

650650
tcmu_dev_dbg(dev, "cmdproc cleanup done\n");
651651
}
@@ -872,10 +872,10 @@ static void *tcmur_cmdproc_thread(void *arg)
872872
* requests that LIO has completed. We only need to wait for replies
873873
* for outstanding requests so throttle the cmdproc thread now.
874874
*/
875-
pthread_mutex_lock(&rdev->state_lock);
875+
pthread_mutex_lock(&rdev->rdev_lock);
876876
if (rdev->flags & TCMUR_DEV_FLAG_STOPPING)
877877
dev_stopping = true;
878-
pthread_mutex_unlock(&rdev->state_lock);
878+
pthread_mutex_unlock(&rdev->rdev_lock);
879879
}
880880

881881
/*
@@ -1038,15 +1038,15 @@ static int dev_added(struct tcmu_device *dev)
10381038
goto cleanup_caw_lock;
10391039
}
10401040

1041-
ret = pthread_mutex_init(&rdev->state_lock, NULL);
1041+
ret = pthread_mutex_init(&rdev->rdev_lock, NULL);
10421042
if (ret) {
10431043
ret = -ret;
10441044
goto cleanup_format_lock;
10451045
}
10461046

10471047
ret = setup_io_work_queue(dev);
10481048
if (ret < 0)
1049-
goto cleanup_state_lock;
1049+
goto cleanup_rdev_lock;
10501050

10511051
ret = setup_aio_tracking(rdev);
10521052
if (ret < 0)
@@ -1088,8 +1088,8 @@ static int dev_added(struct tcmu_device *dev)
10881088
cleanup_aio_tracking(rdev);
10891089
cleanup_io_work_queue:
10901090
cleanup_io_work_queue(dev, true);
1091-
cleanup_state_lock:
1092-
pthread_mutex_destroy(&rdev->state_lock);
1091+
cleanup_rdev_lock:
1092+
pthread_mutex_destroy(&rdev->rdev_lock);
10931093
cleanup_format_lock:
10941094
pthread_mutex_destroy(&rdev->format_lock);
10951095
cleanup_caw_lock:
@@ -1106,9 +1106,9 @@ static void dev_removed(struct tcmu_device *dev)
11061106
struct tcmur_device *rdev = tcmu_dev_get_private(dev);
11071107
int ret;
11081108

1109-
pthread_mutex_lock(&rdev->state_lock);
1109+
pthread_mutex_lock(&rdev->rdev_lock);
11101110
rdev->flags |= TCMUR_DEV_FLAG_STOPPING;
1111-
pthread_mutex_unlock(&rdev->state_lock);
1111+
pthread_mutex_unlock(&rdev->rdev_lock);
11121112

11131113
/*
11141114
* The order of cleaning up worker threads and calling ->removed()
@@ -1130,7 +1130,7 @@ static void dev_removed(struct tcmu_device *dev)
11301130

11311131
tcmur_destroy_work(rdev->event_work);
11321132

1133-
ret = pthread_mutex_destroy(&rdev->state_lock);
1133+
ret = pthread_mutex_destroy(&rdev->rdev_lock);
11341134
if (ret != 0)
11351135
tcmu_err("could not cleanup state lock %d\n", ret);
11361136

target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
static struct list_head tpg_recovery_list = LIST_HEAD_INIT(tpg_recovery_list);
3030
/*
3131
* Locking ordering:
32-
* rdev->state_lock
32+
* rdev->rdev_lock
3333
* tpg_recovery_lock
3434
*/
3535
static pthread_mutex_t tpg_recovery_lock = PTHREAD_MUTEX_INITIALIZER;

tcmur_cmd_handler.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,9 +2329,9 @@ void tcmur_set_pending_ua(struct tcmu_device *dev, int ua)
23292329
{
23302330
struct tcmur_device *rdev = tcmu_dev_get_private(dev);
23312331

2332-
pthread_mutex_lock(&rdev->state_lock);
2332+
pthread_mutex_lock(&rdev->rdev_lock);
23332333
rdev->pending_uas |= (1 << ua);
2334-
pthread_mutex_unlock(&rdev->state_lock);
2334+
pthread_mutex_unlock(&rdev->rdev_lock);
23352335
}
23362336

23372337
/*
@@ -2348,7 +2348,7 @@ static int handle_pending_ua(struct tcmur_device *rdev, struct tcmulib_cmd *cmd)
23482348
/* The kernel will handle REPORT_LUNS */
23492349
return TCMU_STS_NOT_HANDLED;
23502350
}
2351-
pthread_mutex_lock(&rdev->state_lock);
2351+
pthread_mutex_lock(&rdev->rdev_lock);
23522352

23532353
if (!rdev->pending_uas) {
23542354
ret = TCMU_STS_NOT_HANDLED;
@@ -2364,7 +2364,7 @@ static int handle_pending_ua(struct tcmur_device *rdev, struct tcmulib_cmd *cmd)
23642364
rdev->pending_uas &= ~(1 << ua);
23652365

23662366
unlock:
2367-
pthread_mutex_unlock(&rdev->state_lock);
2367+
pthread_mutex_unlock(&rdev->rdev_lock);
23682368
return ret;
23692369
}
23702370

0 commit comments

Comments
 (0)