Commit 190c75a3 authored by Trond Myklebust's avatar Trond Myklebust

pNFS: Add helpers for allocation/free of struct nfs4_pnfs_ds_addr

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent a12f996d
...@@ -661,6 +661,20 @@ _data_server_lookup_locked(const struct list_head *dsaddrs) ...@@ -661,6 +661,20 @@ _data_server_lookup_locked(const struct list_head *dsaddrs)
return NULL; return NULL;
} }
static struct nfs4_pnfs_ds_addr *nfs4_pnfs_ds_addr_alloc(gfp_t gfp_flags)
{
struct nfs4_pnfs_ds_addr *da = kzalloc(sizeof(*da), gfp_flags);
if (da)
INIT_LIST_HEAD(&da->da_node);
return da;
}
static void nfs4_pnfs_ds_addr_free(struct nfs4_pnfs_ds_addr *da)
{
kfree(da->da_remotestr);
kfree(da);
}
static void destroy_ds(struct nfs4_pnfs_ds *ds) static void destroy_ds(struct nfs4_pnfs_ds *ds)
{ {
struct nfs4_pnfs_ds_addr *da; struct nfs4_pnfs_ds_addr *da;
...@@ -676,8 +690,7 @@ static void destroy_ds(struct nfs4_pnfs_ds *ds) ...@@ -676,8 +690,7 @@ static void destroy_ds(struct nfs4_pnfs_ds *ds)
struct nfs4_pnfs_ds_addr, struct nfs4_pnfs_ds_addr,
da_node); da_node);
list_del_init(&da->da_node); list_del_init(&da->da_node);
kfree(da->da_remotestr); nfs4_pnfs_ds_addr_free(da);
kfree(da);
} }
kfree(ds->ds_remotestr); kfree(ds->ds_remotestr);
...@@ -1094,12 +1107,10 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags) ...@@ -1094,12 +1107,10 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags)
} }
*portstr = '\0'; *portstr = '\0';
da = kzalloc(sizeof(*da), gfp_flags); da = nfs4_pnfs_ds_addr_alloc(gfp_flags);
if (unlikely(!da)) if (unlikely(!da))
goto out_free_buf; goto out_free_buf;
INIT_LIST_HEAD(&da->da_node);
if (!rpc_pton(net, buf, portstr-buf, (struct sockaddr *)&da->da_addr, if (!rpc_pton(net, buf, portstr-buf, (struct sockaddr *)&da->da_addr,
sizeof(da->da_addr))) { sizeof(da->da_addr))) {
dprintk("%s: error parsing address %s\n", __func__, buf); dprintk("%s: error parsing address %s\n", __func__, buf);
......
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