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=ham 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 E8DE7C10F14 for ; Thu, 3 Oct 2019 16:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A92EC20700 for ; Thu, 3 Oct 2019 16:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118429; bh=v5z7osx8ZrhN/0iHMnVEgaI9K9aFHg+JY9Ifsi+bC+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RJ8VM6ZiFKHHfeFSZtpilDLXAHynz4ytQH9gSYa0zpBcLSgRJ8zXI/kGKEOqkKanR ZK5hkMG9oS3hcfE+VpjFsWoySJvjcWg3Kxj//7pH91fsmxvUX9iWt8Wk6t1HzW8VQ6 iD/pZLMJfq/AF4glmp453tU8p0oZZW9gasZ4nP70= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728955AbfJCQA2 (ORCPT ); Thu, 3 Oct 2019 12:00:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:44086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731563AbfJCQAY (ORCPT ); Thu, 3 Oct 2019 12:00:24 -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 A9B6F20700; Thu, 3 Oct 2019 16:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118424; bh=v5z7osx8ZrhN/0iHMnVEgaI9K9aFHg+JY9Ifsi+bC+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmgscjCcuOwgP07YJm4DvttoqWUIHRMV64y8+7h6+7AfZd6gRz67L3fI5RVFd8n1w AWcERSBA8NXsmdKvaCmsNdwv2sMdURo6zMfcW9r7oLFoJDjIhSZzzMG0abCPJp9eY7 nLNnLRQMkIrw0jW4pEH1ZiQGqsz2PvGveTxTAPKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso Subject: [PATCH 4.4 91/99] ext4: fix punch hole for inline_data file systems Date: Thu, 3 Oct 2019 17:53:54 +0200 Message-Id: <20191003154339.624879548@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154252.297991283@linuxfoundation.org> References: <20191003154252.297991283@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -3705,6 +3705,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.