@@ -23,6 +23,7 @@ import (
2323 "github.com/cockroachdb/pebble/internal/manifest"
2424 "github.com/cockroachdb/pebble/internal/manual"
2525 "github.com/cockroachdb/pebble/objstorage"
26+ "github.com/cockroachdb/pebble/objstorage/shared"
2627 "github.com/cockroachdb/pebble/rangekey"
2728 "github.com/cockroachdb/pebble/record"
2829 "github.com/cockroachdb/pebble/sstable"
@@ -1904,7 +1905,30 @@ func WithApproximateSpanBytes() SSTablesOption {
19041905 }
19051906}
19061907
1907- // SSTableInfo export manifest.TableInfo with sstable.Properties
1908+ // BackingType denotes the type of storage backing a given sstable.
1909+ type BackingType int
1910+
1911+ const (
1912+ // BackingTypeLocal denotes an sstable stored on local disk according to the
1913+ // objprovider. This file is completely owned by us.
1914+ BackingTypeLocal BackingType = iota
1915+ // BackingTypeShared denotes an sstable stored on shared storage, created
1916+ // by this Pebble instance and possibly shared by other Pebble instances.
1917+ // These types of files have lifecycle managed by Pebble.
1918+ BackingTypeShared
1919+ // BackingTypeSharedForeign denotes an sstable stored on shared storage,
1920+ // created by a Pebble instance other than this one. These types of files have
1921+ // lifecycle managed by Pebble.
1922+ BackingTypeSharedForeign
1923+ // BackingTypeExternal denotes an sstable stored on external storage,
1924+ // not owned by any Pebble instance and with no refcounting/cleanup methods
1925+ // or lifecycle management. An example of an external file is a file restored
1926+ // from a backup.
1927+ BackingTypeExternal
1928+ )
1929+
1930+ // SSTableInfo export manifest.TableInfo with sstable.Properties alongside
1931+ // other file backing info.
19081932type SSTableInfo struct {
19091933 manifest.TableInfo
19101934 // Virtual indicates whether the sstable is virtual.
@@ -1913,6 +1937,11 @@ type SSTableInfo struct {
19131937 // backs the sstable associated with this SSTableInfo. If Virtual is false,
19141938 // then BackingSSTNum == FileNum.
19151939 BackingSSTNum base.FileNum
1940+ // BackingType is the type of storage backing this sstable.
1941+ BackingType BackingType
1942+ // Locator is the shared.Locator backing this sstable, if one was specified
1943+ // during ingest.
1944+ Locator shared.Locator
19161945
19171946 // Properties is the sstable properties of this table. If Virtual is true,
19181947 // then the Properties are associated with the backing sst.
@@ -1972,6 +2001,22 @@ func (d *DB) SSTables(opts ...SSTablesOption) ([][]SSTableInfo, error) {
19722001 }
19732002 destTables [j ].Virtual = m .Virtual
19742003 destTables [j ].BackingSSTNum = m .FileBacking .DiskFileNum .FileNum ()
2004+ objMeta , err := d .objProvider .Lookup (fileTypeTable , m .FileBacking .DiskFileNum )
2005+ if err != nil {
2006+ return nil , err
2007+ }
2008+ if objMeta .IsShared () {
2009+ if d .objProvider .IsForeign (objMeta ) {
2010+ destTables [j ].BackingType = BackingTypeSharedForeign
2011+ } else if objMeta .Shared .CleanupMethod == objstorage .SharedNoCleanup {
2012+ destTables [j ].BackingType = BackingTypeExternal
2013+ } else {
2014+ destTables [j ].BackingType = BackingTypeShared
2015+ }
2016+ destTables [j ].Locator = objMeta .Shared .Locator
2017+ } else {
2018+ destTables [j ].BackingType = BackingTypeLocal
2019+ }
19752020
19762021 if opt .withApproximateSpanBytes {
19772022 var spanBytes uint64
0 commit comments