From patchwork Wed Sep 20 22:45:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9962835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AF826056A for ; Wed, 20 Sep 2017 22:49:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D77628925 for ; Wed, 20 Sep 2017 22:49:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 800B528A28; Wed, 20 Sep 2017 22:49:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 370B228A28 for ; Wed, 20 Sep 2017 22:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751636AbdITWsv (ORCPT ); Wed, 20 Sep 2017 18:48:51 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35924 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751813AbdITWrI (ORCPT ); Wed, 20 Sep 2017 18:47:08 -0400 Received: by mail-pg0-f66.google.com with SMTP id d8so2372895pgt.3; Wed, 20 Sep 2017 15:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IggHwABRZFA4QcnHeUfeWTo3vHu5MJz9hAOmovqjsmc=; b=Tq8AbgOEcuQEvMA6z0iwMbYdEHQN/t+LyWxtSU7IOzucc6wdbMEM16rBAJFXH5U2xm aWQDoGBnKbgWDv5E+8Kw/36+vE8Lo0Qj3M2Pi6PKHqBRvjvWKj/Ho/eNpjOxJUEz9DFT KqSAHdGDphLcr/8+9iiLyVNOBN0b58V6sv7dogYy9WBpIxQgURmGm7CTMaEFvKYvKqps 0XuBqoLYrlo2F9nT6oYCLuD+c08obL9Qs57iV2Bh5I8B306mP31Q1P2GvZgi7Gl6l0Kq hgA6J9ckS8vVNjctg3ZYRE4OgQklAOnRXR9YSGx1X3/hvc25aQkJ8uFfMZW91lKVt8wL tDDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IggHwABRZFA4QcnHeUfeWTo3vHu5MJz9hAOmovqjsmc=; b=UkN+dfHC3J8//Mj+I871qH2ArEh9poC4Rl14FhsX/seakhu5iU4l3MdTADyq/5rotm UOH8hLhgHsEMQPDFzfGYM3QROXs+getgBFw19WYEHtsp6SG/9QqurjoG/biLIsoZ9+tz OQL6TwVjtbyO7uCH4h5BpIZzdpV72SI1T/TaP2PSbhRU4s6f8mG46m2n6xDCQfCa7eST dh6GYRwUFj+sKOMjQAWTSGi08GXp75wYvMrnoYhFD02JHjCgNvmHHY41lV1zf/pkbQvv HOEcQ18QV4XzDG3JxzfUHmxdjERGcLS+sTCxothQnYJglolZ3aWbHZ6e9gMd0CxvGKIk iB5g== X-Gm-Message-State: AHPjjUitz+4xzmKKYCgpsdFw+D1IcHlL/37QiTGN+nnEE+9ShCawLEE4 T9A7nEIWkMag31v8uvhEsFbJMAXUId8= X-Google-Smtp-Source: AOwi7QDu9zLe9MpV2DEY8V5dX957ETiMp/SmMH349YX3kQs/5nXlouGJ2Z29Awi0NhxQ+BmfuH9MJg== X-Received: by 10.84.216.87 with SMTP id f23mr3512435plj.307.1505947627777; Wed, 20 Sep 2017 15:47:07 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id j2sm6249pgn.26.2017.09.20.15.47.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 15:47:07 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, "Theodore Y . Ts'o" , Jaegeuk Kim , Michael Halcrow , Eric Biggers Subject: [PATCH 15/25] ext4: switch to fscrypt_prepare_setattr() Date: Wed, 20 Sep 2017 15:45:55 -0700 Message-Id: <20170920224605.22030-16-ebiggers3@gmail.com> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog In-Reply-To: <20170920224605.22030-1-ebiggers3@gmail.com> References: <20170920224605.22030-1-ebiggers3@gmail.com> Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Signed-off-by: Eric Biggers --- fs/ext4/inode.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d5a471939fbc..617c7feced24 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5311,6 +5311,10 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (error) return error; + error = fscrypt_prepare_setattr(dentry, attr); + if (error) + return error; + if (is_quota_modification(inode, attr)) { error = dquot_initialize(inode); if (error) @@ -5356,14 +5360,6 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) loff_t oldsize = inode->i_size; int shrink = (attr->ia_size <= inode->i_size); - if (ext4_encrypted_inode(inode)) { - error = fscrypt_get_encryption_info(inode); - if (error) - return error; - if (!fscrypt_has_encryption_key(inode)) - return -ENOKEY; - } - if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);