Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2296494pja; Thu, 26 Mar 2020 12:50:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsQTA6ckN5mR2l3FwmvG9MhiDhRFzcgQUK920bvNtVBxS7LUI0MwG/jda+BlHcs8UXkm/YG X-Received: by 2002:a05:6830:1104:: with SMTP id w4mr869566otq.54.1585252217742; Thu, 26 Mar 2020 12:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585252217; cv=none; d=google.com; s=arc-20160816; b=ki/doHnvYh0buD+iOzGJWOM00polqADjY+q6l8EanKlEFGL0pOSBUu3VhyM5txUix1 NY+38deLsjqUpcmGJfM18rVxYpMbRmOSBpg9Y05MpxIgw5xCND3MoeQIaFd9zQZFC8yN PpGkoP9Uf+KZdPvVrRcVqyGpqRd3Prse4G6I4AYKZeHaA5z7xsTj4v19Q+E/LNa/LiJx voTVCgj7/wfMQSqwVy+I2L+gVB0Qx931uC/kmdd5sEd+m93w83zk/QVjc0rRJRnqMaMV BASidF0RFAr1XttPyA+6FmvvJWYkExkaAfmZ8pi/Ae8uVSBynSI6wlWAXbDATJRQhufV F6jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iHe4siNzFkxQaIEc5fZ6aufrbN+L7q8/bKExZJ6cDCo=; b=UbYWdvedtoqNSn2Vpos/JH1Rfe3QriCAaCLqv1kIO6+/78M8N++xnjmwTw8zvgZ6Sq SRr0W135T5hPZDObxwBwBiPPwopSXGZdEXJ6S9wvGvoxwNtpHiIPqGhwJEHdqstvCPcm fNF63CHddfIXEftBR9T7y96ur4imIvJAKfV0L4fziF1FRpnxaCD527jybaXETIbHcLBD htfRkiK76CrIPEOzsb+9T7xtObTxdzzYTWeFAx1tggsk/at4V4nG6UI28ijN4US/4B1r E0PnOjNCZJZ0G5ycB4WJBduJLpjA94OuleLlw5j0IV8q1uwZnVVcN6Reyb7wmHZxFuBD 7zOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=THQwnp8y; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a190si1327415oib.146.2020.03.26.12.49.54; Thu, 26 Mar 2020 12:50:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=THQwnp8y; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727541AbgCZTtr (ORCPT + 99 others); Thu, 26 Mar 2020 15:49:47 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:37211 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbgCZTtr (ORCPT ); Thu, 26 Mar 2020 15:49:47 -0400 Received: by mail-ot1-f68.google.com with SMTP id g23so7282177otq.4 for ; Thu, 26 Mar 2020 12:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iHe4siNzFkxQaIEc5fZ6aufrbN+L7q8/bKExZJ6cDCo=; b=THQwnp8yNtvjBHc3Qnwp3GNmSNdDKvBUZ+oGYULsHm6ia9hcwiDD91lV7yjJjPLLbP AKZf+wN10jhnfQs66PN4C74xZiCNXh05UOIKAFCFnyBKiy8OEeVO5CQpTNNn9OZ3PqXI Xo9QDgiMIfropxB62xUEJ0yf0t2TRCcucgNNxqhmHNpzqLsikmTqC/yDvC9FRytpXNXP pz5QhN6TkpeHQ9sNbTMKIvdDT3a3nsfOW/LGCdXkyS13Ly8ja0leK+vSdGwV+dWXTVS0 vTZZKJBkHSX9exKFM0nsDfv96qvR86vE51QDPT1YNCzAJuamhpteQ/JFwcNHhSFRRBOC 1kcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iHe4siNzFkxQaIEc5fZ6aufrbN+L7q8/bKExZJ6cDCo=; b=uEzAsFT8copM1mdi4X117h+kP++2u3Mt1NngJLgkbeteRX8S7B/8PxAe1ZnwwwofpS OPG3Bv1tUxCYYxUvoi6ELoZ0khPsC+ZHTdJPv/9chzCzN/p9Gu5i28Qq3vXS2/NhhgYr rFfs2YXcQbc2oVlAybMQ/btvcxx27eViBsGX23wp3dWYBz6pMChh9K1Z+wgyO4Rubsq8 R13Roth5oKm88PPVjazVeY9ycvArYKrFBrzxtQ56cN+kNMdDUos1UjAqTVBtq0Q/YY4S B1R53kgVesIrjPBU4IBpK6q7V+Gf8c4gt+I+TSB+TRrHPmSKbCmYQt4/wjx1qRzQSO+E cxaw== X-Gm-Message-State: ANhLgQ0B9FOSTsnMwoVhHVOP6J0s+s8HFnpSXXJmt8osslprhyUBm5ko ewoQPUyMeBO+sZ1L1O+S3dx7KpZYB+tQeOuPavIsWjXs X-Received: by 2002:a4a:e047:: with SMTP id v7mr6424723oos.49.1585252186143; Thu, 26 Mar 2020 12:49:46 -0700 (PDT) MIME-Version: 1.0 References: <20200325093728.204211-1-harshadshirwadkar@gmail.com> <20200325093728.204211-2-harshadshirwadkar@gmail.com> <04F44879-15DE-42EE-B87A-0690E9B13BB2@dilger.ca> In-Reply-To: <04F44879-15DE-42EE-B87A-0690E9B13BB2@dilger.ca> From: harshad shirwadkar Date: Thu, 26 Mar 2020 12:49:35 -0700 Message-ID: Subject: Re: [PATCH 2/2] ext4: shrink directories on dentry delete To: Andreas Dilger Cc: linux-ext4 Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Mar 25, 2020 at 3:06 AM Andreas Dilger wrote: > > On Mar 25, 2020, at 3:37 AM, Harshad Shirwadkar wrote: > > But note that most of the shrinking happens during last 1-2% deletions > > in an average case. Therefore, the next step here is to merge dx nodes > > when possible. That can be achieved by storing the fullness index in > > htree nodes. But that's an on-disk format change. We can instead build > > on tooling added by this patch to perform reverse lookup on a dx > > node and then reading adjacent nodes to check their fullness. > > Thank you for updating these patches again. I haven't had a chance to look > at them yet, but I hope to review the patches in the near future. > > As for storing the fullness on disk changing the on-disk format... That is > true, but the original htree implementation anticipated this and reserved > space in the htree index to store the fullness, so it would not break the > ability of older kernels to access directories with the fullness information. > Yeah, you are right, good to know that we have bits reserved already and that wouldn't break older kernels if we use these in future. > I think if you used just a few bits (maybe just 2) to store: > 0 = unset (every directory today) > 1 = under 20% full > 2 = under 40% full > 3 = under 60% full > > or similar. It doesn't matter if they are more full since they won't be > candidates for merging, and then lazily update the htree index fullness > as entries are removed, this will simplify the shrinking process, and will > avoid the need to repeatedly scan the leaf blocks to see if they are empty > enough for merging. It wouldn't be any worse *not* to store these values > on disk after the first time a "0 = unset" entry was found and not merged, > or setting the fullness on the merged block if it is merged, and running > "e2fsck -D" can easily update the fullness values. > > The benefit of using 20%, 40%, and 60% as the fullness markers is that it > is possible to either merge adjacent 60% and 40% blocks or alternately a > 60% and two adjacent 20% blocks. Also, since these values are very coarse > they would not need to be updated frequently. If the values are slightly > outdated, then it is again not worse than the "always scan" model (one scan > and the fullness would be updated), but more efficient than repeat scanning. > > Using only two bits for fullness also leaves two bits free for future use. Thanks Andreas, that makes sense. This kind of merging will require lot of tooling provided in this patch - for example swapping out freed block with last block to not leave any holes. So, my hope is that we get this patch in first and thereby get a step closer to coalescing solution. Thanks, Harshad > > Cheers, Andreas > > > > >