Commit 5cefcab3 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw

* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw: (34 commits)
  [GFS2] Uncomment sprintf_symbol calling code
  [DLM] lowcomms style
  [GFS2] printk warning fixes
  [GFS2] Patch to fix mmap of stuffed files
  [GFS2] use lib/parser for parsing mount options
  [DLM] Lowcomms nodeid range & initialisation fixes
  [DLM] Fix dlm_lowcoms_stop hang
  [DLM] fix mode munging
  [GFS2] lockdump improvements
  [GFS2] Patch to detect corrupt number of dir entries in leaf and/or inode blocks
  [GFS2] bz 236008: Kernel gpf doing cat /debugfs/gfs2/xxx (lock dump)
  [DLM] fs/dlm/ast.c should #include "ast.h"
  [DLM] Consolidate transport protocols
  [DLM] Remove redundant assignment
  [GFS2] Fix bz 234168 (ignoring rgrp flags)
  [DLM] change lkid format
  [DLM] interface for purge (2/2)
  [DLM] add orphan purging code (1/2)
  [DLM] split create_message function
  [GFS2] Set drop_count to 0 (off) by default
  ...
parents 5f757f91 37fde8ca
...@@ -3,36 +3,19 @@ menu "Distributed Lock Manager" ...@@ -3,36 +3,19 @@ menu "Distributed Lock Manager"
config DLM config DLM
tristate "Distributed Lock Manager (DLM)" tristate "Distributed Lock Manager (DLM)"
depends on SYSFS && (IPV6 || IPV6=n) depends on IPV6 || IPV6=n
select CONFIGFS_FS select CONFIGFS_FS
select IP_SCTP if DLM_SCTP select IP_SCTP
help help
A general purpose distributed lock manager for kernel or userspace A general purpose distributed lock manager for kernel or userspace
applications. applications.
choice
prompt "Select DLM communications protocol"
depends on DLM
default DLM_TCP
help
The DLM Can use TCP or SCTP for it's network communications.
SCTP supports multi-homed operations whereas TCP doesn't.
However, SCTP seems to have stability problems at the moment.
config DLM_TCP
bool "TCP/IP"
config DLM_SCTP
bool "SCTP"
endchoice
config DLM_DEBUG config DLM_DEBUG
bool "DLM debugging" bool "DLM debugging"
depends on DLM depends on DLM
help help
Under the debugfs mount point, the name of each lockspace will Under the debugfs mount point, the name of each lockspace will
appear as a file in the "dlm" directory. The output is the appear as a file in the "dlm" directory. The output is the
list of resource and locks the local node knows about. list of resource and locks the local node knows about.
endmenu endmenu
...@@ -8,14 +8,12 @@ dlm-y := ast.o \ ...@@ -8,14 +8,12 @@ dlm-y := ast.o \
member.o \ member.o \
memory.o \ memory.o \
midcomms.o \ midcomms.o \
lowcomms.o \
rcom.o \ rcom.o \
recover.o \ recover.o \
recoverd.o \ recoverd.o \
requestqueue.o \ requestqueue.o \
user.o \ user.o \
util.o util.o
dlm-$(CONFIG_DLM_DEBUG) += debug_fs.o dlm-$(CONFIG_DLM_DEBUG) += debug_fs.o
dlm-$(CONFIG_DLM_TCP) += lowcomms-tcp.o
dlm-$(CONFIG_DLM_SCTP) += lowcomms-sctp.o
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "dlm_internal.h" #include "dlm_internal.h"
#include "lock.h" #include "lock.h"
#include "user.h" #include "user.h"
#include "ast.h"
#define WAKE_ASTS 0 #define WAKE_ASTS 0
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
******************************************************************************* *******************************************************************************
** **
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -89,6 +89,7 @@ struct cluster { ...@@ -89,6 +89,7 @@ struct cluster {
unsigned int cl_toss_secs; unsigned int cl_toss_secs;
unsigned int cl_scan_secs; unsigned int cl_scan_secs;
unsigned int cl_log_debug; unsigned int cl_log_debug;
unsigned int cl_protocol;
}; };
enum { enum {
...@@ -101,6 +102,7 @@ enum { ...@@ -101,6 +102,7 @@ enum {
CLUSTER_ATTR_TOSS_SECS, CLUSTER_ATTR_TOSS_SECS,
CLUSTER_ATTR_SCAN_SECS, CLUSTER_ATTR_SCAN_SECS,
CLUSTER_ATTR_LOG_DEBUG, CLUSTER_ATTR_LOG_DEBUG,
CLUSTER_ATTR_PROTOCOL,
}; };
struct cluster_attribute { struct cluster_attribute {
...@@ -159,6 +161,7 @@ CLUSTER_ATTR(recover_timer, 1); ...@@ -159,6 +161,7 @@ CLUSTER_ATTR(recover_timer, 1);
CLUSTER_ATTR(toss_secs, 1); CLUSTER_ATTR(toss_secs, 1);
CLUSTER_ATTR(scan_secs, 1); CLUSTER_ATTR(scan_secs, 1);
CLUSTER_ATTR(log_debug, 0); CLUSTER_ATTR(log_debug, 0);
CLUSTER_ATTR(protocol, 0);
static struct configfs_attribute *cluster_attrs[] = { static struct configfs_attribute *cluster_attrs[] = {
[CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr, [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr,
...@@ -170,6 +173,7 @@ static struct configfs_attribute *cluster_attrs[] = { ...@@ -170,6 +173,7 @@ static struct configfs_attribute *cluster_attrs[] = {
[CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr, [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr,
[CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr, [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr,
[CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr, [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr,
[CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol.attr,
NULL, NULL,
}; };
...@@ -904,6 +908,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num) ...@@ -904,6 +908,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
#define DEFAULT_TOSS_SECS 10 #define DEFAULT_TOSS_SECS 10
#define DEFAULT_SCAN_SECS 5 #define DEFAULT_SCAN_SECS 5
#define DEFAULT_LOG_DEBUG 0 #define DEFAULT_LOG_DEBUG 0
#define DEFAULT_PROTOCOL 0
struct dlm_config_info dlm_config = { struct dlm_config_info dlm_config = {
.ci_tcp_port = DEFAULT_TCP_PORT, .ci_tcp_port = DEFAULT_TCP_PORT,
...@@ -914,6 +919,7 @@ struct dlm_config_info dlm_config = { ...@@ -914,6 +919,7 @@ struct dlm_config_info dlm_config = {
.ci_recover_timer = DEFAULT_RECOVER_TIMER, .ci_recover_timer = DEFAULT_RECOVER_TIMER,
.ci_toss_secs = DEFAULT_TOSS_SECS, .ci_toss_secs = DEFAULT_TOSS_SECS,
.ci_scan_secs = DEFAULT_SCAN_SECS, .ci_scan_secs = DEFAULT_SCAN_SECS,
.ci_log_debug = DEFAULT_LOG_DEBUG .ci_log_debug = DEFAULT_LOG_DEBUG,
.ci_protocol = DEFAULT_PROTOCOL
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
******************************************************************************* *******************************************************************************
** **
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -26,6 +26,7 @@ struct dlm_config_info { ...@@ -26,6 +26,7 @@ struct dlm_config_info {
int ci_toss_secs; int ci_toss_secs;
int ci_scan_secs; int ci_scan_secs;
int ci_log_debug; int ci_log_debug;
int ci_protocol;
}; };
extern struct dlm_config_info dlm_config; extern struct dlm_config_info dlm_config;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
******************************************************************************* *******************************************************************************
** **
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -210,6 +210,9 @@ struct dlm_args { ...@@ -210,6 +210,9 @@ struct dlm_args {
#define DLM_IFL_MSTCPY 0x00010000 #define DLM_IFL_MSTCPY 0x00010000
#define DLM_IFL_RESEND 0x00020000 #define DLM_IFL_RESEND 0x00020000
#define DLM_IFL_DEAD 0x00040000 #define DLM_IFL_DEAD 0x00040000
#define DLM_IFL_OVERLAP_UNLOCK 0x00080000
#define DLM_IFL_OVERLAP_CANCEL 0x00100000
#define DLM_IFL_ENDOFLIFE 0x00200000
#define DLM_IFL_USER 0x00000001 #define DLM_IFL_USER 0x00000001
#define DLM_IFL_ORPHAN 0x00000002 #define DLM_IFL_ORPHAN 0x00000002
...@@ -230,8 +233,8 @@ struct dlm_lkb { ...@@ -230,8 +233,8 @@ struct dlm_lkb {
int8_t lkb_grmode; /* granted lock mode */ int8_t lkb_grmode; /* granted lock mode */
int8_t lkb_bastmode; /* requested mode */ int8_t lkb_bastmode; /* requested mode */
int8_t lkb_highbast; /* highest mode bast sent for */ int8_t lkb_highbast; /* highest mode bast sent for */
int8_t lkb_wait_type; /* type of reply waiting for */ int8_t lkb_wait_type; /* type of reply waiting for */
int8_t lkb_wait_count;
int8_t lkb_ast_type; /* type of ast queued for */ int8_t lkb_ast_type; /* type of ast queued for */
struct list_head lkb_idtbl_list; /* lockspace lkbtbl */ struct list_head lkb_idtbl_list; /* lockspace lkbtbl */
...@@ -339,6 +342,7 @@ struct dlm_header { ...@@ -339,6 +342,7 @@ struct dlm_header {
#define DLM_MSG_LOOKUP 11 #define DLM_MSG_LOOKUP 11
#define DLM_MSG_REMOVE 12 #define DLM_MSG_REMOVE 12
#define DLM_MSG_LOOKUP_REPLY 13 #define DLM_MSG_LOOKUP_REPLY 13
#define DLM_MSG_PURGE 14
struct dlm_message { struct dlm_message {
struct dlm_header m_header; struct dlm_header m_header;
...@@ -440,6 +444,9 @@ struct dlm_ls { ...@@ -440,6 +444,9 @@ struct dlm_ls {
struct mutex ls_waiters_mutex; struct mutex ls_waiters_mutex;
struct list_head ls_waiters; /* lkbs needing a reply */ struct list_head ls_waiters; /* lkbs needing a reply */
struct mutex ls_orphans_mutex;
struct list_head ls_orphans;
struct list_head ls_nodes; /* current nodes in ls */ struct list_head ls_nodes; /* current nodes in ls */
struct list_head ls_nodes_gone; /* dead node list, recovery */ struct list_head ls_nodes_gone; /* dead node list, recovery */
int ls_num_nodes; /* number of nodes in ls */ int ls_num_nodes; /* number of nodes in ls */
......
This diff is collapsed.
...@@ -41,6 +41,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, ...@@ -41,6 +41,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
uint32_t flags, uint32_t lkid, char *lvb_in); uint32_t flags, uint32_t lkid, char *lvb_in);
int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
uint32_t flags, uint32_t lkid); uint32_t flags, uint32_t lkid);
int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
int nodeid, int pid);
void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc); void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);
static inline int is_master(struct dlm_rsb *r) static inline int is_master(struct dlm_rsb *r)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
******************************************************************************* *******************************************************************************
** **
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
** **
** This copyrighted material is made available to anyone wishing to use, ** This copyrighted material is made available to anyone wishing to use,
** modify, copy, or redistribute it subject to the terms and conditions ** modify, copy, or redistribute it subject to the terms and conditions
...@@ -459,6 +459,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace, ...@@ -459,6 +459,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
INIT_LIST_HEAD(&ls->ls_waiters); INIT_LIST_HEAD(&ls->ls_waiters);
mutex_init(&ls->ls_waiters_mutex); mutex_init(&ls->ls_waiters_mutex);
INIT_LIST_HEAD(&ls->ls_orphans);
mutex_init(&ls->ls_orphans_mutex);
INIT_LIST_HEAD(&ls->ls_nodes); INIT_LIST_HEAD(&ls->ls_nodes);
INIT_LIST_HEAD(&ls->ls_nodes_gone); INIT_LIST_HEAD(&ls->ls_nodes_gone);
......
This diff is collapsed.
This diff is collapsed.
/* /*
* Copyright (C) 2006 Red Hat, Inc. All rights reserved. * Copyright (C) 2006-2007 Red Hat, Inc. All rights reserved.
* *
* This copyrighted material is made available to anyone wishing to use, * This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions * modify, copy, or redistribute it subject to the terms and conditions
...@@ -56,6 +56,7 @@ struct dlm_write_request32 { ...@@ -56,6 +56,7 @@ struct dlm_write_request32 {
union { union {
struct dlm_lock_params32 lock; struct dlm_lock_params32 lock;
struct dlm_lspace_params lspace; struct dlm_lspace_params lspace;
struct dlm_purge_params purge;
} i; } i;
}; };
...@@ -92,6 +93,9 @@ static void compat_input(struct dlm_write_request *kb, ...@@ -92,6 +93,9 @@ static void compat_input(struct dlm_write_request *kb,
kb->i.lspace.flags = kb32->i.lspace.flags; kb->i.lspace.flags = kb32->i.lspace.flags;
kb->i.lspace.minor = kb32->i.lspace.minor; kb->i.lspace.minor = kb32->i.lspace.minor;
strcpy(kb->i.lspace.name, kb32->i.lspace.name); strcpy(kb->i.lspace.name, kb32->i.lspace.name);
} else if (kb->cmd == DLM_USER_PURGE) {
kb->i.purge.nodeid = kb32->i.purge.nodeid;
kb->i.purge.pid = kb32->i.purge.pid;
} else { } else {
kb->i.lock.mode = kb32->i.lock.mode; kb->i.lock.mode = kb32->i.lock.mode;
kb->i.lock.namelen = kb32->i.lock.namelen; kb->i.lock.namelen = kb32->i.lock.namelen;
...@@ -111,8 +115,6 @@ static void compat_input(struct dlm_write_request *kb, ...@@ -111,8 +115,6 @@ static void compat_input(struct dlm_write_request *kb,
static void compat_output(struct dlm_lock_result *res, static void compat_output(struct dlm_lock_result *res,
struct dlm_lock_result32 *res32) struct dlm_lock_result32 *res32)
{ {
res32->length = res->length - (sizeof(struct dlm_lock_result) -
sizeof(struct dlm_lock_result32));
res32->user_astaddr = (__u32)(long)res->user_astaddr; res32->user_astaddr = (__u32)(long)res->user_astaddr;
res32->user_astparam = (__u32)(long)res->user_astparam; res32->user_astparam = (__u32)(long)res->user_astparam;
res32->user_lksb = (__u32)(long)res->user_lksb; res32->user_lksb = (__u32)(long)res->user_lksb;
...@@ -128,35 +130,30 @@ static void compat_output(struct dlm_lock_result *res, ...@@ -128,35 +130,30 @@ static void compat_output(struct dlm_lock_result *res,
} }
#endif #endif
/* we could possibly check if the cancel of an orphan has resulted in the lkb
being removed and then remove that lkb from the orphans list and free it */
void dlm_user_add_ast(struct dlm_lkb *lkb, int type) void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
{ {
struct dlm_ls *ls; struct dlm_ls *ls;
struct dlm_user_args *ua; struct dlm_user_args *ua;
struct dlm_user_proc *proc; struct dlm_user_proc *proc;
int remove_ownqueue = 0; int eol = 0, ast_type;
/* dlm_clear_proc_locks() sets ORPHAN/DEAD flag on each if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
lkb before dealing with it. We need to check this
flag before taking ls_clear_proc_locks mutex because if
it's set, dlm_clear_proc_locks() holds the mutex. */
if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) {
/* log_print("user_add_ast skip1 %x", lkb->lkb_flags); */
return; return;
}
ls = lkb->lkb_resource->res_ls; ls = lkb->lkb_resource->res_ls;
mutex_lock(&ls->ls_clear_proc_locks); mutex_lock(&ls->ls_clear_proc_locks);
/* If ORPHAN/DEAD flag is set, it means the process is dead so an ast /* If ORPHAN/DEAD flag is set, it means the process is dead so an ast
can't be delivered. For ORPHAN's, dlm_clear_proc_locks() freed can't be delivered. For ORPHAN's, dlm_clear_proc_locks() freed
lkb->ua so we can't try to use it. */ lkb->ua so we can't try to use it. This second check is necessary
for cases where a completion ast is received for an operation that
began before clear_proc_locks did its cancel/unlock. */
if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) { if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
/* log_print("user_add_ast skip2 %x", lkb->lkb_flags); */
goto out; goto out;
}
DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb);); DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb););
ua = (struct dlm_user_args *)lkb->lkb_astparam; ua = (struct dlm_user_args *)lkb->lkb_astparam;
...@@ -166,28 +163,42 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type) ...@@ -166,28 +163,42 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
goto out; goto out;
spin_lock(&proc->asts_spin); spin_lock(&proc->asts_spin);
if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) {
ast_type = lkb->lkb_ast_type;
lkb->lkb_ast_type |= type;
if (!ast_type) {
kref_get(&lkb->lkb_ref); kref_get(&lkb->lkb_ref);
list_add_tail(&lkb->lkb_astqueue, &proc->asts); list_add_tail(&lkb->lkb_astqueue, &proc->asts);
lkb->lkb_ast_type |= type;
wake_up_interruptible(&proc->wait); wake_up_interruptible(&proc->wait);
} }
if (type == AST_COMP && (ast_type & AST_COMP))
/* noqueue requests that fail may need to be removed from the log_debug(ls, "ast overlap %x status %x %x",
proc's locks list, there should be a better way of detecting lkb->lkb_id, ua->lksb.sb_status, lkb->lkb_flags);
this situation than checking all these things... */
/* Figure out if this lock is at the end of its life and no longer
if (type == AST_COMP && lkb->lkb_grmode == DLM_LOCK_IV && available for the application to use. The lkb still exists until
ua->lksb.sb_status == -EAGAIN && !list_empty(&lkb->lkb_ownqueue)) the final ast is read. A lock becomes EOL in three situations:
remove_ownqueue = 1; 1. a noqueue request fails with EAGAIN
2. an unlock completes with EUNLOCK
/* unlocks or cancels of waiting requests need to be removed from the 3. a cancel of a waiting request completes with ECANCEL
proc's unlocking list, again there must be a better way... */ An EOL lock needs to be removed from the process's list of locks.
And we can't allow any new operation on an EOL lock. This is
if (ua->lksb.sb_status == -DLM_EUNLOCK || not related to the lifetime of the lkb struct which is managed
entirely by refcount. */
if (type == AST_COMP &&
lkb->lkb_grmode == DLM_LOCK_IV &&
ua->lksb.sb_status == -EAGAIN)
eol = 1;
else if (ua->lksb.sb_status == -DLM_EUNLOCK ||
(ua->lksb.sb_status == -DLM_ECANCEL && (ua->lksb.sb_status == -DLM_ECANCEL &&
lkb->lkb_grmode == DLM_LOCK_IV)) lkb->lkb_grmode == DLM_LOCK_IV))
remove_ownqueue = 1; eol = 1;
if (eol) {
lkb->lkb_ast_type &= ~AST_BAST;
lkb->lkb_flags |= DLM_IFL_ENDOFLIFE;
}
/* We want to copy the lvb to userspace when the completion /* We want to copy the lvb to userspace when the completion
ast is read if the status is 0, the lock has an lvb and ast is read if the status is 0, the lock has an lvb and
...@@ -204,11 +215,13 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type) ...@@ -204,11 +215,13 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
spin_unlock(&proc->asts_spin); spin_unlock(&proc->asts_spin);
if (remove_ownqueue) { if (eol) {
spin_lock(&ua->proc->locks_spin); spin_lock(&ua->proc->locks_spin);
list_del_init(&lkb->lkb_ownqueue); if (!list_empty(&lkb->lkb_ownqueue)) {
list_del_init(&lkb->lkb_ownqueue);
dlm_put_lkb(lkb);
}
spin_unlock(&ua->proc->locks_spin); spin_unlock(&ua->proc->locks_spin);
dlm_put_lkb(lkb);
} }
out: out:
mutex_unlock(&ls->ls_clear_proc_locks); mutex_unlock(&ls->ls_clear_proc_locks);
...@@ -286,47 +299,71 @@ static int device_user_unlock(struct dlm_user_proc *proc, ...@@ -286,47 +299,71 @@ static int device_user_unlock(struct dlm_user_proc *proc,
return error; return error;
} }
static int device_create_lockspace(struct dlm_lspace_params *params) static int create_misc_device(struct dlm_ls *ls, char *name)
{ {
dlm_lockspace_t *lockspace;
struct dlm_ls *ls;
int error, len; int error, len;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
error = dlm_new_lockspace(params->name, strlen(params->name),
&lockspace, 0, DLM_USER_LVB_LEN);
if (error)
return error;
ls = dlm_find_lockspace_local(lockspace);
if (!ls)
return -ENOENT;
error = -ENOMEM; error = -ENOMEM;
len = strlen(params->name) + strlen(name_prefix) + 2; len = strlen(name) + strlen(name_prefix) + 2;
ls->ls_device.name = kzalloc(len, GFP_KERNEL); ls->ls_device.name = kzalloc(len, GFP_KERNEL);
if (!ls->ls_device.name) if (!ls->ls_device.name)
goto fail; goto fail;
snprintf((char *)ls->ls_device.name, len, "%s_%s", name_prefix, snprintf((char *)ls->ls_device.name, len, "%s_%s", name_prefix,
params->name); name);
ls->ls_device.fops = &device_fops; ls->ls_device.fops = &device_fops;
ls->ls_device.minor = MISC_DYNAMIC_MINOR; ls->ls_device.minor = MISC_DYNAMIC_MINOR;
error = misc_register(&ls->ls_device); error = misc_register(&ls->ls_device);
if (error) { if (error) {
kfree(ls->ls_device.name); kfree(ls->ls_device.name);
goto fail;
} }
fail:
return error;
}
static int device_user_purge(struct dlm_user_proc *proc,
struct dlm_purge_params *params)
{
struct dlm_ls *ls;
int error;
ls = dlm_find_lockspace_local(proc->lockspace);
if (!ls)
return -ENOENT;
error = dlm_user_purge(ls, proc, params->nodeid, params->pid);
error = ls->ls_device.minor;
dlm_put_lockspace(ls); dlm_put_lockspace(ls);
return error; return error;
}
static int device_create_lockspace(struct dlm_lspace_params *params)
{
dlm_lockspace_t *lockspace;
struct dlm_ls *ls;
int error;
fail: if (!capable(CAP_SYS_ADMIN))
return -EPERM;
error = dlm_new_lockspace(params->name, strlen(params->name),
&lockspace, 0, DLM_USER_LVB_LEN);
if (error)
return error;
ls = dlm_find_lockspace_local(lockspace);
if (!ls)
return -ENOENT;
error = create_misc_device(ls, params->name);
dlm_put_lockspace(ls); dlm_put_lockspace(ls);
dlm_release_lockspace(lockspace, 0);
if (error)
dlm_release_lockspace(lockspace, 0);
else
error = ls->ls_device.minor;
return error; return error;
} }
...@@ -343,6 +380,10 @@ static int device_remove_lockspace(struct dlm_lspace_params *params) ...@@ -343,6 +380,10 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
if (!ls) if (!ls)
return -ENOENT; return -ENOENT;
/* Deregister the misc device first, so we don't have
* a device that's not attached to a lockspace. If
* dlm_release_lockspace fails then we can recreate it
*/
error = misc_deregister(&ls->ls_device); error = misc_deregister(&ls->ls_device);
if (error) { if (error) {
dlm_put_lockspace(ls); dlm_put_lockspace(ls);
...@@ -361,6 +402,8 @@ static int device_remove_lockspace(struct dlm_lspace_params *params) ...@@ -361,6 +402,8 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
dlm_put_lockspace(ls); dlm_put_lockspace(ls);
error = dlm_release_lockspace(lockspace, force); error = dlm_release_lockspace(lockspace, force);
if (error)
create_misc_device(ls, ls->ls_name);
out: out:
return error; return error;
} }
...@@ -497,6 +540,14 @@ static ssize_t device_write(struct file *file, const char __user *buf, ...@@ -497,6 +540,14 @@ static ssize_t device_write(struct file *file, const char __user *buf,
error = device_remove_lockspace(&kbuf->i.lspace); error = device_remove_lockspace(&kbuf->i.lspace);
break; break;
case DLM_USER_PURGE:
if (!proc) {
log_print("no locking on control device");
goto out_sig;
}
error = device_user_purge(proc, &kbuf->i.purge);
break;
default: default:
log_print("Unknown command passed to DLM device : %d\n", log_print("Unknown command passed to DLM device : %d\n",
kbuf->cmd); kbuf->cmd);
......
...@@ -1262,9 +1262,10 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, ...@@ -1262,9 +1262,10 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
u64 leaf_no) u64 leaf_no)
{ {
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
struct buffer_head *bh; struct buffer_head *bh;
struct gfs2_leaf *lf; struct gfs2_leaf *lf;
unsigned entries = 0; unsigned entries = 0, entries2 = 0;
unsigned leaves = 0; unsigned leaves = 0;
const struct gfs2_dirent **darr, *dent; const struct gfs2_dirent **darr, *dent;
struct dirent_gather g; struct dirent_gather g;
...@@ -1290,7 +1291,13 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, ...@@ -1290,7 +1291,13 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
return 0; return 0;
error = -ENOMEM; error = -ENOMEM;
larr = vmalloc((leaves + entries) * sizeof(void *)); /*
* The extra 99 entries are not normally used, but are a buffer
* zone in case the number of entries in the leaf is corrupt.
* 99 is the maximum number of entries that can fit in a single
* leaf block.
*/
larr = vmalloc((leaves + entries + 99) * sizeof(void *));
if (!larr) if (!larr)
goto out; goto out;
darr = (const struct gfs2_dirent **)(larr + leaves); darr = (const struct gfs2_dirent **)(larr + leaves);
...@@ -1305,10 +1312,20 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, ...@@ -1305,10 +1312,20 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
lf = (struct gfs2_leaf *)bh->b_data; lf = (struct gfs2_leaf *)bh->b_data;
lfn = be64_to_cpu(lf->lf_next); lfn = be64_to_cpu(lf->lf_next);
if (lf->lf_entries) { if (lf->lf_entries) {
entries2 += be16_to_cpu(lf->lf_entries);
dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size,
gfs2_dirent_gather, NULL, &g); gfs2_dirent_gather, NULL, &g);
error = PTR_ERR(dent); error = PTR_ERR(dent);
if (IS_ERR(dent)) { if (IS_ERR(dent))
goto out_kfree;
if (entries2 != g.offset) {
fs_warn(sdp, "Number of entries corrupt in dir "
"leaf %llu, entries2 (%u) != "
"g.offset (%u)\n",
(unsigned long long)bh->b_blocknr,
entries2, g.offset);
error = -EIO;
goto out_kfree; goto out_kfree;
} }
error = 0; error = 0;
...@@ -1318,6 +1335,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, ...@@ -1318,6 +1335,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
} }
} while(lfn); } while(lfn);
BUG_ON(entries2 != entries);
error = do_filldir_main(ip, offset, opaque, filldir, darr, error = do_filldir_main(ip, offset, opaque, filldir, darr,
entries, copied); entries, copied);
out_kfree: out_kfree:
...@@ -1401,6 +1419,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1401,6 +1419,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
filldir_t filldir) filldir_t filldir)
{ {
struct gfs2_inode *dip = GFS2_I(inode); struct gfs2_inode *dip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
struct dirent_gather g; struct dirent_gather g;
const struct gfs2_dirent **darr, *dent; const struct gfs2_dirent **darr, *dent;
struct buffer_head *dibh; struct buffer_head *dibh;
...@@ -1423,8 +1442,8 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1423,8 +1442,8 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
return error; return error;
error = -ENOMEM; error = -ENOMEM;
darr = kmalloc(dip->i_di.di_entries * sizeof(struct gfs2_dirent *), /* 96 is max number of dirents which can be stuffed into an inode */
GFP_KERNEL); darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_KERNEL);
if (darr) { if (darr) {
g.pdent = darr; g.pdent = darr;
g.offset = 0; g.offset = 0;
...@@ -1434,6 +1453,15 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1434,6 +1453,15 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
error = PTR_ERR(dent); error = PTR_ERR(dent);
goto out; goto out;
} }
if (dip->i_di.di_entries != g.offset) {
fs_warn(sdp, "Number of entries corrupt in dir %llu, "
"ip->i_di.di_entries (%u) != g.offset (%u)\n",
(unsigned long long)dip->i_num.no_addr,
dip->i_di.di_entries,
g.offset);
error = -EIO;
goto out;
}
error = do_filldir_main(dip, offset, opaque, filldir, darr, error = do_filldir_main(dip, offset, opaque, filldir, darr,
dip->i_di.di_entries, &copied); dip->i_di.di_entries, &copied);
out: out:
......
This diff is collapsed.
...@@ -38,7 +38,7 @@ static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl) ...@@ -38,7 +38,7 @@ static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl)
/* Look in glock's list of holders for one with current task as owner */ /* Look in glock's list of holders for one with current task as owner */
spin_lock(&gl->gl_spin); spin_lock(&gl->gl_spin);
list_for_each_entry(gh, &gl->gl_holders, gh_list) { list_for_each_entry(gh, &gl->gl_holders, gh_list) {
if (gh->gh_owner == current) { if (gh->gh_owner_pid == current->pid) {
locked = 1; locked = 1;
break; break;
} }
...@@ -67,7 +67,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl) ...@@ -67,7 +67,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl)
{ {
int ret; int ret;
spin_lock(&gl->gl_spin); spin_lock(&gl->gl_spin);
ret = !list_empty(&gl->gl_waiters2) || !list_empty(&gl->gl_waiters3); ret = test_bit(GLF_DEMOTE, &gl->gl_flags) || !list_empty(&gl->gl_waiters3);
spin_unlock(&gl->gl_spin); spin_unlock(&gl->gl_spin);
return ret; return ret;
} }
...@@ -135,5 +135,9 @@ void gfs2_scand_internal(struct gfs2_sbd *sdp); ...@@ -135,5 +135,9 @@ void gfs2_scand_internal(struct gfs2_sbd *sdp);
void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait); void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait);
int __init gfs2_glock_init(void); int __init gfs2_glock_init(void);
int gfs2_create_debugfs_file(struct gfs2_sbd *sdp);
void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp);
int gfs2_register_debugfs(void);
void gfs2_unregister_debugfs(void);
#endif /* __GLOCK_DOT_H__ */ #endif /* __GLOCK_DOT_H__ */
...@@ -115,11 +115,8 @@ enum { ...@@ -115,11 +115,8 @@ enum {
/* Actions */ /* Actions */
HIF_MUTEX = 0, HIF_MUTEX = 0,
HIF_PROMOTE = 1, HIF_PROMOTE = 1,
HIF_DEMOTE = 2,
/* States */ /* States */
HIF_ALLOCED = 4,
HIF_DEALLOC = 5,
HIF_HOLDER = 6, HIF_HOLDER = 6,
HIF_FIRST = 7, HIF_FIRST = 7,
HIF_ABORTED = 9, HIF_ABORTED = 9,
...@@ -130,7 +127,7 @@ struct gfs2_holder { ...@@ -130,7 +127,7 @@ struct gfs2_holder {
struct list_head gh_list; struct list_head gh_list;
struct gfs2_glock *gh_gl; struct gfs2_glock *gh_gl;
struct task_struct *gh_owner; pid_t gh_owner_pid;
unsigned int gh_state; unsigned int gh_state;
unsigned gh_flags; unsigned gh_flags;
...@@ -142,8 +139,8 @@ struct gfs2_holder { ...@@ -142,8 +139,8 @@ struct gfs2_holder {
enum { enum {
GLF_LOCK = 1, GLF_LOCK = 1,
GLF_STICKY = 2, GLF_STICKY = 2,
GLF_DEMOTE = 3,
GLF_DIRTY = 5, GLF_DIRTY = 5,
GLF_SKIP_WAITERS2 = 6,
}; };
struct gfs2_glock { struct gfs2_glock {
...@@ -156,11 +153,12 @@ struct gfs2_glock { ...@@ -156,11 +153,12 @@ struct gfs2_glock {
unsigned int gl_state; unsigned int gl_state;
unsigned int gl_hash; unsigned int gl_hash;
struct task_struct *gl_owner; unsigned int gl_demote_state; /* state requested by remote node */
unsigned long gl_demote_time; /* time of first demote request */
pid_t gl_owner_pid;
unsigned long gl_ip; unsigned long gl_ip;
struct list_head gl_holders; struct list_head gl_holders;
struct list_head gl_waiters1; /* HIF_MUTEX */ struct list_head gl_waiters1; /* HIF_MUTEX */
struct list_head gl_waiters2; /* HIF_DEMOTE */
struct list_head gl_waiters3; /* HIF_PROMOTE */ struct list_head gl_waiters3; /* HIF_PROMOTE */
const struct gfs2_glock_operations *gl_ops; const struct gfs2_glock_operations *gl_ops;
...@@ -611,6 +609,8 @@ struct gfs2_sbd { ...@@ -611,6 +609,8 @@ struct gfs2_sbd {
unsigned long sd_last_warning; unsigned long sd_last_warning;
struct vfsmount *sd_gfs2mnt; struct vfsmount *sd_gfs2mnt;
struct dentry *debugfs_dir; /* debugfs directory */
struct dentry *debugfs_dentry_glocks; /* for debugfs */
}; };
#endif /* __INCORE_DOT_H__ */ #endif /* __INCORE_DOT_H__ */
......
...@@ -151,7 +151,7 @@ static inline unsigned int make_flags(struct gdlm_lock *lp, ...@@ -151,7 +151,7 @@ static inline unsigned int make_flags(struct gdlm_lock *lp,
/* make_strname - convert GFS lock numbers to a string */ /* make_strname - convert GFS lock numbers to a string */
static inline void make_strname(struct lm_lockname *lockname, static inline void make_strname(const struct lm_lockname *lockname,
struct gdlm_strname *str) struct gdlm_strname *str)
{ {
sprintf(str->name, "%8x%16llx", lockname->ln_type, sprintf(str->name, "%8x%16llx", lockname->ln_type,
...@@ -169,6 +169,7 @@ static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name, ...@@ -169,6 +169,7 @@ static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name,
return -ENOMEM; return -ENOMEM;
lp->lockname = *name; lp->lockname = *name;
make_strname(name, &lp->strname);
lp->ls = ls; lp->ls = ls;
lp->cur = DLM_LOCK_IV; lp->cur = DLM_LOCK_IV;
lp->lvb = NULL; lp->lvb = NULL;
...@@ -227,7 +228,6 @@ void gdlm_put_lock(void *lock) ...@@ -227,7 +228,6 @@ void gdlm_put_lock(void *lock)
unsigned int gdlm_do_lock(struct gdlm_lock *lp) unsigned int gdlm_do_lock(struct gdlm_lock *lp)
{ {
struct gdlm_ls *ls = lp->ls; struct gdlm_ls *ls = lp->ls;
struct gdlm_strname str;
int error, bast = 1; int error, bast = 1;
/* /*
...@@ -249,8 +249,6 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp) ...@@ -249,8 +249,6 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
if (test_bit(LFL_NOBAST, &lp->flags)) if (test_bit(LFL_NOBAST, &lp->flags))
bast = 0; bast = 0;
make_strname(&lp->lockname, &str);
set_bit(LFL_ACTIVE, &lp->flags); set_bit(LFL_ACTIVE, &lp->flags);
log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type, log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type,
...@@ -258,8 +256,8 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp) ...@@ -258,8 +256,8 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
lp->cur, lp->req, lp->lkf); lp->cur, lp->req, lp->lkf);
error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf, error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf,
str.name, str.namelen, 0, gdlm_ast, lp, lp->strname.name, lp->strname.namelen, 0, gdlm_ast,
bast ? gdlm_bast : NULL); lp, bast ? gdlm_bast : NULL);
if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) { if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) {
lp->lksb.sb_status = -EAGAIN; lp->lksb.sb_status = -EAGAIN;
...@@ -268,7 +266,7 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp) ...@@ -268,7 +266,7 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
} }
if (error) { if (error) {
log_debug("%s: gdlm_lock %x,%llx err=%d cur=%d req=%d lkf=%x " log_error("%s: gdlm_lock %x,%llx err=%d cur=%d req=%d lkf=%x "
"flags=%lx", ls->fsname, lp->lockname.ln_type, "flags=%lx", ls->fsname, lp->lockname.ln_type,
(unsigned long long)lp->lockname.ln_number, error, (unsigned long long)lp->lockname.ln_number, error,
lp->cur, lp->req, lp->lkf, lp->flags); lp->cur, lp->req, lp->lkf, lp->flags);
...@@ -296,7 +294,7 @@ static unsigned int gdlm_do_unlock(struct gdlm_lock *lp) ...@@ -296,7 +294,7 @@ static unsigned int gdlm_do_unlock(struct gdlm_lock *lp)
error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, NULL, lp); error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, NULL, lp);
if (error) { if (error) {
log_debug("%s: gdlm_unlock %x,%llx err=%d cur=%d req=%d lkf=%x " log_error("%s: gdlm_unlock %x,%llx err=%d cur=%d req=%d lkf=%x "
"flags=%lx", ls->fsname, lp->lockname.ln_type, "flags=%lx", ls->fsname, lp->lockname.ln_type,
(unsigned long long)lp->lockname.ln_number, error, (unsigned long long)lp->lockname.ln_number, error,
lp->cur, lp->req, lp->lkf, lp->flags); lp->cur, lp->req, lp->lkf, lp->flags);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define GDLM_STRNAME_BYTES 24 #define GDLM_STRNAME_BYTES 24
#define GDLM_LVB_SIZE 32 #define GDLM_LVB_SIZE 32
#define GDLM_DROP_COUNT 200000 #define GDLM_DROP_COUNT 0
#define GDLM_DROP_PERIOD 60 #define GDLM_DROP_PERIOD 60
#define GDLM_NAME_LEN 128 #define GDLM_NAME_LEN 128
...@@ -106,6 +106,7 @@ enum { ...@@ -106,6 +106,7 @@ enum {
struct gdlm_lock { struct gdlm_lock {
struct gdlm_ls *ls; struct gdlm_ls *ls;
struct lm_lockname lockname; struct lm_lockname lockname;
struct gdlm_strname strname;
char *lvb; char *lvb;
struct dlm_lksb lksb; struct dlm_lksb lksb;
......
...@@ -33,16 +33,17 @@ static void glock_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) ...@@ -33,16 +33,17 @@ static void glock_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
tr->tr_touched = 1; tr->tr_touched = 1;
if (!list_empty(&le->le_list))
return;
gl = container_of(le, struct gfs2_glock, gl_le); gl = container_of(le, struct gfs2_glock, gl_le);
if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(gl))) if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(gl)))
return; return;
gfs2_glock_hold(gl);
set_bit(GLF_DIRTY, &gl->gl_flags);
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
if (!list_empty(&le->le_list)){
gfs2_log_unlock(sdp);
return;
}
gfs2_glock_hold(gl);
set_bit(GLF_DIRTY, &gl->gl_flags);
sdp->sd_log_num_gl++; sdp->sd_log_num_gl++;
list_add(&le->le_list, &sdp->sd_log_le_gl); list_add(&le->le_list, &sdp->sd_log_le_gl);
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
...@@ -415,13 +416,14 @@ static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) ...@@ -415,13 +416,14 @@ static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
tr->tr_touched = 1; tr->tr_touched = 1;
if (!list_empty(&le->le_list))
return;
rgd = container_of(le, struct gfs2_rgrpd, rd_le); rgd = container_of(le, struct gfs2_rgrpd, rd_le);
gfs2_rgrp_bh_hold(rgd);
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
if (!list_empty(&le->le_list)){
gfs2_log_unlock(sdp);
return;
}
gfs2_rgrp_bh_hold(rgd);
sdp->sd_log_num_rg++; sdp->sd_log_num_rg++;
list_add(&le->le_list, &sdp->sd_log_le_rg); list_add(&le->le_list, &sdp->sd_log_le_rg);
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
......
...@@ -43,7 +43,6 @@ static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned ...@@ -43,7 +43,6 @@ static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned
spin_lock_init(&gl->gl_spin); spin_lock_init(&gl->gl_spin);
INIT_LIST_HEAD(&gl->gl_holders); INIT_LIST_HEAD(&gl->gl_holders);
INIT_LIST_HEAD(&gl->gl_waiters1); INIT_LIST_HEAD(&gl->gl_waiters1);
INIT_LIST_HEAD(&gl->gl_waiters2);
INIT_LIST_HEAD(&gl->gl_waiters3); INIT_LIST_HEAD(&gl->gl_waiters3);
gl->gl_lvb = NULL; gl->gl_lvb = NULL;
atomic_set(&gl->gl_lvb_count, 0); atomic_set(&gl->gl_lvb_count, 0);
...@@ -101,6 +100,8 @@ static int __init init_gfs2_fs(void) ...@@ -101,6 +100,8 @@ static int __init init_gfs2_fs(void)
if (error) if (error)
goto fail_unregister; goto fail_unregister;
gfs2_register_debugfs();
printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__); printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
return 0; return 0;
...@@ -128,6 +129,7 @@ static int __init init_gfs2_fs(void) ...@@ -128,6 +129,7 @@ static int __init init_gfs2_fs(void)
static void __exit exit_gfs2_fs(void) static void __exit exit_gfs2_fs(void)
{ {
gfs2_unregister_debugfs();
unregister_filesystem(&gfs2_fs_type); unregister_filesystem(&gfs2_fs_type);
unregister_filesystem(&gfs2meta_fs_type); unregister_filesystem(&gfs2meta_fs_type);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h> #include <linux/gfs2_ondisk.h>
#include <linux/lm_interface.h> #include <linux/lm_interface.h>
#include <linux/parser.h>
#include "gfs2.h" #include "gfs2.h"
#include "incore.h" #include "incore.h"
...@@ -20,6 +21,52 @@ ...@@ -20,6 +21,52 @@
#include "sys.h" #include "sys.h"
#include "util.h" #include "util.h"
enum {
Opt_lockproto,
Opt_locktable,
Opt_hostdata,
Opt_spectator,
Opt_ignore_local_fs,
Opt_localflocks,
Opt_localcaching,
Opt_debug,
Opt_nodebug,
Opt_upgrade,
Opt_num_glockd,
Opt_acl,
Opt_noacl,
Opt_quota_off,
Opt_quota_account,
Opt_quota_on,
Opt_suiddir,
Opt_nosuiddir,
Opt_data_writeback,
Opt_data_ordered,
};
static match_table_t tokens = {
{Opt_lockproto, "lockproto=%s"},
{Opt_locktable, "locktable=%s"},
{Opt_hostdata, "hostdata=%s"},
{Opt_spectator, "spectator"},
{Opt_ignore_local_fs, "ignore_local_fs"},
{Opt_localflocks, "localflocks"},
{Opt_localcaching, "localcaching"},
{Opt_debug, "debug"},
{Opt_nodebug, "nodebug"},
{Opt_upgrade, "upgrade"},
{Opt_num_glockd, "num_glockd=%d"},
{Opt_acl, "acl"},
{Opt_noacl, "noacl"},
{Opt_quota_off, "quota=off"},
{Opt_quota_account, "quota=account"},
{Opt_quota_on, "quota=on"},
{Opt_suiddir, "suiddir"},
{Opt_nosuiddir, "nosuiddir"},
{Opt_data_writeback, "data=writeback"},
{Opt_data_ordered, "data=ordered"}
};
/** /**
* gfs2_mount_args - Parse mount options * gfs2_mount_args - Parse mount options
* @sdp: * @sdp:
...@@ -54,146 +101,150 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount) ...@@ -54,146 +101,150 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
process them */ process them */
for (options = data; (o = strsep(&options, ",")); ) { for (options = data; (o = strsep(&options, ",")); ) {
int token, option;
substring_t tmp[MAX_OPT_ARGS];
if (!*o) if (!*o)
continue; continue;
v = strchr(o, '='); token = match_token(o, tokens, tmp);
if (v) switch (token) {
*v++ = 0; case Opt_lockproto:
v = match_strdup(&tmp[0]);
if (!v) {
fs_info(sdp, "no memory for lockproto\n");
error = -ENOMEM;
goto out_error;
}
if (!strcmp(o, "lockproto")) { if (remount && strcmp(v, args->ar_lockproto)) {
if (!v) kfree(v);
goto need_value;
if (remount && strcmp(v, args->ar_lockproto))
goto cant_remount; goto cant_remount;
}
strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN); strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0; args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
} kfree(v);
break;
case Opt_locktable:
v = match_strdup(&tmp[0]);
if (!v) {
fs_info(sdp, "no memory for locktable\n");
error = -ENOMEM;
goto out_error;
}
else if (!strcmp(o, "locktable")) { if (remount && strcmp(v, args->ar_locktable)) {
if (!v) kfree(v);
goto need_value;
if (remount && strcmp(v, args->ar_locktable))
goto cant_remount; goto cant_remount;
}
strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN); strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0; args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
} kfree(v);
break;
case Opt_hostdata:
v = match_strdup(&tmp[0]);
if (!v) {
fs_info(sdp, "no memory for hostdata\n");
error = -ENOMEM;
goto out_error;
}
else if (!strcmp(o, "hostdata")) { if (remount && strcmp(v, args->ar_hostdata)) {
if (!v) kfree(v);
goto need_value;
if (remount && strcmp(v, args->ar_hostdata))
goto cant_remount; goto cant_remount;
}
strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN); strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0; args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
} kfree(v);
break;
else if (!strcmp(o, "spectator")) { case Opt_spectator:
if (remount && !args->ar_spectator) if (remount && !args->ar_spectator)
goto cant_remount; goto cant_remount;
args->ar_spectator = 1; args->ar_spectator = 1;
sdp->sd_vfs->s_flags |= MS_RDONLY; sdp->sd_vfs->s_flags |= MS_RDONLY;
} break;
case Opt_ignore_local_fs:
else if (!strcmp(o, "ignore_local_fs")) {
if (remount && !args->ar_ignore_local_fs) if (remount && !args->ar_ignore_local_fs)
goto cant_remount; goto cant_remount;
args->ar_ignore_local_fs = 1; args->ar_ignore_local_fs = 1;
} break;
case Opt_localflocks:
else if (!strcmp(o, "localflocks")) {
if (remount && !args->ar_localflocks) if (remount && !args->ar_localflocks)
goto cant_remount; goto cant_remount;
args->ar_localflocks = 1; args->ar_localflocks = 1;
} break;
case Opt_localcaching:
else if (!strcmp(o, "localcaching")) {
if (remount && !args->ar_localcaching) if (remount && !args->ar_localcaching)
goto cant_remount; goto cant_remount;
args->ar_localcaching = 1; args->ar_localcaching = 1;
} break;
case Opt_debug:
else if (!strcmp(o, "debug"))
args->ar_debug = 1; args->ar_debug = 1;
break;
else if (!strcmp(o, "nodebug")) case Opt_nodebug:
args->ar_debug = 0; args->ar_debug = 0;
break;
else if (!strcmp(o, "upgrade")) { case Opt_upgrade:
if (remount && !args->ar_upgrade) if (remount && !args->ar_upgrade)
goto cant_remount; goto cant_remount;
args->ar_upgrade = 1; args->ar_upgrade = 1;
} break;
case Opt_num_glockd:
if ((error = match_int(&tmp[0], &option))) {
fs_info(sdp, "problem getting num_glockd\n");
goto out_error;
}
else if (!strcmp(o, "num_glockd")) { if (remount && option != args->ar_num_glockd)
unsigned int x;
if (!v)
goto need_value;
sscanf(v, "%u", &x);
if (remount && x != args->ar_num_glockd)
goto cant_remount; goto cant_remount;
if (!x || x > GFS2_GLOCKD_MAX) { if (!option || option > GFS2_GLOCKD_MAX) {
fs_info(sdp, "0 < num_glockd <= %u (not %u)\n", fs_info(sdp, "0 < num_glockd <= %u (not %u)\n",
GFS2_GLOCKD_MAX, x); GFS2_GLOCKD_MAX, option);
error = -EINVAL; error = -EINVAL;
break; goto out_error;
} }
args->ar_num_glockd = x; args->ar_num_glockd = option;
} break;
case Opt_acl:
else if (!strcmp(o, "acl")) {
args->ar_posix_acl = 1; args->ar_posix_acl = 1;
sdp->sd_vfs->s_flags |= MS_POSIXACL; sdp->sd_vfs->s_flags |= MS_POSIXACL;
} break;
case Opt_noacl:
else if (!strcmp(o, "noacl")) {
args->ar_posix_acl = 0; args->ar_posix_acl = 0;
sdp->sd_vfs->s_flags &= ~MS_POSIXACL; sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
} break;
case Opt_quota_off:
else if (!strcmp(o, "quota")) { args->ar_quota = GFS2_QUOTA_OFF;
if (!v) break;
goto need_value; case Opt_quota_account:
if (!strcmp(v, "off")) args->ar_quota = GFS2_QUOTA_ACCOUNT;
args->ar_quota = GFS2_QUOTA_OFF; break;
else if (!strcmp(v, "account")) case Opt_quota_on:
args->ar_quota = GFS2_QUOTA_ACCOUNT; args->ar_quota = GFS2_QUOTA_ON;
else if (!strcmp(v, "on")) break;
args->ar_quota = GFS2_QUOTA_ON; case Opt_suiddir:
else {
fs_info(sdp, "invalid value for quota\n");
error = -EINVAL;
break;
}
}
else if (!strcmp(o, "suiddir"))
args->ar_suiddir = 1; args->ar_suiddir = 1;
break;
else if (!strcmp(o, "nosuiddir")) case Opt_nosuiddir:
args->ar_suiddir = 0; args->ar_suiddir = 0;
break;
else if (!strcmp(o, "data")) { case Opt_data_writeback:
if (!v) args->ar_data = GFS2_DATA_WRITEBACK;
goto need_value; break;
if (!strcmp(v, "writeback")) case Opt_data_ordered:
args->ar_data = GFS2_DATA_WRITEBACK; args->ar_data = GFS2_DATA_ORDERED;
else if (!strcmp(v, "ordered")) break;
args->ar_data = GFS2_DATA_ORDERED; default:
else {
fs_info(sdp, "invalid value for data\n");
error = -EINVAL;
break;
}
}
else {
fs_info(sdp, "unknown option: %s\n", o); fs_info(sdp, "unknown option: %s\n", o);
error = -EINVAL; error = -EINVAL;
break; goto out_error;
} }
} }
out_error:
if (error) if (error)
fs_info(sdp, "invalid mount option(s)\n"); fs_info(sdp, "invalid mount option(s)\n");
...@@ -202,10 +253,6 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount) ...@@ -202,10 +253,6 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
return error; return error;
need_value:
fs_info(sdp, "need value for option %s\n", o);
return -EINVAL;
cant_remount: cant_remount:
fs_info(sdp, "can't remount with option %s\n", o); fs_info(sdp, "can't remount with option %s\n", o);
return -EINVAL; return -EINVAL;
......
...@@ -197,7 +197,19 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) ...@@ -197,7 +197,19 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
void *kaddr; void *kaddr;
int error; int error;
BUG_ON(page->index); /*
* Due to the order of unstuffing files and ->nopage(), we can be
* asked for a zero page in the case of a stuffed file being extended,
* so we need to supply one here. It doesn't happen often.
*/
if (unlikely(page->index)) {
kaddr = kmap_atomic(page, KM_USER0);
memset(kaddr, 0, PAGE_CACHE_SIZE);
kunmap_atomic(kaddr, KM_USER0);
flush_dcache_page(page);
SetPageUptodate(page);
return 0;
}
error = gfs2_meta_inode_buffer(ip, &dibh); error = gfs2_meta_inode_buffer(ip, &dibh);
if (error) if (error)
...@@ -208,9 +220,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) ...@@ -208,9 +220,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
ip->i_di.di_size); ip->i_di.di_size);
memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
kunmap_atomic(kaddr, KM_USER0); kunmap_atomic(kaddr, KM_USER0);
flush_dcache_page(page);
brelse(dibh); brelse(dibh);
SetPageUptodate(page); SetPageUptodate(page);
return 0; return 0;
...@@ -507,7 +518,9 @@ static int gfs2_commit_write(struct file *file, struct page *page, ...@@ -507,7 +518,9 @@ static int gfs2_commit_write(struct file *file, struct page *page,
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
gfs2_alloc_put(ip); gfs2_alloc_put(ip);
} }
unlock_page(page);
gfs2_glock_dq_m(1, &ip->i_gh); gfs2_glock_dq_m(1, &ip->i_gh);
lock_page(page);
gfs2_holder_uninit(&ip->i_gh); gfs2_holder_uninit(&ip->i_gh);
return 0; return 0;
...@@ -520,7 +533,9 @@ static int gfs2_commit_write(struct file *file, struct page *page, ...@@ -520,7 +533,9 @@ static int gfs2_commit_write(struct file *file, struct page *page,
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
gfs2_alloc_put(ip); gfs2_alloc_put(ip);
} }
unlock_page(page);
gfs2_glock_dq_m(1, &ip->i_gh); gfs2_glock_dq_m(1, &ip->i_gh);
lock_page(page);
gfs2_holder_uninit(&ip->i_gh); gfs2_holder_uninit(&ip->i_gh);
fail_nounlock: fail_nounlock:
ClearPageUptodate(page); ClearPageUptodate(page);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment