1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-10-05 07:33:15 +03:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Alasdair Kergon
6a98f60e2e 2.00.25 2004-09-29 15:08:20 +00:00
Alasdair Kergon
6f2e24c47d Use macro in vgremove locking fix. 2004-09-27 10:32:36 +00:00
Patrick Caulfield
aafa368923 Hold VG lock while doing vgremove.
agk - you may want to check this.
2004-09-24 12:48:43 +00:00
Patrick Caulfield
eb783cab4c Remove spurious trailing dot in man page. 2004-09-24 10:34:53 +00:00
Patrick Caulfield
6533aa865a Keep client locks (VG locks usually) in their own hash table so
we can actually have more then one of them per client.
2004-09-24 09:39:57 +00:00
Patrick Caulfield
f1a1e1bc07 Update WHATS_NEW with latest clvmd change 2004-09-23 13:12:09 +00:00
Patrick Caulfield
953f4838dd Make the thread handling a little less cavalier. In particular, calling
pthread_exit in a signal handler was a /really/ bad idea.
2004-09-23 12:51:56 +00:00
Patrick Caulfield
130b892d34 Don't use hold_lock for VG locks as that doesn't stop processes contending
on the same node, only across the cluster.
2004-09-23 12:29:35 +00:00
Alasdair Kergon
6ad525c77e Fix return code from rm_link for vgmknodes. 2004-09-22 13:38:37 +00:00
Patrick Caulfield
d0ca74ad27 Put some locking round the LV hash table as it could be accessed by
different threads concurrently.
2004-09-22 12:10:34 +00:00
Alasdair Kergon
9806f69b4d post-2.00.24 2004-09-16 21:48:26 +00:00
12 changed files with 144 additions and 48 deletions

View File

@@ -1 +1 @@
2.00.24-cvs (2004-09-16)
2.00.25-cvs (2004-09-29)

View File

@@ -1,3 +1,12 @@
Version 2.00.25 - 29th September 2004
=====================================
Fix return code from rm_link for vgmknodes.
Make clvmd LV hash table thread-safe.
Fix clvmd locking so it will lock out multiple users on the same node.
Fix clvmd VG locking to it can cope with multiple VG locks.
Remove spurious trailing dot in lvreduce man page.
Fix vgremove locking.
Version 2.00.24 - 16th September 2004
=====================================
Fix pool_empty so it really does empty the memory pool.

View File

@@ -337,7 +337,7 @@ static void get_members()
}
nodelist.max_members = count_nodes;
nodelist.nodes = nodes;
num_nodes = ioctl(cluster_sock, SIOCCLUSTER_GETMEMBERS, &nodelist);
if (num_nodes <= 0) {
perror("get node details");
@@ -441,6 +441,7 @@ int sync_lock(const char *resource, int mode, int flags, int *lockid)
return -1;
}
DEBUGLOG("sync_lock: '%s' mode:%d flags=%d\n", resource,mode,flags);
/* Conversions need the lockid in the LKSB */
if (flags & LKF_CONVERT)
lwait.lksb.sb_lkid = *lockid;
@@ -466,6 +467,7 @@ int sync_lock(const char *resource, int mode, int flags, int *lockid)
*lockid = lwait.lksb.sb_lkid;
errno = lwait.lksb.sb_status;
DEBUGLOG("sync_lock: returning lkid %x\n", *lockid);
if (lwait.lksb.sb_status)
return -1;
else
@@ -477,6 +479,8 @@ int sync_unlock(const char *resource /* UNUSED */, int lockid)
int status;
struct lock_wait lwait;
DEBUGLOG("sync_unlock: '%s' lkid:%x\n", resource, lockid);
pthread_cond_init(&lwait.cond, NULL);
pthread_mutex_init(&lwait.mutex, NULL);
pthread_mutex_lock(&lwait.mutex);

View File

@@ -66,6 +66,7 @@
#include <errno.h>
#include "list.h"
#include "hash.h"
#include "locking.h"
#include "log.h"
#include "lvm-functions.h"
@@ -135,6 +136,61 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
}
static int lock_vg(struct local_client *client)
{
struct hash_table *lock_hash;
struct clvm_header *header =
(struct clvm_header *) client->bits.localsock.cmd;
unsigned char lock_cmd;
unsigned char lock_flags;
char *args = header->node + strlen(header->node) + 1;
int lkid;
int status = 0;
char *lockname;
/* Keep a track of VG locks in our own hash table. In current
practice there should only ever be more than two VGs locked
if a user tries to merge lots of them at once */
if (client->bits.localsock.private) {
lock_hash = (struct hash_table *)client->bits.localsock.private;
}
else {
lock_hash = hash_create(3);
if (!lock_hash)
return ENOMEM;
client->bits.localsock.private = (void *)lock_hash;
}
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
DEBUGLOG("doing PRE command LOCK_VG '%s' at %x (client=%p)\n", lockname, lock_cmd, client);
if (lock_cmd == LCK_UNLOCK) {
lkid = (int)(long)hash_lookup(lock_hash, lockname);
if (lkid == 0)
return EINVAL;
status = sync_unlock(lockname, lkid);
if (status)
status = errno;
else
hash_remove(lock_hash, lockname);
}
else {
status = sync_lock(lockname, (int)lock_cmd, (int)lock_flags, &lkid);
if (status)
status = errno;
else
hash_insert(lock_hash, lockname, (void *)lkid);
}
return status;
}
/* Pre-command is a good place to get locks that are needed only for the duration
of the commands around the cluster (don't forget to free them in post-command),
and to sanity check the command arguments */
@@ -156,20 +212,7 @@ int do_pre_command(struct local_client *client)
break;
case CLVMD_CMD_LOCK_VG:
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
DEBUGLOG("doing PRE command LOCK_VG %s at %x\n", lockname,
lock_cmd);
if (lock_cmd == LCK_UNLOCK) {
hold_unlock(lockname);
} else {
status =
hold_lock(lockname, (int) lock_cmd,
(int) lock_flags);
if (status)
status = errno;
}
status = lock_vg(client);
break;
case CLVMD_CMD_LOCK_LV:
@@ -202,6 +245,7 @@ int do_post_command(struct local_client *client)
case CLVMD_CMD_TEST:
status =
sync_unlock("CLVMD_TEST", (int) (long) client->bits.localsock.private);
client->bits.localsock.private = 0;
break;
case CLVMD_CMD_LOCK_VG:
@@ -217,3 +261,25 @@ int do_post_command(struct local_client *client)
}
return status;
}
/* Called when the client is about to be deleted */
void cmd_client_cleanup(struct local_client *client)
{
if (client->bits.localsock.private) {
struct hash_node *v;
struct hash_table *lock_hash =
(struct hash_table *)client->bits.localsock.private;
hash_iterate(v, lock_hash) {
int lkid = (int)(long)hash_get_data(lock_hash, v);
DEBUGLOG("cleanup: Unlocking lkid %x\n", lkid);
sync_unlock("DUMMY", lkid);
}
hash_destroy(lock_hash);
client->bits.localsock.private = 0;
}
}

View File

@@ -303,6 +303,7 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
newfd->bits.localsock.threadid = 0;
newfd->bits.localsock.finished = 0;
newfd->bits.localsock.pipe_client = NULL;
newfd->bits.localsock.private = NULL;
newfd->bits.localsock.all_success = 1;
DEBUGLOG("Got new connection on fd %d\n", newfd->fd);
*new_client = newfd;
@@ -496,6 +497,7 @@ static void main_loop(int local_sock, int cmd_timeout)
lastfd->next = thisfd->next;
free_fd = thisfd;
thisfd = lastfd;
cmd_client_cleanup(free_fd);
free(free_fd);
break;
}
@@ -717,6 +719,7 @@ static int read_from_local_sock(struct local_client *thisfd)
struct local_client *newfd;
char csid[MAX_CSID_LEN];
struct clvm_header *inheader;
int status;
inheader = (struct clvm_header *) buffer;
@@ -863,8 +866,10 @@ static int read_from_local_sock(struct local_client *thisfd)
/* Run the pre routine */
thisfd->bits.localsock.in_progress = TRUE;
thisfd->bits.localsock.state = PRE_COMMAND;
pthread_create(&thisfd->bits.localsock.threadid, NULL,
DEBUGLOG("Creating pre&post thread\n");
status = pthread_create(&thisfd->bits.localsock.threadid, NULL,
pre_and_post_thread, thisfd);
DEBUGLOG("Created pre&post thread, state = %d\n", status);
}
return len;
}
@@ -1292,7 +1297,8 @@ static void *pre_and_post_thread(void *arg)
DEBUGLOG("Got pre command condition...\n");
}
DEBUGLOG("Subthread finished\n");
return (void *) 0;
pthread_exit((void *) 0);
return 0;
}
/* Process a command on the local node and store the result */
@@ -1681,7 +1687,6 @@ static void ntoh_clvm(struct clvm_header *hdr)
static void sigusr2_handler(int sig)
{
DEBUGLOG("SIGUSR2 received\n");
pthread_exit((void *) -1);
return;
}

View File

@@ -111,7 +111,7 @@ extern int do_command(struct local_client *client, struct clvm_header *msg,
/* Pre and post command routines are called only on the local node */
extern int do_pre_command(struct local_client *client);
extern int do_post_command(struct local_client *client);
extern void cmd_client_cleanup(struct local_client *client);
extern int add_client(struct local_client *new_client);
extern void clvmd_cluster_init_completed(void);

View File

@@ -105,6 +105,7 @@
#define MSG_MULTICAST 0x080000 /* Message was sent to all nodes in the cluster
*/
#define MSG_ALLINT 0x100000 /* Send out of all interfaces */
#define MSG_REPLYEXP 0x200000 /* Reply is expected */
typedef enum { NODESTATE_REMOTEMEMBER, NODESTATE_JOINING, NODESTATE_MEMBER,
NODESTATE_DEAD } nodestate_t;

View File

@@ -46,6 +46,7 @@
static struct cmd_context *cmd = NULL;
static struct hash_table *lv_hash = NULL;
static pthread_mutex_t lv_hash_lock;
struct lv_info {
int lock_id;
@@ -57,7 +58,9 @@ static int get_current_lock(char *resource)
{
struct lv_info *lvi;
pthread_mutex_lock(&lv_hash_lock);
lvi = hash_lookup(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
if (lvi) {
return lvi->lock_mode;
} else {
@@ -69,11 +72,14 @@ static int get_current_lock(char *resource)
void unlock_all()
{
struct hash_node *v;
pthread_mutex_lock(&lv_hash_lock);
hash_iterate(v, lv_hash) {
struct lv_info *lvi = hash_get_data(lv_hash, v);
sync_unlock(hash_get_key(lv_hash, v), lvi->lock_id);
}
pthread_mutex_unlock(&lv_hash_lock);
}
/* Gets a real lock and keeps the info in the hash table */
@@ -85,7 +91,9 @@ int hold_lock(char *resource, int mode, int flags)
flags &= LKF_NOQUEUE; /* Only LKF_NOQUEUE is valid here */
pthread_mutex_lock(&lv_hash_lock);
lvi = hash_lookup(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
if (lvi) {
/* Already exists - convert it */
status =
@@ -113,7 +121,9 @@ int hold_lock(char *resource, int mode, int flags)
DEBUGLOG("hold_lock. lock at %d failed: %s\n", mode,
strerror(errno));
} else {
pthread_mutex_lock(&lv_hash_lock);
hash_insert(lv_hash, resource, lvi);
pthread_mutex_unlock(&lv_hash_lock);
}
errno = saved_errno;
}
@@ -127,8 +137,9 @@ int hold_unlock(char *resource)
int status;
int saved_errno;
pthread_mutex_lock(&lv_hash_lock);
lvi = hash_lookup(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
if (!lvi) {
DEBUGLOG("hold_unlock, lock not already held\n");
return 0;
@@ -137,7 +148,9 @@ int hold_unlock(char *resource)
status = sync_unlock(resource, lvi->lock_id);
saved_errno = errno;
if (!status) {
pthread_mutex_lock(&lv_hash_lock);
hash_remove(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
free(lvi);
} else {
DEBUGLOG("hold_unlock. unlock failed(%d): %s\n", status,
@@ -427,6 +440,7 @@ void init_lvhash()
{
/* Create hash table for keeping LV locks & status */
lv_hash = hash_create(100);
pthread_mutex_init(&lv_hash_lock, NULL);
}
/* Called to initialise the LVM context of the daemon */

View File

@@ -65,10 +65,10 @@ static int _rm_dir(const char *dev_dir, const char *vg_name)
return 0;
}
log_very_verbose("Removing directory %s", vg_path);
if (is_empty_dir(vg_path))
if (is_empty_dir(vg_path)) {
log_very_verbose("Removing directory %s", vg_path);
rmdir(vg_path);
}
return 1;
}
@@ -202,9 +202,9 @@ static int _rm_link(const char *dev_dir, const char *vg_name,
}
if (lstat(lv_path, &buf) || !S_ISLNK(buf.st_mode)) {
if (errno != ENOENT)
log_error("%s not symbolic link - not removing",
lv_path);
if (errno == ENOENT)
return 1;
log_error("%s not symbolic link - not removing", lv_path);
return 0;
}

View File

@@ -17,7 +17,7 @@ You should therefore ensure that any filesystem on the volume is
resized
.i before
running lvreduce so that the extents that are to be removed are not in use.
.br.
.br
Shrinking snapshot logical volumes (see
.B lvcreate(8)
for information to create snapshots) is supported as well.

View File

@@ -1,12 +1,13 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2004-09-15 16:28+0100\n"
"POT-Creation-Date: 2004-09-29 16:06+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -185,11 +186,11 @@ msgstr ""
#: format_text/archive.c:142 format_text/archive.c:169
#: format_text/archive.c:264 format_text/archive.c:374
#: format_text/export.c:257 format_text/export.c:258 format_text/export.c:259
#: format_text/export.c:262 format_text/export.c:266 format_text/export.c:267
#: format_text/export.c:262 format_text/export.c:264 format_text/export.c:267
#: format_text/export.c:277 format_text/export.c:281 format_text/export.c:283
#: format_text/export.c:286 format_text/export.c:289 format_text/export.c:293
#: format_text/export.c:296 format_text/export.c:300 format_text/export.c:304
#: format_text/export.c:307 format_text/export.c:308 format_text/export.c:314
#: format_text/export.c:307 format_text/export.c:308 format_text/export.c:313
#: format_text/export.c:338 format_text/export.c:345 format_text/export.c:350
#: format_text/export.c:354 format_text/export.c:358 format_text/export.c:360
#: format_text/export.c:366 format_text/export.c:369 format_text/export.c:373
@@ -198,14 +199,14 @@ msgstr ""
#: format_text/export.c:403 format_text/export.c:406 format_text/export.c:411
#: format_text/export.c:415 format_text/export.c:418 format_text/export.c:423
#: format_text/export.c:428 format_text/export.c:441 format_text/export.c:448
#: format_text/export.c:454 format_text/export.c:460 format_text/export.c:465
#: format_text/export.c:452 format_text/export.c:457 format_text/export.c:465
#: format_text/export.c:488 format_text/export.c:492 format_text/export.c:496
#: format_text/export.c:500 format_text/export.c:504 format_text/export.c:505
#: format_text/export.c:511 format_text/export.c:533 format_text/export.c:538
#: format_text/export.c:553 format_text/export.c:575 format_text/export.c:582
#: format_text/export.c:587 format_text/export.c:591 format_text/export.c:594
#: format_text/export.c:597 format_text/export.c:601 format_text/export.c:604
#: format_text/export.c:609 format_text/export.c:612 format_text/export.c:614
#: format_text/export.c:608 format_text/export.c:612 format_text/export.c:614
#: format_text/export.c:616 format_text/export.c:617 format_text/export.c:623
#: format_text/export.c:629 format_text/export.c:633 format_text/export.c:638
#: format_text/export.c:656 format_text/export.c:661 format_text/export.c:670
@@ -290,7 +291,7 @@ msgstr ""
#: regex/ttree.c:111 report/report.c:522 report/report.c:550
#: report/report.c:682 snapshot/snapshot.c:74 snapshot/snapshot.c:83
#: snapshot/snapshot.c:84 snapshot/snapshot.c:85 snapshot/snapshot.c:154
#: striped/striped.c:91 striped/striped.c:160 striped/striped.c:209
#: striped/striped.c:90 striped/striped.c:160 striped/striped.c:209
#: toollib.c:739 toollib.c:789 toollib.c:836 vgcfgbackup.c:65 vgcfgbackup.c:74
#: vgcfgbackup.c:81 vgreduce.c:28 vgreduce.c:84 vgreduce.c:92 vgreduce.c:98
#: vgreduce.c:106 vgreduce.c:142 vgreduce.c:158 zero/zero.c:90
@@ -453,7 +454,7 @@ msgstr ""
msgid "device layer %s missing from hash"
msgstr ""
#: activate/dev_manager.c:741
#: activate/dev_manager.c:740
#, c-format
msgid "Failed to format device number as dm target (%u,%u)"
msgstr ""
@@ -638,7 +639,7 @@ msgstr ""
msgid "%s: %s failed: %s"
msgstr ""
#: activate/fs.c:68
#: activate/fs.c:69
#, c-format
msgid "Removing directory %s"
msgstr ""
@@ -687,7 +688,7 @@ msgstr ""
msgid "Couldn't determine link pathname."
msgstr ""
#: activate/fs.c:206
#: activate/fs.c:207
#, c-format
msgid "%s not symbolic link - not removing"
msgstr ""
@@ -2941,10 +2942,6 @@ msgstr ""
msgid "Test mode: Metadata will NOT be updated."
msgstr ""
#: log/log.c:231
msgid "vsnprintf failed: skipping external logging function"
msgstr ""
#: lvchange.c:26
#, c-format
msgid "Logical volume \"%s\" is already writable"
@@ -4367,7 +4364,7 @@ msgstr ""
msgid "Couldn't create area maps in %s"
msgstr ""
#: metadata/segtypes.c:30
#: metadata/segtype.c:30
#, c-format
msgid "Unrecognised segment type %s"
msgstr ""
@@ -4575,7 +4572,7 @@ msgstr ""
msgid "Unable to find volume group of \"%s\""
msgstr ""
#: pvchange.c:80
#: pvchange.c:79
#, c-format
msgid "Unable to find \"%s\" in volume group \"%s\""
msgstr ""
@@ -4894,11 +4891,11 @@ msgstr ""
msgid "Ignoring remaining command line arguments"
msgstr ""
#: pvmove.c:305
#: pvmove.c:304
msgid "ABORTING: Failed to generate list of moving LVs"
msgstr ""
#: pvmove.c:313
#: pvmove.c:312
msgid "ABORTING: Temporary mirror activation failed."
msgstr ""

View File

@@ -88,8 +88,8 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
}
ret = process_each_vg(cmd, argc, argv,
LCK_VG | LCK_WRITE | LCK_NONBLOCK, 1, NULL,
&vgremove_single);
LCK_VG_WRITE | LCK_NONBLOCK, 1,
NULL, &vgremove_single);
unlock_vg(cmd, "");