mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 11:35:19 +00:00
Revert "virlockspace: Allow caller to specify start and length offset in virLockSpaceAcquireResource"
This reverts commit afd5a27575e8b6a494d2728552fe0e89c71e32b4. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
81ce42b087
commit
b3a3759b62
@ -50,8 +50,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNU
|
|||||||
virNetServerClientGetPrivateData(client);
|
virNetServerClientGetPrivateData(client);
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
unsigned int newFlags;
|
unsigned int newFlags;
|
||||||
off_t start = 0;
|
|
||||||
off_t len = 1;
|
|
||||||
|
|
||||||
virMutexLock(&priv->lock);
|
virMutexLock(&priv->lock);
|
||||||
|
|
||||||
@ -86,7 +84,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNU
|
|||||||
if (virLockSpaceAcquireResource(lockspace,
|
if (virLockSpaceAcquireResource(lockspace,
|
||||||
args->name,
|
args->name,
|
||||||
priv->ownerPid,
|
priv->ownerPid,
|
||||||
start, len,
|
|
||||||
newFlags) < 0)
|
newFlags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -115,10 +115,8 @@ static void virLockSpaceResourceFree(virLockSpaceResourcePtr res)
|
|||||||
static virLockSpaceResourcePtr
|
static virLockSpaceResourcePtr
|
||||||
virLockSpaceResourceNew(virLockSpacePtr lockspace,
|
virLockSpaceResourceNew(virLockSpacePtr lockspace,
|
||||||
const char *resname,
|
const char *resname,
|
||||||
pid_t owner,
|
unsigned int flags,
|
||||||
off_t start,
|
pid_t owner)
|
||||||
off_t len,
|
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
virLockSpaceResourcePtr res;
|
virLockSpaceResourcePtr res;
|
||||||
bool shared = !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED);
|
bool shared = !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED);
|
||||||
@ -159,7 +157,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileLock(res->fd, shared, start, len, false) < 0) {
|
if (virFileLock(res->fd, shared, 0, 1, false) < 0) {
|
||||||
if (errno == EACCES || errno == EAGAIN) {
|
if (errno == EACCES || errno == EAGAIN) {
|
||||||
virReportError(VIR_ERR_RESOURCE_BUSY,
|
virReportError(VIR_ERR_RESOURCE_BUSY,
|
||||||
_("Lockspace resource '%s' is locked"),
|
_("Lockspace resource '%s' is locked"),
|
||||||
@ -206,7 +204,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileLock(res->fd, shared, start, len, false) < 0) {
|
if (virFileLock(res->fd, shared, 0, 1, false) < 0) {
|
||||||
if (errno == EACCES || errno == EAGAIN) {
|
if (errno == EACCES || errno == EAGAIN) {
|
||||||
virReportError(VIR_ERR_RESOURCE_BUSY,
|
virReportError(VIR_ERR_RESOURCE_BUSY,
|
||||||
_("Lockspace resource '%s' is locked"),
|
_("Lockspace resource '%s' is locked"),
|
||||||
@ -614,8 +612,6 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspace,
|
|||||||
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
|
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
|
||||||
const char *resname,
|
const char *resname,
|
||||||
pid_t owner,
|
pid_t owner,
|
||||||
off_t start,
|
|
||||||
off_t len,
|
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -645,8 +641,7 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(res = virLockSpaceResourceNew(lockspace, resname,
|
if (!(res = virLockSpaceResourceNew(lockspace, resname, flags, owner)))
|
||||||
owner, start, len, flags)))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virHashAddEntry(lockspace->resources, resname, res) < 0) {
|
if (virHashAddEntry(lockspace->resources, resname, res) < 0) {
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#ifndef __VIR_LOCK_SPACE_H__
|
#ifndef __VIR_LOCK_SPACE_H__
|
||||||
# define __VIR_LOCK_SPACE_H__
|
# define __VIR_LOCK_SPACE_H__
|
||||||
|
|
||||||
# include <sys/types.h>
|
|
||||||
|
|
||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
# include "virjson.h"
|
# include "virjson.h"
|
||||||
|
|
||||||
@ -52,8 +50,6 @@ typedef enum {
|
|||||||
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
|
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
|
||||||
const char *resname,
|
const char *resname,
|
||||||
pid_t owner,
|
pid_t owner,
|
||||||
off_t start,
|
|
||||||
off_t len,
|
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
|
int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
|
||||||
|
@ -98,8 +98,6 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const off_t start = 0;
|
|
||||||
const off_t len = 1;
|
|
||||||
|
|
||||||
rmdir(LOCKSPACE_DIR);
|
rmdir(LOCKSPACE_DIR);
|
||||||
|
|
||||||
@ -112,13 +110,13 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED)
|
|||||||
if (virLockSpaceCreateResource(lockspace, "foo") < 0)
|
if (virLockSpaceCreateResource(lockspace, "foo") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, len, 0) < 0)
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virFileExists(LOCKSPACE_DIR "/foo"))
|
if (!virFileExists(LOCKSPACE_DIR "/foo"))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, len, 0) == 0)
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) == 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceDeleteResource(lockspace, "foo") == 0)
|
if (virLockSpaceDeleteResource(lockspace, "foo") == 0)
|
||||||
@ -146,8 +144,6 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const off_t start = 0;
|
|
||||||
const off_t len = 1;
|
|
||||||
|
|
||||||
rmdir(LOCKSPACE_DIR);
|
rmdir(LOCKSPACE_DIR);
|
||||||
|
|
||||||
@ -161,7 +157,6 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -187,8 +182,6 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const off_t start = 0;
|
|
||||||
const off_t len = 1;
|
|
||||||
|
|
||||||
rmdir(LOCKSPACE_DIR);
|
rmdir(LOCKSPACE_DIR);
|
||||||
|
|
||||||
@ -202,16 +195,13 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
|
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo",
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) == 0)
|
||||||
geteuid(), start, len, 0) == 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
|
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -246,8 +236,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const off_t start = 0;
|
|
||||||
const off_t len = 1;
|
|
||||||
|
|
||||||
rmdir(LOCKSPACE_DIR);
|
rmdir(LOCKSPACE_DIR);
|
||||||
|
|
||||||
@ -261,7 +249,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_SHARED |
|
VIR_LOCK_SPACE_ACQUIRE_SHARED |
|
||||||
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -270,7 +257,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) == 0)
|
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) == 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -278,7 +264,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
|
||||||
start, len,
|
|
||||||
VIR_LOCK_SPACE_ACQUIRE_SHARED |
|
VIR_LOCK_SPACE_ACQUIRE_SHARED |
|
||||||
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -311,8 +296,6 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const off_t start = 0;
|
|
||||||
const off_t len = 1;
|
|
||||||
|
|
||||||
rmdir(LOCKSPACE_DIR);
|
rmdir(LOCKSPACE_DIR);
|
||||||
|
|
||||||
@ -325,15 +308,13 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED)
|
|||||||
if (virLockSpaceCreateResource(lockspace, LOCKSPACE_DIR "/foo") < 0)
|
if (virLockSpaceCreateResource(lockspace, LOCKSPACE_DIR "/foo") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo",
|
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteuid(), 0) < 0)
|
||||||
geteuid(), start, len, 0) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virFileExists(LOCKSPACE_DIR "/foo"))
|
if (!virFileExists(LOCKSPACE_DIR "/foo"))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo",
|
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteuid(), 0) == 0)
|
||||||
geteuid(), start, len, 0) == 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLockSpaceDeleteResource(lockspace, LOCKSPACE_DIR "/foo") == 0)
|
if (virLockSpaceDeleteResource(lockspace, LOCKSPACE_DIR "/foo") == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user