Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1110642pxb; Sun, 22 Aug 2021 06:16:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXUYsMMUjH94nVZzi29/cTql2N+vK4UYhDeKKcxJVYboEoNhOLeGQUU+cjXPkr4W4L2jkY X-Received: by 2002:a17:906:c006:: with SMTP id e6mr31143073ejz.510.1629638192281; Sun, 22 Aug 2021 06:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629638192; cv=none; d=google.com; s=arc-20160816; b=q8K0gwic/HaKatIl+wXtI7ltISx3+swT8fnApPkHa7HVNgifilY/V3F9p13XFwhhUC /sX51ZekBCjJ6OtXAHM+XEwAZcOC1Rh6ttdxcJ0NvOIWuKwqIEAx1Zocd85YTTofeLeb Qlzsoo+Tm7euRZ+q0S1hNF4gycHmR6LGuw2N9DYiHpJUbMEK19AAAcL5njd3+jB6JDr/ AtIt/L/0x0NDjwNx10KDn618I3jkpel4rK/TD+WTRAGF4GlHFynVE2x9MDXcIhFaH3+6 /Kp5M+GzVSX02uLgaWP7FNThxYvNLXTay0Rrrcr6sm1Bjnr4v76T6X5auSMRPp5nx1wZ tL4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=pV72QtIJKCG6gPXz53uO183f6+sJgo0W2St9MfPXLz4=; b=tI01mj1dxfYa3+KYE5s9RVvnMOloGRYBJRRlSIJhS6KrNDbu+Yd/uV1AfC66NI/6jM 8+oMjd30jiEaiHPEA1xbCrqt8/bl/Tmiipr0iYuGDvuFYUCoMuFNWjIqiwzBME3ev5Gg v1icFvhLe2JG8yvY9pMhk4mRoRHu8TxLR3aUao9nHuiWsJO+0rn++92wfAYqCQ3BDxvZ S2DbIWL5QIpG4K8oDs5S8Xze6rBumottaGjh6GNjFA6iTxRpa5lPr0p5unHLCiIYYRz1 mATFwEecxUvJfyTpAxzHZ4yGraN+od8Ve0O3KSZm/bqXN1hD08uLcUZiklTI8opM4b4r undw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si11875233edy.417.2021.08.22.06.16.08; Sun, 22 Aug 2021 06:16:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231659AbhHVNPC (ORCPT + 99 others); Sun, 22 Aug 2021 09:15:02 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:49029 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbhHVNPB (ORCPT ); Sun, 22 Aug 2021 09:15:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Ul-h5c8_1629638058; Received: from B-D1K7ML85-0059.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0Ul-h5c8_1629638058) by smtp.aliyun-inc.com(127.0.0.1); Sun, 22 Aug 2021 21:14:19 +0800 Subject: Re: [PATCH] ext4: fix reserved space counter leakage From: Joseph Qi To: Eric Whitney , Jeffle Xu Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org References: <20210819091351.19297-1-jefflexu@linux.alibaba.com> <20210820164556.GA30851@localhost.localdomain> Message-ID: Date: Sun, 22 Aug 2021 21:14:18 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 8/22/21 9:06 PM, Joseph Qi wrote: > > > On 8/21/21 12:45 AM, Eric Whitney wrote: >> * Jeffle Xu : >>> When ext4_es_insert_delayed_block() returns error, e.g., ENOMEM, >>> previously reserved space is not released as the error handling, >>> in which case @s_dirtyclusters_counter is left over. Since this delayed >>> extent failes to be inserted into extent status tree, when inode is >>> written back, the extra @s_dirtyclusters_counter won't be subtracted and >>> remains there forever. >>> >>> This can leads to /sys/fs/ext4//delayed_allocation_blocks remains >>> non-zero even when syncfs is executed on the filesystem. >>> >> >> Hi: >> >> I think the fix below looks fine. However, this comment doesn't look right >> to me. Are you really seeing delayed_allocation_blocks values that remain >> incorrectly elevated across last closes (or across file system unmounts and >> remounts)? s_dirtyclusters_counter isn't written out to stable storage - >> it's an in-memory only variable that's created when a file is first opened >> and destroyed on last close. >> > > Actually we've encountered a real case in our production environment, > which has about 20G space lost (df - du = ~20G). > After some investigation, we've confirmed that it cause by leaked > s_dirtyclusters_counter (~5M), and even we do manually sync, it remains. > Since there is no error messages, we've checked all logic around > s_dirtyclusters_counter and found this. Also we can manually inject > error and reproduce the leaked s_dirtyclusters_counter. > BTW, it's a runtime lost, but not about on-disk. If umount and then mount it again, it becomes normal. But application also should be restarted... Thanks, Joseph