Skip to content

Commit dc44799

Browse files
address Mohit's review comments
1 parent 660ed8e commit dc44799

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

internal/fs/inode/file.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"io"
2121
"strconv"
2222
"strings"
23-
"syscall"
2423
"time"
2524

2625
"github.com/googlecloudplatform/gcsfuse/v3/cfg"
@@ -394,7 +393,8 @@ func (f *FileInode) Source() *gcs.MinObject {
394393
func (f *FileInode) SourceGenerationIsAuthoritative() bool {
395394
// Source generation is authoritative if:
396395
// 1. No pending writes exists on the inode (both content and bwh are nil).
397-
return f.content == nil && f.bwh == nil
396+
// 2. The bucket is zonal and there are no pending writes in the temporary file.
397+
return (f.content == nil && f.bwh == nil) || (f.bucket.BucketType().Zonal && f.content == nil)
398398
}
399399

400400
// Equivalent to the generation returned by f.Source().
@@ -551,14 +551,6 @@ func (f *FileInode) Read(
551551
ctx context.Context,
552552
dst []byte,
553553
offset int64) (n int, err error) {
554-
// It is not nil when streaming writes are enabled and bucket type is Zonal.
555-
if f.bwh != nil {
556-
// Allow reading from unfinalized objects.
557-
if !f.src.IsUnfinalized() {
558-
err = fmt.Errorf("cannot read a file when upload in progress: %w", syscall.ENOTSUP)
559-
return
560-
}
561-
}
562554

563555
// Make sure f.content != nil.
564556
err = f.ensureContent(ctx)

internal/fs/inode/file_streaming_writes_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,12 @@ func (t *FileStreamingWritesZonalBucketTest) TestSourceGenerationIsAuthoritative
223223
assert.True(t.T(), t.in.SourceGenerationIsAuthoritative())
224224
}
225225

226-
func (t *FileStreamingWritesZonalBucketTest) TestSourceGenerationIsAuthoritativeReturnsFalseAfterWriteForZonalBuckets() {
226+
func (t *FileStreamingWritesZonalBucketTest) TestSourceGenerationIsAuthoritativeReturnsTrueAfterWriteForZonalBuckets() {
227227
t.createBufferedWriteHandler()
228228
gcsSynced, err := t.in.Write(t.ctx, []byte("taco"), 0, util.Write)
229229
assert.NoError(t.T(), err)
230230
assert.False(t.T(), gcsSynced)
231-
232-
assert.False(t.T(), t.in.SourceGenerationIsAuthoritative())
231+
assert.True(t.T(), t.in.SourceGenerationIsAuthoritative())
233232
}
234233

235234
func (t *FileStreamingWritesZonalBucketTest) TestSyncPendingBufferedWritesForZonalBucketsPromotesInodeToNonLocal() {

0 commit comments

Comments
 (0)