Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp57224ybg; Sat, 25 Jul 2020 19:49:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUD/5hZ6nBlhblevOw0Xu7hUlVAZxFoOU+mBNPzl2Pl2fgOUeTjkYKMCptgYdjs7KSncwO X-Received: by 2002:a17:906:2e0c:: with SMTP id n12mr729480eji.35.1595731788246; Sat, 25 Jul 2020 19:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595731788; cv=none; d=google.com; s=arc-20160816; b=HfbK9eN8B4uwgSWGdbK5Y3lndc+4pJovhQ/kTBFL2IQ/c71nsGKupJr5/Q16mDDlqV AVhInmdWp3QeP12xWdLPVH1kVpfqOgkmq1XETv2hPvp9TVw5Z/s7gh1+L1dbvuhtf6Eg HeT9Y8n0oFKzAxe9+01ezFT7TKI5dIPBgl4J9gSa/uw4ql9vU/+JFMvqcgJkmLAkMODf m3rnn+1+AbmO6MN9uzbEuoyAKabKSRHiMuGTU1FtOoKFUQQGEIzbEyffYIOQ9KLuu+vT TcjWun16e3uwExRNgnYmgz+b5T9L2E3qEuEQPieT6dDOhv7PK0wakK3itC88Dtn8tANW IYMQ== 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=+1a0/7JO4HqjhinhNYm+Up9n6U32nbGmWIUXYuzkBCw=; b=l/RMb3BEYwz0x0aCsGTALsoWtRZ89wlTKSrMCp6CIDFckQhmV/9vkOemVwn7/bSL6e bPupboA4eFyTayORLGeT2N54Jcn7MBOKdEdOIpoZOTONGg3N1L71Qvmf6D9BJtcdCkkR 4GeDjOf7zGnn7dm93BU/eSPEFK7/cROHZlYReGB/SN5b8RfK/UGffUxQaNQsylk8V8x5 RR0T6lvE5JUrYMR6UwfJTNl8u+Uj/Qa8QpCHagMoRcgTQu+nBJZTjbLe89aIN+OuBUqf IJ2qOaF1aM2IAueM98SG0fZ/pPp2doI7SdUzet1P/sOt9DpUvqcTf0yhwkMRvNq7ElsL n+Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Rk0JV3yK; 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 r15si3226156eja.493.2020.07.25.19.49.23; Sat, 25 Jul 2020 19:49:48 -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=Rk0JV3yK; 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 S1728207AbgGZCtW (ORCPT + 99 others); Sat, 25 Jul 2020 22:49:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbgGZCtW (ORCPT ); Sat, 25 Jul 2020 22:49:22 -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 95BDA205CB; Sun, 26 Jul 2020 02:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595731761; bh=NAdi/klNeTi1UKbatqqEO+YULbHx0XAXFAEJ2boRXms=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rk0JV3yKOUVfoUzNKVR9NotJxck+84sGURjCBkcBqzTj0HgOll1QTZl7K95qYKjeU 1+1/MouEdKh1SKByzaHGghSyQ46DxASQ8JPOOOr4iAp5aHjFmp1Wko56K2W7TZbqmp Ue1h8bWvDCTu45/rkYFfAsH3QAOvEe3FCGZP9Ldc= Date: Sat, 25 Jul 2020 19:49:20 -0700 From: Eric Biggers To: Dave Chinner Cc: Satya Tangirala , linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH v6 1/7] fscrypt: Add functions for direct I/O support Message-ID: <20200726024920.GB14321@sol.localdomain> References: <20200724184501.1651378-1-satyat@google.com> <20200724184501.1651378-2-satyat@google.com> <20200725001441.GQ2005@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200725001441.GQ2005@dread.disaster.area> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, Jul 25, 2020 at 10:14:41AM +1000, Dave Chinner 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_alignment(iter), blocksize)) > > + return false; > > Doesn't this force user buffers to be filesystem block size aligned, > instead of 512 byte aligned as is typical for direct IO? > > That's going to cause applications that work fine on normal > filesystems becaues the memalign() buffers to 512 bytes or logical > block device sector sizes (as per the open(2) man page) to fail on > encrypted volumes, and it's not going to be obvious to users as to > why this happens. The status quo is that direct I/O on encrypted files falls back to buffered I/O. So this patch is strictly an improvement; it's making direct I/O work in a case where previously it didn't work. > > XFS has XFS_IOC_DIOINFO to expose exactly this information to > userspace on a per-file basis. Other filesystem and VFS developers > have said for the past 15 years "we don't need no stinking DIOINFO". > The same people shot down adding optional IO alignment > constraint fields to statx() a few years ago, too. > > Yet here were are again, with alignment of DIO buffers being an > issue that userspace needs to know about.... > A DIOINFO ioctl sounds like a good idea to me, although I'm not familiar with previous discussions about it. Note that there are lots of other cases where ext4 and f2fs fall back to buffered I/O; see ext4_dio_supported() and f2fs_force_buffered_io(). So this isn't a new problem. - Eric