From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B5C12C43331 for ; Thu, 4 Mar 2021 13:49:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F2A964F0A for ; Thu, 4 Mar 2021 13:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241543AbhCDNtI (ORCPT ); Thu, 4 Mar 2021 08:49:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48590 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbhCDNsm (ORCPT ); Thu, 4 Mar 2021 08:48:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614865637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hNSJeU6DHgk1JDrXPc6wXwBH7UNAGKwi0d2+igWtU6Y=; b=IlCdif604/TTZmoELwdR98IdQN3RUDdD6x5dwiJJSOGHBxMaMEfkAyLaFRTokCVVJJsHkR Kji+jw/u9j5BvNckMlcq4lsiFfQzYVLQg6e4FGdJ3bg9RbG2mebsIC4GzsusHByvxI1Jqr pRp/byz14sXvfz5a3lYcpTsC8hhNc1k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-hcFeYL5qNHGg6spmwsZ5Zw-1; Thu, 04 Mar 2021 08:47:13 -0500 X-MC-Unique: hcFeYL5qNHGg6spmwsZ5Zw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76E8BEC1A3; Thu, 4 Mar 2021 13:47:11 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-66.rdu2.redhat.com [10.10.112.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id D08AD5C1A1; Thu, 4 Mar 2021 13:47:05 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <2653261.1614813611@warthog.procyon.org.uk> References: <2653261.1614813611@warthog.procyon.org.uk> To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Jeff Layton , David Wysochanski , "Matthew Wilcox (Oracle)" , "J. Bruce Fields" , Christoph Hellwig , Dave Chinner , Alexander Viro , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: fscache: Redesigning the on-disk cache - LRU handling MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2973222.1614865624.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 04 Mar 2021 13:47:04 +0000 Message-ID: <2973223.1614865624@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org David Howells wrote: > = > (3) OpenAFS-style format. One index file to look up {file_key,block#} = and an > array of data files, each holding one block (e.g. a 256KiB-aligned = chunk > of a file). Each index entry has valid start/end offsets for easy > truncation. > = > The index has a hash to facilitate the lookup and an LRU that allow= s a > block to be recycled at any time. The LRU would probably have to be a doubly-linked list so that entries can= be removed from it easily. This means typically touching two other entries, which might not be in the same page; further, if the entry is being freed, we'd need to excise it from the hash chain also, necessitating touching ma= ybe two more entries - which might also be in different pages. Maybe the LRU idea plus a free block bitmap could be combined, however. (1) Say that there's a bit-pair map, with one bit pair per block. The pa= ir is set to 0 when the block is free. When the block is accessed, the = pair is set to 3. (2) When we run out of free blocks (ie. pairs that are zero), we decremen= t all the pairs and then look again. (3) Excision from the old hash chain would need to be done at allocation, though it does give a block whose usage has been reduced to 0 the cha= nce to be resurrected. Possible variations on the theme could be: (*) Set the pair to 2, not 3 when accessed. Set the block to 3 to pin it= ; the process of decrementing all the pairs would leave it at 3. (*) Rather than decrementing all pairs at once, have a rotating window th= at does a part of the map at once. (*) If a round of decrementing doesn't reduce any pairs to zero, reject a request for space. This would also work for a file index. David