Commit 6736c047 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'nfs-for-3.2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

* 'nfs-for-3.2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (25 commits)
  nfs: set vs_hidden on nfs4_callback_version4 (try #2)
  pnfs-obj: Support for RAID5 read-4-write interface.
  pnfs-obj: move to ore 03: Remove old raid engine
  pnfs-obj: move to ore 02: move to ORE
  pnfs-obj: move to ore 01: ore_layout & ore_components
  pnfs-obj: Rename objlayout_io_state => objlayout_io_res
  pnfs-obj: Get rid of objlayout_{alloc,free}_io_state
  pnfs-obj: Return PNFS_NOT_ATTEMPTED in case of read/write_pagelist
  pnfs-obj: Remove redundant EOF from objlayout_io_state
  nfs: Remove unused variable from write.c
  nfs: Fix unused variable warning from file.c
  NFS: Remove no-op less-than-zero checks on unsigned variables.
  NFS: Clean up nfs4_xdr_dec_secinfo()
  NFS: Fix documenting comment for nfs_create_request()
  NFS4: fix cb_recallany decode error
  nfs4: serialize layoutcommit
  SUNRPC: remove rpcbind clients destruction on module cleanup
  SUNRPC: remove rpcbind clients creation during service registering
  NFSd: call svc rpcbind cleanup explicitly
  SUNRPC: cleanup service destruction
  ...
parents 16dfd1fa 6070295e
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# selected by any of the users. # selected by any of the users.
config ORE config ORE
tristate tristate
depends on EXOFS_FS depends on EXOFS_FS || PNFS_OBJLAYOUT
select ASYNC_XOR select ASYNC_XOR
default SCSI_OSD_ULD default SCSI_OSD_ULD
......
...@@ -488,17 +488,18 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp, ...@@ -488,17 +488,18 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp,
struct xdr_stream *xdr, struct xdr_stream *xdr,
struct cb_recallanyargs *args) struct cb_recallanyargs *args)
{ {
__be32 *p; uint32_t bitmap[2];
__be32 *p, status;
args->craa_addr = svc_addr(rqstp); args->craa_addr = svc_addr(rqstp);
p = read_buf(xdr, 4); p = read_buf(xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return htonl(NFS4ERR_BADXDR); return htonl(NFS4ERR_BADXDR);
args->craa_objs_to_keep = ntohl(*p++); args->craa_objs_to_keep = ntohl(*p++);
p = read_buf(xdr, 4); status = decode_bitmap(xdr, bitmap);
if (unlikely(p == NULL)) if (unlikely(status))
return htonl(NFS4ERR_BADXDR); return status;
args->craa_type_mask = ntohl(*p); args->craa_type_mask = bitmap[0];
return 0; return 0;
} }
...@@ -986,4 +987,5 @@ struct svc_version nfs4_callback_version4 = { ...@@ -986,4 +987,5 @@ struct svc_version nfs4_callback_version4 = {
.vs_proc = nfs4_callback_procedures1, .vs_proc = nfs4_callback_procedures1,
.vs_xdrsize = NFS4_CALLBACK_XDRSIZE, .vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
.vs_dispatch = NULL, .vs_dispatch = NULL,
.vs_hidden = 1,
}; };
...@@ -137,11 +137,9 @@ nfs_file_open(struct inode *inode, struct file *filp) ...@@ -137,11 +137,9 @@ nfs_file_open(struct inode *inode, struct file *filp)
static int static int
nfs_file_release(struct inode *inode, struct file *filp) nfs_file_release(struct inode *inode, struct file *filp)
{ {
struct dentry *dentry = filp->f_path.dentry;
dprintk("NFS: release(%s/%s)\n", dprintk("NFS: release(%s/%s)\n",
dentry->d_parent->d_name.name, filp->f_path.dentry->d_parent->d_name.name,
dentry->d_name.name); filp->f_path.dentry->d_name.name);
nfs_inc_stats(inode, NFSIOS_VFSRELEASE); nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
return nfs_release(inode, filp); return nfs_release(inode, filp);
...@@ -228,14 +226,13 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -228,14 +226,13 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
struct dentry * dentry = iocb->ki_filp->f_path.dentry; struct dentry * dentry = iocb->ki_filp->f_path.dentry;
struct inode * inode = dentry->d_inode; struct inode * inode = dentry->d_inode;
ssize_t result; ssize_t result;
size_t count = iov_length(iov, nr_segs);
if (iocb->ki_filp->f_flags & O_DIRECT) if (iocb->ki_filp->f_flags & O_DIRECT)
return nfs_file_direct_read(iocb, iov, nr_segs, pos); return nfs_file_direct_read(iocb, iov, nr_segs, pos);
dprintk("NFS: read(%s/%s, %lu@%lu)\n", dprintk("NFS: read(%s/%s, %lu@%lu)\n",
dentry->d_parent->d_name.name, dentry->d_name.name, dentry->d_parent->d_name.name, dentry->d_name.name,
(unsigned long) count, (unsigned long) pos); (unsigned long) iov_length(iov, nr_segs), (unsigned long) pos);
result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
if (!result) { if (!result) {
......
...@@ -449,9 +449,8 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, ...@@ -449,9 +449,8 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo,
fl->dsaddr = dsaddr; fl->dsaddr = dsaddr;
if (fl->first_stripe_index < 0 || if (fl->first_stripe_index >= dsaddr->stripe_count) {
fl->first_stripe_index >= dsaddr->stripe_count) { dprintk("%s Bad first_stripe_index %u\n",
dprintk("%s Bad first_stripe_index %d\n",
__func__, fl->first_stripe_index); __func__, fl->first_stripe_index);
goto out_put; goto out_put;
} }
...@@ -552,7 +551,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, ...@@ -552,7 +551,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
/* Note that a zero value for num_fh is legal for STRIPE_SPARSE. /* Note that a zero value for num_fh is legal for STRIPE_SPARSE.
* Futher checking is done in filelayout_check_layout */ * Futher checking is done in filelayout_check_layout */
if (fl->num_fh < 0 || fl->num_fh > if (fl->num_fh >
max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT)) max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT))
goto out_err; goto out_err;
......
...@@ -5950,6 +5950,7 @@ static void nfs4_layoutcommit_release(void *calldata) ...@@ -5950,6 +5950,7 @@ static void nfs4_layoutcommit_release(void *calldata)
{ {
struct nfs4_layoutcommit_data *data = calldata; struct nfs4_layoutcommit_data *data = calldata;
struct pnfs_layout_segment *lseg, *tmp; struct pnfs_layout_segment *lseg, *tmp;
unsigned long *bitlock = &NFS_I(data->args.inode)->flags;
pnfs_cleanup_layoutcommit(data); pnfs_cleanup_layoutcommit(data);
/* Matched by references in pnfs_set_layoutcommit */ /* Matched by references in pnfs_set_layoutcommit */
...@@ -5959,6 +5960,11 @@ static void nfs4_layoutcommit_release(void *calldata) ...@@ -5959,6 +5960,11 @@ static void nfs4_layoutcommit_release(void *calldata)
&lseg->pls_flags)) &lseg->pls_flags))
put_lseg(lseg); put_lseg(lseg);
} }
clear_bit_unlock(NFS_INO_LAYOUTCOMMITTING, bitlock);
smp_mb__after_clear_bit();
wake_up_bit(bitlock, NFS_INO_LAYOUTCOMMITTING);
put_rpccred(data->cred); put_rpccred(data->cred);
kfree(data); kfree(data);
} }
......
...@@ -6602,8 +6602,6 @@ static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, ...@@ -6602,8 +6602,6 @@ static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp,
if (status) if (status)
goto out; goto out;
status = decode_secinfo(xdr, res); status = decode_secinfo(xdr, res);
if (status)
goto out;
out: out:
return status; return status;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -74,19 +74,11 @@ OBJLAYOUT(struct pnfs_layout_hdr *lo) ...@@ -74,19 +74,11 @@ OBJLAYOUT(struct pnfs_layout_hdr *lo)
* per-I/O operation state * per-I/O operation state
* embedded in objects provider io_state data structure * embedded in objects provider io_state data structure
*/ */
struct objlayout_io_state { struct objlayout_io_res {
struct pnfs_layout_segment *lseg; struct objlayout *objlay;
struct page **pages;
unsigned pgbase;
unsigned nr_pages;
unsigned long count;
loff_t offset;
bool sync;
void *rpcdata; void *rpcdata;
int status; /* res */ int status; /* res */
int eof; /* res */
int committed; /* res */ int committed; /* res */
/* Error reporting (layout_return) */ /* Error reporting (layout_return) */
...@@ -100,6 +92,18 @@ struct objlayout_io_state { ...@@ -100,6 +92,18 @@ struct objlayout_io_state {
struct pnfs_osd_ioerr *ioerrs; struct pnfs_osd_ioerr *ioerrs;
}; };
static inline
void objlayout_init_ioerrs(struct objlayout_io_res *oir, unsigned num_comps,
struct pnfs_osd_ioerr *ioerrs, void *rpcdata,
struct pnfs_layout_hdr *pnfs_layout_type)
{
oir->objlay = OBJLAYOUT(pnfs_layout_type);
oir->rpcdata = rpcdata;
INIT_LIST_HEAD(&oir->err_list);
oir->num_comps = num_comps;
oir->ioerrs = ioerrs;
}
/* /*
* Raid engine I/O API * Raid engine I/O API
*/ */
...@@ -110,28 +114,24 @@ extern int objio_alloc_lseg(struct pnfs_layout_segment **outp, ...@@ -110,28 +114,24 @@ extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
gfp_t gfp_flags); gfp_t gfp_flags);
extern void objio_free_lseg(struct pnfs_layout_segment *lseg); extern void objio_free_lseg(struct pnfs_layout_segment *lseg);
extern int objio_alloc_io_state( /* objio_free_result will free these @oir structs recieved from
struct pnfs_layout_segment *lseg, * objlayout_{read,write}_done
struct objlayout_io_state **outp, */
gfp_t gfp_flags); extern void objio_free_result(struct objlayout_io_res *oir);
extern void objio_free_io_state(struct objlayout_io_state *state);
extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state); extern int objio_read_pagelist(struct nfs_read_data *rdata);
extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, extern int objio_write_pagelist(struct nfs_write_data *wdata, int how);
bool stable);
/* /*
* callback API * callback API
*/ */
extern void objlayout_io_set_result(struct objlayout_io_state *state, extern void objlayout_io_set_result(struct objlayout_io_res *oir,
unsigned index, struct pnfs_osd_objid *pooid, unsigned index, struct pnfs_osd_objid *pooid,
int osd_error, u64 offset, u64 length, bool is_write); int osd_error, u64 offset, u64 length, bool is_write);
static inline void static inline void
objlayout_add_delta_space_used(struct objlayout_io_state *state, s64 space_used) objlayout_add_delta_space_used(struct objlayout *objlay, s64 space_used)
{ {
struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout);
/* If one of the I/Os errored out and the delta_space_used was /* If one of the I/Os errored out and the delta_space_used was
* invalid we render the complete report as invalid. Protocol mandate * invalid we render the complete report as invalid. Protocol mandate
* the DSU be accurate or not reported. * the DSU be accurate or not reported.
...@@ -144,9 +144,9 @@ objlayout_add_delta_space_used(struct objlayout_io_state *state, s64 space_used) ...@@ -144,9 +144,9 @@ objlayout_add_delta_space_used(struct objlayout_io_state *state, s64 space_used)
spin_unlock(&objlay->lock); spin_unlock(&objlay->lock);
} }
extern void objlayout_read_done(struct objlayout_io_state *state, extern void objlayout_read_done(struct objlayout_io_res *oir,
ssize_t status, bool sync); ssize_t status, bool sync);
extern void objlayout_write_done(struct objlayout_io_state *state, extern void objlayout_write_done(struct objlayout_io_res *oir,
ssize_t status, bool sync); ssize_t status, bool sync);
extern int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay, extern int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
......
...@@ -41,7 +41,7 @@ nfs_page_free(struct nfs_page *p) ...@@ -41,7 +41,7 @@ nfs_page_free(struct nfs_page *p)
/** /**
* nfs_create_request - Create an NFS read/write request. * nfs_create_request - Create an NFS read/write request.
* @file: file descriptor to use * @ctx: open context to use
* @inode: inode to which the request is attached * @inode: inode to which the request is attached
* @page: page to write * @page: page to write
* @offset: starting offset within the page for the write * @offset: starting offset within the page for the write
......
...@@ -1443,17 +1443,31 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) ...@@ -1443,17 +1443,31 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
/* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */ /* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */
data = kzalloc(sizeof(*data), GFP_NOFS); data = kzalloc(sizeof(*data), GFP_NOFS);
if (!data) { if (!data) {
mark_inode_dirty_sync(inode);
status = -ENOMEM; status = -ENOMEM;
goto out; goto out;
} }
if (!test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags))
goto out_free;
if (test_and_set_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags)) {
if (!sync) {
status = -EAGAIN;
goto out_free;
}
status = wait_on_bit_lock(&nfsi->flags, NFS_INO_LAYOUTCOMMITTING,
nfs_wait_bit_killable, TASK_KILLABLE);
if (status)
goto out_free;
}
INIT_LIST_HEAD(&data->lseg_list); INIT_LIST_HEAD(&data->lseg_list);
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (!test_and_clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { if (!test_and_clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
clear_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
kfree(data); wake_up_bit(&nfsi->flags, NFS_INO_LAYOUTCOMMITTING);
goto out; goto out_free;
} }
pnfs_list_write_lseg(inode, &data->lseg_list); pnfs_list_write_lseg(inode, &data->lseg_list);
...@@ -1475,6 +1489,11 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) ...@@ -1475,6 +1489,11 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
status = nfs4_proc_layoutcommit(data, sync); status = nfs4_proc_layoutcommit(data, sync);
out: out:
if (status)
mark_inode_dirty_sync(inode);
dprintk("<-- %s status %d\n", __func__, status); dprintk("<-- %s status %d\n", __func__, status);
return status; return status;
out_free:
kfree(data);
goto out;
} }
...@@ -1243,7 +1243,6 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) ...@@ -1243,7 +1243,6 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
{ {
struct nfs_writeargs *argp = &data->args; struct nfs_writeargs *argp = &data->args;
struct nfs_writeres *resp = &data->res; struct nfs_writeres *resp = &data->res;
struct nfs_server *server = NFS_SERVER(data->inode);
int status; int status;
dprintk("NFS: %5u nfs_writeback_done (status %d)\n", dprintk("NFS: %5u nfs_writeback_done (status %d)\n",
...@@ -1277,7 +1276,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) ...@@ -1277,7 +1276,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
if (time_before(complain, jiffies)) { if (time_before(complain, jiffies)) {
dprintk("NFS: faulty NFS server %s:" dprintk("NFS: faulty NFS server %s:"
" (committed = %d) != (stable = %d)\n", " (committed = %d) != (stable = %d)\n",
server->nfs_client->cl_hostname, NFS_SERVER(data->inode)->nfs_client->cl_hostname,
resp->verf->committed, argp->stable); resp->verf->committed, argp->stable);
complain = jiffies + 300 * HZ; complain = jiffies + 300 * HZ;
} }
......
...@@ -256,6 +256,8 @@ static void nfsd_last_thread(struct svc_serv *serv) ...@@ -256,6 +256,8 @@ static void nfsd_last_thread(struct svc_serv *serv)
nfsd_serv = NULL; nfsd_serv = NULL;
nfsd_shutdown(); nfsd_shutdown();
svc_rpcb_cleanup(serv);
printk(KERN_WARNING "nfsd: last server has exited, flushing export " printk(KERN_WARNING "nfsd: last server has exited, flushing export "
"cache\n"); "cache\n");
nfsd_export_flush(); nfsd_export_flush();
......
...@@ -229,6 +229,7 @@ struct nfs_inode { ...@@ -229,6 +229,7 @@ struct nfs_inode {
#define NFS_INO_COMMIT (7) /* inode is committing unstable writes */ #define NFS_INO_COMMIT (7) /* inode is committing unstable writes */
#define NFS_INO_PNFS_COMMIT (8) /* use pnfs code for commit */ #define NFS_INO_PNFS_COMMIT (8) /* use pnfs code for commit */
#define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */ #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
#define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */
static inline struct nfs_inode *NFS_I(const struct inode *inode) static inline struct nfs_inode *NFS_I(const struct inode *inode)
{ {
......
...@@ -136,6 +136,8 @@ void rpc_shutdown_client(struct rpc_clnt *); ...@@ -136,6 +136,8 @@ void rpc_shutdown_client(struct rpc_clnt *);
void rpc_release_client(struct rpc_clnt *); void rpc_release_client(struct rpc_clnt *);
void rpc_task_release_client(struct rpc_task *); void rpc_task_release_client(struct rpc_task *);
int rpcb_create_local(void);
void rpcb_put_local(void);
int rpcb_register(u32, u32, int, unsigned short); int rpcb_register(u32, u32, int, unsigned short);
int rpcb_v4_register(const u32 program, const u32 version, int rpcb_v4_register(const u32 program, const u32 version,
const struct sockaddr *address, const struct sockaddr *address,
......
...@@ -413,6 +413,7 @@ struct svc_procedure { ...@@ -413,6 +413,7 @@ struct svc_procedure {
/* /*
* Function prototypes. * Function prototypes.
*/ */
void svc_rpcb_cleanup(struct svc_serv *serv);
struct svc_serv *svc_create(struct svc_program *, unsigned int, struct svc_serv *svc_create(struct svc_program *, unsigned int,
void (*shutdown)(struct svc_serv *)); void (*shutdown)(struct svc_serv *));
struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
......
...@@ -129,6 +129,9 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) ...@@ -129,6 +129,9 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
for (i = 0; i < groups ; i++) for (i = 0; i < groups ; i++)
if (cred->uc_gids[i] != GROUP_AT(acred->group_info, i)) if (cred->uc_gids[i] != GROUP_AT(acred->group_info, i))
return 0; return 0;
if (groups < NFS_NGROUPS &&
cred->uc_gids[groups] != NOGROUP)
return 0;
return 1; return 1;
} }
......
...@@ -114,6 +114,9 @@ static struct rpc_program rpcb_program; ...@@ -114,6 +114,9 @@ static struct rpc_program rpcb_program;
static struct rpc_clnt * rpcb_local_clnt; static struct rpc_clnt * rpcb_local_clnt;
static struct rpc_clnt * rpcb_local_clnt4; static struct rpc_clnt * rpcb_local_clnt4;
DEFINE_SPINLOCK(rpcb_clnt_lock);
unsigned int rpcb_users;
struct rpcbind_args { struct rpcbind_args {
struct rpc_xprt * r_xprt; struct rpc_xprt * r_xprt;
...@@ -161,6 +164,56 @@ static void rpcb_map_release(void *data) ...@@ -161,6 +164,56 @@ static void rpcb_map_release(void *data)
kfree(map); kfree(map);
} }
static int rpcb_get_local(void)
{
int cnt;
spin_lock(&rpcb_clnt_lock);
if (rpcb_users)
rpcb_users++;
cnt = rpcb_users;
spin_unlock(&rpcb_clnt_lock);
return cnt;
}
void rpcb_put_local(void)
{
struct rpc_clnt *clnt = rpcb_local_clnt;
struct rpc_clnt *clnt4 = rpcb_local_clnt4;
int shutdown;
spin_lock(&rpcb_clnt_lock);
if (--rpcb_users == 0) {
rpcb_local_clnt = NULL;
rpcb_local_clnt4 = NULL;
}
shutdown = !rpcb_users;
spin_unlock(&rpcb_clnt_lock);
if (shutdown) {
/*
* cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
*/
if (clnt4)
rpc_shutdown_client(clnt4);
if (clnt)
rpc_shutdown_client(clnt);
}
}
static void rpcb_set_local(struct rpc_clnt *clnt, struct rpc_clnt *clnt4)
{
/* Protected by rpcb_create_local_mutex */
rpcb_local_clnt = clnt;
rpcb_local_clnt4 = clnt4;
smp_wmb();
rpcb_users = 1;
dprintk("RPC: created new rpcb local clients (rpcb_local_clnt: "
"%p, rpcb_local_clnt4: %p)\n", rpcb_local_clnt,
rpcb_local_clnt4);
}
/* /*
* Returns zero on success, otherwise a negative errno value * Returns zero on success, otherwise a negative errno value
* is returned. * is returned.
...@@ -205,9 +258,7 @@ static int rpcb_create_local_unix(void) ...@@ -205,9 +258,7 @@ static int rpcb_create_local_unix(void)
clnt4 = NULL; clnt4 = NULL;
} }
/* Protected by rpcb_create_local_mutex */ rpcb_set_local(clnt, clnt4);
rpcb_local_clnt = clnt;
rpcb_local_clnt4 = clnt4;
out: out:
return result; return result;
...@@ -259,9 +310,7 @@ static int rpcb_create_local_net(void) ...@@ -259,9 +310,7 @@ static int rpcb_create_local_net(void)
clnt4 = NULL; clnt4 = NULL;
} }
/* Protected by rpcb_create_local_mutex */ rpcb_set_local(clnt, clnt4);
rpcb_local_clnt = clnt;
rpcb_local_clnt4 = clnt4;
out: out:
return result; return result;
...@@ -271,16 +320,16 @@ static int rpcb_create_local_net(void) ...@@ -271,16 +320,16 @@ static int rpcb_create_local_net(void)
* Returns zero on success, otherwise a negative errno value * Returns zero on success, otherwise a negative errno value
* is returned. * is returned.
*/ */
static int rpcb_create_local(void) int rpcb_create_local(void)
{ {
static DEFINE_MUTEX(rpcb_create_local_mutex); static DEFINE_MUTEX(rpcb_create_local_mutex);
int result = 0; int result = 0;
if (rpcb_local_clnt) if (rpcb_get_local())
return result; return result;
mutex_lock(&rpcb_create_local_mutex); mutex_lock(&rpcb_create_local_mutex);
if (rpcb_local_clnt) if (rpcb_get_local())
goto out; goto out;
if (rpcb_create_local_unix() != 0) if (rpcb_create_local_unix() != 0)
...@@ -382,11 +431,6 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) ...@@ -382,11 +431,6 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
struct rpc_message msg = { struct rpc_message msg = {
.rpc_argp = &map, .rpc_argp = &map,
}; };
int error;
error = rpcb_create_local();
if (error)
return error;
dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
"rpcbind\n", (port ? "" : "un"), "rpcbind\n", (port ? "" : "un"),
...@@ -522,11 +566,7 @@ int rpcb_v4_register(const u32 program, const u32 version, ...@@ -522,11 +566,7 @@ int rpcb_v4_register(const u32 program, const u32 version,
struct rpc_message msg = { struct rpc_message msg = {
.rpc_argp = &map, .rpc_argp = &map,
}; };
int error;
error = rpcb_create_local();
if (error)
return error;
if (rpcb_local_clnt4 == NULL) if (rpcb_local_clnt4 == NULL)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
...@@ -1060,15 +1100,3 @@ static struct rpc_program rpcb_program = { ...@@ -1060,15 +1100,3 @@ static struct rpc_program rpcb_program = {
.version = rpcb_version, .version = rpcb_version,
.stats = &rpcb_stats, .stats = &rpcb_stats,
}; };
/**
* cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
*
*/
void cleanup_rpcb_clnt(void)
{
if (rpcb_local_clnt4)
rpc_shutdown_client(rpcb_local_clnt4);
if (rpcb_local_clnt)
rpc_shutdown_client(rpcb_local_clnt);
}
...@@ -61,8 +61,6 @@ static struct pernet_operations sunrpc_net_ops = { ...@@ -61,8 +61,6 @@ static struct pernet_operations sunrpc_net_ops = {
extern struct cache_detail unix_gid_cache; extern struct cache_detail unix_gid_cache;
extern void cleanup_rpcb_clnt(void);
static int __init static int __init
init_sunrpc(void) init_sunrpc(void)
{ {
...@@ -102,7 +100,6 @@ init_sunrpc(void) ...@@ -102,7 +100,6 @@ init_sunrpc(void)
static void __exit static void __exit
cleanup_sunrpc(void) cleanup_sunrpc(void)
{ {
cleanup_rpcb_clnt();
rpcauth_remove_module(); rpcauth_remove_module();
cleanup_socket_xprt(); cleanup_socket_xprt();
svc_cleanup_xprt_sock(); svc_cleanup_xprt_sock();
......
...@@ -366,6 +366,42 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu) ...@@ -366,6 +366,42 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)
return &serv->sv_pools[pidx % serv->sv_nrpools]; return &serv->sv_pools[pidx % serv->sv_nrpools];
} }
static int svc_rpcb_setup(struct svc_serv *serv)
{
int err;
err = rpcb_create_local();
if (err)
return err;
/* Remove any stale portmap registrations */
svc_unregister(serv);
return 0;
}
void svc_rpcb_cleanup(struct svc_serv *serv)
{
svc_unregister(serv);
rpcb_put_local();
}
EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
static int svc_uses_rpcbind(struct svc_serv *serv)
{
struct svc_program *progp;
unsigned int i;
for (progp = serv->sv_program; progp; progp = progp->pg_next) {
for (i = 0; i < progp->pg_nvers; i++) {
if (progp->pg_vers[i] == NULL)
continue;
if (progp->pg_vers[i]->vs_hidden == 0)
return 1;
}
}
return 0;
}
/* /*
* Create an RPC service * Create an RPC service
...@@ -431,8 +467,15 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, ...@@ -431,8 +467,15 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
spin_lock_init(&pool->sp_lock); spin_lock_init(&pool->sp_lock);
} }
/* Remove any stale portmap registrations */ if (svc_uses_rpcbind(serv)) {
svc_unregister(serv); if (svc_rpcb_setup(serv) < 0) {
kfree(serv->sv_pools);
kfree(serv);
return NULL;
}
if (!serv->sv_shutdown)
serv->sv_shutdown = svc_rpcb_cleanup;
}
return serv; return serv;
} }
...@@ -500,7 +543,6 @@ svc_destroy(struct svc_serv *serv) ...@@ -500,7 +543,6 @@ svc_destroy(struct svc_serv *serv)
if (svc_serv_is_pooled(serv)) if (svc_serv_is_pooled(serv))
svc_pool_map_put(); svc_pool_map_put();
svc_unregister(serv);
kfree(serv->sv_pools); kfree(serv->sv_pools);
kfree(serv); kfree(serv);
} }
......
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