You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'for-2.6.28' of git://linux-nfs.org/~bfields/linux
* 'for-2.6.28' of git://linux-nfs.org/~bfields/linux: (59 commits) svcrdma: Fix IRD/ORD polarity svcrdma: Update svc_rdma_send_error to use DMA LKEY svcrdma: Modify the RPC reply path to use FRMR when available svcrdma: Modify the RPC recv path to use FRMR when available svcrdma: Add support to svc_rdma_send to handle chained WR svcrdma: Modify post recv path to use local dma key svcrdma: Add a service to register a Fast Reg MR with the device svcrdma: Query device for Fast Reg support during connection setup svcrdma: Add FRMR get/put services NLM: Remove unused argument from svc_addsock() function NLM: Remove "proto" argument from lockd_up() NLM: Always start both UDP and TCP listeners lockd: Remove unused fields in the nlm_reboot structure lockd: Add helper to sanity check incoming NOTIFY requests lockd: change nlmclnt_grant() to take a "struct sockaddr *" lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET lockd: Support non-AF_INET addresses in nlm_lookup_host() NLM: Convert nlm_lookup_host() to use a single argument svcrdma: Add Fast Reg MR Data Types ...
This commit is contained in:
+30
@@ -433,6 +433,14 @@ config FS_POSIX_ACL
|
||||
bool
|
||||
default n
|
||||
|
||||
config FILE_LOCKING
|
||||
bool "Enable POSIX file locking API" if EMBEDDED
|
||||
default y
|
||||
help
|
||||
This option enables standard file locking support, required
|
||||
for filesystems like NFS and for the flock() system
|
||||
call. Disabling this option saves about 11k.
|
||||
|
||||
source "fs/xfs/Kconfig"
|
||||
source "fs/gfs2/Kconfig"
|
||||
|
||||
@@ -1779,6 +1787,28 @@ config SUNRPC_XPRT_RDMA
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config SUNRPC_REGISTER_V4
|
||||
bool "Register local RPC services via rpcbind v4 (EXPERIMENTAL)"
|
||||
depends on SUNRPC && EXPERIMENTAL
|
||||
default n
|
||||
help
|
||||
Sun added support for registering RPC services at an IPv6
|
||||
address by creating two new versions of the rpcbind protocol
|
||||
(RFC 1833).
|
||||
|
||||
This option enables support in the kernel RPC server for
|
||||
registering kernel RPC services via version 4 of the rpcbind
|
||||
protocol. If you enable this option, you must run a portmapper
|
||||
daemon that supports rpcbind protocol version 4.
|
||||
|
||||
Serving NFS over IPv6 from knfsd (the kernel's NFS server)
|
||||
requires that you enable this option and use a portmapper that
|
||||
supports rpcbind version 4.
|
||||
|
||||
If unsure, say N to get traditional behavior (register kernel
|
||||
RPC services using only rpcbind version 2). Distributions
|
||||
using the legacy Linux portmapper daemon must say N here.
|
||||
|
||||
config RPCSEC_GSS_KRB5
|
||||
tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)"
|
||||
depends on SUNRPC && EXPERIMENTAL
|
||||
|
||||
+2
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
obj-y := open.o read_write.o file_table.o super.o \
|
||||
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
|
||||
ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
|
||||
ioctl.o readdir.o select.o fifo.o dcache.o inode.o \
|
||||
attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
|
||||
seq_file.o xattr.o libfs.o fs-writeback.o \
|
||||
pnode.o drop_caches.o splice.o sync.o utimes.o \
|
||||
@@ -27,6 +27,7 @@ obj-$(CONFIG_ANON_INODES) += anon_inodes.o
|
||||
obj-$(CONFIG_SIGNALFD) += signalfd.o
|
||||
obj-$(CONFIG_TIMERFD) += timerfd.o
|
||||
obj-$(CONFIG_EVENTFD) += eventfd.o
|
||||
obj-$(CONFIG_FILE_LOCKING) += locks.o
|
||||
obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
|
||||
|
||||
nfsd-$(CONFIG_NFSD) := nfsctl.o
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@
|
||||
obj-$(CONFIG_LOCKD) += lockd.o
|
||||
|
||||
lockd-objs-y := clntlock.o clntproc.o host.o svc.o svclock.o svcshare.o \
|
||||
svcproc.o svcsubs.o mon.o xdr.o
|
||||
svcproc.o svcsubs.o mon.o xdr.o grace.o
|
||||
lockd-objs-$(CONFIG_LOCKD_V4) += xdr4.o svc4proc.o
|
||||
lockd-objs := $(lockd-objs-y)
|
||||
|
||||
+6
-7
@@ -54,14 +54,13 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
|
||||
u32 nlm_version = (nlm_init->nfs_version == 2) ? 1 : 4;
|
||||
int status;
|
||||
|
||||
status = lockd_up(nlm_init->protocol);
|
||||
status = lockd_up();
|
||||
if (status < 0)
|
||||
return ERR_PTR(status);
|
||||
|
||||
host = nlmclnt_lookup_host((struct sockaddr_in *)nlm_init->address,
|
||||
host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen,
|
||||
nlm_init->protocol, nlm_version,
|
||||
nlm_init->hostname,
|
||||
strlen(nlm_init->hostname));
|
||||
nlm_init->hostname);
|
||||
if (host == NULL) {
|
||||
lockd_down();
|
||||
return ERR_PTR(-ENOLCK);
|
||||
@@ -142,7 +141,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
|
||||
/*
|
||||
* The server lockd has called us back to tell us the lock was granted
|
||||
*/
|
||||
__be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock)
|
||||
__be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
|
||||
{
|
||||
const struct file_lock *fl = &lock->fl;
|
||||
const struct nfs_fh *fh = &lock->fh;
|
||||
@@ -166,7 +165,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
|
||||
*/
|
||||
if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
|
||||
continue;
|
||||
if (!nlm_cmp_addr(&block->b_host->h_addr, addr))
|
||||
if (!nlm_cmp_addr(nlm_addr(block->b_host), addr))
|
||||
continue;
|
||||
if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
|
||||
continue;
|
||||
@@ -216,7 +215,7 @@ reclaimer(void *ptr)
|
||||
/* This one ensures that our parent doesn't terminate while the
|
||||
* reclaim is in progress */
|
||||
lock_kernel();
|
||||
lockd_up(0); /* note: this cannot fail as lockd is already running */
|
||||
lockd_up(); /* note: this cannot fail as lockd is already running */
|
||||
|
||||
dprintk("lockd: reclaiming locks for host %s\n", host->h_name);
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Common code for control of lockd and nfsv4 grace periods.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/lockd/bind.h>
|
||||
|
||||
static LIST_HEAD(grace_list);
|
||||
static DEFINE_SPINLOCK(grace_lock);
|
||||
|
||||
/**
|
||||
* locks_start_grace
|
||||
* @lm: who this grace period is for
|
||||
*
|
||||
* A grace period is a period during which locks should not be given
|
||||
* out. Currently grace periods are only enforced by the two lock
|
||||
* managers (lockd and nfsd), using the locks_in_grace() function to
|
||||
* check when they are in a grace period.
|
||||
*
|
||||
* This function is called to start a grace period.
|
||||
*/
|
||||
void locks_start_grace(struct lock_manager *lm)
|
||||
{
|
||||
spin_lock(&grace_lock);
|
||||
list_add(&lm->list, &grace_list);
|
||||
spin_unlock(&grace_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(locks_start_grace);
|
||||
|
||||
/**
|
||||
* locks_end_grace
|
||||
* @lm: who this grace period is for
|
||||
*
|
||||
* Call this function to state that the given lock manager is ready to
|
||||
* resume regular locking. The grace period will not end until all lock
|
||||
* managers that called locks_start_grace() also call locks_end_grace().
|
||||
* Note that callers count on it being safe to call this more than once,
|
||||
* and the second call should be a no-op.
|
||||
*/
|
||||
void locks_end_grace(struct lock_manager *lm)
|
||||
{
|
||||
spin_lock(&grace_lock);
|
||||
list_del_init(&lm->list);
|
||||
spin_unlock(&grace_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(locks_end_grace);
|
||||
|
||||
/**
|
||||
* locks_in_grace
|
||||
*
|
||||
* Lock managers call this function to determine when it is OK for them
|
||||
* to answer ordinary lock requests, and when they should accept only
|
||||
* lock reclaims.
|
||||
*/
|
||||
int locks_in_grace(void)
|
||||
{
|
||||
return !list_empty(&grace_list);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(locks_in_grace);
|
||||
+256
-92
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -51,7 +51,7 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
args.mon_name = nsm->sm_name;
|
||||
args.addr = nsm->sm_addr.sin_addr.s_addr;
|
||||
args.addr = nsm_addr_in(nsm)->sin_addr.s_addr;
|
||||
args.prog = NLM_PROGRAM;
|
||||
args.vers = 3;
|
||||
args.proc = NLMPROC_NSM_NOTIFY;
|
||||
|
||||
+38
-52
@@ -51,7 +51,6 @@ static DEFINE_MUTEX(nlmsvc_mutex);
|
||||
static unsigned int nlmsvc_users;
|
||||
static struct task_struct *nlmsvc_task;
|
||||
static struct svc_rqst *nlmsvc_rqst;
|
||||
int nlmsvc_grace_period;
|
||||
unsigned long nlmsvc_timeout;
|
||||
|
||||
/*
|
||||
@@ -85,27 +84,23 @@ static unsigned long get_lockd_grace_period(void)
|
||||
return nlm_timeout * 5 * HZ;
|
||||
}
|
||||
|
||||
unsigned long get_nfs_grace_period(void)
|
||||
static struct lock_manager lockd_manager = {
|
||||
};
|
||||
|
||||
static void grace_ender(struct work_struct *not_used)
|
||||
{
|
||||
unsigned long lockdgrace = get_lockd_grace_period();
|
||||
unsigned long nfsdgrace = 0;
|
||||
|
||||
if (nlmsvc_ops)
|
||||
nfsdgrace = nlmsvc_ops->get_grace_period();
|
||||
|
||||
return max(lockdgrace, nfsdgrace);
|
||||
}
|
||||
EXPORT_SYMBOL(get_nfs_grace_period);
|
||||
|
||||
static unsigned long set_grace_period(void)
|
||||
{
|
||||
nlmsvc_grace_period = 1;
|
||||
return get_nfs_grace_period() + jiffies;
|
||||
locks_end_grace(&lockd_manager);
|
||||
}
|
||||
|
||||
static inline void clear_grace_period(void)
|
||||
static DECLARE_DELAYED_WORK(grace_period_end, grace_ender);
|
||||
|
||||
static void set_grace_period(void)
|
||||
{
|
||||
nlmsvc_grace_period = 0;
|
||||
unsigned long grace_period = get_lockd_grace_period();
|
||||
|
||||
locks_start_grace(&lockd_manager);
|
||||
cancel_delayed_work_sync(&grace_period_end);
|
||||
schedule_delayed_work(&grace_period_end, grace_period);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -116,7 +111,6 @@ lockd(void *vrqstp)
|
||||
{
|
||||
int err = 0, preverr = 0;
|
||||
struct svc_rqst *rqstp = vrqstp;
|
||||
unsigned long grace_period_expire;
|
||||
|
||||
/* try_to_freeze() is called from svc_recv() */
|
||||
set_freezable();
|
||||
@@ -139,7 +133,7 @@ lockd(void *vrqstp)
|
||||
nlm_timeout = LOCKD_DFLT_TIMEO;
|
||||
nlmsvc_timeout = nlm_timeout * HZ;
|
||||
|
||||
grace_period_expire = set_grace_period();
|
||||
set_grace_period();
|
||||
|
||||
/*
|
||||
* The main request loop. We don't terminate until the last
|
||||
@@ -153,21 +147,12 @@ lockd(void *vrqstp)
|
||||
flush_signals(current);
|
||||
if (nlmsvc_ops) {
|
||||
nlmsvc_invalidate_all();
|
||||
grace_period_expire = set_grace_period();
|
||||
set_grace_period();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retry any blocked locks that have been notified by
|
||||
* the VFS. Don't do this during grace period.
|
||||
* (Theoretically, there shouldn't even be blocked locks
|
||||
* during grace period).
|
||||
*/
|
||||
if (!nlmsvc_grace_period) {
|
||||
timeout = nlmsvc_retry_blocked();
|
||||
} else if (time_before(grace_period_expire, jiffies))
|
||||
clear_grace_period();
|
||||
timeout = nlmsvc_retry_blocked();
|
||||
|
||||
/*
|
||||
* Find a socket with data available and call its
|
||||
@@ -195,6 +180,7 @@ lockd(void *vrqstp)
|
||||
svc_process(rqstp);
|
||||
}
|
||||
flush_signals(current);
|
||||
cancel_delayed_work_sync(&grace_period_end);
|
||||
if (nlmsvc_ops)
|
||||
nlmsvc_invalidate_all();
|
||||
nlm_shutdown_hosts();
|
||||
@@ -203,25 +189,28 @@ lockd(void *vrqstp)
|
||||
}
|
||||
|
||||
/*
|
||||
* Make any sockets that are needed but not present.
|
||||
* If nlm_udpport or nlm_tcpport were set as module
|
||||
* options, make those sockets unconditionally
|
||||
* Ensure there are active UDP and TCP listeners for lockd.
|
||||
*
|
||||
* Even if we have only TCP NFS mounts and/or TCP NFSDs, some
|
||||
* local services (such as rpc.statd) still require UDP, and
|
||||
* some NFS servers do not yet support NLM over TCP.
|
||||
*
|
||||
* Returns zero if all listeners are available; otherwise a
|
||||
* negative errno value is returned.
|
||||
*/
|
||||
static int make_socks(struct svc_serv *serv, int proto)
|
||||
static int make_socks(struct svc_serv *serv)
|
||||
{
|
||||
static int warned;
|
||||
struct svc_xprt *xprt;
|
||||
int err = 0;
|
||||
|
||||
if (proto == IPPROTO_UDP || nlm_udpport) {
|
||||
xprt = svc_find_xprt(serv, "udp", 0, 0);
|
||||
if (!xprt)
|
||||
err = svc_create_xprt(serv, "udp", nlm_udpport,
|
||||
SVC_SOCK_DEFAULTS);
|
||||
else
|
||||
svc_xprt_put(xprt);
|
||||
}
|
||||
if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport)) {
|
||||
xprt = svc_find_xprt(serv, "udp", 0, 0);
|
||||
if (!xprt)
|
||||
err = svc_create_xprt(serv, "udp", nlm_udpport,
|
||||
SVC_SOCK_DEFAULTS);
|
||||
else
|
||||
svc_xprt_put(xprt);
|
||||
if (err >= 0) {
|
||||
xprt = svc_find_xprt(serv, "tcp", 0, 0);
|
||||
if (!xprt)
|
||||
err = svc_create_xprt(serv, "tcp", nlm_tcpport,
|
||||
@@ -241,8 +230,7 @@ static int make_socks(struct svc_serv *serv, int proto)
|
||||
/*
|
||||
* Bring up the lockd process if it's not already up.
|
||||
*/
|
||||
int
|
||||
lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */
|
||||
int lockd_up(void)
|
||||
{
|
||||
struct svc_serv *serv;
|
||||
int error = 0;
|
||||
@@ -251,11 +239,8 @@ lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */
|
||||
/*
|
||||
* Check whether we're already up and running.
|
||||
*/
|
||||
if (nlmsvc_rqst) {
|
||||
if (proto)
|
||||
error = make_socks(nlmsvc_rqst->rq_server, proto);
|
||||
if (nlmsvc_rqst)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sanity check: if there's no pid,
|
||||
@@ -266,13 +251,14 @@ lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */
|
||||
"lockd_up: no pid, %d users??\n", nlmsvc_users);
|
||||
|
||||
error = -ENOMEM;
|
||||
serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL);
|
||||
serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, AF_INET, NULL);
|
||||
if (!serv) {
|
||||
printk(KERN_WARNING "lockd_up: create service failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((error = make_socks(serv, proto)) < 0)
|
||||
error = make_socks(serv);
|
||||
if (error < 0)
|
||||
goto destroy_and_out;
|
||||
|
||||
/*
|
||||
|
||||
+9
-22
@@ -88,12 +88,6 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
dprintk("lockd: TEST4 called\n");
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept test requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Obtain client and file */
|
||||
if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
|
||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||
@@ -122,12 +116,6 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period && !argp->reclaim) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Obtain client and file */
|
||||
if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
|
||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||
@@ -146,7 +134,8 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
|
||||
/* Now try to lock the file */
|
||||
resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock,
|
||||
argp->block, &argp->cookie);
|
||||
argp->block, &argp->cookie,
|
||||
argp->reclaim);
|
||||
if (resp->status == nlm_drop_reply)
|
||||
rc = rpc_drop_reply;
|
||||
else
|
||||
@@ -169,7 +158,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -202,7 +191,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -231,7 +220,7 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
dprintk("lockd: GRANTED called\n");
|
||||
resp->status = nlmclnt_grant(svc_addr_in(rqstp), &argp->lock);
|
||||
resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
|
||||
dprintk("lockd: GRANTED status %d\n", ntohl(resp->status));
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -341,7 +330,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period && !argp->reclaim) {
|
||||
if (locks_in_grace() && !argp->reclaim) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -374,7 +363,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -432,11 +421,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
|
||||
{
|
||||
struct sockaddr_in saddr;
|
||||
|
||||
memcpy(&saddr, svc_addr_in(rqstp), sizeof(saddr));
|
||||
|
||||
dprintk("lockd: SM_NOTIFY called\n");
|
||||
if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
|
||||
|| ntohs(saddr.sin_port) >= 1024) {
|
||||
|
||||
if (!nlm_privileged_requester(rqstp)) {
|
||||
char buf[RPC_MAX_ADDRBUFLEN];
|
||||
printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
|
||||
svc_print_addr(rqstp, buf, sizeof(buf)));
|
||||
|
||||
+17
-1
@@ -360,7 +360,7 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block)
|
||||
__be32
|
||||
nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||
struct nlm_host *host, struct nlm_lock *lock, int wait,
|
||||
struct nlm_cookie *cookie)
|
||||
struct nlm_cookie *cookie, int reclaim)
|
||||
{
|
||||
struct nlm_block *block = NULL;
|
||||
int error;
|
||||
@@ -406,6 +406,15 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (locks_in_grace() && !reclaim) {
|
||||
ret = nlm_lck_denied_grace_period;
|
||||
goto out;
|
||||
}
|
||||
if (reclaim && !locks_in_grace()) {
|
||||
ret = nlm_lck_denied_grace_period;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!wait)
|
||||
lock->fl.fl_flags &= ~FL_SLEEP;
|
||||
error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL);
|
||||
@@ -502,6 +511,10 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (locks_in_grace()) {
|
||||
ret = nlm_lck_denied_grace_period;
|
||||
goto out;
|
||||
}
|
||||
error = vfs_test_lock(file->f_file, &lock->fl);
|
||||
if (error == FILE_LOCK_DEFERRED) {
|
||||
ret = nlmsvc_defer_lock_rqst(rqstp, block);
|
||||
@@ -582,6 +595,9 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
|
||||
(long long)lock->fl.fl_start,
|
||||
(long long)lock->fl.fl_end);
|
||||
|
||||
if (locks_in_grace())
|
||||
return nlm_lck_denied_grace_period;
|
||||
|
||||
mutex_lock(&file->f_mutex);
|
||||
block = nlmsvc_lookup_block(file, lock);
|
||||
mutex_unlock(&file->f_mutex);
|
||||
|
||||
+9
-22
@@ -117,12 +117,6 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
dprintk("lockd: TEST called\n");
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept test requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Obtain client and file */
|
||||
if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
|
||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||
@@ -152,12 +146,6 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period && !argp->reclaim) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Obtain client and file */
|
||||
if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
|
||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||
@@ -176,7 +164,8 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
|
||||
/* Now try to lock the file */
|
||||
resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
|
||||
argp->block, &argp->cookie));
|
||||
argp->block, &argp->cookie,
|
||||
argp->reclaim));
|
||||
if (resp->status == nlm_drop_reply)
|
||||
rc = rpc_drop_reply;
|
||||
else
|
||||
@@ -199,7 +188,7 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -232,7 +221,7 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -261,7 +250,7 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
dprintk("lockd: GRANTED called\n");
|
||||
resp->status = nlmclnt_grant(svc_addr_in(rqstp), &argp->lock);
|
||||
resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
|
||||
dprintk("lockd: GRANTED status %d\n", ntohl(resp->status));
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -373,7 +362,7 @@ nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept new lock requests during grace period */
|
||||
if (nlmsvc_grace_period && !argp->reclaim) {
|
||||
if (locks_in_grace() && !argp->reclaim) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -406,7 +395,7 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||
resp->cookie = argp->cookie;
|
||||
|
||||
/* Don't accept requests during grace period */
|
||||
if (nlmsvc_grace_period) {
|
||||
if (locks_in_grace()) {
|
||||
resp->status = nlm_lck_denied_grace_period;
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -464,11 +453,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
|
||||
{
|
||||
struct sockaddr_in saddr;
|
||||
|
||||
memcpy(&saddr, svc_addr_in(rqstp), sizeof(saddr));
|
||||
|
||||
dprintk("lockd: SM_NOTIFY called\n");
|
||||
if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
|
||||
|| ntohs(saddr.sin_port) >= 1024) {
|
||||
|
||||
if (!nlm_privileged_requester(rqstp)) {
|
||||
char buf[RPC_MAX_ADDRBUFLEN];
|
||||
printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
|
||||
svc_print_addr(rqstp, buf, sizeof(buf)));
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb);
|
||||
static int
|
||||
nlmsvc_match_ip(void *datap, struct nlm_host *host)
|
||||
{
|
||||
return nlm_cmp_addr(&host->h_saddr, datap);
|
||||
return nlm_cmp_addr(nlm_srcaddr(host), datap);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -351,8 +351,6 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
|
||||
argp->state = ntohl(*p++);
|
||||
/* Preserve the address in network byte order */
|
||||
argp->addr = *p++;
|
||||
argp->vers = *p++;
|
||||
argp->proto = *p++;
|
||||
return xdr_argsize_check(rqstp, p);
|
||||
}
|
||||
|
||||
|
||||
@@ -358,8 +358,6 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp
|
||||
argp->state = ntohl(*p++);
|
||||
/* Preserve the address in network byte order */
|
||||
argp->addr = *p++;
|
||||
argp->vers = *p++;
|
||||
argp->proto = *p++;
|
||||
return xdr_argsize_check(rqstp, p);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -105,7 +105,8 @@ int nfs_callback_up(void)
|
||||
mutex_lock(&nfs_callback_mutex);
|
||||
if (nfs_callback_info.users++ || nfs_callback_info.task != NULL)
|
||||
goto out;
|
||||
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL);
|
||||
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,
|
||||
AF_INET, NULL);
|
||||
ret = -ENOMEM;
|
||||
if (!serv)
|
||||
goto out_err;
|
||||
|
||||
@@ -70,7 +70,6 @@ nlm_fclose(struct file *filp)
|
||||
static struct nlmsvc_binding nfsd_nlm_ops = {
|
||||
.fopen = nlm_fopen, /* open file for locking */
|
||||
.fclose = nlm_fclose, /* close file */
|
||||
.get_grace_period = get_nfs4_grace_period,
|
||||
};
|
||||
|
||||
void
|
||||
|
||||
+5
-3
@@ -63,7 +63,8 @@ nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
|
||||
SVCFH_fmt(&argp->fh));
|
||||
|
||||
fh_copy(&resp->fh, &argp->fh);
|
||||
nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
|
||||
nfserr = fh_verify(rqstp, &resp->fh, 0,
|
||||
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
||||
if (nfserr)
|
||||
RETURN_STATUS(nfserr);
|
||||
|
||||
@@ -530,7 +531,7 @@ nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
|
||||
dprintk("nfsd: FSSTAT(3) %s\n",
|
||||
SVCFH_fmt(&argp->fh));
|
||||
|
||||
nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats);
|
||||
nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
|
||||
fh_put(&argp->fh);
|
||||
RETURN_STATUS(nfserr);
|
||||
}
|
||||
@@ -558,7 +559,8 @@ nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
|
||||
resp->f_maxfilesize = ~(u32) 0;
|
||||
resp->f_properties = NFS3_FSF_DEFAULT;
|
||||
|
||||
nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
|
||||
nfserr = fh_verify(rqstp, &argp->fh, 0,
|
||||
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
||||
|
||||
/* Check special features of the file system. May request
|
||||
* different read/write sizes for file systems known to have
|
||||
|
||||
@@ -225,7 +225,8 @@ encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec)
|
||||
|
||||
RESERVE_SPACE(12+sizeof(cb_rec->cbr_stateid) + len);
|
||||
WRITE32(OP_CB_RECALL);
|
||||
WRITEMEM(&cb_rec->cbr_stateid, sizeof(stateid_t));
|
||||
WRITE32(cb_rec->cbr_stateid.si_generation);
|
||||
WRITEMEM(&cb_rec->cbr_stateid.si_opaque, sizeof(stateid_opaque_t));
|
||||
WRITE32(cb_rec->cbr_trunc);
|
||||
WRITE32(len);
|
||||
WRITEMEM(cb_rec->cbr_fhval, len);
|
||||
@@ -379,6 +380,7 @@ static int do_probe_callback(void *data)
|
||||
.addrsize = sizeof(addr),
|
||||
.timeout = &timeparms,
|
||||
.program = &cb_program,
|
||||
.prognumber = cb->cb_prog,
|
||||
.version = nfs_cb_version[1]->number,
|
||||
.authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */
|
||||
.flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET),
|
||||
@@ -396,9 +398,6 @@ static int do_probe_callback(void *data)
|
||||
addr.sin_port = htons(cb->cb_port);
|
||||
addr.sin_addr.s_addr = htonl(cb->cb_addr);
|
||||
|
||||
/* Initialize rpc_stat */
|
||||
memset(args.program->stats, 0, sizeof(struct rpc_stat));
|
||||
|
||||
/* Create RPC client */
|
||||
client = rpc_create(&args);
|
||||
if (IS_ERR(client)) {
|
||||
|
||||
+4
-4
@@ -201,10 +201,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
/* Openowner is now set, so sequence id will get bumped. Now we need
|
||||
* these checks before we do any creates: */
|
||||
status = nfserr_grace;
|
||||
if (nfs4_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
|
||||
if (locks_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
|
||||
goto out;
|
||||
status = nfserr_no_grace;
|
||||
if (!nfs4_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
|
||||
if (!locks_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
|
||||
goto out;
|
||||
|
||||
switch (open->op_claim_type) {
|
||||
@@ -575,7 +575,7 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
{
|
||||
__be32 status;
|
||||
|
||||
if (nfs4_in_grace())
|
||||
if (locks_in_grace())
|
||||
return nfserr_grace;
|
||||
status = nfsd_unlink(rqstp, &cstate->current_fh, 0,
|
||||
remove->rm_name, remove->rm_namelen);
|
||||
@@ -596,7 +596,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
|
||||
if (!cstate->save_fh.fh_dentry)
|
||||
return status;
|
||||
if (nfs4_in_grace() && !(cstate->save_fh.fh_export->ex_flags
|
||||
if (locks_in_grace() && !(cstate->save_fh.fh_export->ex_flags
|
||||
& NFSEXP_NOSUBTREECHECK))
|
||||
return nfserr_grace;
|
||||
status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname,
|
||||
|
||||
+15
-19
@@ -61,7 +61,6 @@
|
||||
static time_t lease_time = 90; /* default lease time */
|
||||
static time_t user_lease_time = 90;
|
||||
static time_t boot_time;
|
||||
static int in_grace = 1;
|
||||
static u32 current_ownerid = 1;
|
||||
static u32 current_fileid = 1;
|
||||
static u32 current_delegid = 1;
|
||||
@@ -1640,7 +1639,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta
|
||||
case NFS4_OPEN_CLAIM_NULL:
|
||||
/* Let's not give out any delegations till everyone's
|
||||
* had the chance to reclaim theirs.... */
|
||||
if (nfs4_in_grace())
|
||||
if (locks_in_grace())
|
||||
goto out;
|
||||
if (!atomic_read(&cb->cb_set) || !sop->so_confirmed)
|
||||
goto out;
|
||||
@@ -1816,12 +1815,15 @@ out:
|
||||
return status;
|
||||
}
|
||||
|
||||
struct lock_manager nfsd4_manager = {
|
||||
};
|
||||
|
||||
static void
|
||||
end_grace(void)
|
||||
nfsd4_end_grace(void)
|
||||
{
|
||||
dprintk("NFSD: end of grace period\n");
|
||||
nfsd4_recdir_purge_old();
|
||||
in_grace = 0;
|
||||
locks_end_grace(&nfsd4_manager);
|
||||
}
|
||||
|
||||
static time_t
|
||||
@@ -1838,8 +1840,8 @@ nfs4_laundromat(void)
|
||||
nfs4_lock_state();
|
||||
|
||||
dprintk("NFSD: laundromat service - starting\n");
|
||||
if (in_grace)
|
||||
end_grace();
|
||||
if (locks_in_grace())
|
||||
nfsd4_end_grace();
|
||||
list_for_each_safe(pos, next, &client_lru) {
|
||||
clp = list_entry(pos, struct nfs4_client, cl_lru);
|
||||
if (time_after((unsigned long)clp->cl_time, (unsigned long)cutoff)) {
|
||||
@@ -1974,7 +1976,7 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
|
||||
return nfserr_bad_stateid;
|
||||
else if (ONE_STATEID(stateid) && (flags & RD_STATE))
|
||||
return nfs_ok;
|
||||
else if (nfs4_in_grace()) {
|
||||
else if (locks_in_grace()) {
|
||||
/* Answer in remaining cases depends on existance of
|
||||
* conflicting state; so we must wait out the grace period. */
|
||||
return nfserr_grace;
|
||||
@@ -1993,7 +1995,7 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
|
||||
static inline int
|
||||
io_during_grace_disallowed(struct inode *inode, int flags)
|
||||
{
|
||||
return nfs4_in_grace() && (flags & (RD_STATE | WR_STATE))
|
||||
return locks_in_grace() && (flags & (RD_STATE | WR_STATE))
|
||||
&& mandatory_lock(inode);
|
||||
}
|
||||
|
||||
@@ -2693,10 +2695,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
filp = lock_stp->st_vfs_file;
|
||||
|
||||
status = nfserr_grace;
|
||||
if (nfs4_in_grace() && !lock->lk_reclaim)
|
||||
if (locks_in_grace() && !lock->lk_reclaim)
|
||||
goto out;
|
||||
status = nfserr_no_grace;
|
||||
if (!nfs4_in_grace() && lock->lk_reclaim)
|
||||
if (!locks_in_grace() && lock->lk_reclaim)
|
||||
goto out;
|
||||
|
||||
locks_init_lock(&file_lock);
|
||||
@@ -2779,7 +2781,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
int error;
|
||||
__be32 status;
|
||||
|
||||
if (nfs4_in_grace())
|
||||
if (locks_in_grace())
|
||||
return nfserr_grace;
|
||||
|
||||
if (check_lock_length(lockt->lt_offset, lockt->lt_length))
|
||||
@@ -3192,9 +3194,9 @@ __nfs4_state_start(void)
|
||||
unsigned long grace_time;
|
||||
|
||||
boot_time = get_seconds();
|
||||
grace_time = get_nfs_grace_period();
|
||||
grace_time = get_nfs4_grace_period();
|
||||
lease_time = user_lease_time;
|
||||
in_grace = 1;
|
||||
locks_start_grace(&nfsd4_manager);
|
||||
printk(KERN_INFO "NFSD: starting %ld-second grace period\n",
|
||||
grace_time/HZ);
|
||||
laundry_wq = create_singlethread_workqueue("nfsd4");
|
||||
@@ -3213,12 +3215,6 @@ nfs4_state_start(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
nfs4_in_grace(void)
|
||||
{
|
||||
return in_grace;
|
||||
}
|
||||
|
||||
time_t
|
||||
nfs4_lease_time(void)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user