Re: [f2fs-dev] [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 03:13:38PM -0700, Matthew Wilcox wrote: > > +/** > > + * clear_page_private - clear page's private field and PG_private. > > + * @page: page to be cleared. > > + * > > + * The counterpart function of attach_page_private. > > + * Return: private data of page or NULL if page

Re: [f2fs-dev] [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Al Viro
On Fri, May 01, 2020 at 02:42:29AM +0100, Al Viro wrote: > On Thu, Apr 30, 2020 at 03:13:38PM -0700, Matthew Wilcox wrote: > > > > +/** > > > + * clear_page_private - clear page's private field and PG_private. > > > + * @page: page to be cleared. > > > + * > > > + * The counterpart function of

Re: [f2fs-dev] [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Matthew Wilcox
On Thu, Apr 30, 2020 at 11:44:42PM +0200, Guoqing Jiang wrote: > +/** > + * attach_page_private - attach data to page's private field and set > PG_private. > + * @page: page to be attached and set flag. > + * @data: data to attach to page's private field. > + * > + * Need to take reference as

Re: [f2fs-dev] [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Andreas Grünbacher
Hi, Am Do., 30. Apr. 2020 um 23:56 Uhr schrieb Guoqing Jiang : > The logic in attach_page_buffers and __clear_page_buffers are quite > paired, but > > 1. they are located in different files. > > 2. attach_page_buffers is implemented in buffer_head.h, so it could be >used by other files. But

[f2fs-dev] [RFC PATCH V2 5/9] f2fs: use attach/clear_page_private

2020-04-30 Thread Guoqing Jiang
Since the new pair function is introduced, we can call them to clean the code in f2fs.h. Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net Acked-by: Chao Yu Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private.

Re: [f2fs-dev] [PATCH v12 10/12] fscrypt: add inline encryption support

2020-04-30 Thread Eric Biggers
On Thu, Apr 30, 2020 at 11:59:57AM +, Satya Tangirala wrote: > +bool __fscrypt_inode_uses_inline_crypto(const struct inode *inode) > +{ > + return inode->i_crypt_info->ci_inlinecrypt; > +} > +EXPORT_SYMBOL_GPL(fscrypt_inode_uses_inline_crypto); Right, this still needs to be exported (I

Re: [f2fs-dev] [PATCH v12 00/12] Inline Encryption Support

2020-04-30 Thread Eric Biggers
On Thu, Apr 30, 2020 at 11:59:47AM +, Satya Tangirala wrote: > This patch series adds support for Inline Encryption to the block layer, > UFS, fscrypt, f2fs and ext4. Thanks, that was fast! As usual I pushed this out to Repo: https://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git

[f2fs-dev] [PATCH v12 12/12] ext4: add inline encryption support

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
From: Eric Biggers Wire up ext4 to support inline encryption via the helper functions which fs/crypto/ now provides. This includes: - Adding a mount option 'inlinecrypt' which enables inline encryption on encrypted files where it can be used. - Setting the bio_crypt_ctx on bios that will be

[f2fs-dev] [PATCH v12 09/12] fs: introduce SB_INLINECRYPT

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Introduce SB_INLINECRYPT, which is set by filesystems that wish to use blk-crypto for file content en/decryption. This flag maps to the '-o inlinecrypt' mount option which multiple filesystems will implement, and code in fs/crypto/ needs to be able to check for this mount option in a

[f2fs-dev] [PATCH v12 00/12] Inline Encryption Support

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
This patch series adds support for Inline Encryption to the block layer, UFS, fscrypt, f2fs and ext4. Note that the patches in this series for the block layer (i.e. patches 1, 2, 3, 4 and 5) can be applied independently of the subsequent patches in this series. Inline Encryption hardware allows

[f2fs-dev] [PATCH v12 01/12] Documentation: Document the blk-crypto framework

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
The blk-crypto framework adds support for inline encryption. There are numerous changes throughout the storage stack. This patch documents the main design choices in the block layer, the API presented to users of the block layer (like fscrypt or layered devices) and the API presented to drivers

[f2fs-dev] [PATCH v12 05/12] block: blk-crypto-fallback for Inline Encryption

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Blk-crypto delegates crypto operations to inline encryption hardware when available. The separately configurable blk-crypto-fallback contains a software fallback to the kernel crypto API - when enabled, blk-crypto will use this fallback for en/decryption when inline encryption hardware is not

[f2fs-dev] [PATCH v12 07/12] scsi: ufs: UFS crypto API

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Introduce functions to manipulate UFS inline encryption hardware in line with the JEDEC UFSHCI v2.1 specification and to work with the block keyslot manager. The UFS crypto API will assume by default that a vendor driver doesn't support UFS crypto, even if the hardware advertises the capability,

[f2fs-dev] [PATCH v12 11/12] f2fs: add inline encryption support

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Wire up f2fs to support inline encryption via the helper functions which fs/crypto/ now provides. This includes: - Adding a mount option 'inlinecrypt' which enables inline encryption on encrypted files where it can be used. - Setting the bio_crypt_ctx on bios that will be submitted to an

[f2fs-dev] [PATCH v12 06/12] scsi: ufs: UFS driver v2.1 spec crypto additions

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Add the crypto registers and structs defined in v2.1 of the JEDEC UFSHCI specification in preparation to add support for inline encryption to UFS. Signed-off-by: Satya Tangirala --- drivers/scsi/ufs/ufshcd.c | 2 ++ drivers/scsi/ufs/ufshcd.h | 6 drivers/scsi/ufs/ufshci.h | 67

[f2fs-dev] [PATCH v12 08/12] scsi: ufs: Add inline encryption support to UFS

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Wire up ufshcd.c with the UFS Crypto API, the block layer inline encryption additions and the keyslot manager. Signed-off-by: Satya Tangirala --- drivers/scsi/ufs/ufshcd-crypto.h | 18 + drivers/scsi/ufs/ufshcd.c| 44

[f2fs-dev] [PATCH v12 03/12] block: Inline encryption support for blk-mq

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
We must have some way of letting a storage device driver know what encryption context it should use for en/decrypting a request. However, it's the upper layers (like the filesystem/fscrypt) that know about and manages encryption contexts. As such, when the upper layer submits a bio to the block

[f2fs-dev] [PATCH v12 10/12] fscrypt: add inline encryption support

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Add support for inline encryption to fs/crypto/. With "inline encryption", the block layer handles the decryption/encryption as part of the bio, instead of the filesystem doing the crypto itself via Linux's crypto API. This model is needed in order to take advantage of the inline encryption

[f2fs-dev] [PATCH v12 04/12] block: Make blk-integrity preclude hardware inline encryption

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Whenever a device supports blk-integrity, make the kernel pretend that the device doesn't support inline encryption (essentially by setting the keyslot manager in the request queue to NULL). There's no hardware currently that supports both integrity and inline encryption. However, it seems

[f2fs-dev] [PATCH v12 02/12] block: Keyslot Manager for Inline Encryption

2020-04-30 Thread Satya Tangirala via Linux-f2fs-devel
Inline Encryption hardware allows software to specify an encryption context (an encryption key, crypto algorithm, data unit num, data unit size) along with a data transfer request to a storage device, and the inline encryption hardware will use that context to en/decrypt the data. The inline

[f2fs-dev] [PATCH V4] f2fs: Avoid double lock for cp_rwsem during checkpoint

2020-04-30 Thread Sayali Lokhande
There could be a scenario where f2fs_sync_node_pages gets called during checkpoint, which in turn tries to flush inline data and calls iput(). This results in deadlock as iput() tries to hold cp_rwsem, which is already held at the beginning by checkpoint->block_operations(). Call stack : Thread

Re: [f2fs-dev] [PATCH V3] f2fs: Avoid double lock for cp_rwsem during checkpoint

2020-04-30 Thread Sayali Lokhande
On 4/30/2020 6:41 AM, Chao Yu wrote: On 2020/4/30 1:00, Sayali Lokhande wrote: There could be a scenario where f2fs_sync_node_pages gets called during checkpoint, which in turn tries to flush inline data and calls iput(). This results in deadlock as iput() tries to hold cp_rwsem, which is

Re: [f2fs-dev] [PATCH v11 10/12] fscrypt: add inline encryption support

2020-04-30 Thread Eric Biggers
On Wed, Apr 29, 2020 at 07:21:19AM +, Satya Tangirala wrote: > +/** > + * fscrypt_inode_uses_inline_crypto - test whether an inode uses inline > + * encryption > + * @inode: an inode I think this should also mention that the key must be setup, like * @inode:

Re: [f2fs-dev] [PATCH v11 04/12] block: Make blk-integrity preclude hardware inline encryption

2020-04-30 Thread Eric Biggers
On Wed, Apr 29, 2020 at 07:21:13AM +, Satya Tangirala wrote: > Whenever a device supports blk-integrity, the kernel will now always > pretend that the device doesn't support inline encryption (essentially > by setting the keyslot manager in the request queue to NULL). "the kernel will now

Re: [f2fs-dev] [PATCH v11 03/12] block: Inline encryption support for blk-mq

2020-04-30 Thread Eric Biggers
On Wed, Apr 29, 2020 at 07:21:12AM +, Satya Tangirala wrote: > diff --git a/block/blk-crypto.c b/block/blk-crypto.c [...] > +void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], > + unsigned int inc) > +{ > + int i = 0; > + > + while (inc && i <

Re: [f2fs-dev] [PATCH v11 02/12] block: Keyslot Manager for Inline Encryption

2020-04-30 Thread Eric Biggers
A few very minor comments: On Wed, Apr 29, 2020 at 07:21:11AM +, Satya Tangirala wrote: > diff --git a/block/keyslot-manager.c b/block/keyslot-manager.c > new file mode 100644 > index 0..b584723b392ad > --- /dev/null > +++ b/block/keyslot-manager.c > @@ -0,0 +1,380 @@ > +//