Skip to contentSkip to conversation

Handle OFD lock flags

PATCH In review Stefan Agner 2 participants 2 messages Jan 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Handle OFD lock flags

Linux 3.15 and newer introduced new open file description locks. Currently pseudo prints a warning if fcntl is used with OFD locks:
unknown fcntl argument 37, assuming long argument.

However, calls to fcntl with a OFC lock set need a struct flock pointer. Treat F_OFD_GETLK (and friends) like F_GETLK (and friends).

This issue has been observed with ostree. Comparing strace output between two runs with/without this patch shows the same fcntl calls, hence it seems not to matter in practice.

---
Hi,

I noticed this when using meta-updater which uses ostree to commit the root file system. We observe this warnings on every build, but the last error message only rather seldom:

...
unknown fcntl argument 37, assuming long argument.
unknown fcntl argument 37, assuming long argument.
unknown fcntl argument 37, assuming long argument.
error: Locking repo exclusive failed: Resource temporarily unavailable

Looking at a strace it seems that with pseudo in place the fcntl seems to pass the argument properly nontheless:
fcntl(7, F_OFD_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0 fcntl(7, F_OFD_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0

So this effectively just gets rid of the warnings.

--
Stefan

 ports/linux/guts/fcntl.c | 3 +++
 1 file changed, 3 insertions(+)
ports/linux/guts/fcntl.c +3 -0
index 639fd24..3991e25 100644
@@ -50,6 +50,9 @@
 	case F_GETLK:
 	case F_SETLK:
 	case F_SETLKW:
+	case F_OFD_GETLK:
+	case F_OFD_SETLK:
+	case F_OFD_SETLKW:
 		rc = real_fcntl(fd, cmd, lock);
 		break;
 #if defined(F_GETLK64) && (F_GETLK64 != F_GETLK)
Signature · 1 line
2.20.1
#1 lore raw

ports/linux/guts/fcntl.c line 55

Quoted 3 lines · On Tue, 15 Jan 2019 13:31:13 +0100 Stefan Agner <[email protected]> wrote:
ports/linux/guts/fcntl.c +3 -0
+	case F_OFD_GETLK:
+	case F_OFD_SETLK:
+	case F_OFD_SETLKW:

These probably need an #ifdef for systems that don't have those names yet, but otherwise this looks reasonable?

-s