Re: [GIT] NFS client updates for 2.6.22...

From: Geert Uytterhoeven
Date: Tue May 08 2007 - 05:37:44 EST


On Wed, 2 May 2007, Trond Myklebust wrote:
> commit c5a4dd8b7c15927a8fbff83171b57cad675a79b9
> Author: Chuck Lever <chuck.lever@xxxxxxxxxx>
> Date: Thu Mar 29 16:47:58 2007 -0400
>
> SUNRPC: Eliminate side effects from rpc_malloc
>
> Currently rpc_malloc sets req->rq_buffer internally. Make this a more
> generic interface: return a pointer to the new buffer (or NULL) and
> make the caller set req->rq_buffer and req->rq_bufsize. This looks much
> more like kmalloc and eliminates the side effects.
>
> To fix a potential deadlock, this patch also replaces GFP_NOFS with
> GFP_NOWAIT in rpc_malloc. This prevents async RPCs from sleeping outside
> the RPC's task scheduler while allocating their buffer.
>
> Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
> Signed-off-by: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>

This patch introduced the following compiler warnings:

net/sunrpc/sched.c:766: warning: format â%uâ expects type âunsigned intâ, but argument 3 has type âsize_tâ
net/sunrpc/sched.c:785: warning: format â%uâ expects type âunsigned intâ, but argument 2 has type âsize_tâ

- Use %zu to format size_t
- Kill 2 useless casts

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@xxxxxxxxxxx>

--- ps3-linux-2.6.21.orig/net/sunrpc/sched.c
+++ ps3-linux-2.6.21/net/sunrpc/sched.c
@@ -763,9 +763,9 @@ void *rpc_malloc(struct rpc_task *task,
else
buf = kmalloc(size, gfp);
*buf = size;
- dprintk("RPC: %5u allocated buffer of size %u at %p\n",
+ dprintk("RPC: %5u allocated buffer of size %zu at %p\n",
task->tk_pid, size, buf);
- return (void *) ++buf;
+ return ++buf;
}

/**
@@ -775,14 +775,14 @@ void *rpc_malloc(struct rpc_task *task,
*/
void rpc_free(void *buffer)
{
- size_t size, *buf = (size_t *) buffer;
+ size_t size, *buf = buffer;

if (!buffer)
return;
size = *buf;
buf--;

- dprintk("RPC: freeing buffer of size %u at %p\n",
+ dprintk("RPC: freeing buffer of size %zu at %p\n",
size, buf);
if (size <= RPC_BUFFER_MAXSIZE)
mempool_free(buf, rpc_buffer_mempool);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@xxxxxxxxxxx ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium