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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no 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 372BAC4338F for ; Sun, 22 Aug 2021 13:14:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 194086127B for ; Sun, 22 Aug 2021 13:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbhHVNPC (ORCPT ); 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