From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 310ACC10F14 for ; Thu, 3 Oct 2019 17:35:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2C9420865 for ; Thu, 3 Oct 2019 17:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570124117; bh=U3cSNGwvy96rqIcgZucrgWm//sFCVaq6bqSnn3Ebk50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0jmA7oPQX9JV01tu/WVnDHA2ovvDwb3d0dhOj6dpKmV/qYukXQjKB3CcXSaQa3RNM bWoTW/yFJdVY+w90jRjFV3OsKPrggQdM0diGgthD+KnM9Bdx0SdECukO0ul1ls2wK3 SeXTtmt1Q57S8duqlyqJWh41uiNTj5/9rr/LOYw4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbfJCQGU (ORCPT ); Thu, 3 Oct 2019 12:06:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:53546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732730AbfJCQGU (ORCPT ); Thu, 3 Oct 2019 12:06:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA6F121783; Thu, 3 Oct 2019 16:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118780; bh=U3cSNGwvy96rqIcgZucrgWm//sFCVaq6bqSnn3Ebk50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c/jCvKYuomFWAJXrlpbFX1/Z/P1ae9fma8LoQSeqGzEB51cptAuhTxDM9cJ5mXdzb 807k20ryo3Uto7IubPAoHJ81HT9cgUdk67EbToYdAeU8cvqTEHbYCsoe4Ruk5lAxd8 XQvYBiB8heurIC631zz+2Vx+rzf5fiMa3IqsPF78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso Subject: [PATCH 4.9 122/129] ext4: fix punch hole for inline_data file systems Date: Thu, 3 Oct 2019 17:54:05 +0200 Message-Id: <20191003154415.763594742@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154318.081116689@linuxfoundation.org> References: <20191003154318.081116689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Theodore Ts'o commit c1e8220bd316d8ae8e524df39534b8a412a45d5e upstream. If a program attempts to punch a hole on an inline data file, we need to convert it to a normal file first. This was detected using ext4/032 using the adv configuration. Simple reproducer: mke2fs -Fq -t ext4 -O inline_data /dev/vdc mount /vdc echo "" > /vdc/testfile xfs_io -c 'truncate 33554432' /vdc/testfile xfs_io -c 'fpunch 0 1048576' /vdc/testfile umount /vdc e2fsck -fy /dev/vdc Cc: stable@vger.kernel.org Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3957,6 +3957,15 @@ int ext4_punch_hole(struct inode *inode, trace_ext4_punch_hole(inode, offset, length, 0); + ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); + if (ext4_has_inline_data(inode)) { + down_write(&EXT4_I(inode)->i_mmap_sem); + ret = ext4_convert_inline_data(inode); + up_write(&EXT4_I(inode)->i_mmap_sem); + if (ret) + return ret; + } + /* * Write out all dirty pages to avoid race conditions * Then release them.