Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1259284ybl; Fri, 23 Aug 2019 16:23:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYVfsAT0JnuI5yyFBXnWiX5qOSuNsUsapCvQUrId72frOJflxDIFtmyIvH4DNTwpYBMhC1 X-Received: by 2002:aa7:8d88:: with SMTP id i8mr8220742pfr.28.1566602581564; Fri, 23 Aug 2019 16:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602581; cv=none; d=google.com; s=arc-20160816; b=M5zK54IIxIhzNhAIhe1ImbYiV0SjWQ4PVFgM4wIGlal+j28tmED4/mRBL+PKnDzBS4 ANid58IfPGuBpkDyKiK/isB1cmECy5qyV5mMlNVTkNcDYuTj110WhZn20RoxLV++86ST dJ/81weBxx+zseap6RBicqjmaw1RfD6z63PtsCSWPxraQBIT/0AkMeBc727l4w6rSgRy EjDNCl6xhLICZjvmbamAyXhfZoBunt7tLnFsCZCUnwH/v0W23IJ31iiv3pOs3jEbqFRC K6CT0BGxUkppgadAGkfxGsR7wVQD+9pSWn3cru7i9A0hIMMcSmURL5TI2XFlqETWc3uh 6zpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=baRWthHmEwIFco3qkgn0yVqKwWtTW73gbs7Z0izsGUc=; b=RbGeKbjrZYvqz4M1cLgSRxpQm/mmw/oLlLM8QAQY6GKRoyiWMLBAElzz1ISc/v6L0q pvqOZTMbKt4s81jrnx1q5N00BYxnN0uUDoLY3C6ILXWXhl4aZ2ZpaN+ppYfrGIWCU+/H jjlDTWmZeLbz+McLGkkTuGeZPb+CONfsTztrrEhwRDYFg4xeXhhg1pXclK5+JT+xe3eu QOVmpg4FjJMQM5GvL13avJt3CAHhYN1TrzEZnRSiXBpMwc+zTusbZa0tUtp5yVhFgCXA Sf0emLeTi72w+ndsEQhTr+uqn9hMOI47SE+8+Z1ilgqAPYOrUKE4MDvymcN7+98yEZkv Slmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si3258185pjn.5.2019.08.23.16.22.47; Fri, 23 Aug 2019 16:23:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392299AbfHWNYd (ORCPT + 99 others); Fri, 23 Aug 2019 09:24:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:22466 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392194AbfHWNYd (ORCPT ); Fri, 23 Aug 2019 09:24:33 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7NDMlII072880; Fri, 23 Aug 2019 09:24:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ujghy1dpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Aug 2019 09:24:14 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7NDMu2Z073569; Fri, 23 Aug 2019 09:24:13 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ujghy1dpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Aug 2019 09:24:13 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7NDLKme004308; Fri, 23 Aug 2019 13:24:11 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma01wdc.us.ibm.com with ESMTP id 2uj099my1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Aug 2019 13:24:11 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7NDOCUA51511688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Aug 2019 13:24:12 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0BF2AC060; Fri, 23 Aug 2019 13:24:11 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 993F4AC05F; Fri, 23 Aug 2019 13:24:08 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.199.53.214]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 23 Aug 2019 13:24:08 +0000 (GMT) From: Chandan Rajendra To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fscrypt@vger.kernel.org Cc: Chandan Rajendra , tytso@mit.edu, adilger.kernel@dilger.ca, ebiggers@kernel.org, hch@infradead.org, chandanrlinux@gmail.com Subject: [PATCH V5 0/7] Consolidate FS read I/O callbacks code Date: Fri, 23 Aug 2019 18:55:35 +0530 Message-Id: <20190823132542.13434-1-chandan@linux.ibm.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-23_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908230138 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patchset moves the "FS read I/O callbacks" code into a file of its own (i.e. fs/read_callbacks.c) and modifies the generic do_mpage_readpge() to make use of the functionality provided. "FS read I/O callbacks" code implements the state machine that needs to be executed after reading data from files that are encrypted and/or have verity metadata associated with them. With these changes in place, the patchset changes Ext4 to use mpage_readpage[s] instead of its own custom ext4_readpage[s]() functions. This is done to reduce duplication of code across filesystems. Also, "FS read I/O callbacks" source files will be built only if CONFIG_FS_ENCRYPTION is enabled. The patchset also modifies fs/buffer.c to get file encryption/decryption to work with subpage-sized blocks. The patches can also be obtained from https://github.com/chandanr/linux.git at branch subpage-encryption-v5. Changelog: V4 -> V5: 1. Since F2FS uses its own workqueue and also since its decompression logic isn't an fs independent entity like fscrypt or fsverity, this patchset drops support for F2FS. The patchset still helps in removing a copy of do_mpage_readpage() from Ext4 (i.e. ext4_readpage()) and also prevents a copy of block_read_full_page() from being added into Ext4 by adding support to "read callbacks" API invocations into block_read_full_page(). V3 -> V4: 1. A new buffer_head flag (i.e. BH_Read_Cb) is introduced to reliably check if a buffer head's content has to be decrypted. 2. Fix layering violation. Now the code flow for decryption happens as shown below, FS => read callbacks => fscrypt 3. Select FS_READ_CALLBACKS from FS specific kconfig file if FS_ENCRYPTION is enabled. 4. Make 'struct read_callbacks_ctx' an opaque structure. 5. Make use of FS' endio function rather than implementing one in read callbacks. 6. Make read_callbacks.h self-contained. 7. Split patchset to separate out ext4 and f2fs changes. V2 -> V3: 1. Split the V2 patch "Consolidate 'read callbacks' into a new file" into three patches, - Introduce the read_callbacks functionality. - Convert encryption to use read_callbacks. - Remove union from struct fscrypt_context. 2. fs/Kconfig Do not explicitly set the default value of 'n' for FS_READ_CALLBACKS. 3. fs/crypto/Kconfig Select CONFIG_FS_READ_CALLBACKS only if CONFIG_BLOCK is selected. 4. Remove verity associated code in read_callbacks code. 5. Introduce a callback argument to read_callbacks_setup() function which gets invoked for each page for bio. F2FS uses this to perform custom operations like decrementing the value of f2fs_sb_info->nr_pages[]. 6. Encapsulate the details of "read callbacks" (e.g. Usage of "struct read_callbacks *ctx") within its own functions. When CONFIG_FS_READ_CALLBACKS is set to 'n', the corresponding stub functions return approriate error values. 7. Split fscrypt_decrypt() function into fscrypt_decrypt_bio() and fscrypt_decrypt_bh(). 8. Split end_read_callbacks() function into end_read_callbacks_bio() and end_read_callbacks_bh(). V1 -> V2: 1. Removed the phrase "post_read_process" from file names and functions. Instead we now use the phrase "read_callbacks" in its place. 2. When performing changes associated with (1), the changes made by the patch "Remove the term 'bio' from post read processing" are made in the earlier patch "Consolidate 'read callbacks' into a new file". Hence the patch "Remove the term 'bio' from post read processing" is removed from the patchset. RFC V2 -> V1: 1. Test and verify FS_CFLG_OWN_PAGES subset of fscrypt_encrypt_page() code by executing fstests on UBIFS. 2. Implement F2fs function call back to check if the contents of a page holding a verity file's data needs to be verified. RFC V1 -> RFC V2: 1. Describe the purpose of "Post processing code" in the cover letter. 2. Fix build errors when CONFIG_FS_VERITY is enabled. Chandan Rajendra (7): buffer_head: Introduce BH_Read_Cb flag FS: Introduce read callbacks fs/mpage.c: Integrate read callbacks fs/buffer.c: add decryption support via read_callbacks ext4: Wire up ext4_readpage[s] to use mpage_readpage[s] ext4: Enable encryption for subpage-sized blocks fscrypt: remove struct fscrypt_ctx Documentation/filesystems/fscrypt.rst | 4 +- fs/Kconfig | 3 + fs/Makefile | 1 + fs/buffer.c | 33 ++- fs/crypto/bio.c | 18 -- fs/crypto/crypto.c | 89 +------- fs/crypto/fscrypt_private.h | 3 - fs/ext4/Kconfig | 1 + fs/ext4/Makefile | 2 +- fs/ext4/inode.c | 5 +- fs/ext4/readpage.c | 295 -------------------------- fs/ext4/super.c | 7 - fs/f2fs/Kconfig | 1 + fs/mpage.c | 24 ++- fs/read_callbacks.c | 285 +++++++++++++++++++++++++ include/linux/buffer_head.h | 2 + include/linux/fscrypt.h | 32 --- include/linux/read_callbacks.h | 48 +++++ 18 files changed, 391 insertions(+), 462 deletions(-) delete mode 100644 fs/ext4/readpage.c create mode 100644 fs/read_callbacks.c create mode 100644 include/linux/read_callbacks.h -- 2.19.1