diff --git a/internal/fs/fs.go b/internal/fs/fs.go index 3f623d7abb..3e57cf259d 100644 --- a/internal/fs/fs.go +++ b/internal/fs/fs.go @@ -252,9 +252,9 @@ func createFileCacheHandler(serverCfg *ServerConfig) (fileCacheHandler *file.Cac } func makeRootForBucket( - ctx context.Context, - fs *fileSystem, - syncerBucket gcsx.SyncerBucket) inode.DirInode { + ctx context.Context, + fs *fileSystem, + syncerBucket gcsx.SyncerBucket) inode.DirInode { return inode.NewDirInode( fuseops.RootInodeID, inode.NewRootName(""), @@ -967,9 +967,9 @@ func (fs *fileSystem) lookUpOrCreateInodeIfNotStale(ic inode.Core) (in inode.Ino // LOCKS_EXCLUDED(parent) // LOCK_FUNCTION(child) func (fs *fileSystem) lookUpOrCreateChildInode( - ctx context.Context, - parent inode.DirInode, - childName string) (child inode.Inode, err error) { + ctx context.Context, + parent inode.DirInode, + childName string) (child inode.Inode, err error) { // First check if the requested child is a localFileInode. child = fs.lookUpLocalFileInode(parent, childName) if child != nil { @@ -1093,9 +1093,9 @@ func (fs *fileSystem) lookUpLocalFileInode(parent inode.DirInode, childName stri // LOCKS_EXCLUDED(parent) // LOCK_FUNCTION(child) func (fs *fileSystem) lookUpOrCreateChildDirInode( - ctx context.Context, - parent inode.DirInode, - childName string) (child inode.BucketOwnedDirInode, err error) { + ctx context.Context, + parent inode.DirInode, + childName string) (child inode.BucketOwnedDirInode, err error) { in, err := fs.lookUpOrCreateChildInode(ctx, parent, childName) if err != nil { return nil, fmt.Errorf("lookup or create %q: %w", childName, err) @@ -1114,8 +1114,8 @@ func (fs *fileSystem) lookUpOrCreateChildDirInode( // LOCKS_EXCLUDED(fs.mu) // LOCKS_REQUIRED(f) func (fs *fileSystem) syncFile( - ctx context.Context, - f *inode.FileInode) (err error) { + ctx context.Context, + f *inode.FileInode) (err error) { // SyncFile can be triggered for unlinked files if the fileHandle is open by // same or another user. This indicates a potential file clobbering scenario: // - The file was deleted (unlinked) while a handle to it was still open. @@ -1232,8 +1232,8 @@ func (fs *fileSystem) unlockAndDecrementLookupCount(in inode.Inode, N uint64) { // LOCKS_EXCLUDED(fs.mu) // UNLOCK_FUNCTION(in) func (fs *fileSystem) unlockAndMaybeDisposeOfInode( - in inode.Inode, - err *error) { + in inode.Inode, + err *error) { // If there is no error, just unlock. if *err == nil { in.Unlock() @@ -1249,11 +1249,11 @@ func (fs *fileSystem) unlockAndMaybeDisposeOfInode( // // LOCKS_REQUIRED(in) func (fs *fileSystem) getAttributes( - ctx context.Context, - in inode.Inode) ( - attr fuseops.InodeAttributes, - expiration time.Time, - err error) { + ctx context.Context, + in inode.Inode) ( + attr fuseops.InodeAttributes, + expiration time.Time, + err error) { // Call through. attr, err = in.Attributes(ctx) if err != nil { @@ -1314,7 +1314,7 @@ func (fs *fileSystem) fileInodeOrDie(id fuseops.InodeID) (in *inode.FileInode) { // // LOCKS_REQUIRED(fs.mu) func (fs *fileSystem) symlinkInodeOrDie( - id fuseops.InodeID) (in *inode.SymlinkInode) { + id fuseops.InodeID) (in *inode.SymlinkInode) { tmp := fs.inodes[id] in, ok := tmp.(*inode.SymlinkInode) if !ok { @@ -1360,8 +1360,8 @@ func (fs *fileSystem) Destroy() { } func (fs *fileSystem) StatFS( - ctx context.Context, - op *fuseops.StatFSOp) (err error) { + ctx context.Context, + op *fuseops.StatFSOp) (err error) { // Simulate a large amount of free space so that the Finder doesn't refuse to // copy in files. (See issue #125.) Use 2^17 as the block size because that // is the largest that OS X will pass on. @@ -1383,8 +1383,8 @@ func (fs *fileSystem) StatFS( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) LookUpInode( - ctx context.Context, - op *fuseops.LookUpInodeOp) (err error) { + ctx context.Context, + op *fuseops.LookUpInodeOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1419,8 +1419,8 @@ func (fs *fileSystem) LookUpInode( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) GetInodeAttributes( - ctx context.Context, - op *fuseops.GetInodeAttributesOp) (err error) { + ctx context.Context, + op *fuseops.GetInodeAttributesOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1447,8 +1447,8 @@ func (fs *fileSystem) GetInodeAttributes( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) SetInodeAttributes( - ctx context.Context, - op *fuseops.SetInodeAttributesOp) (err error) { + ctx context.Context, + op *fuseops.SetInodeAttributesOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1497,8 +1497,8 @@ func (fs *fileSystem) SetInodeAttributes( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ForgetInode( - ctx context.Context, - op *fuseops.ForgetInodeOp) (err error) { + ctx context.Context, + op *fuseops.ForgetInodeOp) (err error) { // Find the inode. fs.mu.Lock() in := fs.inodeOrDie(op.Inode) @@ -1513,8 +1513,8 @@ func (fs *fileSystem) ForgetInode( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) MkDir( - ctx context.Context, - op *fuseops.MkDirOp) (err error) { + ctx context.Context, + op *fuseops.MkDirOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1572,8 +1572,8 @@ func (fs *fileSystem) MkDir( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) MkNode( - ctx context.Context, - op *fuseops.MkNodeOp) (err error) { + ctx context.Context, + op *fuseops.MkNodeOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1612,10 +1612,10 @@ func (fs *fileSystem) MkNode( // LOCKS_EXCLUDED(fs.mu) // LOCK_FUNCTION(child) func (fs *fileSystem) createFile( - ctx context.Context, - parentID fuseops.InodeID, - name string, - mode os.FileMode) (child inode.Inode, err error) { + ctx context.Context, + parentID fuseops.InodeID, + name string, + mode os.FileMode) (child inode.Inode, err error) { // Find the parent. fs.mu.Lock() parent := fs.dirInodeOrDie(parentID) @@ -1708,8 +1708,8 @@ func (fs *fileSystem) createLocalFile(ctx context.Context, parentID fuseops.Inod // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) CreateFile( - ctx context.Context, - op *fuseops.CreateFileOp) (err error) { + ctx context.Context, + op *fuseops.CreateFileOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1758,8 +1758,8 @@ func (fs *fileSystem) CreateFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) CreateSymlink( - ctx context.Context, - op *fuseops.CreateSymlinkOp) (err error) { + ctx context.Context, + op *fuseops.CreateSymlinkOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1816,20 +1816,20 @@ func (fs *fileSystem) CreateSymlink( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) RmDir( -// When rm -r or os.RemoveAll call is made, the following calls are made in order -// 1. RmDir (only in the case of os.RemoveAll) -// 2. Unlink all nested files, -// 3. lookupInode call on implicit directory -// 4. Rmdir on the directory. -// -// When type cache ttl is set, we construct an implicitDir even though one doesn't -// exist on GCS (https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/internal/fs/inode/dir.go#L452), -// and thus, we get rmDir call to GCSFuse. -// Whereas when ttl is zero, lookupInode call itself fails and RmDir is not called -// because object is not present in GCS. - - ctx context.Context, - op *fuseops.RmDirOp) (err error) { + // When rm -r or os.RemoveAll call is made, the following calls are made in order + // 1. RmDir (only in the case of os.RemoveAll) + // 2. Unlink all nested files, + // 3. lookupInode call on implicit directory + // 4. Rmdir on the directory. + // + // When type cache ttl is set, we construct an implicitDir even though one doesn't + // exist on GCS (https://github.com/GoogleCloudPlatform/gcsfuse/blob/master/internal/fs/inode/dir.go#L452), + // and thus, we get rmDir call to GCSFuse. + // Whereas when ttl is zero, lookupInode call itself fails and RmDir is not called + // because object is not present in GCS. + + ctx context.Context, + op *fuseops.RmDirOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -1936,8 +1936,8 @@ func (fs *fileSystem) RmDir( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) Rename( - ctx context.Context, - op *fuseops.RenameOp) (err error) { + ctx context.Context, + op *fuseops.RenameOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2032,12 +2032,12 @@ func (fs *fileSystem) renameHierarchicalFile(ctx context.Context, oldParent inod // LOCKS_EXCLUDED(oldParent) // LOCKS_EXCLUDED(newParent) func (fs *fileSystem) renameNonHierarchicalFile( - ctx context.Context, - oldParent inode.DirInode, - oldName string, - oldObject *gcs.MinObject, - newParent inode.DirInode, - newFileName string) error { + ctx context.Context, + oldParent inode.DirInode, + oldName string, + oldObject *gcs.MinObject, + newParent inode.DirInode, + newFileName string) error { // Clone into the new location. newParent.Lock() _, err := newParent.CloneToChildFile(ctx, newFileName, oldObject) @@ -2178,11 +2178,11 @@ func (fs *fileSystem) renameHierarchicalDir(ctx context.Context, oldParent inode // LOCKS_EXCLUDED(oldParent) // LOCKS_EXCLUDED(newParent) func (fs *fileSystem) renameNonHierarchicalDir( - ctx context.Context, - oldParent inode.DirInode, - oldName string, - newParent inode.DirInode, - newName string) error { + ctx context.Context, + oldParent inode.DirInode, + oldName string, + newParent inode.DirInode, + newName string) error { // Set up a function that throws away the lookup count increment from // lookUpOrCreateChildInode (since the pending inodes are not sent back to @@ -2271,8 +2271,8 @@ func (fs *fileSystem) renameNonHierarchicalDir( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) Unlink( - ctx context.Context, - op *fuseops.UnlinkOp) (err error) { + ctx context.Context, + op *fuseops.UnlinkOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2320,7 +2320,7 @@ func (fs *fileSystem) Unlink( err = parent.DeleteChildFile( ctx, op.Name, - 0, // Latest generation + 0, // Latest generation nil) // No meta-generation precondition if err != nil { @@ -2337,8 +2337,8 @@ func (fs *fileSystem) Unlink( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) OpenDir( - ctx context.Context, - op *fuseops.OpenDirOp) (err error) { + ctx context.Context, + op *fuseops.OpenDirOp) (err error) { fs.mu.Lock() // Make sure the inode still exists and is a directory. If not, something has @@ -2368,8 +2368,8 @@ func (fs *fileSystem) OpenDir( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ReadDir( - ctx context.Context, - op *fuseops.ReadDirOp) (err error) { + ctx context.Context, + op *fuseops.ReadDirOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2398,8 +2398,8 @@ func (fs *fileSystem) ReadDir( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ReleaseDirHandle( - ctx context.Context, - op *fuseops.ReleaseDirHandleOp) (err error) { + ctx context.Context, + op *fuseops.ReleaseDirHandleOp) (err error) { fs.mu.Lock() defer fs.mu.Unlock() @@ -2414,8 +2414,8 @@ func (fs *fileSystem) ReleaseDirHandle( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) OpenFile( - ctx context.Context, - op *fuseops.OpenFileOp) (err error) { + ctx context.Context, + op *fuseops.OpenFileOp) (err error) { fs.mu.Lock() // Find the inode. @@ -2448,8 +2448,8 @@ func (fs *fileSystem) OpenFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ReadFile( - ctx context.Context, - op *fuseops.ReadFileOp) (err error) { + ctx context.Context, + op *fuseops.ReadFileOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2481,8 +2481,8 @@ func (fs *fileSystem) ReadFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ReadSymlink( - ctx context.Context, - op *fuseops.ReadSymlinkOp) (err error) { + ctx context.Context, + op *fuseops.ReadSymlinkOp) (err error) { // Find the inode. fs.mu.Lock() in := fs.symlinkInodeOrDie(op.Inode) @@ -2499,8 +2499,8 @@ func (fs *fileSystem) ReadSymlink( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) WriteFile( - ctx context.Context, - op *fuseops.WriteFileOp) (err error) { + ctx context.Context, + op *fuseops.WriteFileOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2526,8 +2526,8 @@ func (fs *fileSystem) WriteFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) SyncFile( - ctx context.Context, - op *fuseops.SyncFileOp) (err error) { + ctx context.Context, + op *fuseops.SyncFileOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2559,8 +2559,8 @@ func (fs *fileSystem) SyncFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) FlushFile( - ctx context.Context, - op *fuseops.FlushFileOp) (err error) { + ctx context.Context, + op *fuseops.FlushFileOp) (err error) { if fs.newConfig.FileSystem.IgnoreInterrupts { // When ignore interrupts config is set, we are creating a new context not // cancellable by parent context. @@ -2586,8 +2586,8 @@ func (fs *fileSystem) FlushFile( // LOCKS_EXCLUDED(fs.mu) func (fs *fileSystem) ReleaseFileHandle( - ctx context.Context, - op *fuseops.ReleaseFileHandleOp) (err error) { + ctx context.Context, + op *fuseops.ReleaseFileHandleOp) (err error) { fs.mu.Lock() fileHandle := fs.handles[op.Handle].(*handle.FileHandle) @@ -2605,13 +2605,13 @@ func (fs *fileSystem) ReleaseFileHandle( } func (fs *fileSystem) GetXattr( - ctx context.Context, - op *fuseops.GetXattrOp) (err error) { + ctx context.Context, + op *fuseops.GetXattrOp) (err error) { return syscall.ENOSYS } func (fs *fileSystem) ListXattr( - ctx context.Context, - op *fuseops.ListXattrOp) error { + ctx context.Context, + op *fuseops.ListXattrOp) error { return syscall.ENOSYS }