-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add ex-lock utils setupVF finished #17
base: master
Are you sure you want to change the base?
Conversation
Hi @okletswin, Can you explain the problem in your setupVF ? |
fixup #16 |
sriov/sriov.go
Outdated
@@ -29,6 +29,7 @@ func setupVF(conf *SriovConf, ifName string, netns ns.NetNS) error { | |||
var ( | |||
err error | |||
vfDevName string | |||
locker *FileLocker |
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.
How about make locker
as global variable and initialize it in init
function?
sriov/sriov.go
Outdated
if err != nil { | ||
return err | ||
} | ||
} else { | ||
// alloc a free virtual function | ||
if vfIdx, vfDevName, err = allocFreeVF(masterName); err != nil { | ||
if vfIdx, vfDevName, locker, err = allocFreeVF(masterName); err != nil { |
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.
Maybe have no need to change allocFreeVF
function, We can change it as follows:
locker.Lock()
allocFreeVF()
locker.UnLock()
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.
yes, It's more better implementation. locker is global, Lock() maybe need an angument vfId and make it saved, Unlock() free the vfId and opened file. I will try
still make lock in getVFDeviceName
@hustcat , I pushed a new commit, and due to my level of golang is pitiful, some places are not too standard, improve it as you want |
@okletswin I made some changes, PTAL |
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.
Oh, vf level none-block changed into process level with block, I think there is no problem
@hustcat |
哥,什么情况,咋么还没合并呢??? |
@okletswin There are some conflicts, could you like to fix it? |
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.
retain setPF and setVF
@hustcat |
IMO, in order to support high concurrency allocate VF, this file level lock is MUST....... |
Sometimes, process allocated a free vf, but got error 'device not found' while setup it.
so, add a lock while find a free vf, other process will continue finding another free vf for use