Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1647065pxv; Fri, 23 Jul 2021 13:43:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2U/ztUivQVM2a1QDoW1IQtofuRuk9EfVllSeSvw4j3zKekIpEpUMRf6xDHcXNr/LS0HZy X-Received: by 2002:a05:6402:278d:: with SMTP id b13mr7906099ede.20.1627073022690; Fri, 23 Jul 2021 13:43:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627073022; cv=none; d=google.com; s=arc-20160816; b=tpPeQouaxk2GqHsgfAnvDcbd9VKNcS5rE2hphr/17Lv2kLxG8CjikFxIOAy+JeduXd YvJh8Dp++DKHb6tqmqHPhcZJ32TqyEF74LffmFGky+2qjGbKbvdFJR6viL+NK0nZgBdQ Jy6C4q+d8PEsO3VbVjxxMvIDGwV9ZK6C5Ax2jmmdTS8KqYLkPy4akSzSP/C2xETmoMhu cp8vKJHjRUneuKdbvTJC/LzBReBEW18QvVdhxFZ3QnE0RKQ94ndz966I3rxhbYt9mR4Z 6CMG4ecF6Y0DsfYhzWInyVYt3sRBRoIKOBTHWS2T40nPayTe8vVYj3rOreZXGZwD1BA5 4G7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gshdmV5sCPIyTsnONig0vf9pb2L6W0zCgVoo+HoA69Q=; b=HcjW1xZYOsOMf9GU0nm8I8UCTkB9m6hsgv2uju7Rl1gN+EUMn8S+qp1y2sSBr99uDR 9NIMLwST+MghKdOOCWUVToLL8TTc2l6KL6dhkhQz71Gf1oIJba0wPF1n4zAeiU1LnGoZ I62qFAX8+5uFzKznfKM/G9r/hS7+/rXfc4kuEUjFRU8DuDgEnhTAr12qgMLdcpMKTnHl W5HwxGUp2okaX7blQR83IQpG7Zfj8Q2vdQnht+5BAp+X+L8SDgbV4GcgHopPgi100YXV 1OEVLrgAyUbh9Vye6+YdhNUEpTWoUvoZ71SeyITe/xmf6ozBx7sfsLdgZaoLa9KelsCL Qvyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T1+CBtZy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ce8si133618edb.350.2021.07.23.13.43.14; Fri, 23 Jul 2021 13:43:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T1+CBtZy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 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 S229655AbhGWUCX (ORCPT + 99 others); Fri, 23 Jul 2021 16:02:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhGWUCW (ORCPT ); Fri, 23 Jul 2021 16:02:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75F8160F23; Fri, 23 Jul 2021 20:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627072975; bh=TQl9qpbSL80dQcAC9WCWLAGTK4VIfAAnAyZ6NEgT94M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T1+CBtZyuA9OIlEWZhVkp/TH/VYyWc/syzT/QR7XR/sSNAqlNn4jkiyy5MWY4ad6H /Um9CPCGc2BTgVe5udLbu6YXr3zNu3Tj5HTvkQldQws8yBAst9mXG058FjKfPYm8FG lFJv6t0o9xd+CM25ebapR9MFZ743Q7FMKIF+9QvEHFTAhKIuHuJaYlfVVWUROJlykA 9LGt8F0IwH4Yu59CYyJB1g283VPmCE8tIHrKm3ZwrE5NG7h+eag7crHnaHOCMmKILg pfBQULmJlkI7OqponWRHDB+NsVIcDvIZxNi9duVI8cF5ib/oA7qYRGN+5NBvFy7E3B i+m57No0e/C6w== Date: Fri, 23 Jul 2021 13:42:54 -0700 From: Eric Biggers To: Satya Tangirala Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , Chao Yu , Jens Axboe , "Darrick J . Wong" , linux-kernel@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org, linux-ext4@vger.kernel.org Subject: Re: [PATCH v9 3/9] fscrypt: add functions for direct I/O support Message-ID: References: <20210604210908.2105870-1-satyat@google.com> <20210604210908.2105870-4-satyat@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210604210908.2105870-4-satyat@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Jun 04, 2021 at 09:09:02PM +0000, Satya Tangirala wrote: > +bool fscrypt_dio_supported(struct kiocb *iocb, struct iov_iter *iter) > +{ > + const struct inode *inode = file_inode(iocb->ki_filp); > + const unsigned int blocksize = i_blocksize(inode); > + > + /* If the file is unencrypted, no veto from us. */ > + if (!fscrypt_needs_contents_encryption(inode)) > + return true; > + > + /* We only support direct I/O with inline crypto, not fs-layer crypto */ > + if (!fscrypt_inode_uses_inline_crypto(inode)) > + return false; > + > + /* > + * Since the granularity of encryption is filesystem blocks, the I/O > + * must be block aligned -- not just disk sector aligned. > + */ > + if (!IS_ALIGNED(iocb->ki_pos | iov_iter_count(iter), blocksize)) > + return false; The above comment should make it clear that "block aligned" here intentionally applies to just the position and total length, not to the individual data buffers, for which only disk sector alignment is required. - Eric