From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3FE7C433E2 for ; Mon, 20 Jul 2020 20:14:15 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA9582080D; Mon, 20 Jul 2020 20:14:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="RM+j2AB9"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="MgqLN8Jh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="PPMtmi5E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA9582080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jxcAw-0005oA-UL; Mon, 20 Jul 2020 20:14:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jxcAw-0005o3-HZ for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Jul 2020 20:14:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EsGMGhzKIpTaob8DadHHmrZfJzdmog+xLTQECJDRdFI=; b=RM+j2AB9x3rFzpqPb+P2EJOwnD i0Fq8pZD3dvVeBQ3Mcj/2b+5v1K8RHNsvXpe7wE9kORr/9LKlT0hnDd5AI4NyRlpKSOVtK7wa0ozH cz2/eMr8DY5O+e7NREVZ5afsYznXeaVmbqnbmNtYD17xuaTYNFmb8fhUx3edFUGD/0ao=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EsGMGhzKIpTaob8DadHHmrZfJzdmog+xLTQECJDRdFI=; b=MgqLN8Jh9THIHp4h2Dgd5nwi88 yYKX6ZZGEqLrNU/fpIv2jidjY8lRAfEpnzcJRMN11fNrUBFt8Nk29TNUvPUHEP4itZEEEPl7b7zXa rO+g+c8Z/xzLgl7sEwfz6yV/aECoO2nY4GARqKOgYaL+yj6F9nfAw/vsO/rWV3WFU980=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jxcAv-0021uM-Cc for linux-f2fs-devel@lists.sourceforge.net; Mon, 20 Jul 2020 20:14:14 +0000 Received: from gmail.com (unknown [104.132.1.76]) (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 680AD2080D; Mon, 20 Jul 2020 20:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595276045; bh=wDxijBprww99JyKZ7zq1b0Bm+gBJfpxa+gZiTN2MMac=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PPMtmi5EfngGRLVXC4qUYRQ1gdrrDIyuG8biGtRFAryZ0R9CC8s/0ZXIdD+Ovfbla JnQVA+559vhRMT7XehRKOYcnDREV63fo/E7ZW17Y80AOMn3OmELWauhiaC/+dIA1E8 5l8h0NDI2Cq1StzoLJGfBfBTNTRRaqlHa6Pc2oyE= Date: Mon, 20 Jul 2020 13:14:04 -0700 From: Eric Biggers To: Satya Tangirala Message-ID: <20200720201404.GJ1292162@gmail.com> References: <20200717014540.71515-1-satyat@google.com> <20200717014540.71515-2-satyat@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200717014540.71515-2-satyat@google.com> X-Headers-End: 1jxcAv-0021uM-Cc Subject: Re: [f2fs-dev] [PATCH v3 1/7] fscrypt: Add functions for direct I/O support X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Fri, Jul 17, 2020 at 01:45:34AM +0000, Satya Tangirala wrote: > From: Eric Biggers > > Introduce fscrypt_dio_supported() to check whether a direct I/O request > is unsupported due to encryption constraints, and > fscrypt_limit_io_pages() to check how many pages may be added to a bio > being prepared for direct I/O. > > The IV_INO_LBLK_32 fscrypt policy introduced the possibility that DUNs > in logically continuous file blocks might wrap from 0xffffffff to 0. > Since this was particularly difficult to handle when block_size != > PAGE_SIZE, fscrypt only supports blk-crypto en/decryption with > the IV_INO_LBLK_32 policy when block_size == PAGE_SIZE, and ensures that > the DUN never wraps around within any submitted bio. > fscrypt_limit_io_pages() can be used to determine the number of logically > contiguous blocks/pages that may be added to the bio without causing the > DUN to wrap around within the bio. This is an alternative to calling > fscrypt_mergeable_bio() on each page in a range of logically contiguous > pages. This is a bit hard to read, especially the second paragraph. How about: "Introduce fscrypt_dio_supported() to check whether a direct I/O request is unsupported due to encryption constraints. Also introduce fscrypt_limit_io_pages() to limit how many pages can be added to a bio being prepared for direct I/O. This is needed for the iomap direct I/O implementation to avoid DUN wraparound in the middle of a bio (which is possible with the IV_INO_LBLK_32 IV generation method). Elsewhere fscrypt_mergeable_bio() is used for this, but iomap operates on logical ranges directly and thus needs doesn't have a chance to call fscrypt_mergeable_bio() on every block or page. So we need a function which limits a logical range in one go." In particular, the detail about PAGE_SIZE better belongs in the code, I think. > +/** > + * fscrypt_limit_io_pages() - limit I/O pages to avoid discontiguous DUNs > + * @inode: the file on which I/O is being done > + * @pos: the file position (in bytes) at which the I/O is being done > + * @nr_pages: the number of pages we want to submit starting at @pos > + * > + * Determine the limit to the number of pages that can be submitted in the bio > + * targeting @pos without causing a data unit number (DUN) discontinuity. > + * > + * For IV generation methods that can't cause DUN wraparounds > + * within logically continuous data blocks, the maximum number of pages is > + * simply @nr_pages. For those IV generation methods that *might* cause DUN > + * wraparounds, the returned number of pages is the largest possible number of > + * pages (less than @nr_pages) that can be added to the bio without causing a > + * DUN wraparound within the bio. How about replacing the second paragraph here with: * This is normally just @nr_pages, as normally the DUNs just increment along * with the logical blocks. (Or the file is not encrypted.) * * In rare cases, fscrypt can be using an IV generation method that allows the * DUN to wrap around within logically continuous blocks, and that wraparound * will occur. If this happens, a value less than @nr_pages will be returned so * that the wraparound doesn't occur in the middle of the bio. Note that we * only support block_size == PAGE_SIZE (and page-aligned DIO) in such cases. _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel