Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3310868imu; Sun, 11 Nov 2018 12:07:03 -0800 (PST) X-Google-Smtp-Source: AJdET5eRJrg1C2IEJte891TazfhkdUhOQ4QVB6ypmNiTfJRH6JEDuO6wZxtNWn+dDe9AmRvNOCpZ X-Received: by 2002:a17:902:b617:: with SMTP id b23-v6mr9753687pls.205.1541966823670; Sun, 11 Nov 2018 12:07:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966823; cv=none; d=google.com; s=arc-20160816; b=u1pmo/vCeW9J7iSDU37SGF92EXTYP9rbUxwRq4ZxLUlRhZXLHThJq1uOZ8lgpzP8SX Wre3XH0bwmaat58bGJqBMw8xTwHI4F5WQoGfDzLBQC3bsnCY+SXh/hxrl7+LFq4xrSb1 46fJuleP2BckJ4SEfuJYgLTLkHqWB7XeK2E1RtV8ABcoChaGeWlmO7eKuKRnRQqCnpa6 T0FGxuLjV1bQTlank0XoMm67JAt0RgPLpilbwujSKzmifDJqxcHa5Ybe2iI1rskEyE2V 8y4tYrN3EuQGGhUAr6E7iwIylDpm++gxYOfm3IlTx14HJosKxXsC6TjpdJ/NFL3TIFJN 8UBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=bgurkLY3Bt8upNqfHE0NlD0WNb0VtRvWE3hrYGKjkZU=; b=ySixcL2LOkQMNKh47isI9VZD+rRbBweEJG2XhbLpygqoCiJoI6OquGYsc2/0uX4SZi Pv5dOMH70FQeM8uPN8k7mgOGsAEkBfLN18BndK80faGX0gWEZSbF5Sz+YN3lf16brppO gmmaTCqiYG9AijF4cAEBF4qXR6O0mNJkKNUjwluow48juwcVY0F4BM2kM8bmmJZzqZY/ dfy/g3QIczMc5mg2oA1L5nNr99cYNcOIxB+OZTar2Rm9tkWp/kLweh+KT8vtIEh7cjCb kKanQr/PO2J989ZoJ+tWKohMOmVkWMyisbh3JhKerf1d8aInhKm7fgSA3Btu58F2+uYA p0Fw== 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 l20-v6si4769994pff.126.2018.11.11.12.06.48; Sun, 11 Nov 2018 12:07:03 -0800 (PST) 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 S1731361AbeKLFz4 (ORCPT + 99 others); Mon, 12 Nov 2018 00:55:56 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51972 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731143AbeKLFz4 (ORCPT ); Mon, 12 Nov 2018 00:55:56 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtB-0000l5-Po; Sun, 11 Nov 2018 19:59:21 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001PU-Lp; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Joe Habermann" , "Lukas Czerner" , "Theodore Ts'o" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 043/366] ext4: update mtime in ext4_punch_hole even if no blocks are released In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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 Signed-off-by: Ben Hutchings --- fs/ext4/inode.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3749,28 +3749,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);