Commit 95fd6cb4 authored by wanghailiangx's avatar wanghailiangx Committed by Konrad Sztyber
Browse files

example/nvme: Adjust logic lines about if (current_queue_depth > 0)



The original code is logically correct because
spdk_nvme_qpair_process_completions() may decrease
ns_ctx->current_queue_depth. But I still recommend doing
an optimization so users can easily understand the code.
Prioritize code cleanup more than one additional polling.

Change-Id: I3613b1b4e294661fd35b7e5bebdb32e1c8352270
Signed-off-by: default avatarHailiang Wang <hailiangx.e.wang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14332


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatar <qun.wan@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 8c6de5eb
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -474,11 +474,9 @@ work_fn(void *arg)
			}
			if (ns_ctx->current_queue_depth > 0) {
				spdk_nvme_qpair_process_completions(ns_ctx->qpair, 0);
				if (ns_ctx->current_queue_depth == 0) {
					spdk_nvme_ctrlr_free_io_qpair(ns_ctx->qpair);
				} else {
				unfinished_ctx++;
				}
			} else {
				spdk_nvme_ctrlr_free_io_qpair(ns_ctx->qpair);
			}
		}
	} while (unfinished_ctx > 0);
@@ -491,10 +489,8 @@ work_fn(void *arg)
				pthread_mutex_lock(&ctrlr_ctx->mutex);
				if (ctrlr_ctx->current_queue_depth > 0) {
					spdk_nvme_ctrlr_process_admin_completions(ctrlr_ctx->ctrlr);
					if (ctrlr_ctx->current_queue_depth > 0) {
					unfinished_ctx++;
				}
				}
				pthread_mutex_unlock(&ctrlr_ctx->mutex);
			}
		} while (unfinished_ctx > 0);