From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F35CF2DECC6 for ; Tue, 28 Apr 2026 09:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777368015; cv=none; b=oCejfXdxRNRRJdqe8liF70Vr8U8BdZBSJy5VDaGwvi3sK4I5QTpEYD36nHSG5zFFwDgV9R+BdEmjNngmZtuD4oFvn9LfSU4Npi5hpQ1nh4ExUCGsuRJV8KNhp+Lpbzo93ET3EuSTjpL2tPUKTj0VBD1ftjmN0mPwSVK6Wzq8ymg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777368015; c=relaxed/simple; bh=E59q141eIMRoVS0CIFBNpImOnrZTdEnPeY4n1aRI5qI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PiNuMSnslAZ6XfrDysQjG5Rg7ArTzZ1HlQzr7jlYRuenVMkKNxICh/bn/oFjlNEKFwf0q1M5scA0qpz77eI2QkR0v+U5+cUbP+2hgqjrOFfBHAv+2quNIssiOjTGJm7+d2s9jQ5/8eygdwBIUNUVjGKHKsohqsZftyW9OabsGcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=QEyvf2UM; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WOmlfpAC; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="QEyvf2UM"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WOmlfpAC" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63S7vjGM1744761 for ; Tue, 28 Apr 2026 09:20:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vpAxPHzEnIqyJBQRocZHAzzK0xrcj2x1AR2IF+lJmZc=; b=QEyvf2UMeBITgznu +c0glZBplK9L1i6Oaneda/tHjAbz6LNUlUwMrH0Jpxp8ViGgZEBprVEyNgn85/Tc TwLrPEcgFWBuxVHTSHUX0nJlMzkGWEjtsG7KuBooBBkBFhsE4Xj9zE62/Dalag6F F6lx98sxn4wrLMEMF5Q5ZcgrQFeGOxnhaQ57CU9xxtaRTvb8Q9w69P2XbAtXDRyS 3HzBUOMTtgTdyJ/Hy0mZAW30tndjpuiVRCZVbMp/Ku8g7DOLK0gSQ4cujAUYp+Wn 90gFXSWaT2eNtjZuzKSenmmPGazPCvNuaI62Hfc/V3u7oRS0Q/ZDAdD84nNgGy+C 4Fd0AQ== Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dtryd8ajf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 28 Apr 2026 09:20:13 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-2de07c12745so36853807eec.1 for ; Tue, 28 Apr 2026 02:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777368012; x=1777972812; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vpAxPHzEnIqyJBQRocZHAzzK0xrcj2x1AR2IF+lJmZc=; b=WOmlfpAC7eJHFXYE+rj3XDYSE6sVNibDBVQ+SqD0vpSlyqFSTWzaGYLasVUWaWdcoT o7LDmvVvmo7EPJu0qX3VJVl8xnZ3K/pWSFLiUqE5KOPtfs/s7wAvUD9UFFCTbZzxgmJ6 xak+FwLRQEU1OOt2mLODrNWO0hjY32dLzyWyTocho2yj8nhDXpq4K3eApymkEp9+RRwA tmurd8v5ar5eTN8vLpshwc0fxbIC9whh4p4Mpp9E0MPPL4TrLEltPrWIWmXrDt7SLgoY lgsb9NjUJKk5yIUBjZTKW9vtXqOXefA+w2IJQwp1h3stZOmhNLfaDih18hHv0mJSo1E5 PEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777368012; x=1777972812; 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=vpAxPHzEnIqyJBQRocZHAzzK0xrcj2x1AR2IF+lJmZc=; b=KENU9DVb+SasrgZHETNY9th9Qbu6xfJlmHgvUFN3O7x/EUFUNEDRyB7Y8gXi9Bz3eb 64k9GdcR4qWUvAOVr+3/plxRMzePIuEQJb0PtZKv0KPE87W/+MaDIwIutqrfyP0AHspx 6XJVC90W2gWx9P636isuZXFqgO0whqeOuzyGuqikYDzFnIIQsu4ascH3CsBrPQKyxuoM PlZqkbRgPNWNkYqynZir2pfCvD7qOJN3IGYl07v3RWS7Y4xduopk/GdclwYdgArShe2K H1zQHxdsq2+8kuBlIvZ/fTICb9kMHn+m0OB46xQRq1C4FImPuqci/bDBMlOPvyg+wpRl lagw== X-Forwarded-Encrypted: i=1; AFNElJ+GxXvGafOnpIQlmL0P9EEt+N2xjubclXpl+b9+qX2ZaoCvTaESD0cfDbwVRhSCtDs9FjEq/jewisPvqq0=@vger.kernel.org X-Gm-Message-State: AOJu0YxILW/uswRbOn5w/rSrPqCu5MhVHVcYdRet9nNyUXTxrBcR0d97 xdOKayNk0J/TAZBJO4aTrfRmTiJt4ZwYi25aqEIRKnLOCoSMhEY1ZoKBzawNR6MAHpvQvADD/0u Tee6oI/kqZgUlJj7jrL31lWhT+pTLdIxY3rA1omgVun6nmEMMnQ9JXHzjaT/ODMHaU9c= X-Gm-Gg: AeBDieuTGlTd8ospOmRuGYHqfP/fzp5uxyjzv8xR3JZbs3NcMclKA2VgGn5Hke3Lalw WWltniLIZs9AODoU5UukV9ZENF090YNe7sOlh412H1lAMxX6bwchOGrFFhrLhyfemQCCDbU01YG sdh44QMFB5VA55ikpNvnWgWlPNLx/216LoWH7vutCx0EXQcMjuv5KbMjk4m+cSUtVKDOo8xFr2v Jt1ezjYbRcQrOgMsQ08Qm92FqubPJae49z4Rslqlw7d6NcPp5bL8FsOp+2FmpcJzQoZLnX+4SBt etI9U2r+RvgIdzbbQDnYkz+GzOXhKQU/FPo9RWOAU3yEpGP+D7daa5WAZUfPir/afBA1s3UsVqt T8YtBeotcp4yTN443KIY62AbJqRY/MPKkA+qS80tprMwxk8K5rDiWR54u1CUJyXqdLcqiAPdm9z m9NC6Mzc6uweGN2w== X-Received: by 2002:a05:7300:bc1a:b0:2ed:e17:d50d with SMTP id 5a478bee46e88-2ed0e17d71dmr608532eec.32.1777368012411; Tue, 28 Apr 2026 02:20:12 -0700 (PDT) X-Received: by 2002:a05:7300:bc1a:b0:2ed:e17:d50d with SMTP id 5a478bee46e88-2ed0e17d71dmr608514eec.32.1777368011821; Tue, 28 Apr 2026 02:20:11 -0700 (PDT) Received: from [10.110.45.159] (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ed0a103542sm2463767eec.21.2026.04.28.02.20.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Apr 2026 02:20:11 -0700 (PDT) Message-ID: <6390db35-7f8e-4d00-9c1f-43d676007910@oss.qualcomm.com> Date: Tue, 28 Apr 2026 17:20:07 +0800 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: [PATCH v2 2/3] dm-inlinecrypt: add target for inline block device encryption To: Benjamin Marzinski Cc: linux-block@vger.kernel.org, ebiggers@kernel.org, mpatocka@redhat.com, gmazyland@gmail.com, linux-kernel@vger.kernel.org, adrianvovk@gmail.com, dm-devel@lists.linux.dev, quic_mdalam@quicinc.com, israelr@nvidia.com, hch@infradead.org, axboe@kernel.dk References: <20260410134031.2880675-1-linlin.zhang@oss.qualcomm.com> <20260410134031.2880675-3-linlin.zhang@oss.qualcomm.com> Content-Language: en-US From: Linlin Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: SPc5ngKnOZBaFCy4DAMHKdn3irYJ-GPp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDA4MiBTYWx0ZWRfX3NDP6MwdfTCy TbqN+sMbYahzea3XOxl2PtFBa4mg1jc1ZY6lPXZK7gqBw9+VClE9/KY2SqW1WMrGn9tnPhsOdfB bhL3jRefC8yhvMTa0vkOseZqPgLazlqN0/uumsob6ixEWW+NZ5xBy+NZcraj4OyVdYtldjszBQ0 rHDffyYqdPCVeaqGIcWIf6AflBOTORbGBWII2YD8wyGhfolvSiSFxctO0zToOC5DyXtdawXvs9m ZRpzdMSG0kDWT5yIE9ZVh0vv710NAzVDuE5VFbr/B4W2dgO1YSAtniZ9E0TEobjrF6XSoFk/Xg0 VCuDc+kc4yUmjks/MY129eXCdkK8jYTh/aAcwyzawyY7MqfXvs6Md2K3GMj1QcoSgoePHd+lLhG 5NiPR6FDpG+Bj4KnWhMX9BU+i5DP2ykFdGF4BSPAq1LB5hwrZP23TG9DUgq5Fad8+sMCLNbQVT2 feer/TkuRffkE7SKOuQ== X-Proofpoint-ORIG-GUID: SPc5ngKnOZBaFCy4DAMHKdn3irYJ-GPp X-Authority-Analysis: v=2.4 cv=cMnQdFeN c=1 sm=1 tr=0 ts=69f07bcd cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=1XWaLZrsAAAA:8 a=mLr8kJcTbZJnnLskd6wA:9 a=QEXdDO2ut3YA:10 a=bBxd6f-gb0O0v-kibOvt:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_02,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280082 On 4/28/2026 7:21 AM, Benjamin Marzinski wrote: > On Mon, Apr 27, 2026 at 01:23:27AM -0400, Benjamin Marzinski wrote: >> On Fri, Apr 10, 2026 at 06:40:30AM -0700, Linlin Zhang wrote: >>> From: Eric Biggers >>> + /* >>> + * Since we've added an encryption context to the bio and >>> + * blk-crypto-fallback may be needed to process it, it's necessary to >>> + * use the fallback-aware bio submission code rather than >>> + * unconditionally returning DM_MAPIO_REMAPPED. >>> + * >>> + * To get the correct accounting for a dm target in the case where >>> + * __blk_crypto_submit_bio() doesn't take ownership of the bio (returns >>> + * true), call __blk_crypto_submit_bio() directly and return >>> + * DM_MAPIO_REMAPPED in that case, rather than relying on >>> + * blk_crypto_submit_bio() which calls submit_bio() in that case. >>> + */ >>> + if (__blk_crypto_submit_bio(bio)) >> >> This will still double account for fallback writes (which call >> submit_bio() on the encrypted bios, and return DM_MAPIO_SUBMITTED here). > > Just to clarify, I'm talking about the vmstats accounting. The IO > originally gets accounted by submit_bio() when the bio is submitted to > the dm device. For actual inline encryption and fallback reads, dm will > submit the bio to the underlying device using submit_bio_noacct() to > avoid double-counting the IO. > > For fallback writes, __blk_crypto_submit_bio() will submit the encrypted > bios to the underlying device with submit_bio(). This adds the IO > sectors again, even though it's the same IO, only encrypted now. Right, thanks for calling this out. For fallback writes, the IO is still double-counted. Given that this only affects IO accounting in the blk-crypto fallback write slow-path and not correctness, I think this is an acceptable tradeoff, and we can leave a TODO to revisit the accounting once a better solution exists. Add the bellow to the annotate. /* * TODO: blk-crypto fallback write slow-path currently double-accounts * IO in vmstat, as encrypted bios are submitted via submit_bio(). * This does not affect data correctness. Consider fixing this if * a cleaner accounting model for derived bios is introduced. */ Do you agree? > > -Ben > >> >> -Ben >> >>> + return DM_MAPIO_REMAPPED; >>> + return DM_MAPIO_SUBMITTED; >>> +} >> >