Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeenkaur committed Jul 26, 2024
1 parent 0d9252c commit 9e32d09
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1832,9 +1832,12 @@ func (fs *fileSystem) RmDir(
err = fmt.Errorf("ReadEntries: %w", err)
return err
}
//Clear kernel list cache after removing a directory. This ensures remote
//GCS files are included in future directory listings for unlinking.
childDir.InvalidateKernelListCache()

if fs.kernelListCacheTTL > 0 {
// Clear kernel list cache after removing a directory. This ensures remote
// GCS files are included in future directory listings for unlinking.
childDir.InvalidateKernelListCache()
}

// Are there any entries?
if len(entries) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/fs/inode/base_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (d *baseDirInode) ShouldInvalidateKernelListCache(ttl time.Duration) bool {
return true
}

// Kernel list cache is not supported for baseDirInode.
// List operation is not supported for baseDirInode.
func (d *baseDirInode) InvalidateKernelListCache() {}

func (d *baseDirInode) RenameFolder(ctx context.Context, folderName string, destinationFolderId string) (op *gcs.Folder, err error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/fs/inode/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ type DirInode interface {
// should be invalidated or not.
ShouldInvalidateKernelListCache(ttl time.Duration) bool

//InvalidateKernelListCache sets the prevDirListingTimeStamp to zero so that
//cache is invalidated for next list call.
// InvalidateKernelListCache guarantees that the subsequent list call will be
// served from GCSFuse.
InvalidateKernelListCache()

// RLock readonly lock.
Expand Down
1 change: 1 addition & 0 deletions internal/fs/inode/dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ func (t *DirTest) TestRenameFolderWithNonExistentSourceFolder() {
func (t *DirTest) Test_InvalidateKernelListCache() {
d := t.in.(*dirInode)
d.prevDirListingTimeStamp = d.cacheClock.Now()
AssertFalse(d.prevDirListingTimeStamp.IsZero())

t.in.InvalidateKernelListCache()

Expand Down

0 comments on commit 9e32d09

Please sign in to comment.