From: Boxi Liu Subject: there is a BUG in disk full case in inlinedata feature. Date: Wed, 28 Aug 2013 01:09:11 +0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: "lewis.liulei" To: "linux-ext4@vger.kernel.org" , Robin Dong , Theodore Tso , "tm@tao.ma" Return-path: Received: from mail-wi0-f178.google.com ([209.85.212.178]:63604 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700Ab3H0RJN (ORCPT ); Tue, 27 Aug 2013 13:09:13 -0400 Received: by mail-wi0-f178.google.com with SMTP id c10so1556978wiw.5 for ; Tue, 27 Aug 2013 10:09:11 -0700 (PDT) Sender: linux-ext4-owner@vger.kernel.org List-ID: 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;