Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2964598imm; Sun, 1 Jul 2018 09:17:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdx0uG+4e4IoYttcdU46DieObfZB/izHkdwAI+huWVtyvcQA1NpLvILuHqvP6jA43jDec7M X-Received: by 2002:a62:2ec1:: with SMTP id u184-v6mr22276438pfu.184.1530461821139; Sun, 01 Jul 2018 09:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530461821; cv=none; d=google.com; s=arc-20160816; b=i64qWmIu9fM95CvaIBvdn8nfyOlEYiWaWanZu7qqeHzu5v2L27ZLHEB58YmSrrmsO8 26v2l/92FgAn08iQkIRlYWE2t3+W478owIvpv0+ZsJtHGWuA60QVx/2diZNaDMbTgL1I w8PEBEqxYSnrgTgjGkArdLkydm+UCVi7QmpdV9Dz7HK9MRQ4AZ815JJsynBclBk51IEJ EsK3u0Rrz7ChcqCbufQa1O02TCDo5pzsC4Judom8Jn7NDpOvRtf54PhRFiixrLIkpiWs XoLcuHBHRmxbBzVQgFdR1KVQznTUgSh+EPaSQ4TQsPvyE1W0sMMOS4yGJvXlA0DsjfjN 1kbA== 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=VsqjUP47EqBVrJsUNwh5iNwZNb5rsuVgihUj02hjv+A=; b=IxPvD/YulRAvcpclhpWW6ZmYBUKHgZgfsIVjRsWnccWFoXqs/1wYZJPzI0QR0Afw9J kOe/ZR/xnkB2WjmpNT2XTy0m2xOeuqBTPI8nTWUuKl/fRDoORdi2KnndhAi6w35TW6+p GKrlrw00s4d+nzU5snyvAOhtghshkXEiGk/bIIIKj1s76iWjBFAeD5HM4B0jqZbylFSt rA9QLZoo00MEsrztBEREKgAGuk7pLGqHNQL1XlldB2boKwttkd0vmCTvR9Pm4Yi6mqBp NMgsRgc0Az9mQIieS4U/uAfKUR8Xsh/+tI+wLuvTt5gLaLjTWsUXM72FcmH/uPzrbVeS /T0Q== 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 t17-v6si11802932pgv.615.2018.07.01.09.16.46; Sun, 01 Jul 2018 09:17:01 -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 S933001AbeGAQP1 (ORCPT + 99 others); Sun, 1 Jul 2018 12:15:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60554 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753211AbeGAQPW (ORCPT ); Sun, 1 Jul 2018 12:15:22 -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 AA5474A3; Sun, 1 Jul 2018 16:15:21 +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 4.4 013/105] ext4: update mtime in ext4_punch_hole even if no blocks are released Date: Sun, 1 Jul 2018 18:01:23 +0200 Message-Id: <20180701153150.412482422@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153149.382300170@linuxfoundation.org> References: <20180701153149.382300170@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 4.4-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 @@ -3787,28 +3787,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);