[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2973223.1614865624@warthog.procyon.org.uk>
Date: Thu, 04 Mar 2021 13:47:04 +0000
From: David Howells <dhowells@...hat.com>
To: linux-cachefs@...hat.com
Cc: dhowells@...hat.com, Jeff Layton <jlayton@...hat.com>,
David Wysochanski <dwysocha@...hat.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
"J. Bruce Fields" <bfields@...ldses.org>,
Christoph Hellwig <hch@...radead.org>,
Dave Chinner <dchinner@...hat.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-afs@...ts.infradead.org, linux-nfs@...r.kernel.org,
linux-cifs@...r.kernel.org, ceph-devel@...r.kernel.org,
v9fs-developer@...ts.sourceforge.net,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: fscache: Redesigning the on-disk cache - LRU handling
David Howells <dhowells@...hat.com> 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 allows 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 maybe
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 pair
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 decrement
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 chance
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 that
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
Powered by blists - more mailing lists