Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1411255ybf; Thu, 27 Feb 2020 10:26:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzYmlKK5aPN/E58nQRsmqFo6Dn83Fi+or8DNHCFVVRO40nFAge4U1IyMmqhfI+ifGtjDY+m X-Received: by 2002:aca:b7c5:: with SMTP id h188mr298160oif.100.1582827990830; Thu, 27 Feb 2020 10:26:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582827990; cv=none; d=google.com; s=arc-20160816; b=RE6mgEwxwzeyz+PZnPUOe5ZyNOKTB7HPqSDbg1hklPGGuHENOsBM8BWf30CJIr2eba RSKZo2MOKNqaQ9h5YKd6rYDxzdzXmyvgot7burL7ZsysSsYr2/yrSRU4gEWy4QkyL8Y8 IArXcjGqx/kHgDjM8UcesouikaR9uZ+EPmeQFneJFFP25GOUz2AWGdZ4g+EVYiyA0DwW BEHBdEU33/fUsJzhRuPC+Ovqzdy2253I7RrcAMkJki8/a7XsPhidO1gvQlLzmcFI/ReM Ozd92d8+y76etmssf0sDXyZiXOYzcEsOOhJeIxBR6q5GAvD84TfuAL1Kcy0ne2vubIln 0tfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rGN2ZVzy+sEmHT6JKLIaNK0I1WLlg56MSs0ePUE9bbg=; b=G56qsT2SsNBC6cQ5ewXLvOZ2o7zt+dV2+bJiAcHUaOrAyQ6k3hmWbyRNxGyE+VcC5C FrDWFGumGr7nmJlvUdBTgzcuMtMjam9pXs88+LD3ppqB1VlCI6Q/Gn2Btw8aJ51VShI6 2p5FnbaB09rAORDc5cDM5dVNGWPy8s0g7HWKa4lKh6S0p2t6GdUxSHOs2etmPiJDJr/N A/Q9+LJFgYtG/AtxiuhxjWRtbU6p+K3sL2PaJsAvFwT7W9QR3oDXWr1tN0Pw6+wZiF8O nEHF3M2PF4K1aTmEIUkz2y5++3mM6uU25eR/Qc5tUekf05sapOU8QYciwI6w2mqCewiY vjag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Rv/J+aex"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1si13079otg.113.2020.02.27.10.26.16; Thu, 27 Feb 2020 10:26:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Rv/J+aex"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730059AbgB0SZp (ORCPT + 99 others); Thu, 27 Feb 2020 13:25:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:48138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729504AbgB0SZp (ORCPT ); Thu, 27 Feb 2020 13:25:45 -0500 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 92AA12469C; Thu, 27 Feb 2020 18:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582827944; bh=ppmsgmJewgic6G8TyCPg5XN+BbEH2w+mIirTlE881lU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rv/J+aex7sJzrVtxikFTce8cCr8/2At1pTM6DS4zoQmnPK6LdfBrO3VcaDBml1o8j uZlALOG7V9KujDvjy4l3Yzoe2v9e4amlZ1g7tPPyYoCDeWkO3x8y/pZMpA/jHoajC5 fNsOS3mWSF3O1iNaWOlI5CNtSb+C4H/O2cjhJHGE= Date: Thu, 27 Feb 2020 10:25:43 -0800 From: Eric Biggers To: Christoph Hellwig Cc: Satya Tangirala , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, Barani Muthukumaran , Kuohong Wang , Kim Boojin Subject: Re: [PATCH v7 2/9] block: Inline encryption support for blk-mq Message-ID: <20200227182543.GC877@sol.localdomain> References: <20200221115050.238976-1-satyat@google.com> <20200221115050.238976-3-satyat@google.com> <20200221172205.GB438@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200221172205.GB438@infradead.org> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Feb 21, 2020 at 09:22:05AM -0800, Christoph Hellwig wrote: > > +int blk_crypto_evict_key(struct request_queue *q, > > + const struct blk_crypto_key *key) > > +{ > > + if (q->ksm && blk_ksm_crypto_mode_supported(q->ksm, key)) > > + return blk_ksm_evict_key(q->ksm, key); > > + > > + return 0; > > +} > > Is there any point in this wrapper that just has a single caller? > Als why doesn't blk_ksm_evict_key have the blk_ksm_crypto_mode_supported > sanity check itself? Later in the series it's changed to: int blk_crypto_evict_key(struct request_queue *q, const struct blk_crypto_key *key) { if (q->ksm && blk_ksm_crypto_mode_supported(q->ksm, key)) return blk_ksm_evict_key(q->ksm, key); return blk_crypto_fallback_evict_key(key); } I.e. if the encryption mode is using hardware, then the key needs to be evicted from q->ksm. Otherwise the key needs to be evicted from the fallback. Also keep in mind that our goal is to define a clean API for any user of the block layer to use encryption, not just fs/crypto/. That API includes: blk_crypto_init_key() blk_crypto_start_using_key() bio_crypt_set_ctx() blk_crypto_evict_key() If anyone else decides to use inline encryption (e.g., if inline encryption support were added to dm-crypt or another device-mapper target), they'll use these same functions. So IMO it's important to define a clean API that won't need to be refactored as soon as anyone else starts using it, and not e.g. micro-optimize for code length based on there currently being only one user. - Eric