2009-04-01 21:23:00 +08:00
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
(c) 2007 Network Appliance, Inc. All Rights Reserved.
|
|
|
|
(c) 2009 NetApp. All Rights Reserved.
|
|
|
|
|
|
|
|
NetApp provides this source code under the GPL v2 License.
|
|
|
|
The GPL v2 license is available at
|
2020-07-08 03:50:12 +08:00
|
|
|
https://opensource.org/licenses/gpl-license.php.
|
2009-04-01 21:23:00 +08:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include <linux/tcp.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-04-01 21:23:00 +08:00
|
|
|
#include <linux/sunrpc/xprt.h>
|
2011-07-15 23:47:34 +08:00
|
|
|
#include <linux/export.h>
|
2012-03-12 03:22:54 +08:00
|
|
|
#include <linux/sunrpc/bc_xprt.h>
|
2009-04-01 21:23:00 +08:00
|
|
|
|
2014-11-18 05:58:04 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
|
2009-04-01 21:23:00 +08:00
|
|
|
#define RPCDBG_FACILITY RPCDBG_TRANS
|
|
|
|
#endif
|
|
|
|
|
2019-07-17 01:51:29 +08:00
|
|
|
#define BC_MAX_SLOTS 64U
|
|
|
|
|
|
|
|
unsigned int xprt_bc_max_slots(struct rpc_xprt *xprt)
|
|
|
|
{
|
|
|
|
return BC_MAX_SLOTS;
|
|
|
|
}
|
|
|
|
|
2009-04-01 21:23:00 +08:00
|
|
|
/*
|
|
|
|
* Helper routines that track the number of preallocation elements
|
|
|
|
* on the transport.
|
|
|
|
*/
|
|
|
|
static inline int xprt_need_to_requeue(struct rpc_xprt *xprt)
|
|
|
|
{
|
2019-07-17 01:51:29 +08:00
|
|
|
return xprt->bc_alloc_count < xprt->bc_alloc_max;
|
2009-04-01 21:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the preallocated rpc_rqst structure and the memory
|
|
|
|
* buffers hanging off of it.
|
|
|
|
*/
|
|
|
|
static void xprt_free_allocation(struct rpc_rqst *req)
|
|
|
|
{
|
|
|
|
struct xdr_buf *xbufp;
|
|
|
|
|
|
|
|
dprintk("RPC: free allocations for req= %p\n", req);
|
2012-10-23 22:43:33 +08:00
|
|
|
WARN_ON_ONCE(test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state));
|
2015-06-02 03:10:25 +08:00
|
|
|
xbufp = &req->rq_rcv_buf;
|
2009-04-01 21:23:00 +08:00
|
|
|
free_page((unsigned long)xbufp->head[0].iov_base);
|
|
|
|
xbufp = &req->rq_snd_buf;
|
|
|
|
free_page((unsigned long)xbufp->head[0].iov_base);
|
|
|
|
kfree(req);
|
|
|
|
}
|
|
|
|
|
2015-06-02 03:05:38 +08:00
|
|
|
static int xprt_alloc_xdr_buf(struct xdr_buf *buf, gfp_t gfp_flags)
|
|
|
|
{
|
|
|
|
struct page *page;
|
|
|
|
/* Preallocate one XDR receive buffer */
|
|
|
|
page = alloc_page(gfp_flags);
|
|
|
|
if (page == NULL)
|
|
|
|
return -ENOMEM;
|
2016-09-15 22:55:12 +08:00
|
|
|
xdr_buf_init(buf, page_address(page), PAGE_SIZE);
|
2015-06-02 03:05:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
struct rpc_rqst *xprt_alloc_bc_req(struct rpc_xprt *xprt, gfp_t gfp_flags)
|
|
|
|
{
|
|
|
|
struct rpc_rqst *req;
|
|
|
|
|
|
|
|
/* Pre-allocate one backchannel rpc_rqst */
|
|
|
|
req = kzalloc(sizeof(*req), gfp_flags);
|
|
|
|
if (req == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
req->rq_xprt = xprt;
|
|
|
|
INIT_LIST_HEAD(&req->rq_bc_list);
|
|
|
|
|
|
|
|
/* Preallocate one XDR receive buffer */
|
|
|
|
if (xprt_alloc_xdr_buf(&req->rq_rcv_buf, gfp_flags) < 0) {
|
|
|
|
printk(KERN_ERR "Failed to create bc receive xbuf\n");
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
req->rq_rcv_buf.len = PAGE_SIZE;
|
|
|
|
|
|
|
|
/* Preallocate one XDR send buffer */
|
|
|
|
if (xprt_alloc_xdr_buf(&req->rq_snd_buf, gfp_flags) < 0) {
|
|
|
|
printk(KERN_ERR "Failed to create bc snd xbuf\n");
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
out_free:
|
|
|
|
xprt_free_allocation(req);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-01 21:23:00 +08:00
|
|
|
/*
|
|
|
|
* Preallocate up to min_reqs structures and related buffers for use
|
|
|
|
* by the backchannel. This function can be called multiple times
|
|
|
|
* when creating new sessions that use the same rpc_xprt. The
|
|
|
|
* preallocated buffers are added to the pool of resources used by
|
2020-08-23 09:07:38 +08:00
|
|
|
* the rpc_xprt. Any one of these resources may be used by an
|
2009-04-01 21:23:00 +08:00
|
|
|
* incoming callback request. It's up to the higher levels in the
|
|
|
|
* stack to enforce that the maximum number of session slots is not
|
|
|
|
* being exceeded.
|
|
|
|
*
|
|
|
|
* Some callback arguments can be large. For example, a pNFS server
|
|
|
|
* using multiple deviceids. The list can be unbound, but the client
|
|
|
|
* has the ability to tell the server the maximum size of the callback
|
|
|
|
* requests. Each deviceID is 16 bytes, so allocate one page
|
|
|
|
* for the arguments to have enough room to receive a number of these
|
|
|
|
* deviceIDs. The NFS client indicates to the pNFS server that its
|
|
|
|
* callback requests can be up to 4096 bytes in size.
|
|
|
|
*/
|
|
|
|
int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
|
2015-10-25 05:27:35 +08:00
|
|
|
{
|
|
|
|
if (!xprt->ops->bc_setup)
|
|
|
|
return 0;
|
|
|
|
return xprt->ops->bc_setup(xprt, min_reqs);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(xprt_setup_backchannel);
|
|
|
|
|
|
|
|
int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
|
2009-04-01 21:23:00 +08:00
|
|
|
{
|
2015-06-02 03:05:38 +08:00
|
|
|
struct rpc_rqst *req;
|
2009-04-01 21:23:00 +08:00
|
|
|
struct list_head tmp_list;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dprintk("RPC: setup backchannel transport\n");
|
|
|
|
|
2019-07-17 01:51:29 +08:00
|
|
|
if (min_reqs > BC_MAX_SLOTS)
|
|
|
|
min_reqs = BC_MAX_SLOTS;
|
|
|
|
|
2009-04-01 21:23:00 +08:00
|
|
|
/*
|
|
|
|
* We use a temporary list to keep track of the preallocated
|
|
|
|
* buffers. Once we're done building the list we splice it
|
|
|
|
* into the backchannel preallocation list off of the rpc_xprt
|
|
|
|
* struct. This helps minimize the amount of time the list
|
|
|
|
* lock is held on the rpc_xprt struct. It also makes cleanup
|
|
|
|
* easier in case of memory allocation errors.
|
|
|
|
*/
|
|
|
|
INIT_LIST_HEAD(&tmp_list);
|
|
|
|
for (i = 0; i < min_reqs; i++) {
|
|
|
|
/* Pre-allocate one backchannel rpc_rqst */
|
2015-06-02 03:05:38 +08:00
|
|
|
req = xprt_alloc_bc_req(xprt, GFP_KERNEL);
|
2009-04-01 21:23:00 +08:00
|
|
|
if (req == NULL) {
|
|
|
|
printk(KERN_ERR "Failed to create bc rpc_rqst\n");
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the allocated buffer to the tmp list */
|
|
|
|
dprintk("RPC: adding req= %p\n", req);
|
|
|
|
list_add(&req->rq_bc_pa_list, &tmp_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the temporary list to the backchannel preallocation list
|
|
|
|
*/
|
2017-08-17 00:09:44 +08:00
|
|
|
spin_lock(&xprt->bc_pa_lock);
|
2009-04-01 21:23:00 +08:00
|
|
|
list_splice(&tmp_list, &xprt->bc_pa_list);
|
2019-07-17 01:51:29 +08:00
|
|
|
xprt->bc_alloc_count += min_reqs;
|
|
|
|
xprt->bc_alloc_max += min_reqs;
|
|
|
|
atomic_add(min_reqs, &xprt->bc_slot_count);
|
2017-08-17 00:09:44 +08:00
|
|
|
spin_unlock(&xprt->bc_pa_lock);
|
2009-04-01 21:23:00 +08:00
|
|
|
|
|
|
|
dprintk("RPC: setup backchannel transport done\n");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free:
|
|
|
|
/*
|
|
|
|
* Memory allocation failed, free the temporary list
|
|
|
|
*/
|
2015-06-02 03:05:38 +08:00
|
|
|
while (!list_empty(&tmp_list)) {
|
|
|
|
req = list_first_entry(&tmp_list,
|
|
|
|
struct rpc_rqst,
|
|
|
|
rq_bc_pa_list);
|
2014-02-12 02:56:54 +08:00
|
|
|
list_del(&req->rq_bc_pa_list);
|
2009-04-01 21:23:00 +08:00
|
|
|
xprt_free_allocation(req);
|
2014-02-12 02:56:54 +08:00
|
|
|
}
|
2009-04-01 21:23:00 +08:00
|
|
|
|
|
|
|
dprintk("RPC: setup backchannel transport failed\n");
|
2012-11-01 23:21:53 +08:00
|
|
|
return -ENOMEM;
|
2009-04-01 21:23:00 +08:00
|
|
|
}
|
|
|
|
|
2012-07-10 18:55:09 +08:00
|
|
|
/**
|
|
|
|
* xprt_destroy_backchannel - Destroys the backchannel preallocated structures.
|
|
|
|
* @xprt: the transport holding the preallocated strucures
|
2018-12-20 00:00:22 +08:00
|
|
|
* @max_reqs: the maximum number of preallocated structures to destroy
|
2012-07-10 18:55:09 +08:00
|
|
|
*
|
2009-04-01 21:23:00 +08:00
|
|
|
* Since these structures may have been allocated by multiple calls
|
|
|
|
* to xprt_setup_backchannel, we only destroy up to the maximum number
|
|
|
|
* of reqs specified by the caller.
|
|
|
|
*/
|
|
|
|
void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
|
2015-10-25 05:27:35 +08:00
|
|
|
{
|
|
|
|
if (xprt->ops->bc_destroy)
|
|
|
|
xprt->ops->bc_destroy(xprt, max_reqs);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(xprt_destroy_backchannel);
|
|
|
|
|
|
|
|
void xprt_destroy_bc(struct rpc_xprt *xprt, unsigned int max_reqs)
|
2009-04-01 21:23:00 +08:00
|
|
|
{
|
|
|
|
struct rpc_rqst *req = NULL, *tmp = NULL;
|
|
|
|
|
|
|
|
dprintk("RPC: destroy backchannel transport\n");
|
|
|
|
|
2012-10-23 22:43:34 +08:00
|
|
|
if (max_reqs == 0)
|
|
|
|
goto out;
|
|
|
|
|
2009-04-01 21:23:00 +08:00
|
|
|
spin_lock_bh(&xprt->bc_pa_lock);
|
2019-10-17 21:02:21 +08:00
|
|
|
xprt->bc_alloc_max -= min(max_reqs, xprt->bc_alloc_max);
|
2009-04-01 21:23:00 +08:00
|
|
|
list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) {
|
|
|
|
dprintk("RPC: req=%p\n", req);
|
2014-02-12 02:56:54 +08:00
|
|
|
list_del(&req->rq_bc_pa_list);
|
2009-04-01 21:23:00 +08:00
|
|
|
xprt_free_allocation(req);
|
2019-07-17 01:51:29 +08:00
|
|
|
xprt->bc_alloc_count--;
|
|
|
|
atomic_dec(&xprt->bc_slot_count);
|
2009-04-01 21:23:00 +08:00
|
|
|
if (--max_reqs == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&xprt->bc_pa_lock);
|
|
|
|
|
2012-10-23 22:43:34 +08:00
|
|
|
out:
|
2009-04-01 21:23:00 +08:00
|
|
|
dprintk("RPC: backchannel list empty= %s\n",
|
|
|
|
list_empty(&xprt->bc_pa_list) ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2019-03-03 02:12:22 +08:00
|
|
|
static struct rpc_rqst *xprt_get_bc_request(struct rpc_xprt *xprt, __be32 xid,
|
|
|
|
struct rpc_rqst *new)
|
2009-04-01 21:23:00 +08:00
|
|
|
{
|
2014-02-11 00:18:39 +08:00
|
|
|
struct rpc_rqst *req = NULL;
|
2009-04-01 21:23:00 +08:00
|
|
|
|
|
|
|
dprintk("RPC: allocate a backchannel request\n");
|
2015-06-05 03:37:10 +08:00
|
|
|
if (list_empty(&xprt->bc_pa_list)) {
|
2019-03-03 02:12:22 +08:00
|
|
|
if (!new)
|
2015-06-05 03:37:10 +08:00
|
|
|
goto not_found;
|
2019-07-17 01:51:29 +08:00
|
|
|
if (atomic_read(&xprt->bc_slot_count) >= BC_MAX_SLOTS)
|
|
|
|
goto not_found;
|
2019-03-03 02:12:22 +08:00
|
|
|
list_add_tail(&new->rq_bc_pa_list, &xprt->bc_pa_list);
|
2015-07-23 04:31:17 +08:00
|
|
|
xprt->bc_alloc_count++;
|
2019-07-17 01:51:29 +08:00
|
|
|
atomic_inc(&xprt->bc_slot_count);
|
2015-06-05 03:37:10 +08:00
|
|
|
}
|
2014-02-11 00:18:39 +08:00
|
|
|
req = list_first_entry(&xprt->bc_pa_list, struct rpc_rqst,
|
|
|
|
rq_bc_pa_list);
|
|
|
|
req->rq_reply_bytes_recvd = 0;
|
|
|
|
memcpy(&req->rq_private_buf, &req->rq_rcv_buf,
|
2009-04-01 21:23:00 +08:00
|
|
|
sizeof(req->rq_private_buf));
|
2014-02-11 00:18:39 +08:00
|
|
|
req->rq_xid = xid;
|
|
|
|
req->rq_connect_cookie = xprt->connect_cookie;
|
2009-04-01 21:23:00 +08:00
|
|
|
dprintk("RPC: backchannel req=%p\n", req);
|
2019-03-03 02:12:22 +08:00
|
|
|
not_found:
|
2009-04-01 21:23:00 +08:00
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the preallocated rpc_rqst structure and XDR buffers
|
|
|
|
* associated with this rpc_task.
|
|
|
|
*/
|
|
|
|
void xprt_free_bc_request(struct rpc_rqst *req)
|
|
|
|
{
|
|
|
|
struct rpc_xprt *xprt = req->rq_xprt;
|
|
|
|
|
2015-10-25 05:27:35 +08:00
|
|
|
xprt->ops->bc_free_rqst(req);
|
|
|
|
}
|
|
|
|
|
|
|
|
void xprt_free_bc_rqst(struct rpc_rqst *req)
|
|
|
|
{
|
|
|
|
struct rpc_xprt *xprt = req->rq_xprt;
|
|
|
|
|
2009-04-01 21:23:00 +08:00
|
|
|
dprintk("RPC: free backchannel req=%p\n", req);
|
|
|
|
|
2014-02-11 00:18:39 +08:00
|
|
|
req->rq_connect_cookie = xprt->connect_cookie - 1;
|
2014-03-18 01:06:10 +08:00
|
|
|
smp_mb__before_atomic();
|
2009-04-01 21:23:00 +08:00
|
|
|
clear_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
|
2014-03-18 01:06:10 +08:00
|
|
|
smp_mb__after_atomic();
|
2009-04-01 21:23:00 +08:00
|
|
|
|
2015-06-05 03:37:10 +08:00
|
|
|
/*
|
|
|
|
* Return it to the list of preallocations so that it
|
|
|
|
* may be reused by a new callback request.
|
|
|
|
*/
|
|
|
|
spin_lock_bh(&xprt->bc_pa_lock);
|
|
|
|
if (xprt_need_to_requeue(xprt)) {
|
|
|
|
list_add_tail(&req->rq_bc_pa_list, &xprt->bc_pa_list);
|
|
|
|
xprt->bc_alloc_count++;
|
2019-07-17 01:51:29 +08:00
|
|
|
atomic_inc(&xprt->bc_slot_count);
|
2015-06-05 03:37:10 +08:00
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&xprt->bc_pa_lock);
|
|
|
|
if (req != NULL) {
|
2009-04-01 21:23:00 +08:00
|
|
|
/*
|
|
|
|
* The last remaining session was destroyed while this
|
|
|
|
* entry was in use. Free the entry and don't attempt
|
|
|
|
* to add back to the list because there is no need to
|
|
|
|
* have anymore preallocated entries.
|
|
|
|
*/
|
|
|
|
dprintk("RPC: Last session removed req=%p\n", req);
|
|
|
|
xprt_free_allocation(req);
|
|
|
|
}
|
2019-10-17 21:02:19 +08:00
|
|
|
xprt_put(xprt);
|
2009-04-01 21:23:00 +08:00
|
|
|
}
|
|
|
|
|
2014-02-11 00:18:39 +08:00
|
|
|
/*
|
|
|
|
* One or more rpc_rqst structure have been preallocated during the
|
|
|
|
* backchannel setup. Buffer space for the send and private XDR buffers
|
|
|
|
* has been preallocated as well. Use xprt_alloc_bc_request to allocate
|
|
|
|
* to this request. Use xprt_free_bc_request to return it.
|
|
|
|
*
|
|
|
|
* We know that we're called in soft interrupt context, grab the spin_lock
|
|
|
|
* since there is no need to grab the bottom half spin_lock.
|
|
|
|
*
|
|
|
|
* Return an available rpc_rqst, otherwise NULL if non are available.
|
|
|
|
*/
|
|
|
|
struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid)
|
|
|
|
{
|
2019-03-03 02:12:22 +08:00
|
|
|
struct rpc_rqst *req, *new = NULL;
|
|
|
|
|
|
|
|
do {
|
|
|
|
spin_lock(&xprt->bc_pa_lock);
|
|
|
|
list_for_each_entry(req, &xprt->bc_pa_list, rq_bc_pa_list) {
|
|
|
|
if (req->rq_connect_cookie != xprt->connect_cookie)
|
|
|
|
continue;
|
|
|
|
if (req->rq_xid == xid)
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
req = xprt_get_bc_request(xprt, xid, new);
|
2014-02-11 00:18:39 +08:00
|
|
|
found:
|
2019-03-03 02:12:22 +08:00
|
|
|
spin_unlock(&xprt->bc_pa_lock);
|
|
|
|
if (new) {
|
|
|
|
if (req != new)
|
2019-10-17 21:02:19 +08:00
|
|
|
xprt_free_allocation(new);
|
2019-03-03 02:12:22 +08:00
|
|
|
break;
|
|
|
|
} else if (req)
|
|
|
|
break;
|
|
|
|
new = xprt_alloc_bc_req(xprt, GFP_KERNEL);
|
|
|
|
} while (new);
|
2014-02-11 00:18:39 +08:00
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add callback request to callback list. The callback
|
|
|
|
* service sleeps on the sv_cb_waitq waiting for new
|
|
|
|
* requests. Wake it up after adding enqueing the
|
|
|
|
* request.
|
|
|
|
*/
|
|
|
|
void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied)
|
|
|
|
{
|
|
|
|
struct rpc_xprt *xprt = req->rq_xprt;
|
|
|
|
struct svc_serv *bc_serv = xprt->bc_serv;
|
|
|
|
|
2015-02-14 02:08:25 +08:00
|
|
|
spin_lock(&xprt->bc_pa_lock);
|
|
|
|
list_del(&req->rq_bc_pa_list);
|
2019-07-17 01:51:29 +08:00
|
|
|
xprt->bc_alloc_count--;
|
2015-02-14 02:08:25 +08:00
|
|
|
spin_unlock(&xprt->bc_pa_lock);
|
|
|
|
|
2014-02-11 00:18:39 +08:00
|
|
|
req->rq_private_buf.len = copied;
|
|
|
|
set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
|
|
|
|
|
|
|
|
dprintk("RPC: add callback request to list\n");
|
2019-10-17 21:02:19 +08:00
|
|
|
xprt_get(xprt);
|
2014-02-11 00:18:39 +08:00
|
|
|
spin_lock(&bc_serv->sv_cb_lock);
|
|
|
|
list_add(&req->rq_bc_list, &bc_serv->sv_cb_list);
|
|
|
|
wake_up(&bc_serv->sv_cb_waitq);
|
|
|
|
spin_unlock(&bc_serv->sv_cb_lock);
|
|
|
|
}
|