From 869d81df53ad28ce78fc92504b3365b8196a2fa1 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Tue, 17 Jan 2006 08:47:12 +0000 Subject: [GFS2] An update of the GFS2 lock modules This brings the lock modules uptodate and removes the stray .mod.c file which accidently got included in the last check in. Signed-off-by: David Teigland Signed-off-by: Steven Whitehouse --- fs/gfs2/locking/dlm/mount.c | 189 +++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 91 deletions(-) (limited to 'fs/gfs2/locking/dlm/mount.c') diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c index 92b1789deb8..bfb224638f2 100644 --- a/fs/gfs2/locking/dlm/mount.c +++ b/fs/gfs2/locking/dlm/mount.c @@ -1,15 +1,11 @@ -/****************************************************************************** -******************************************************************************* -** -** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. -** -** This copyrighted material is made available to anyone wishing to use, -** modify, copy, or redistribute it subject to the terms and conditions -** of the GNU General Public License v.2. -** -******************************************************************************* -******************************************************************************/ +/* + * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + */ #include "lock_dlm.h" @@ -24,27 +20,21 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata, struct gdlm_ls *ls; char buf[256], *p; - ls = kmalloc(sizeof(struct gdlm_ls), GFP_KERNEL); + ls = kzalloc(sizeof(struct gdlm_ls), GFP_KERNEL); if (!ls) return NULL; - memset(ls, 0, sizeof(struct gdlm_ls)); - ls->drop_locks_count = gdlm_drop_count; ls->drop_locks_period = gdlm_drop_period; - ls->fscb = cb; ls->fsdata = fsdata; ls->fsflags = flags; - spin_lock_init(&ls->async_lock); - INIT_LIST_HEAD(&ls->complete); INIT_LIST_HEAD(&ls->blocking); INIT_LIST_HEAD(&ls->delayed); INIT_LIST_HEAD(&ls->submit); INIT_LIST_HEAD(&ls->all_locks); - init_waitqueue_head(&ls->thread_wait); init_waitqueue_head(&ls->wait_control); ls->thread1 = NULL; @@ -57,23 +47,75 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata, p = strstr(buf, ":"); if (!p) { - printk("lock_dlm: invalid table_name \"%s\"\n", table_name); + log_info("invalid table_name \"%s\"", table_name); kfree(ls); return NULL; } *p = '\0'; p++; - strncpy(ls->clustername, buf, 128); - strncpy(ls->fsname, p, 128); + strncpy(ls->clustername, buf, GDLM_NAME_LEN); + strncpy(ls->fsname, p, GDLM_NAME_LEN); return ls; } +static int make_args(struct gdlm_ls *ls, char *data_arg) +{ + char data[256]; + char *options, *x, *y; + int error = 0; + + memset(data, 0, 256); + strncpy(data, data_arg, 255); + + for (options = data; (x = strsep(&options, ":")); ) { + if (!*x) + continue; + + y = strchr(x, '='); + if (y) + *y++ = 0; + + if (!strcmp(x, "jid")) { + if (!y) { + log_error("need argument to jid"); + error = -EINVAL; + break; + } + sscanf(y, "%u", &ls->jid); + + } else if (!strcmp(x, "first")) { + if (!y) { + log_error("need argument to first"); + error = -EINVAL; + break; + } + sscanf(y, "%u", &ls->first); + + } else if (!strcmp(x, "id")) { + if (!y) { + log_error("need argument to id"); + error = -EINVAL; + break; + } + sscanf(y, "%u", &ls->id); + + } else { + log_error("unkonwn option: %s", x); + error = -EINVAL; + break; + } + } + + return error; +} + static int gdlm_mount(char *table_name, char *host_data, lm_callback_t cb, lm_fsdata_t *fsdata, unsigned int min_lvb_size, int flags, - struct lm_lockstruct *lockstruct) + struct lm_lockstruct *lockstruct, + struct kobject *fskobj) { struct gdlm_ls *ls; int error = -ENOMEM; @@ -92,30 +134,18 @@ static int gdlm_mount(char *table_name, char *host_data, error = dlm_new_lockspace(ls->fsname, strlen(ls->fsname), &ls->dlm_lockspace, 0, GDLM_LVB_SIZE); if (error) { - printk("lock_dlm: dlm_new_lockspace error %d\n", error); + log_error("dlm_new_lockspace error %d", error); goto out_thread; } - error = gdlm_kobject_setup(ls); + error = gdlm_kobject_setup(ls, fskobj); if (error) goto out_dlm; - kobject_uevent(&ls->kobj, KOBJ_MOUNT, NULL); - /* Now we depend on userspace to notice the new mount, - join the appropriate group, and do a write to our sysfs - "mounted" or "terminate" file. Before the start, userspace - must set "jid" and "first". */ - - error = wait_event_interruptible(ls->wait_control, - test_bit(DFL_JOIN_DONE, &ls->flags)); + error = make_args(ls, host_data); if (error) goto out_sysfs; - if (test_bit(DFL_TERMINATE, &ls->flags)) { - error = -ERESTARTSYS; - goto out_sysfs; - } - lockstruct->ls_jid = ls->jid; lockstruct->ls_first = ls->first; lockstruct->ls_lockspace = ls; @@ -143,22 +173,19 @@ static void gdlm_unmount(lm_lockspace_t *lockspace) log_debug("unmount flags %lx", ls->flags); - if (test_bit(DFL_WITHDRAW, &ls->flags)) { - gdlm_kobject_release(ls); - goto out; - } - - kobject_uevent(&ls->kobj, KOBJ_UMOUNT, NULL); + /* FIXME: serialize unmount and withdraw in case they + happen at once. Also, if unmount follows withdraw, + wait for withdraw to finish. */ - wait_event_interruptible(ls->wait_control, - test_bit(DFL_LEAVE_DONE, &ls->flags)); + if (test_bit(DFL_WITHDRAW, &ls->flags)) + goto out; gdlm_kobject_release(ls); dlm_release_lockspace(ls->dlm_lockspace, 2); gdlm_release_threads(ls); rv = gdlm_release_all_locks(ls); if (rv) - log_all("lm_dlm_unmount: %d stray locks freed", rv); + log_info("gdlm_unmount: %d stray locks freed", rv); out: kfree(ls); } @@ -167,7 +194,7 @@ static void gdlm_recovery_done(lm_lockspace_t *lockspace, unsigned int jid, unsigned int message) { struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; - ls->recover_done = jid; + ls->recover_jid_done = jid; kobject_uevent(&ls->kobj, KOBJ_CHANGE, NULL); } @@ -178,12 +205,14 @@ static void gdlm_others_may_mount(lm_lockspace_t *lockspace) kobject_uevent(&ls->kobj, KOBJ_CHANGE, NULL); } +/* Userspace gets the offline uevent, blocks new gfs locks on + other mounters, and lets us know (sets WITHDRAW flag). Then, + userspace leaves the mount group while we leave the lockspace. */ + static void gdlm_withdraw(lm_lockspace_t *lockspace) { struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; - /* userspace suspends locking on all other members */ - kobject_uevent(&ls->kobj, KOBJ_OFFLINE, NULL); wait_event_interruptible(ls->wait_control, @@ -192,49 +221,27 @@ static void gdlm_withdraw(lm_lockspace_t *lockspace) dlm_release_lockspace(ls->dlm_lockspace, 2); gdlm_release_threads(ls); gdlm_release_all_locks(ls); - - kobject_uevent(&ls->kobj, KOBJ_UMOUNT, NULL); - - /* userspace leaves the mount group, we don't need to wait for - that to complete */ -} - -int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name, - struct file *file, struct file_lock *fl) -{ - return -ENOSYS; -} - -int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, - struct file *file, struct file_lock *fl) -{ - return -ENOSYS; -} - -int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, - struct file *file, int cmd, struct file_lock *fl) -{ - return -ENOSYS; + gdlm_kobject_release(ls); } struct lm_lockops gdlm_ops = { - lm_proto_name:"lock_dlm", - lm_mount:gdlm_mount, - lm_others_may_mount:gdlm_others_may_mount, - lm_unmount:gdlm_unmount, - lm_withdraw:gdlm_withdraw, - lm_get_lock:gdlm_get_lock, - lm_put_lock:gdlm_put_lock, - lm_lock:gdlm_lock, - lm_unlock:gdlm_unlock, - lm_plock:gdlm_plock, - lm_punlock:gdlm_punlock, - lm_plock_get:gdlm_plock_get, - lm_cancel:gdlm_cancel, - lm_hold_lvb:gdlm_hold_lvb, - lm_unhold_lvb:gdlm_unhold_lvb, - lm_sync_lvb:gdlm_sync_lvb, - lm_recovery_done:gdlm_recovery_done, - lm_owner:THIS_MODULE, + .lm_proto_name = "lock_dlm", + .lm_mount = gdlm_mount, + .lm_others_may_mount = gdlm_others_may_mount, + .lm_unmount = gdlm_unmount, + .lm_withdraw = gdlm_withdraw, + .lm_get_lock = gdlm_get_lock, + .lm_put_lock = gdlm_put_lock, + .lm_lock = gdlm_lock, + .lm_unlock = gdlm_unlock, + .lm_plock = gdlm_plock, + .lm_punlock = gdlm_punlock, + .lm_plock_get = gdlm_plock_get, + .lm_cancel = gdlm_cancel, + .lm_hold_lvb = gdlm_hold_lvb, + .lm_unhold_lvb = gdlm_unhold_lvb, + .lm_sync_lvb = gdlm_sync_lvb, + .lm_recovery_done = gdlm_recovery_done, + .lm_owner = THIS_MODULE, }; -- cgit v1.2.3