提交 b3a3759b 编写于 作者: M Michal Privoznik

Revert "virlockspace: Allow caller to specify start and length offset in...

Revert "virlockspace: Allow caller to specify start and length offset in virLockSpaceAcquireResource"

This reverts commit afd5a275.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 81ce42b0
......@@ -50,8 +50,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNU
virNetServerClientGetPrivateData(client);
virLockSpacePtr lockspace;
unsigned int newFlags;
off_t start = 0;
off_t len = 1;
virMutexLock(&priv->lock);
......@@ -86,7 +84,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBUTE_UNU
if (virLockSpaceAcquireResource(lockspace,
args->name,
priv->ownerPid,
start, len,
newFlags) < 0)
goto cleanup;
......
......@@ -115,10 +115,8 @@ static void virLockSpaceResourceFree(virLockSpaceResourcePtr res)
static virLockSpaceResourcePtr
virLockSpaceResourceNew(virLockSpacePtr lockspace,
const char *resname,
pid_t owner,
off_t start,
off_t len,
unsigned int flags)
unsigned int flags,
pid_t owner)
{
virLockSpaceResourcePtr res;
bool shared = !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED);
......@@ -159,7 +157,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
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) {
virReportError(VIR_ERR_RESOURCE_BUSY,
_("Lockspace resource '%s' is locked"),
......@@ -206,7 +204,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
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) {
virReportError(VIR_ERR_RESOURCE_BUSY,
_("Lockspace resource '%s' is locked"),
......@@ -614,8 +612,6 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspace,
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
const char *resname,
pid_t owner,
off_t start,
off_t len,
unsigned int flags)
{
int ret = -1;
......@@ -645,8 +641,7 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
goto cleanup;
}
if (!(res = virLockSpaceResourceNew(lockspace, resname,
owner, start, len, flags)))
if (!(res = virLockSpaceResourceNew(lockspace, resname, flags, owner)))
goto cleanup;
if (virHashAddEntry(lockspace->resources, resname, res) < 0) {
......
......@@ -22,8 +22,6 @@
#ifndef __VIR_LOCK_SPACE_H__
# define __VIR_LOCK_SPACE_H__
# include <sys/types.h>
# include "internal.h"
# include "virjson.h"
......@@ -52,8 +50,6 @@ typedef enum {
int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
const char *resname,
pid_t owner,
off_t start,
off_t len,
unsigned int flags);
int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
......
......@@ -98,8 +98,6 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED)
{
virLockSpacePtr lockspace;
int ret = -1;
const off_t start = 0;
const off_t len = 1;
rmdir(LOCKSPACE_DIR);
......@@ -112,13 +110,13 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED)
if (virLockSpaceCreateResource(lockspace, "foo") < 0)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, len, 0) < 0)
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) < 0)
goto cleanup;
if (!virFileExists(LOCKSPACE_DIR "/foo"))
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, len, 0) == 0)
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) == 0)
goto cleanup;
if (virLockSpaceDeleteResource(lockspace, "foo") == 0)
......@@ -146,8 +144,6 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED)
{
virLockSpacePtr lockspace;
int ret = -1;
const off_t start = 0;
const off_t len = 1;
rmdir(LOCKSPACE_DIR);
......@@ -161,7 +157,6 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
goto cleanup;
......@@ -187,8 +182,6 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED)
{
virLockSpacePtr lockspace;
int ret = -1;
const off_t start = 0;
const off_t len = 1;
rmdir(LOCKSPACE_DIR);
......@@ -202,16 +195,13 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo",
geteuid(), start, len, 0) == 0)
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) == 0)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0)
goto cleanup;
......@@ -246,8 +236,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
{
virLockSpacePtr lockspace;
int ret = -1;
const off_t start = 0;
const off_t len = 1;
rmdir(LOCKSPACE_DIR);
......@@ -261,7 +249,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_SHARED |
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
goto cleanup;
......@@ -270,7 +257,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) == 0)
goto cleanup;
......@@ -278,7 +264,6 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(),
start, len,
VIR_LOCK_SPACE_ACQUIRE_SHARED |
VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0)
goto cleanup;
......@@ -311,8 +296,6 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED)
{
virLockSpacePtr lockspace;
int ret = -1;
const off_t start = 0;
const off_t len = 1;
rmdir(LOCKSPACE_DIR);
......@@ -325,15 +308,13 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED)
if (virLockSpaceCreateResource(lockspace, LOCKSPACE_DIR "/foo") < 0)
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo",
geteuid(), start, len, 0) < 0)
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteuid(), 0) < 0)
goto cleanup;
if (!virFileExists(LOCKSPACE_DIR "/foo"))
goto cleanup;
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo",
geteuid(), start, len, 0) == 0)
if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteuid(), 0) == 0)
goto cleanup;
if (virLockSpaceDeleteResource(lockspace, LOCKSPACE_DIR "/foo") == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册