-
Notifications
You must be signed in to change notification settings - Fork 473
feat(simple reader): Updating MRDInstance when minObject is updated in inode #4259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abhishek10004
wants to merge
9
commits into
master
Choose a base branch
from
abhishek/inode_updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+250
−70
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b993cf6
Updating MRDInstance minobject when inode updates it and retry for sh…
abhishek10004 ccc7025
Removing extra changes from this branch
abhishek10004 fd8d2ba
Added UTs for checking minobject in MrdInstance & some minor improvem…
abhishek10004 1f38585
Fixed an issue with refcount & added few comments
abhishek10004 70b273c
Adding protection for accessing & modifying minObject in MRDWrapper
abhishek10004 de6509a
UT fix
abhishek10004 05c3e3e
Merge branch 'master' of github.com:GoogleCloudPlatform/gcsfuse into …
abhishek10004 d168c31
Ensuring MRD Pool is recreated in case of generation mismatch while s…
abhishek10004 b0f523c
Fixing data race in UT
abhishek10004 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import ( | |
| "io" | ||
| "strconv" | ||
| "sync" | ||
| "sync/atomic" | ||
|
|
||
| "github.com/googlecloudplatform/gcsfuse/v3/cfg" | ||
| "github.com/googlecloudplatform/gcsfuse/v3/internal/cache/lru" | ||
|
|
@@ -38,7 +39,7 @@ type MrdInstance struct { | |
| // inodeId is the ID of the file inode associated with this instance. | ||
| inodeId fuseops.InodeID | ||
| // object is the GCS object for which the downloaders are created. | ||
| object *gcs.MinObject | ||
| object atomic.Pointer[gcs.MinObject] | ||
| // bucket is the GCS bucket containing the object. | ||
| bucket gcs.Bucket | ||
| // refCount tracks the number of active users of this instance. | ||
|
|
@@ -55,13 +56,28 @@ type MrdInstance struct { | |
|
|
||
| // NewMrdInstance creates a new MrdInstance for a given GCS object. | ||
| func NewMrdInstance(obj *gcs.MinObject, bucket gcs.Bucket, cache *lru.Cache, inodeId fuseops.InodeID, cfg cfg.MrdConfig) *MrdInstance { | ||
| return &MrdInstance{ | ||
| object: obj, | ||
| mrdInstance := MrdInstance{ | ||
| bucket: bucket, | ||
| mrdCache: cache, | ||
| inodeId: inodeId, | ||
| mrdConfig: cfg, | ||
| } | ||
| mrdInstance.object.Store(obj) | ||
| return &mrdInstance | ||
| } | ||
|
|
||
| // SetMinObject sets the gcs.MinObject stored in the MrdInstance to passed value, only if it's non nil. | ||
| func (mi *MrdInstance) SetMinObject(minObj *gcs.MinObject) error { | ||
| if minObj == nil { | ||
| return fmt.Errorf("MrdInstance::SetMinObject: Missing MinObject") | ||
| } | ||
| mi.object.Store(minObj) | ||
| return nil | ||
| } | ||
|
|
||
| // GetMinObject returns the gcs.MinObject stored in MrdInstance. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this only for testing? If yes, can we mention that in the comment. |
||
| func (mi *MrdInstance) GetMinObject() *gcs.MinObject { | ||
| return mi.object.Load() | ||
| } | ||
|
|
||
| // getMRDEntry returns a valid MRDEntry from the pool. | ||
|
|
@@ -157,7 +173,7 @@ func (mi *MrdInstance) ensureMRDPool() (err error) { | |
| } | ||
|
|
||
| // Creating a new pool. Not reusing any handle while creating a new pool. | ||
| mi.mrdPool, err = NewMRDPool(&MRDPoolConfig{PoolSize: int(mi.mrdConfig.PoolSize), object: mi.object, bucket: mi.bucket}, nil) | ||
| mi.mrdPool, err = NewMRDPool(&MRDPoolConfig{PoolSize: int(mi.mrdConfig.PoolSize), object: mi.object.Load(), bucket: mi.bucket}, nil) | ||
| if err != nil { | ||
| err = fmt.Errorf("MrdInstance::ensureMRDPool Error in creating MRDPool: %w", err) | ||
| } | ||
|
|
@@ -171,7 +187,7 @@ func (mi *MrdInstance) RecreateMRD() error { | |
| // Create the new pool first to avoid a period where mrdPool is nil. | ||
| newPool, err := NewMRDPool(&MRDPoolConfig{ | ||
| PoolSize: int(mi.mrdConfig.PoolSize), | ||
| object: mi.object, | ||
| object: mi.object.Load(), | ||
| bucket: mi.bucket, | ||
| }, nil) | ||
| if err != nil { | ||
|
|
@@ -218,7 +234,7 @@ func (mi *MrdInstance) IncrementRefCount() { | |
| // Remove from cache | ||
| deletedEntry := mi.mrdCache.Erase(getKey(mi.inodeId)) | ||
| if deletedEntry != nil { | ||
| logger.Tracef("MrdInstance::IncrementRefCount: MrdInstance (%s) erased from cache", mi.object.Name) | ||
| logger.Tracef("MrdInstance::IncrementRefCount: MrdInstance (%s) erased from cache", mi.object.Load().Name) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -269,13 +285,13 @@ func (mi *MrdInstance) DecrementRefCount() { | |
| // This is a safe order. | ||
| evictedValues, err := mi.mrdCache.Insert(getKey(mi.inodeId), mi) | ||
| if err != nil { | ||
| logger.Errorf("MrdInstance::DecrementRefCount: Failed to insert MrdInstance for object (%s) into cache, destroying immediately: %v", mi.object.Name, err) | ||
| logger.Errorf("MrdInstance::DecrementRefCount: Failed to insert MrdInstance for object (%s) into cache, destroying immediately: %v", mi.object.Load().Name, err) | ||
| // The instance could not be inserted into the cache. Since the refCount is 0, | ||
| // we must destroy it now to prevent it from being leaked. | ||
| mi.Destroy() | ||
| return | ||
| } | ||
| logger.Tracef("MrdInstance::DecrementRefCount: MrdInstance for object (%s) added to cache", mi.object.Name) | ||
| logger.Tracef("MrdInstance::DecrementRefCount: MrdInstance for object (%s) added to cache", mi.object.Load().Name) | ||
|
|
||
| // Do not proceed if no eviction happened. | ||
| if evictedValues == nil { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the inode gets updated with new generation we should invalidate the MRD instance and create it again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're leaving object unfinalized, then the generation won't change and we don't have to recreate the MRD. I can recreate it if FinalizeFileForRapid is set to true. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled generation change scenario in SetMinObject.