Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

smb: smbdirect: remove unused smbdirect_connection_mr_io_recovery_work()

This would actually never be used as we only move to
SMBDIRECT_MR_ERROR when we directly call
smbdirect_socket_schedule_cleanup().

Doing an ib_dereg_mr/ib_alloc_mr dance on
working connection is not needed and
it's also pointless on a broken connection
as we don't reuse any ib_pd.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Stefan Metzmacher and committed by
Steve French
00ac2a4f a40e6f01

+10 -85
+10 -85
fs/smb/common/smbdirect/smbdirect_mr.c
··· 6 6 7 7 #include "smbdirect_internal.h" 8 8 9 - static void smbdirect_connection_mr_io_recovery_work(struct work_struct *work); 10 - 11 9 /* 12 10 * Allocate MRs used for RDMA read/write 13 11 * The number of MRs will not exceed hardware capability in responder_resources ··· 63 65 list_add_tail(&mr->list, &sc->mr_io.all.list); 64 66 atomic_inc(&sc->mr_io.ready.count); 65 67 } 66 - 67 - INIT_WORK(&sc->mr_io.recovery_work, smbdirect_connection_mr_io_recovery_work); 68 68 69 69 return 0; 70 70 ··· 123 127 LIST_HEAD(all_list); 124 128 unsigned long flags; 125 129 126 - disable_work_sync(&sc->mr_io.recovery_work); 127 - 128 130 spin_lock_irqsave(&sc->mr_io.all.lock, flags); 129 131 list_splice_tail_init(&sc->mr_io.all.list, &all_list); 130 132 spin_unlock_irqrestore(&sc->mr_io.all.lock, flags); ··· 158 164 159 165 /* 160 166 * Get a MR from mr_list. This function waits until there is at least one MR 161 - * available in the list. It may access the list while the 162 - * smbdirect_connection_mr_io_recovery_work is recovering the MR list. This 163 - * doesn't need a lock as they never modify the same places. However, there may 164 - * be several CPUs issuing I/O trying to get MR at the same time, mr_list_lock 165 - * is used to protect this situation. 167 + * available in the list. There may be several CPUs issuing I/O trying to get MR 168 + * at the same time, mr_list_lock is used to protect this situation. 166 169 */ 167 170 static struct smbdirect_mr_io * 168 171 smbdirect_connection_get_mr_io(struct smbdirect_socket *sc) ··· 235 244 smbdirect_socket_schedule_cleanup(sc, -ECONNABORTED); 236 245 } 237 246 complete(&mr->invalidate_done); 238 - } 239 - 240 - /* 241 - * The work queue function that recovers MRs 242 - * We need to call ib_dereg_mr() and ib_alloc_mr() before this MR can be used 243 - * again. Both calls are slow, so finish them in a workqueue. This will not 244 - * block I/O path. 245 - * There is one workqueue that recovers MRs, there is no need to lock as the 246 - * I/O requests calling smbd_register_mr will never update the links in the 247 - * mr_list. 248 - */ 249 - static void smbdirect_connection_mr_io_recovery_work(struct work_struct *work) 250 - { 251 - struct smbdirect_socket *sc = 252 - container_of(work, struct smbdirect_socket, mr_io.recovery_work); 253 - struct smbdirect_socket_parameters *sp = &sc->parameters; 254 - struct smbdirect_mr_io *mr; 255 - int ret; 256 - 257 - list_for_each_entry(mr, &sc->mr_io.all.list, list) { 258 - if (mr->state != SMBDIRECT_MR_ERROR) 259 - /* This MR is being used, don't recover it */ 260 - continue; 261 - 262 - /* recover this MR entry */ 263 - ret = ib_dereg_mr(mr->mr); 264 - if (ret) { 265 - smbdirect_log_rdma_mr(sc, SMBDIRECT_LOG_ERR, 266 - "ib_dereg_mr failed ret=%u (%1pe)\n", 267 - ret, SMBDIRECT_DEBUG_ERR_PTR(ret)); 268 - smbdirect_socket_schedule_cleanup(sc, ret); 269 - continue; 270 - } 271 - 272 - mr->mr = ib_alloc_mr(sc->ib.pd, 273 - sc->mr_io.type, 274 - sp->max_frmr_depth); 275 - if (IS_ERR(mr->mr)) { 276 - ret = PTR_ERR(mr->mr); 277 - smbdirect_log_rdma_mr(sc, SMBDIRECT_LOG_ERR, 278 - "ib_alloc_mr failed ret=%d (%1pe) type=0x%x depth=%u\n", 279 - ret, SMBDIRECT_DEBUG_ERR_PTR(ret), 280 - sc->mr_io.type, sp->max_frmr_depth); 281 - smbdirect_socket_schedule_cleanup(sc, ret); 282 - continue; 283 - } 284 - 285 - mr->state = SMBDIRECT_MR_READY; 286 - 287 - /* smbdirect_mr->state is updated by this function 288 - * and is read and updated by I/O issuing CPUs trying 289 - * to get a MR, the call to atomic_inc_return 290 - * implicates a memory barrier and guarantees this 291 - * value is updated before waking up any calls to 292 - * get_mr() from the I/O issuing CPUs 293 - */ 294 - if (atomic_inc_return(&sc->mr_io.ready.count) == 1) 295 - wake_up(&sc->mr_io.ready.wait_queue); 296 - } 297 247 } 298 248 299 249 /* ··· 353 421 "ib_post_send failed ret=%d (%1pe) reg_wr->key=0x%x\n", 354 422 ret, SMBDIRECT_DEBUG_ERR_PTR(ret), reg_wr->key); 355 423 356 - /* If all failed, attempt to recover this MR by setting it SMBDIRECT_MR_ERROR*/ 357 424 map_mr_error: 358 425 ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir); 359 426 360 427 dma_map_error: 361 428 mr->sgt.nents = 0; 362 429 mr->state = SMBDIRECT_MR_ERROR; 363 - if (atomic_dec_and_test(&sc->mr_io.used.count)) 364 - wake_up(&sc->mr_io.cleanup.wait_queue); 430 + atomic_dec(&sc->mr_io.used.count); 365 431 366 432 smbdirect_socket_schedule_cleanup(sc, ret); 367 433 ··· 459 529 mr->sgt.nents = 0; 460 530 } 461 531 462 - if (mr->state == SMBDIRECT_MR_INVALIDATED) { 463 - mr->state = SMBDIRECT_MR_READY; 464 - if (atomic_inc_return(&sc->mr_io.ready.count) == 1) 465 - wake_up(&sc->mr_io.ready.wait_queue); 466 - } else 467 - /* 468 - * Schedule the work to do MR recovery for future I/Os MR 469 - * recovery is slow and don't want it to block current I/O 470 - */ 471 - queue_work(sc->workqueue, &sc->mr_io.recovery_work); 532 + WARN_ONCE(mr->state != SMBDIRECT_MR_INVALIDATED, 533 + "mr->state[%u] != SMBDIRECT_MR_INVALIDATED[%u]\n", 534 + mr->state, SMBDIRECT_MR_INVALIDATED); 535 + mr->state = SMBDIRECT_MR_READY; 536 + if (atomic_inc_return(&sc->mr_io.ready.count) == 1) 537 + wake_up(&sc->mr_io.ready.wait_queue); 472 538 473 539 done: 474 - if (atomic_dec_and_test(&sc->mr_io.used.count)) 475 - wake_up(&sc->mr_io.cleanup.wait_queue); 540 + atomic_dec(&sc->mr_io.used.count); 476 541 477 542 put_kref: 478 543 /*