From patchwork Wed May 13 07:17:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hujianyang X-Patchwork-Id: 6394541 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78B99BEEE1 for ; Wed, 13 May 2015 07:17:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DD85203AB for ; Wed, 13 May 2015 07:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52F6820394 for ; Wed, 13 May 2015 07:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752051AbbEMHRg (ORCPT ); Wed, 13 May 2015 03:17:36 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:15740 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751954AbbEMHRg (ORCPT ); Wed, 13 May 2015 03:17:36 -0400 Received: from 172.24.2.119 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CNQ35774; Wed, 13 May 2015 15:17:33 +0800 (CST) Received: from [127.0.0.1] (10.111.68.144) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.158.1; Wed, 13 May 2015 15:17:21 +0800 Message-ID: <5552FA7D.7000704@huawei.com> Date: Wed, 13 May 2015 15:17:17 +0800 From: hujianyang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Jaegeuk Kim CC: Chao Yu , , , "linux-fsdevel@vger.kernel.org" Subject: Space leak in f2fs X-Originating-IP: [10.111.68.144] X-CFilter-Loop: Reflected Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jaegeuk, I found a space leak problem in f2fs. This problem could lead to ENOSPC error during stress tests, e.g. ltp. <<>> growfiles(gf15): 11656 growfiles.c/2249: 16920 tlibio.c/739 write(6, buf, 1352) ret:-1, errno=28 No space left on device gf15 1 TFAIL : growfiles.c:132: Test failed ... And can be reproduced by these steps whether background_gc is on or not: 1) format a 4GB f2fs partition 2) dd a 3G file, 3) unlink it. Do these steps again and again. Soon, after one unlink operation, you can see the space of the 3G file is not free. Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 301064 3854328 8% /mnt/f2fs Fs-Server:/mnt/f2fs # dd if=/dev/zero of=./test bs=1M count=3072 3072+0 records in 3072+0 records out 3221225472 bytes (3.2 GB) copied, 3.1892 s, 1.0 GB/s Fs-Server:/mnt/f2fs # unlink ./test Fs-Server:/mnt/f2fs # dd if=/dev/zero of=./test bs=1M count=3072 3072+0 records in 3072+0 records out 3221225472 bytes (3.2 GB) copied, 3.44288 s, 936 MB/s Fs-Server:/mnt/f2fs # unlink ./test Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 3449888 705504 84% /mnt/f2fs Fs-Server:/mnt/f2fs # ls Fs-Server:/mnt/f2fs # ls Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 3449888 705504 84% /mnt/f2fs Fs-Server:/mnt/f2fs # dd if=/dev/zero of=./test bs=1M count=3072 dd: writing `./test': No space left on device 689+0 records in 688+0 records out 721719296 bytes (722 MB) copied, 0.618972 s, 1.2 GB/s Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 4155392 0 100% /mnt/f2fs Fs-Server:/mnt/f2fs # ls -l test -rw-r--r-- 1 root root 721719296 May 13 14:52 test We can reuse the leaking space after a sync call: Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 4155392 0 100% /mnt/f2fs Fs-Server:/mnt/f2fs # sync Fs-Server:/mnt/f2fs # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdd3 4193280 1006568 3148824 25% /mnt/f2fs I found this may caused by .drop_inode in f2fs. see f2fs_drop_inode() After removing these code, this problem is fixed. But this function is introduced by commit 531ad7d58c6476c5856653448b4c7d26427502b4 to fix a deadlock problem. I wish you and other developers in this list could help me to fix this problem in a correct way. Thanks, Hu --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" 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/f2fs/super.c b/fs/f2fs/super.c index 19438f2..7646d2a 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -424,15 +424,6 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb) static int f2fs_drop_inode(struct inode *inode) { - /* - * This is to avoid a deadlock condition like below. - * writeback_single_inode(inode) - * - f2fs_write_data_page - * - f2fs_gc -> iput -> evict - * - inode_wait_for_writeback(inode) - */ - if (!inode_unhashed(inode) && inode->i_state & I_SYNC) - return 0; return generic_drop_inode(inode); }