From patchwork Thu Aug 29 15:15:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: boxi liu X-Patchwork-Id: 270871 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B79BD2C008A for ; Fri, 30 Aug 2013 01:15:47 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045Ab3H2PPq (ORCPT ); Thu, 29 Aug 2013 11:15:46 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:42878 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753896Ab3H2PPp (ORCPT ); Thu, 29 Aug 2013 11:15:45 -0400 Received: by mail-we0-f171.google.com with SMTP id p57so559140wes.2 for ; Thu, 29 Aug 2013 08:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3lUu4m5ErIYcG/oBdOPBV53foVmsbXDWe+vJnefrM88=; b=k6h7kJSbIsYX3LLqq5AevSTk1b4TeXMuv8ECbJQDqPOoswzFxamiHeQWleiGafbb0F 06bFEeNV+ugiaWq58DLQUGQfAE7MSfl4WP9G8WAiO6pDX0pW7pnmFCvGPejGLqbHisZE H3tM2vsVqmLzLyX8XzHZIWITPA0aJ0AYic5v1fZVSfGnhLAw1hUAgLvInVVpN92ClNsD FoFl2U5FfHsg3JeenH6myUTOeeK730VHyC/iAcfNZfT9ZM+TDq6U9LrrIbcu1+WBMh3h /bWUps+71R6S/GElVIn/wmUJV8Kw86Q9SiG2dLBFBkVKAMr/R5i03tn4Z/+4UVEewv+v Q96A== MIME-Version: 1.0 X-Received: by 10.194.118.169 with SMTP id kn9mr310228wjb.71.1377789344627; Thu, 29 Aug 2013 08:15:44 -0700 (PDT) Received: by 10.194.222.100 with HTTP; Thu, 29 Aug 2013 08:15:44 -0700 (PDT) In-Reply-To: <521D4CB2.2060805@tao.ma> References: <521D4CB2.2060805@tao.ma> Date: Thu, 29 Aug 2013 23:15:44 +0800 Message-ID: Subject: Re: there is a BUG in disk full case in inlinedata feature. From: Boxi Liu To: Tao Ma Cc: "linux-ext4@vger.kernel.org" , Robin Dong , Theodore Tso , "lewis.liulei" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org /* @@ -540,6 +541,9 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, needed_blocks = ext4_writepage_trans_blocks(inode); + if(EXT4_C2B(sbi,percpu_counter_read_positive(&sbi->s_freeclusters_counter)) < needed_blocks) + return -ENOSPC; + ret = ext4_get_inode_loc(inode, &iloc); if (ret) return ret; 2013/8/28 Tao Ma : > Hi Boxi, > Thanks for the detailed explanation and the bug fix. It looks good to me. > So would you mind send out a formal patch? > > Thanks, > Tao > On 08/28/2013 01:09 AM, Boxi Liu wrote: >> there is a BUG in EXT4 inlinedata feature when the disk is full(0B). >> tast case: >> step1: use the dd to make the disk full,has 0B remained. >> step2: touch a inlinedata file >> echo -n "123456" >> test.txt >> step3: make the inlinedata file test.txt convert to extent block. >> echo -n >> "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890">>test.txt >> the step3 will write failed.and print the BUG Backtrace: >> page:c1963bc0 count:-1 mapcount:0 mapping: (null) index:0x0 >> page flags:0x40000000() >> Backtrace: >> [] (dump_backtrace + 0x0/0x12c) from [] >> (dump_stack +0x18/0x1c) >> r6:c0043a84 r5:c0bb688 r4:c1963bc0 r3:00000000 >> [] (dump_stack + 0x0/0x1c) from [] (bad_page + 0xbc/0x13c) >> [] (bad_page + 0x0/0x13c) from [] >> (get_page_from_freelist + 0x4cc/0xb6c) >> r7:c1963bd8 r6:c0043194 r5:c1963bc0 r4:00000001 >> [] (get_page_from_freelist +0x0/0xb6c) from [] >> (__alloc_pages_nodemask + 0x144/0x820) >> [] (__alloc_pages_nodemask +0x0/0x820) from [] >> (handle_pte_fault + 0x574/0x758) >> [] (handle_pte_fault + 0x0/0x758) from [] >> (handle_mm_fault + 0xcc/0x110) >> [] (handel_mm_fault + 0x0/0x110) from [] >> (do_page_fault + 0x16c/0x1f4) >> [] (do_page_fault + 0x0/0x1f4) from [] >> (do_DataAbort + 0x40/0xac) >> [] (do_DataAbort + 0x0/0xac) from [] >> (ret_from_exception + 0x0/0x10) >> >> And when the system reboot , the step2 data "123456" will alse lost. >> You can cat the test.txt,but there is no data in the file. >> the reason is when the inlinedata convert to extent in the limit case, >> the inlinedata read to the page,then destory the inlinedata,next step >> is to __block_write_begin,but it can't get block,return -ENOSPC. so >> the data lost. >> >> there is a patch may fix the bug: >> in inline.c ext4_convert_inline_data_to_extent >> >> needed_blocks = ext4_writepage_trans_blocks(inode); >> >> + if(EXT4_C2B(sbi,percpu_counter_read_positive(&sbi->s_freeclusters_counter)) >> < needed_blocks) >> + return -ENOSPC; >> + >> ret = ext4_get_inode_loc(inode, &iloc); >> if (ret) >> return ret; >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> > --- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index c0fd1a1..f806f27 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -528,6 +528,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, struct page *page = NULL; unsigned from, to; struct ext4_iloc iloc; + struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); if (!ext4_has_inline_data(inode)) {