提交 6736c047 编写于 作者: L 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
  ...
...@@ -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;
} }
......
此差异已折叠。
...@@ -156,77 +156,39 @@ last_byte_offset(u64 start, u64 len) ...@@ -156,77 +156,39 @@ last_byte_offset(u64 start, u64 len)
return end > start ? end - 1 : NFS4_MAX_UINT64; return end > start ? end - 1 : NFS4_MAX_UINT64;
} }
static struct objlayout_io_state * void _fix_verify_io_params(struct pnfs_layout_segment *lseg,
objlayout_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, struct page ***p_pages, unsigned *p_pgbase,
struct page **pages, u64 offset, unsigned long count)
unsigned pgbase,
loff_t offset,
size_t count,
struct pnfs_layout_segment *lseg,
void *rpcdata,
gfp_t gfp_flags)
{ {
struct objlayout_io_state *state;
u64 lseg_end_offset; u64 lseg_end_offset;
dprintk("%s: allocating io_state\n", __func__);
if (objio_alloc_io_state(lseg, &state, gfp_flags))
return NULL;
BUG_ON(offset < lseg->pls_range.offset); BUG_ON(offset < lseg->pls_range.offset);
lseg_end_offset = end_offset(lseg->pls_range.offset, lseg_end_offset = end_offset(lseg->pls_range.offset,
lseg->pls_range.length); lseg->pls_range.length);
BUG_ON(offset >= lseg_end_offset); BUG_ON(offset >= lseg_end_offset);
if (offset + count > lseg_end_offset) { WARN_ON(offset + count > lseg_end_offset);
count = lseg->pls_range.length -
(offset - lseg->pls_range.offset);
dprintk("%s: truncated count %Zd\n", __func__, count);
}
if (pgbase > PAGE_SIZE) { if (*p_pgbase > PAGE_SIZE) {
pages += pgbase >> PAGE_SHIFT; dprintk("%s: pgbase(0x%x) > PAGE_SIZE\n", __func__, *p_pgbase);
pgbase &= ~PAGE_MASK; *p_pages += *p_pgbase >> PAGE_SHIFT;
*p_pgbase &= ~PAGE_MASK;
} }
INIT_LIST_HEAD(&state->err_list);
state->lseg = lseg;
state->rpcdata = rpcdata;
state->pages = pages;
state->pgbase = pgbase;
state->nr_pages = (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
state->offset = offset;
state->count = count;
state->sync = 0;
return state;
}
static void
objlayout_free_io_state(struct objlayout_io_state *state)
{
dprintk("%s: freeing io_state\n", __func__);
if (unlikely(!state))
return;
objio_free_io_state(state);
} }
/* /*
* I/O done common code * I/O done common code
*/ */
static void static void
objlayout_iodone(struct objlayout_io_state *state) objlayout_iodone(struct objlayout_io_res *oir)
{ {
dprintk("%s: state %p status\n", __func__, state); if (likely(oir->status >= 0)) {
objio_free_result(oir);
if (likely(state->status >= 0)) {
objlayout_free_io_state(state);
} else { } else {
struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout); struct objlayout *objlay = oir->objlay;
spin_lock(&objlay->lock); spin_lock(&objlay->lock);
objlay->delta_space_valid = OBJ_DSU_INVALID; objlay->delta_space_valid = OBJ_DSU_INVALID;
list_add(&objlay->err_list, &state->err_list); list_add(&objlay->err_list, &oir->err_list);
spin_unlock(&objlay->lock); spin_unlock(&objlay->lock);
} }
} }
...@@ -238,13 +200,13 @@ objlayout_iodone(struct objlayout_io_state *state) ...@@ -238,13 +200,13 @@ objlayout_iodone(struct objlayout_io_state *state)
* the error for later reporting at layout-return. * the error for later reporting at layout-return.
*/ */
void void
objlayout_io_set_result(struct objlayout_io_state *state, unsigned index, objlayout_io_set_result(struct objlayout_io_res *oir, unsigned index,
struct pnfs_osd_objid *pooid, int osd_error, struct pnfs_osd_objid *pooid, int osd_error,
u64 offset, u64 length, bool is_write) u64 offset, u64 length, bool is_write)
{ {
struct pnfs_osd_ioerr *ioerr = &state->ioerrs[index]; struct pnfs_osd_ioerr *ioerr = &oir->ioerrs[index];
BUG_ON(index >= state->num_comps); BUG_ON(index >= oir->num_comps);
if (osd_error) { if (osd_error) {
ioerr->oer_component = *pooid; ioerr->oer_component = *pooid;
ioerr->oer_comp_offset = offset; ioerr->oer_comp_offset = offset;
...@@ -285,21 +247,18 @@ static void _rpc_read_complete(struct work_struct *work) ...@@ -285,21 +247,18 @@ static void _rpc_read_complete(struct work_struct *work)
} }
void void
objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync) objlayout_read_done(struct objlayout_io_res *oir, ssize_t status, bool sync)
{ {
int eof = state->eof; struct nfs_read_data *rdata = oir->rpcdata;
struct nfs_read_data *rdata;
state->status = status; oir->status = rdata->task.tk_status = status;
dprintk("%s: Begin status=%zd eof=%d\n", __func__, status, eof); if (status >= 0)
rdata = state->rpcdata;
rdata->task.tk_status = status;
if (status >= 0) {
rdata->res.count = status; rdata->res.count = status;
rdata->res.eof = eof; objlayout_iodone(oir);
} /* must not use oir after this point */
objlayout_iodone(state);
/* must not use state after this point */ dprintk("%s: Return status=%zd eof=%d sync=%d\n", __func__,
status, rdata->res.eof, sync);
if (sync) if (sync)
pnfs_ld_read_done(rdata); pnfs_ld_read_done(rdata);
...@@ -317,40 +276,36 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) ...@@ -317,40 +276,36 @@ objlayout_read_pagelist(struct nfs_read_data *rdata)
{ {
loff_t offset = rdata->args.offset; loff_t offset = rdata->args.offset;
size_t count = rdata->args.count; size_t count = rdata->args.count;
struct objlayout_io_state *state; int err;
ssize_t status = 0;
loff_t eof; loff_t eof;
dprintk("%s: Begin inode %p offset %llu count %d\n",
__func__, rdata->inode, offset, (int)count);
eof = i_size_read(rdata->inode); eof = i_size_read(rdata->inode);
if (unlikely(offset + count > eof)) { if (unlikely(offset + count > eof)) {
if (offset >= eof) { if (offset >= eof) {
status = 0; err = 0;
rdata->res.count = 0; rdata->res.count = 0;
rdata->res.eof = 1; rdata->res.eof = 1;
/*FIXME: do we need to call pnfs_ld_read_done() */
goto out; goto out;
} }
count = eof - offset; count = eof - offset;
} }
state = objlayout_alloc_io_state(NFS_I(rdata->inode)->layout, rdata->res.eof = (offset + count) >= eof;
rdata->args.pages, rdata->args.pgbase, _fix_verify_io_params(rdata->lseg, &rdata->args.pages,
offset, count, &rdata->args.pgbase,
rdata->lseg, rdata, rdata->args.offset, rdata->args.count);
GFP_KERNEL);
if (unlikely(!state)) {
status = -ENOMEM;
goto out;
}
state->eof = state->offset + state->count >= eof; dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n",
__func__, rdata->inode->i_ino, offset, count, rdata->res.eof);
status = objio_read_pagelist(state); err = objio_read_pagelist(rdata);
out: out:
dprintk("%s: Return status %Zd\n", __func__, status); if (unlikely(err)) {
rdata->pnfs_error = status; rdata->pnfs_error = err;
dprintk("%s: Returned Error %d\n", __func__, err);
return PNFS_NOT_ATTEMPTED;
}
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
} }
...@@ -371,26 +326,20 @@ static void _rpc_write_complete(struct work_struct *work) ...@@ -371,26 +326,20 @@ static void _rpc_write_complete(struct work_struct *work)
} }
void void
objlayout_write_done(struct objlayout_io_state *state, ssize_t status, objlayout_write_done(struct objlayout_io_res *oir, ssize_t status, bool sync)
bool sync)
{ {
struct nfs_write_data *wdata; struct nfs_write_data *wdata = oir->rpcdata;
dprintk("%s: Begin\n", __func__); oir->status = wdata->task.tk_status = status;
wdata = state->rpcdata;
state->status = status;
wdata->task.tk_status = status;
if (status >= 0) { if (status >= 0) {
wdata->res.count = status; wdata->res.count = status;
wdata->verf.committed = state->committed; wdata->verf.committed = oir->committed;
dprintk("%s: Return status %d committed %d\n", }
__func__, wdata->task.tk_status, objlayout_iodone(oir);
wdata->verf.committed); /* must not use oir after this point */
} else
dprintk("%s: Return status %d\n", dprintk("%s: Return status %zd committed %d sync=%d\n", __func__,
__func__, wdata->task.tk_status); status, wdata->verf.committed, sync);
objlayout_iodone(state);
/* must not use state after this point */
if (sync) if (sync)
pnfs_ld_write_done(wdata); pnfs_ld_write_done(wdata);
...@@ -407,30 +356,18 @@ enum pnfs_try_status ...@@ -407,30 +356,18 @@ enum pnfs_try_status
objlayout_write_pagelist(struct nfs_write_data *wdata, objlayout_write_pagelist(struct nfs_write_data *wdata,
int how) int how)
{ {
struct objlayout_io_state *state; int err;
ssize_t status;
dprintk("%s: Begin inode %p offset %llu count %u\n",
__func__, wdata->inode, wdata->args.offset, wdata->args.count);
state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout,
wdata->args.pages,
wdata->args.pgbase,
wdata->args.offset,
wdata->args.count,
wdata->lseg, wdata,
GFP_NOFS);
if (unlikely(!state)) {
status = -ENOMEM;
goto out;
}
state->sync = how & FLUSH_SYNC; _fix_verify_io_params(wdata->lseg, &wdata->args.pages,
&wdata->args.pgbase,
wdata->args.offset, wdata->args.count);
status = objio_write_pagelist(state, how & FLUSH_STABLE); err = objio_write_pagelist(wdata, how);
out: if (unlikely(err)) {
dprintk("%s: Return status %Zd\n", __func__, status); wdata->pnfs_error = err;
wdata->pnfs_error = status; dprintk("%s: Returned Error %d\n", __func__, err);
return PNFS_NOT_ATTEMPTED;
}
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
} }
...@@ -537,14 +474,14 @@ merge_ioerr(struct pnfs_osd_ioerr *dest_err, ...@@ -537,14 +474,14 @@ merge_ioerr(struct pnfs_osd_ioerr *dest_err,
static void static void
encode_accumulated_error(struct objlayout *objlay, __be32 *p) encode_accumulated_error(struct objlayout *objlay, __be32 *p)
{ {
struct objlayout_io_state *state, *tmp; struct objlayout_io_res *oir, *tmp;
struct pnfs_osd_ioerr accumulated_err = {.oer_errno = 0}; struct pnfs_osd_ioerr accumulated_err = {.oer_errno = 0};
list_for_each_entry_safe(state, tmp, &objlay->err_list, err_list) { list_for_each_entry_safe(oir, tmp, &objlay->err_list, err_list) {
unsigned i; unsigned i;
for (i = 0; i < state->num_comps; i++) { for (i = 0; i < oir->num_comps; i++) {
struct pnfs_osd_ioerr *ioerr = &state->ioerrs[i]; struct pnfs_osd_ioerr *ioerr = &oir->ioerrs[i];
if (!ioerr->oer_errno) if (!ioerr->oer_errno)
continue; continue;
...@@ -563,8 +500,8 @@ encode_accumulated_error(struct objlayout *objlay, __be32 *p) ...@@ -563,8 +500,8 @@ encode_accumulated_error(struct objlayout *objlay, __be32 *p)
merge_ioerr(&accumulated_err, ioerr); merge_ioerr(&accumulated_err, ioerr);
} }
list_del(&state->err_list); list_del(&oir->err_list);
objlayout_free_io_state(state); objio_free_result(oir);
} }
pnfs_osd_xdr_encode_ioerr(p, &accumulated_err); pnfs_osd_xdr_encode_ioerr(p, &accumulated_err);
...@@ -576,7 +513,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, ...@@ -576,7 +513,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay,
const struct nfs4_layoutreturn_args *args) const struct nfs4_layoutreturn_args *args)
{ {
struct objlayout *objlay = OBJLAYOUT(pnfslay); struct objlayout *objlay = OBJLAYOUT(pnfslay);
struct objlayout_io_state *state, *tmp; struct objlayout_io_res *oir, *tmp;
__be32 *start; __be32 *start;
dprintk("%s: Begin\n", __func__); dprintk("%s: Begin\n", __func__);
...@@ -585,13 +522,13 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, ...@@ -585,13 +522,13 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay,
spin_lock(&objlay->lock); spin_lock(&objlay->lock);
list_for_each_entry_safe(state, tmp, &objlay->err_list, err_list) { list_for_each_entry_safe(oir, tmp, &objlay->err_list, err_list) {
__be32 *last_xdr = NULL, *p; __be32 *last_xdr = NULL, *p;
unsigned i; unsigned i;
int res = 0; int res = 0;
for (i = 0; i < state->num_comps; i++) { for (i = 0; i < oir->num_comps; i++) {
struct pnfs_osd_ioerr *ioerr = &state->ioerrs[i]; struct pnfs_osd_ioerr *ioerr = &oir->ioerrs[i];
if (!ioerr->oer_errno) if (!ioerr->oer_errno)
continue; continue;
...@@ -615,7 +552,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, ...@@ -615,7 +552,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay,
} }
last_xdr = p; last_xdr = p;
pnfs_osd_xdr_encode_ioerr(p, &state->ioerrs[i]); pnfs_osd_xdr_encode_ioerr(p, &oir->ioerrs[i]);
} }
/* TODO: use xdr_write_pages */ /* TODO: use xdr_write_pages */
...@@ -631,8 +568,8 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, ...@@ -631,8 +568,8 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay,
encode_accumulated_error(objlay, last_xdr); encode_accumulated_error(objlay, last_xdr);
goto loop_done; goto loop_done;
} }
list_del(&state->err_list); list_del(&oir->err_list);
objlayout_free_io_state(state); objio_free_result(oir);
} }
loop_done: loop_done:
spin_unlock(&objlay->lock); spin_unlock(&objlay->lock);
......
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册