Hi,
we are interested in using virtlockd on an OCFS2 shared filesystem.
We are now facing the problem that virtlockd uses fcntl() locks which
aren't supported by OCFS2 with the o2cb cluster stack and we want
to avoid using indirect leases.
OCFS2 instead supports flock() which is quite similar to fcntl(). I
attached a patch which makes libvirt use flock() *instead* of fcntl()
and it seems to work.
NFS on the contrast only supports fcntl() so it should be configurable
which lock type to use.
I'm not very experienced with locking, so would such a patch be
acceptable or do you see possible problems with it?
Cheers,
David
From b823a9a9bd60a870d64341c4273c42d4eeba8d9b Mon Sep 17 00:00:00 2001
From: David Weber <wb(a)munzinger.de>
Date: Thu, 25 Jul 2013 08:20:20 +0000
Subject: [PATCH] Use flock() instead of fcntl()
---
src/util/virfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 8f0eec3..e243c26 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
int virFileLock(int fd, bool shared, off_t start, off_t len)
.l_len = len,
};
- if (fcntl(fd, F_SETLK, &fl) < 0)
+ if (flock(fd, LOCK_EX | LOCK_NB) < 0)
return -errno;
return 0;
int virFileUnlock(int fd, off_t start, off_t len)
.l_len = len,
};
- if (fcntl(fd, F_SETLK, &fl) < 0)
+ if (flock(fd, LOCK_UN) < 0)
return -errno;
return 0;
--
1.8.1.5