scst_targ: Use 'atomic_inc_return' to check 'dev->dev_cmd_count'

1. atomic_inc_return() avoids a race in between atomic_read() &
   atomic_inc().
2. atomic_inc_return() is a few cycles faster than
   atomic_inc()/atomic_read() sequence.
This commit is contained in:
Gleb Chesnokov
2022-11-09 17:38:34 +03:00
parent bbabdeeec1
commit 31318acbc8

View File

@@ -4345,8 +4345,7 @@ static int __scst_init_cmd(struct scst_cmd *cmd)
}
#ifdef CONFIG_SCST_PER_DEVICE_CMD_COUNT_LIMIT
atomic_inc(&dev->dev_cmd_count);
cnt = atomic_read(&dev->dev_cmd_count);
cnt = atomic_inc_return(&dev->dev_cmd_count);
if (unlikely(cnt > SCST_MAX_DEV_COMMANDS)) {
if (!failure) {
TRACE(TRACE_FLOW_CONTROL,