Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp903074ybh; Wed, 22 Jul 2020 16:46:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTlZJ65hCpkWOnm05n/TOdyWSVokOttdhkVImT1ME3556GmKjMoOhf4gLvs2bXbAGlMyOx X-Received: by 2002:a17:906:36da:: with SMTP id b26mr1839147ejc.45.1595461578966; Wed, 22 Jul 2020 16:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595461578; cv=none; d=google.com; s=arc-20160816; b=oSnwN+qFUjfn9xqsDr6jIgz2G1VpREKVY76wdjIN7zWCuAfBGEVBI3S/v6FDnYRY+G FfC41WRCDi9Xc0IXqgpGaaqiknTamgTE+3LT8lZApGXiujMp8POOTgTBL4i0CHrEUeJ5 I+E3HJOFO+XOxsR6KUfxaRgARuSefiPS8MNbOGIcCYN4cSKCM96vWlQ+1drUAJ9qtoVe MULrM19BsfLs7qG4GacKIuyijhKskpW80rTepsO0JQvX+cbPhJdoBIcOUNYbjQVXgZhS vhEryQD/SpH9qBXJFiEEjs3ZU0OtcsUwWdBbo2S5IdpmWR5kWQp3C/bOGb8eZ4w/jHe0 UDGw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7wKRm1HO0GVmh6x30OI+wRBTuWrH/Roiftg0d9Qae3Y=; b=tCM5LbGlmeCeEM5aXXHN9rIwDBiOEJ82DnbUVvAf1yfFZfUscqHYCnquzJUO8Ae76F f223QdzZsSd9ewRxAGcb8fK5R1Ksw5L4udKST99Tkm2drEspPbOnexA1sOvOpYvxHfV4 APDXVX4HxkxKkSwVpUVdadcRI5+JpUwPN7npXoc2AJhqcvaqW43imgm9oO7q7HOwTC6l eZzkvFJJxYDJ947GsOENCFPrOYI4TcEZc/G+sdKVZQ9Q9VHJybW9QLc3hBkmHb/18BQZ 3+RdYmeRQmYw1RJo6CZwQviTuiSHANeOFsqbmmx4p/0oAYihKK6U1ZYjraTZeXpUDKUJ 0wRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KRJUfI/0"; 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 dn13si887190edb.186.2020.07.22.16.45.51; Wed, 22 Jul 2020 16:46:18 -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=default header.b="KRJUfI/0"; 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 S1733039AbgGVXnO (ORCPT + 99 others); Wed, 22 Jul 2020 19:43:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728607AbgGVXnO (ORCPT ); Wed, 22 Jul 2020 19:43:14 -0400 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 6D4D02086A; Wed, 22 Jul 2020 23:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595461393; bh=jF4qtHjIeuPOhSQlnQYYxpnx0gFWKePcCre3aK7+Bgc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KRJUfI/0Hdt5WoH8m0SRilChyMTwZKEfF3exTbXmO3eZp0Q7tW+XG6cF1yT78SV6H /wRKvBIXl0GVQPL+lU9V4Z7wsy+1Y0YUj9rSQsSLISAPkfUnYYE5zZbu7uXqYUUPT9 nUkWzfow49BJMqirOVydfh2/OJiOVl5ST37Zmm54= Date: Wed, 22 Jul 2020 16:43:12 -0700 From: Eric Biggers To: "Darrick J. Wong" Cc: Dave Chinner , Satya Tangirala , linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH v4 3/7] iomap: support direct I/O with fscrypt using blk-crypto Message-ID: <20200722234312.GC83434@sol.localdomain> References: <20200720233739.824943-1-satyat@google.com> <20200720233739.824943-4-satyat@google.com> <20200722211629.GE2005@dread.disaster.area> <20200722223404.GA76479@sol.localdomain> <20200722232625.GB83434@sol.localdomain> <20200722233247.GO3151642@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200722233247.GO3151642@magnolia> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Jul 22, 2020 at 04:32:47PM -0700, Darrick J. Wong wrote: > On Wed, Jul 22, 2020 at 04:26:25PM -0700, Eric Biggers wrote: > > On Wed, Jul 22, 2020 at 03:34:04PM -0700, Eric Biggers wrote: > > > So, something like this: > > > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > > index 44bad4bb8831..2816194db46c 100644 > > > --- a/fs/ext4/inode.c > > > +++ b/fs/ext4/inode.c > > > @@ -3437,6 +3437,15 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > > > map.m_len = min_t(loff_t, (offset + length - 1) >> blkbits, > > > EXT4_MAX_LOGICAL_BLOCK) - map.m_lblk + 1; > > > > > > + /* > > > + * When inline encryption is enabled, sometimes I/O to an encrypted file > > > + * has to be broken up to guarantee DUN contiguity. Handle this by > > > + * limiting the length of the mapping returned. > > > + */ > > > + if (!(flags & IOMAP_REPORT)) > > > + map.m_len = fscrypt_limit_io_blocks(inode, map.m_lblk, > > > + map.m_len); > > > + > > > if (flags & IOMAP_WRITE) > > > ret = ext4_iomap_alloc(inode, &map, flags); > > > else > > > > > > > > > That also avoids any confusion between pages and blocks, which is nice. > > > > Correction: for fiemap, ext4 actually uses ext4_iomap_begin_report() instead of > > ext4_iomap_begin(). So we don't need to check for !IOMAP_REPORT. > > > > Also it could make sense to limit map.m_len after ext4_iomap_alloc() rather than > > before, so that we don't limit the length of the extent that gets allocated but > > rather just the length that gets returned to iomap. > > Na?ve question here -- if the decision to truncate the bio depends on > the file block offset, can you achieve the same thing by capping the > length of the iovec prior to iomap_dio_rw? > > Granted that probably only makes sense if the LBLK IV thing is only > supposed to be used infrequently, and having to opencode a silly loop > might be more hassle than it's worth... > We *could* do the truncation there, but that would truncate the actual read() or write(). So, userspace would see a short read or write. And I understand that while applications are *supposed* to handle short reads and writes, many don't. I think Dave's suggestion makes more sense, since it would make this case be treated just like normal fragmentation of the file. - Eric