From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D44CD8834 for ; Sat, 27 Dec 2025 09:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766828934; cv=none; b=V5OS9r4yeaNkwSHMQHOEyvCHbGpSIHE+2pmLKWzZ+aghhyk3lnI7FCtY5CkdKWNZxZVuXn0/eQK642Ze5rO+6cT4MZNGNvGxemJZnrF8F2Op9ATB1SS7KXVqHzfcKUTu4hCFHWGvz9+2njTjXmTIozHmquG+EFyuGw3yW54IKQM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766828934; c=relaxed/simple; bh=5UxhLQk/Ry2MEkD4w7LC5ZNXQxLn70QyRQKReNY5bKM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Box3tbdQqlLyZLOlPaUQ+3b8Mdgs4Kb+fKZa9jMFn42w2SaSKwVGrI8ER35I7ZQq+p5PtH1PArKfcEnTpAsVlKLQSfZqL3hxhXedRmyCY464/e+Z88X4UUuSFr3YITKlzHDfmVPWZ5rhzoVTKRWQ5++jzLNbHwWOTfxNT3Dpc74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-42b3c5defb2so4524779f8f.2 for ; Sat, 27 Dec 2025 01:48:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766828931; x=1767433731; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ztrc7rvqCDz1+RF07MiG4SyIq7mNe9Y5gTsg7JzaAgg=; b=tTW+KWor8kUR1NKiY3Ji3CcrGcA3E+JrPR1eOnhXS/3fJHx6noYGqDxV3a5ks5j0xK AgSsM+uVrSRZl0GnWNdy9gcvLAs5D8PYQFL+q7KVtc2Y9B0duwegniXtIiuODZc/TuA3 BCQnz7Rdw6qYzk0g6j3R8nn+ELxAvuak64koFgnFD3wRyTz0ctsjPly/BqlZMrJpGfiS bd6vpGufRQAo72PaLq0VMeChw1JPenqj3a4Ix6RzY+v7C+esGbX+olCBdTAfkR5VunjU 4uIiFuHiqG08TCgfOWlqWLHP72+VVDAp3ROhGw0K02ESJJcQZRIUkuIqcBle+LCkbTXj LWgw== X-Forwarded-Encrypted: i=1; AJvYcCXvShRjomjoOLKgoFByhaphhKA6ic5yodsKpzGBV6IJSe9sSEgKaqx4vxLb2fAUrxTJX+HE81cTRr36p6k=@vger.kernel.org X-Gm-Message-State: AOJu0YyADKv1GDSFwDtuneCPoKevTgjxXUbHngRIu7PjJ7RmZ6hesx2p I/v7G627Cxllzl0ddlk6TrlmQ1jUw7liFJ1ErmRSt3btD9sdCh7/yLYh X-Gm-Gg: AY/fxX6H0N0+xDAoUso1oHbsn1heGOR+u7XST9JByROOVwdJeSnY8wJzDZyPO5toaky zZC58fy+CACB/3cf6gLjuu9TGG3a1ko1b+lD5RDDlzqHhsrw5enxOiy55DeDpgsJYrDTJK9t+H3 w2Y7f02bROaMTdEoEgsx83/ct517OqnQK2eXRS+JsCZGiaUzL42MTuoTeKj/y4fvoGhNvL7QQyu ReWJCOL/BTclJV41CmmMwQnhllx7Fwvs3lLIJ5o4M/pICsggAUNh4QKgAtuWJMQTnNET8P6YFZB yXAMtGlwcCm9ZWsp84DACegTbFqwVDAZG+7G2iX53j5QrnQLVCBXe/bhCKz+4w/GBtA4zsmzVM5 USs7TVkaxSeF/tyXo+qck8RaVVj7s7uahwnP0f+h3cvM9un0MOfLLgYXccsuZMzaiGIGZbwCY3D sRxLcuOnQPuWPqFS+2MDP1XuWPlBFEvniE02bPUE/UETw= X-Google-Smtp-Source: AGHT+IHVmjH6fpcO2VVQjroVv1xu2GYgtksCzhbfZj40KUqqAgqOSsmlZopXRjp09EUyDUeBiXXZuA== X-Received: by 2002:a5d:588c:0:b0:430:fd60:9411 with SMTP id ffacd0b85a97d-4324e4c9dd1mr30540168f8f.21.1766828930999; Sat, 27 Dec 2025 01:48:50 -0800 (PST) Received: from [10.100.102.74] (89-138-76-94.bb.netvision.net.il. [89.138.76.94]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4325b6bfe88sm41925916f8f.19.2025.12.27.01.48.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Dec 2025 01:48:50 -0800 (PST) Message-ID: Date: Sat, 27 Dec 2025 11:48:49 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 05/14] nvmet: Send an AEN on CCR completion To: Mohamed Khalfella Cc: Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Aaron Dailey , Randy Jennings , John Meneghini , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251126021250.2583630-1-mkhalfella@purestorage.com> <20251126021250.2583630-6-mkhalfella@purestorage.com> <13c2bf9c-6eac-4c48-b12c-f76e86c8ef32@grimberg.me> <20251225181313.GC8129-mkhalfella@purestorage.com> Content-Language: en-US From: Sagi Grimberg In-Reply-To: <20251225181313.GC8129-mkhalfella@purestorage.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 25/12/2025 20:13, Mohamed Khalfella wrote: > On Thu 2025-12-25 15:23:51 +0200, Sagi Grimberg wrote: >> >> On 26/11/2025 4:11, Mohamed Khalfella wrote: >>> Send an AEN to initiator when impacted controller exists. The >>> notification points to CCR log page that initiator can read to check >>> which CCR operation completed. >>> >>> Signed-off-by: Mohamed Khalfella >>> --- >>> drivers/nvme/target/core.c | 27 +++++++++++++++++++++++---- >>> drivers/nvme/target/nvmet.h | 3 ++- >>> include/linux/nvme.h | 3 +++ >>> 3 files changed, 28 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c >>> index 7dbe9255ff42..60173833c3eb 100644 >>> --- a/drivers/nvme/target/core.c >>> +++ b/drivers/nvme/target/core.c >>> @@ -202,7 +202,7 @@ static void nvmet_async_event_work(struct work_struct *work) >>> nvmet_async_events_process(ctrl); >>> } >>> >>> -void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, >>> +static void nvmet_add_async_event_locked(struct nvmet_ctrl *ctrl, u8 event_type, >>> u8 event_info, u8 log_page) >>> { >>> struct nvmet_async_event *aen; >>> @@ -215,12 +215,17 @@ void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, >>> aen->event_info = event_info; >>> aen->log_page = log_page; >>> >>> - mutex_lock(&ctrl->lock); >>> list_add_tail(&aen->entry, &ctrl->async_events); >>> - mutex_unlock(&ctrl->lock); >>> >>> queue_work(nvmet_wq, &ctrl->async_event_work); >>> } >>> +void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, >>> + u8 event_info, u8 log_page) >>> +{ >>> + mutex_lock(&ctrl->lock); >>> + nvmet_add_async_event_locked(ctrl, event_type, event_info, log_page); >>> + mutex_unlock(&ctrl->lock); >>> +} >>> >>> static void nvmet_add_to_changed_ns_log(struct nvmet_ctrl *ctrl, __le32 nsid) >>> { >>> @@ -1788,6 +1793,18 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args) >>> } >>> EXPORT_SYMBOL_GPL(nvmet_alloc_ctrl); >>> >>> +static void nvmet_ctrl_notify_ccr(struct nvmet_ctrl *ctrl) >>> +{ >>> + lockdep_assert_held(&ctrl->lock); >>> + >>> + if (nvmet_aen_bit_disabled(ctrl, NVME_AEN_BIT_CCR_COMPLETE)) >>> + return; >>> + >>> + nvmet_add_async_event_locked(ctrl, NVME_AER_NOTICE, >>> + NVME_AER_NOTICE_CCR_COMPLETED, >>> + NVME_LOG_CCR); >>> +} >>> + >>> static void nvmet_ctrl_complete_pending_ccr(struct nvmet_ctrl *ctrl) >>> { >>> struct nvmet_subsys *subsys = ctrl->subsys; >>> @@ -1801,8 +1818,10 @@ static void nvmet_ctrl_complete_pending_ccr(struct nvmet_ctrl *ctrl) >>> list_for_each_entry(sctrl, &subsys->ctrls, subsys_entry) { >>> mutex_lock(&sctrl->lock); >>> list_for_each_entry(ccr, &sctrl->ccrs, entry) { >>> - if (ccr->ctrl == ctrl) >>> + if (ccr->ctrl == ctrl) { >>> + nvmet_ctrl_notify_ccr(sctrl); >>> ccr->ctrl = NULL; >>> + } >> Is this double loop necessary? Would you have more than one controller >> cross resetting the same > As it is implemented now CCRs are linked to sctrl. This decision can be > revisited if found suboptimal. At some point I had CCRs linked to > ctrl->subsys but that led to lock ordering issues. Double loop is > necessary to find all CCRs in all controllers and mark them done. > Yes, it is possible to have more than one sctrl resetting the same > ictrl. I'm more interested in simplifying. > >> controller? Won't it be better to install a callback+opaque that the >> controller removal will call? > Can you elaborate more on that? Better in what terms? > > nvmet_ctrl_complete_pending_ccr() is called from nvmet_ctrl_free() when > we know that ctrl->ref is zero and no new CCRs will be added to this > controller because nvmet_ctrl_find_get_ccr() will not be able to get it. In nvmet, the controller is serving a single host. Hence I am not sure I understand how multiple source controllers will try to reset the impacted controller. So, if there is a 1-1 relationship between source and impacted controller, I'd perhaps suggest to simplify and install on the impacted controller callback+opaque (e.g. void *data) instead of having it iterate and then actually send the AEN from the impacted controller.