Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1109168pxb; Sun, 22 Aug 2021 06:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSpjiPUA1kH5p9R+UvZUnONas03dfp3nI7hfKb7mAXP+ae0pN/F5nYza3jyq7a/mHLzub7 X-Received: by 2002:a5d:96da:: with SMTP id r26mr23116269iol.47.1629638081788; Sun, 22 Aug 2021 06:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629638081; cv=none; d=google.com; s=arc-20160816; b=U/VAjno3EvHyDBGsk6HZIQry6NKn/YX4f/nMnIPAyP1kBwidtnNZmlx7PB9f4U+R/k 6TaYOBckQ20ALIXgvLV5MrcpLmUjD2ASX6k1lSuPhPUe+pLzJHrIiezeX/JoPrjlQxCY aJhlhj5Fs+/A8icJsw7AL1xmjhZ9E5EPK4IzS/L5JWAopxWeh3GzuR2EViAq6kP/0uj2 68RjQYCMqJIMWSZXqzBtEvYUE+QrsT+g2DOV/kdR1gS2bHeiiz4139iobGjVtxwhNRbM Z08fHez9cxe6lh6eH5940sb5tEgue5vwLf5wYYTTLDpIxqxs9W8k/nYnRgjPuUBe3E9f 5NIg== 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:from:references :cc:to:subject; bh=EifDby3t/ESEn+Jhc+p1c9pMnigdAJl3SZG3hnWvcBU=; b=aWvIUWyC571pItmKesxBpvcNsD3yY9VKTtIoG4vHVum9idqWiTHPh2G2Z/OJGo9kho x1CDd3YlipX5qCZc0+P0gCiXCizMz1B9tg+pr7L1mZRULvlN6gCmG/dWL3+po4R0WeDC eHjDDMpnzi8g+FIB7tV3tt6ZlI9EwDnhFo3IGGxvS3RT4OLmfNevq2pjQiGHScS28QHo DqtaRVry6T9QhrBeGnk/2LZR4DnFGfnx5pkeLKpWqDBx6BD5QwA7d3FgDgunqJsxVOKa w1GF7SLvtXanqhM92OBtddf/zgCVfBz7tuxWDuIw3IKNuRHIA+WOXNKzGzS9V4jZBB2E OUew== 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 x10si8284301ilg.50.2021.08.22.06.14.20; Sun, 22 Aug 2021 06:14:41 -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 S232042AbhHVNHq (ORCPT + 99 others); Sun, 22 Aug 2021 09:07:46 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:48117 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbhHVNHn (ORCPT ); Sun, 22 Aug 2021 09:07:43 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Ul-1DN2_1629637620; Received: from B-D1K7ML85-0059.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0Ul-1DN2_1629637620) by smtp.aliyun-inc.com(127.0.0.1); Sun, 22 Aug 2021 21:07:01 +0800 Subject: Re: [PATCH] ext4: fix reserved space counter leakage 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> From: Joseph Qi Message-ID: Date: Sun, 22 Aug 2021 21:06:59 +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: <20210820164556.GA30851@localhost.localdomain> 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/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. Thanks, Joseph