Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 92970
b: refs/heads/master
c: 4373ea8
h: refs/heads/master
v: v3
  • Loading branch information
Wendy Cheng authored and J. Bruce Fields committed Apr 25, 2008
1 parent 7a82516 commit 7bcd6ff
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d91cdcc0cce3186742f38e7352459b2087fbb86
refs/heads/master: 4373ea84c84d8a96e99d3da99e813d3e36d1bd11
36 changes: 31 additions & 5 deletions trunk/fs/lockd/svcsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <linux/lockd/lockd.h>
#include <linux/lockd/share.h>
#include <linux/lockd/sm_inter.h>
#include <linux/module.h>
#include <linux/mount.h>

#define NLMDBG_FACILITY NLMDBG_SVCSUBS

Expand Down Expand Up @@ -230,7 +232,7 @@ nlm_file_inuse(struct nlm_file *file)
* Loop over all files in the file table.
*/
static int
nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match)
nlm_traverse_files(void *data, nlm_host_match_fn_t match)
{
struct hlist_node *pos, *next;
struct nlm_file *file;
Expand All @@ -244,7 +246,7 @@ nlm_traverse_files(struct nlm_host *host, nlm_host_match_fn_t match)

/* Traverse locks, blocks and shares of this file
* and update file->f_locks count */
if (nlm_inspect_file(host, file, match))
if (nlm_inspect_file(data, file, match))
ret = 1;

mutex_lock(&nlm_file_mutex);
Expand Down Expand Up @@ -303,21 +305,27 @@ nlm_release_file(struct nlm_file *file)
* Used by nlmsvc_invalidate_all
*/
static int
nlmsvc_mark_host(struct nlm_host *host, struct nlm_host *dummy)
nlmsvc_mark_host(void *data, struct nlm_host *dummy)
{
struct nlm_host *host = data;

host->h_inuse = 1;
return 0;
}

static int
nlmsvc_same_host(struct nlm_host *host, struct nlm_host *other)
nlmsvc_same_host(void *data, struct nlm_host *other)
{
struct nlm_host *host = data;

return host == other;
}

static int
nlmsvc_is_client(struct nlm_host *host, struct nlm_host *dummy)
nlmsvc_is_client(void *data, struct nlm_host *dummy)
{
struct nlm_host *host = data;

if (host->h_server) {
/* we are destroying locks even though the client
* hasn't asked us too, so don't unmonitor the
Expand Down Expand Up @@ -370,3 +378,21 @@ nlmsvc_invalidate_all(void)
*/
nlm_traverse_files(NULL, nlmsvc_is_client);
}

static int
nlmsvc_match_ip(void *datap, struct nlm_host *host)
{
__be32 *server_addr = datap;

return host->h_saddr.sin_addr.s_addr == *server_addr;
}

int
nlmsvc_unlock_all_by_ip(__be32 server_addr)
{
int ret;
ret = nlm_traverse_files(&server_addr, nlmsvc_match_ip);
return ret ? -EIO : 0;

}
EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_ip);
33 changes: 33 additions & 0 deletions trunk/fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/seq_file.h>
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/inet.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/ctype.h>
Expand All @@ -35,6 +36,7 @@
#include <linux/nfsd/cache.h>
#include <linux/nfsd/xdr.h>
#include <linux/nfsd/syscall.h>
#include <linux/lockd/lockd.h>

#include <asm/uaccess.h>
#include <net/ipv6.h>
Expand All @@ -53,6 +55,7 @@ enum {
NFSD_Getfs,
NFSD_List,
NFSD_Fh,
NFSD_FO_UnlockIP,
NFSD_Threads,
NFSD_Pool_Threads,
NFSD_Versions,
Expand Down Expand Up @@ -89,6 +92,8 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size);
static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
#endif

static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size);

static ssize_t (*write_op[])(struct file *, char *, size_t) = {
[NFSD_Svc] = write_svc,
[NFSD_Add] = write_add,
Expand All @@ -98,6 +103,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
[NFSD_Getfd] = write_getfd,
[NFSD_Getfs] = write_getfs,
[NFSD_Fh] = write_filehandle,
[NFSD_FO_UnlockIP] = failover_unlock_ip,
[NFSD_Threads] = write_threads,
[NFSD_Pool_Threads] = write_pool_threads,
[NFSD_Versions] = write_versions,
Expand Down Expand Up @@ -298,6 +304,31 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)
return err;
}

static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size)
{
__be32 server_ip;
char *fo_path, c;
int b1, b2, b3, b4;

/* sanity check */
if (size == 0)
return -EINVAL;

if (buf[size-1] != '\n')
return -EINVAL;

fo_path = buf;
if (qword_get(&buf, fo_path, size) < 0)
return -EINVAL;

/* get ipv4 address */
if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4)
return -EINVAL;
server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4);

return nlmsvc_unlock_all_by_ip(server_ip);
}

static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
{
/* request is:
Expand Down Expand Up @@ -700,6 +731,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
[NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_List] = {"exports", &exports_operations, S_IRUGO},
[NFSD_FO_UnlockIP] = {"unlock_ip",
&transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void nsm_release(struct nsm_handle *);
* This is used in garbage collection and resource reclaim
* A return value != 0 means destroy the lock/block/share
*/
typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref);
typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref);

/*
* Server-side lock handling
Expand All @@ -220,6 +220,11 @@ void nlmsvc_mark_resources(void);
void nlmsvc_free_host_resources(struct nlm_host *);
void nlmsvc_invalidate_all(void);

/*
* Cluster failover support
*/
int nlmsvc_unlock_all_by_ip(__be32 server_addr);

static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
{
return file->f_file->f_path.dentry->d_inode;
Expand Down

0 comments on commit 7bcd6ff

Please sign in to comment.