Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2962735imm; Sun, 1 Jul 2018 09:14:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVl8PFvBk4WbCO3QK0bTEVZOalmydoDPAY1iRMT5iLLt1Q7sJ9JeW26yNC+v3lC16L4uWn X-Received: by 2002:a65:620b:: with SMTP id d11-v6mr19225357pgv.429.1530461684195; Sun, 01 Jul 2018 09:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530461684; cv=none; d=google.com; s=arc-20160816; b=JFTffyBMnKZ04/Dy0dfZHFN84nFUka/bN9c4fD+jLWQ/xdTi1smym0jY/HF5Dyq6Lh iuqh5Y0s5KceNqaOEezLquyE0OmhknW9v3du3zNLsDQl1Y89KjLCyMH5g/tYcMZoUAsq VPwJOu4hbWeh3dAzFI/es9k6knyOeCd92S6PnCa4botueWFmOxZwKIMQOnvtvlbwt3gn bQ7MV5MwkCH4zarGvg5rg3x/z2Zq5fYMqXUR7jcqZtLOJHGNl9PMl08Ii/xXc9uafvc0 XxEeOlQPG6LkpSgPCRpiPoA10ycUdDshygjkuULILx9QBJxOJfBN2kdRNOx7siG3je4r ic0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=c/XhjRVwpdJ67eOlxsPK8fpVKGtBXfASm82c8TENNrg=; b=zMYCaLmxH0AaFqj1JcLK+FmoTAJQAstepNAftvEAOsT2MYfJIXqIb97gUwPrDpt2bz 9OYfjqexPXn6DFD+DnQ+W8/9n8SX1Lnxiv24J2t0/DTLUIeM4BauD6BBLA+2hpBHNNjc c8JFpZ22XanyGXyMOHf8A1HS0DWUMB3TKgzhVWDJAQiFBnmHD3VrvkYXwi66hg1HCaiA qmExYNZYWqqZJgyxDsGEfCFghNfhI2bjtrQXM4808jj3LSxWcnd2slF1lvH5aWjOx2AO fiAwXzxQtoe4/olf8x7snNHku/Fg7DuycYfLOGmGxDbTrTP+ha7Tvv6ZnHqqtBx9Y5Iv KG+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66-v6si14722196pfx.67.2018.07.01.09.14.29; Sun, 01 Jul 2018 09:14:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932113AbeGAQMh (ORCPT + 99 others); Sun, 1 Jul 2018 12:12:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59948 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932083AbeGAQMb (ORCPT ); Sun, 1 Jul 2018 12:12:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 85408ACC; Sun, 1 Jul 2018 16:12:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Czerner , Theodore Tso , Joe Habermann Subject: [PATCH 3.18 38/85] ext4: update mtime in ext4_punch_hole even if no blocks are released Date: Sun, 1 Jul 2018 18:01:56 +0200 Message-Id: <20180701153123.872914322@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lukas Czerner commit eee597ac931305eff3d3fd1d61d6aae553bc0984 upstream. Currently in ext4_punch_hole we're going to skip the mtime update if there are no actual blocks to release. However we've actually modified the file by zeroing the partial block so the mtime should be updated. Moreover the sync and datasync handling is skipped as well, which is also wrong. Fix it. Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o Reported-by: Joe Habermann Cc: Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3531,28 +3531,28 @@ int ext4_punch_hole(struct inode *inode, EXT4_BLOCK_SIZE_BITS(sb); stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb); - /* If there are no blocks to remove, return now */ - if (first_block >= stop_block) - goto out_stop; - - down_write(&EXT4_I(inode)->i_data_sem); - ext4_discard_preallocations(inode); - - ret = ext4_es_remove_extent(inode, first_block, - stop_block - first_block); - if (ret) { - up_write(&EXT4_I(inode)->i_data_sem); - goto out_stop; - } + /* If there are blocks to remove, do it */ + if (stop_block > first_block) { + + down_write(&EXT4_I(inode)->i_data_sem); + ext4_discard_preallocations(inode); - if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) - ret = ext4_ext_remove_space(inode, first_block, - stop_block - 1); - else - ret = ext4_ind_remove_space(handle, inode, first_block, - stop_block); + ret = ext4_es_remove_extent(inode, first_block, + stop_block - first_block); + if (ret) { + up_write(&EXT4_I(inode)->i_data_sem); + goto out_stop; + } + + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) + ret = ext4_ext_remove_space(inode, first_block, + stop_block - 1); + else + ret = ext4_ind_remove_space(handle, inode, first_block, + stop_block); - up_write(&EXT4_I(inode)->i_data_sem); + up_write(&EXT4_I(inode)->i_data_sem); + } if (IS_SYNC(inode)) ext4_handle_sync(handle);