Skip to content
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

Flock implementation with test. #153

Closed
wants to merge 3 commits into from
Closed

Conversation

OneOfOne
Copy link
Contributor

Please let me know if it doesn't work as expected.

Fixes #134

return
}

if out, err := runExternalFlock(tc.mountFile); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no lighter weight mechanism for this? There must be some command-line utility that exposes flock?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is the flock command but it's part of util-linux-ng, I don't think it's very portable.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use that, and skip the test if we can't find the binary. Running the test binary from within the test binary sounds like it might easily break

@OneOfOne
Copy link
Contributor Author

@hanwen did you get a chance to look at it?

@hanwen
Copy link
Owner

hanwen commented Apr 19, 2017

squashed and committed as ae2e1d5

@hanwen hanwen closed this Apr 19, 2017
@rfjakob
Copy link
Contributor

rfjakob commented May 2, 2017

I think there is still something missing. I have mounted a loopback filesystem with -debug and ran flock in the mountpoint:

$ flock --verbose test.lock sleep 1
flock: getting lock took 0.000005 seconds
flock: executing sleep

loopback debug output:

21:10:32.202610 Dispatch 244: LOOKUP, NodeId: 1. names: [test.lock] 10 bytes
21:10:32.202679 Serialize 244: LOOKUP code: OK value: {NodeId: 4 Generation=2 EntryValid=1.000 AttrValid=1.000 Attr={M0100664 SZ=0 L=1 1026:1026 B0*4096 i0:8782516 A 1493752213.917942455 M 1493752213.917942455 C 1493752213.917661210}}
21:10:32.202791 Dispatch 245: OPEN, NodeId: 4. data: {O_RDONLY,0x8000} 
21:10:32.202834 Serialize 245: OPEN code: OK value: {Fh 3 }
21:10:33.203963 Dispatch 246: FLUSH, NodeId: 4. data: {Fh 3} 
21:10:33.204022 Serialize 246: FLUSH code: OK value: 
21:10:33.204236 Dispatch 247: FLUSH, NodeId: 4. data: {Fh 3} 
21:10:33.204249 Serialize 247: FLUSH code: OK value: 
21:10:33.204308 Dispatch 248: RELEASE, NodeId: 4. data: {Fh 3 0x8000  L0} 
21:10:33.204324 Serialize 248: RELEASE code: OK value: 

As you can see, no FLOCK call! The kernel does not seem to pass the call to us. Maybe we have to set a capability bit when mounting?

@rfjakob
Copy link
Contributor

rfjakob commented May 2, 2017

Ok I think what is missing is that the flock-related operations (_OP_GETLK etc.) are handled in opcode.go

@hanwen
Copy link
Owner

hanwen commented May 2, 2017 via email

@rfjakob
Copy link
Contributor

rfjakob commented May 2, 2017

Yes it is missing the kernel interface. But, it does no harm, the new code is just never called at the moment.

The test passes because the kernel keeps track of the locks when the filesystem does not support locking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants