Skip to content

Commit

Permalink
Add option to ignore-sync for RMAN backup/restore case (#1238)
Browse files Browse the repository at this point in the history
Add option to ignore-sync for RMAN backup/restore case
  • Loading branch information
vibhansa-msft authored Sep 13, 2023
1 parent b593811 commit 5ed243d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

**Bug Fixes**
- [#1237](https://github.com/Azure/azure-storage-fuse/issues/1237) Fixed the case sensitivity of content type for file extensions.
- [#1230](https://github.com/Azure/azure-storage-fuse/issues/1230) Disable deletion of files from local-cache on sync. Use `--ignore-sync` cli option to enable this.

**Optimizations**
- Optimized file-cache to skip download when O_TRUNC flag is provided in open call.
Expand Down
10 changes: 9 additions & 1 deletion component/file_cache/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type FileCache struct {
allowOther bool
offloadIO bool
syncToFlush bool
syncToDelete bool
maxCacheSize float64

defaultPermission os.FileMode
Expand Down Expand Up @@ -105,6 +106,7 @@ type FileCacheOptions struct {
V1Timeout uint32 `config:"file-cache-timeout-in-seconds" yaml:"-"`
EmptyDirCheck bool `config:"empty-dir-check" yaml:"-"`
SyncToFlush bool `config:"sync-to-flush" yaml:"sync-to-flush,omitempty"`
SyncNoOp bool `config:"ignore-sync" yaml:"ignore-sync,omitempty"`

RefreshSec uint32 `config:"refresh-sec" yaml:"refresh-sec,omitempty"`
}
Expand Down Expand Up @@ -229,6 +231,7 @@ func (c *FileCache) Configure(_ bool) error {
c.offloadIO = conf.OffloadIO
c.maxCacheSize = conf.MaxSizeMB
c.syncToFlush = conf.SyncToFlush
c.syncToDelete = !conf.SyncNoOp
c.refreshSec = conf.RefreshSec

c.tmpPath = common.ExpandPath(conf.TmpPath)
Expand Down Expand Up @@ -322,6 +325,8 @@ func (c *FileCache) OnConfigChange() {
c.policyTrace = conf.EnablePolicyTrace
c.offloadIO = conf.OffloadIO
c.maxCacheSize = conf.MaxSizeMB
c.syncToFlush = conf.SyncToFlush
c.syncToDelete = !conf.SyncNoOp
_ = c.policy.UpdateConfig(c.GetPolicyConfig(conf))
}

Expand Down Expand Up @@ -1095,7 +1100,7 @@ func (fc *FileCache) SyncFile(options internal.SyncFileOptions) error {
log.Trace("FileCache::SyncFile : handle=%d, path=%s", options.Handle.ID, options.Handle.Path)
if fc.syncToFlush {
options.Handle.Flags.Set(handlemap.HandleFlagDirty)
} else {
} else if fc.syncToDelete {
err := fc.NextComponent().SyncFile(options)
if err != nil {
log.Err("FileCache::SyncFile : %s failed", options.Handle.Path)
Expand Down Expand Up @@ -1501,6 +1506,9 @@ func init() {
syncToFlush := config.AddBoolFlag("sync-to-flush", false, "Sync call on file will force a upload of the file.")
config.BindPFlag(compName+".sync-to-flush", syncToFlush)

ignoreSync := config.AddBoolFlag("ignore-sync", false, "Just ignore sync call and do not invalidate locally cached file.")
config.BindPFlag(compName+".ignore-sync", ignoreSync)

config.RegisterFlagCompletionFunc("tmp-path", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveDefault
})
Expand Down
3 changes: 2 additions & 1 deletion setup/baseConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ file_cache:
offload-io: true|false <by default libfuse will service reads/writes to files for better perf. Set to true to make file-cache component service read/write calls.>
sync-to-flush: true|false <sync call to a file will force upload of the contents to storage account>
refresh-sec: <number of seconds after which compare lmt of file in local cache and container and refresh file if container has the latest copy>

ignore-sync: true|false <sync call will be ignored and locally cached file will not be deleted>

# Attribute cache related configuration
attr_cache:
timeout-sec: <time attributes can be cached (in sec). Default - 120 sec>
Expand Down

0 comments on commit 5ed243d

Please sign in to comment.