@@ -57,37 +57,33 @@ type Settings struct {
5757 Logger base.Logger
5858
5959 // Local filesystem configuration.
60- FS vfs.FS
61- FSDirName string
62-
63- // FSDirInitialListing is a listing of FSDirName at the time of calling Open.
64- //
65- // This is an optional optimization to avoid double listing on Open when the
66- // higher layer already has a listing. When nil, we obtain the listing on
67- // Open.
68- FSDirInitialListing []string
69-
70- // Cleaner cleans obsolete files from the local filesystem.
71- //
72- // The default cleaner uses the DeleteCleaner.
73- FSCleaner base.Cleaner
74-
75- // NoSyncOnClose decides whether the implementation will enforce a
76- // close-time synchronization (e.g., fdatasync() or sync_file_range())
77- // on files it writes to. Setting this to true removes the guarantee for a
78- // sync on close. Some implementations can still issue a non-blocking sync.
79- NoSyncOnClose bool
80-
81- // BytesPerSync enables periodic syncing of files in order to smooth out
82- // writes to disk. This option does not provide any persistence guarantee, but
83- // is used to avoid latency spikes if the OS automatically decides to write
84- // out a large chunk of dirty filesystem buffers.
85- BytesPerSync int
86-
87- // Local contains fields that are only relevant for files stored on the local
88- // filesystem.
8960 Local struct {
90- // TODO(radu): move FSCleaner, NoSyncOnClose, BytesPerSync here.
61+ FS vfs.FS
62+ FSDirName string
63+
64+ // FSDirInitialListing is a listing of FSDirName at the time of calling Open.
65+ //
66+ // This is an optional optimization to avoid double listing on Open when the
67+ // higher layer already has a listing. When nil, we obtain the listing on
68+ // Open.
69+ FSDirInitialListing []string
70+
71+ // Cleaner cleans obsolete files from the local filesystem.
72+ //
73+ // The default cleaner uses the DeleteCleaner.
74+ FSCleaner base.Cleaner
75+
76+ // NoSyncOnClose decides whether the implementation will enforce a
77+ // close-time synchronization (e.g., fdatasync() or sync_file_range())
78+ // on files it writes to. Setting this to true removes the guarantee for a
79+ // sync on close. Some implementations can still issue a non-blocking sync.
80+ NoSyncOnClose bool
81+
82+ // BytesPerSync enables periodic syncing of files in order to smooth out
83+ // writes to disk. This option does not provide any persistence guarantee, but
84+ // is used to avoid latency spikes if the OS automatically decides to write
85+ // out a large chunk of dirty filesystem buffers.
86+ BytesPerSync int
9187
9288 // ReadaheadConfig is used to retrieve the current readahead mode; it is
9389 // consulted whenever a read handle is initialized.
@@ -198,14 +194,15 @@ const (
198194// DefaultSettings initializes default settings (with no remote storage),
199195// suitable for tests and tools.
200196func DefaultSettings (fs vfs.FS , dirName string ) Settings {
201- return Settings {
202- Logger : base .DefaultLogger ,
203- FS : fs ,
204- FSDirName : dirName ,
205- FSCleaner : base.DeleteCleaner {},
206- NoSyncOnClose : false ,
207- BytesPerSync : 512 * 1024 , // 512KB
208- }
197+ st := Settings {
198+ Logger : base .DefaultLogger ,
199+ }
200+ st .Local .FS = fs
201+ st .Local .FSDirName = dirName
202+ st .Local .FSCleaner = base.DeleteCleaner {}
203+ st .Local .NoSyncOnClose = false
204+ st .Local .BytesPerSync = 512 * 1024
205+ return st
209206}
210207
211208// Open creates the provider.
@@ -231,7 +228,7 @@ func open(settings Settings) (p *provider, _ error) {
231228 p .mu .protectedObjects = make (map [base.DiskFileNum ]int )
232229
233230 if objiotracing .Enabled {
234- p .tracer = objiotracing .Open (settings .FS , settings .FSDirName )
231+ p .tracer = objiotracing .Open (settings .Local . FS , settings . Local .FSDirName )
235232 }
236233
237234 // Initialize local subsystem and add local vfs.FS objects.
@@ -402,12 +399,12 @@ func (p *provider) LinkOrCopyFromLocal(
402399 opts objstorage.CreateOptions ,
403400) (objstorage.ObjectMetadata , error ) {
404401 shared := opts .PreferSharedStorage && p .st .Remote .CreateOnShared != remote .CreateOnSharedNone
405- if ! shared && srcFS == p .st .FS {
402+ if ! shared && srcFS == p .st .Local . FS {
406403 // Wrap the normal filesystem with one which wraps newly created files with
407404 // vfs.NewSyncingFile.
408- fs := vfs .NewSyncingFS (p .st .FS , vfs.SyncingFileOptions {
409- NoSyncOnClose : p .st .NoSyncOnClose ,
410- BytesPerSync : p .st .BytesPerSync ,
405+ fs := vfs .NewSyncingFS (p .st .Local . FS , vfs.SyncingFileOptions {
406+ NoSyncOnClose : p .st .Local . NoSyncOnClose ,
407+ BytesPerSync : p .st .Local . BytesPerSync ,
411408 })
412409 dstPath := p .localPath (dstFileType , dstFileNum )
413410 if err := vfs .LinkOrCopy (fs , srcFilePath , dstPath ); err != nil {
0 commit comments