mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 13:40:22 +03:00
metacache: Allow prefix filtering (#10920)
Do listings with prefix filter when bloom filter is dirty. This will forward the prefix filter to the lister which will make it only scan the folders/objects with the specified prefix. If we have a clean bloom filter we try to build a more generally useful cache so in that case, we will list all objects/folders.
This commit is contained in:
+10
-3
@@ -40,6 +40,12 @@ const (
|
||||
|
||||
// metacacheBlockSize is the number of file/directory entries to have in each block.
|
||||
metacacheBlockSize = 5000
|
||||
|
||||
// metacacheSharePrefix controls whether prefixes on dirty paths are always shared.
|
||||
// This will make `test/a` and `test/b` share listings if they are concurrent.
|
||||
// Enabling this will make cache sharing more likely and cause less IO,
|
||||
// but may cause additional latency to some calls.
|
||||
metacacheSharePrefix = false
|
||||
)
|
||||
|
||||
//go:generate msgp -file $GOFILE -unexported
|
||||
@@ -50,6 +56,7 @@ type metacache struct {
|
||||
bucket string `msg:"b"`
|
||||
root string `msg:"root"`
|
||||
recursive bool `msg:"rec"`
|
||||
filter string `msg:"flt"`
|
||||
status scanStatus `msg:"stat"`
|
||||
fileNotFound bool `msg:"fnf"`
|
||||
error string `msg:"err"`
|
||||
@@ -114,16 +121,16 @@ func (m *metacache) canBeReplacedBy(other *metacache) bool {
|
||||
switch {
|
||||
case !m.recursive && !other.recursive:
|
||||
// If both not recursive root must match.
|
||||
return m.root == other.root
|
||||
return m.root == other.root && strings.HasPrefix(m.filter, other.filter)
|
||||
case m.recursive && !other.recursive:
|
||||
// A recursive can never be replaced by a non-recursive
|
||||
return false
|
||||
case !m.recursive && other.recursive:
|
||||
// If other is recursive it must contain this root
|
||||
return strings.HasPrefix(m.root, other.root)
|
||||
return strings.HasPrefix(m.root, other.root) && other.filter == ""
|
||||
case m.recursive && other.recursive:
|
||||
// Similar if both are recursive
|
||||
return strings.HasPrefix(m.root, other.root)
|
||||
return strings.HasPrefix(m.root, other.root) && other.filter == ""
|
||||
}
|
||||
panic("should be unreachable")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user