Skip to content

Commit c21ce58

Browse files
longlimsftsmfrench
authored andcommitted
cifs: smbd: Only queue work for error recovery on memory registration
It's not necessary to queue invalidated memory registration to work queue, as all we need to do is to unmap the SG and make it usable again. This can save CPU cycles in normal data paths as memory registration errors are rare and normally only happens during reconnection. Signed-off-by: Long Li <[email protected]> Cc: [email protected] Signed-off-by: Steve French <[email protected]>
1 parent 87bc237 commit c21ce58

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

fs/cifs/smbdirect.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,12 +2271,7 @@ static void smbd_mr_recovery_work(struct work_struct *work)
22712271
int rc;
22722272

22732273
list_for_each_entry(smbdirect_mr, &info->mr_list, list) {
2274-
if (smbdirect_mr->state == MR_INVALIDATED)
2275-
ib_dma_unmap_sg(
2276-
info->id->device, smbdirect_mr->sgl,
2277-
smbdirect_mr->sgl_count,
2278-
smbdirect_mr->dir);
2279-
else if (smbdirect_mr->state == MR_ERROR) {
2274+
if (smbdirect_mr->state == MR_ERROR) {
22802275

22812276
/* recover this MR entry */
22822277
rc = ib_dereg_mr(smbdirect_mr->mr);
@@ -2604,11 +2599,20 @@ int smbd_deregister_mr(struct smbd_mr *smbdirect_mr)
26042599
*/
26052600
smbdirect_mr->state = MR_INVALIDATED;
26062601

2607-
/*
2608-
* Schedule the work to do MR recovery for future I/Os
2609-
* MR recovery is slow and we don't want it to block the current I/O
2610-
*/
2611-
queue_work(info->workqueue, &info->mr_recovery_work);
2602+
if (smbdirect_mr->state == MR_INVALIDATED) {
2603+
ib_dma_unmap_sg(
2604+
info->id->device, smbdirect_mr->sgl,
2605+
smbdirect_mr->sgl_count,
2606+
smbdirect_mr->dir);
2607+
smbdirect_mr->state = MR_READY;
2608+
if (atomic_inc_return(&info->mr_ready_count) == 1)
2609+
wake_up_interruptible(&info->wait_mr);
2610+
} else
2611+
/*
2612+
* Schedule the work to do MR recovery for future I/Os MR
2613+
* recovery is slow and don't want it to block current I/O
2614+
*/
2615+
queue_work(info->workqueue, &info->mr_recovery_work);
26122616

26132617
done:
26142618
if (atomic_dec_and_test(&info->mr_used_count))

0 commit comments

Comments
 (0)