Commit 422c93c8 authored by Trond Myklebust's avatar Trond Myklebust

pNFS/flexfiles: Minor refactoring before adding iostats to layoutreturn

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 2f8220c1
...@@ -1988,7 +1988,7 @@ static int ff_layout_encode_ioerr(struct nfs4_flexfile_layout *flo, ...@@ -1988,7 +1988,7 @@ static int ff_layout_encode_ioerr(struct nfs4_flexfile_layout *flo,
} }
/* report nothing for now */ /* report nothing for now */
static void ff_layout_encode_iostats(struct nfs4_flexfile_layout *flo, static void ff_layout_encode_iostats_array(struct nfs4_flexfile_layout *flo,
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs4_layoutreturn_args *args) const struct nfs4_layoutreturn_args *args)
{ {
...@@ -2026,7 +2026,7 @@ ff_layout_encode_layoutreturn(struct xdr_stream *xdr, ...@@ -2026,7 +2026,7 @@ ff_layout_encode_layoutreturn(struct xdr_stream *xdr,
BUG_ON(!start); BUG_ON(!start);
ff_layout_encode_ioerr(flo, xdr, args, ff_opaque->data); ff_layout_encode_ioerr(flo, xdr, args, ff_opaque->data);
ff_layout_encode_iostats(flo, xdr, args); ff_layout_encode_iostats_array(flo, xdr, args);
*start = cpu_to_be32((xdr->p - start - 1) * 4); *start = cpu_to_be32((xdr->p - start - 1) * 4);
dprintk("%s: Return\n", __func__); dprintk("%s: Return\n", __func__);
...@@ -2191,21 +2191,18 @@ ff_layout_encode_io_latency(struct xdr_stream *xdr, ...@@ -2191,21 +2191,18 @@ ff_layout_encode_io_latency(struct xdr_stream *xdr,
} }
static void static void
ff_layout_encode_layoutstats(struct xdr_stream *xdr, ff_layout_encode_ff_layoutupdate(struct xdr_stream *xdr,
struct nfs42_layoutstat_args *args, const struct nfs42_layoutstat_devinfo *devinfo,
struct nfs42_layoutstat_devinfo *devinfo) struct nfs4_ff_layout_mirror *mirror)
{ {
struct nfs4_ff_layout_mirror *mirror = devinfo->layout_private;
struct nfs4_pnfs_ds_addr *da; struct nfs4_pnfs_ds_addr *da;
struct nfs4_pnfs_ds *ds = mirror->mirror_ds->ds; struct nfs4_pnfs_ds *ds = mirror->mirror_ds->ds;
struct nfs_fh *fh = &mirror->fh_versions[0]; struct nfs_fh *fh = &mirror->fh_versions[0];
__be32 *p, *start; __be32 *p;
da = list_first_entry(&ds->ds_addrs, struct nfs4_pnfs_ds_addr, da_node); da = list_first_entry(&ds->ds_addrs, struct nfs4_pnfs_ds_addr, da_node);
dprintk("%s: DS %s: encoding address %s\n", dprintk("%s: DS %s: encoding address %s\n",
__func__, ds->ds_remotestr, da->da_remotestr); __func__, ds->ds_remotestr, da->da_remotestr);
/* layoutupdate length */
start = xdr_reserve_space(xdr, 4);
/* netaddr4 */ /* netaddr4 */
ff_layout_encode_netaddr(xdr, da); ff_layout_encode_netaddr(xdr, da);
/* nfs_fh4 */ /* nfs_fh4 */
...@@ -2222,10 +2219,36 @@ ff_layout_encode_layoutstats(struct xdr_stream *xdr, ...@@ -2222,10 +2219,36 @@ ff_layout_encode_layoutstats(struct xdr_stream *xdr,
/* bool */ /* bool */
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
*p = cpu_to_be32(false); *p = cpu_to_be32(false);
}
static void
ff_layout_encode_layoutstats(struct xdr_stream *xdr, const void *args,
const struct nfs4_xdr_opaque_data *opaque)
{
struct nfs42_layoutstat_devinfo *devinfo = container_of(opaque,
struct nfs42_layoutstat_devinfo, ld_private);
__be32 *start;
/* layoutupdate length */
start = xdr_reserve_space(xdr, 4);
ff_layout_encode_ff_layoutupdate(xdr, devinfo, opaque->data);
*start = cpu_to_be32((xdr->p - start - 1) * 4); *start = cpu_to_be32((xdr->p - start - 1) * 4);
} }
static void
ff_layout_free_layoutstats(struct nfs4_xdr_opaque_data *opaque)
{
struct nfs4_ff_layout_mirror *mirror = opaque->data;
ff_layout_put_mirror(mirror);
}
static const struct nfs4_xdr_opaque_ops layoutstat_ops = {
.encode = ff_layout_encode_layoutstats,
.free = ff_layout_free_layoutstats,
};
static int static int
ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo, ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
struct nfs42_layoutstat_devinfo *devinfo, struct nfs42_layoutstat_devinfo *devinfo,
...@@ -2257,8 +2280,8 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo, ...@@ -2257,8 +2280,8 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
devinfo->write_bytes = mirror->write_stat.io_stat.bytes_completed; devinfo->write_bytes = mirror->write_stat.io_stat.bytes_completed;
spin_unlock(&mirror->lock); spin_unlock(&mirror->lock);
devinfo->layout_type = LAYOUT_FLEX_FILES; devinfo->layout_type = LAYOUT_FLEX_FILES;
devinfo->layoutstats_encode = ff_layout_encode_layoutstats; devinfo->ld_private.ops = &layoutstat_ops;
devinfo->layout_private = mirror; devinfo->ld_private.data = mirror;
devinfo++; devinfo++;
i++; i++;
...@@ -2291,19 +2314,6 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args) ...@@ -2291,19 +2314,6 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
return 0; return 0;
} }
static void
ff_layout_cleanup_layoutstats(struct nfs42_layoutstat_data *data)
{
struct nfs4_ff_layout_mirror *mirror;
int i;
for (i = 0; i < data->args.num_dev; i++) {
mirror = data->args.devinfo[i].layout_private;
data->args.devinfo[i].layout_private = NULL;
ff_layout_put_mirror(mirror);
}
}
static struct pnfs_layoutdriver_type flexfilelayout_type = { static struct pnfs_layoutdriver_type flexfilelayout_type = {
.id = LAYOUT_FLEX_FILES, .id = LAYOUT_FLEX_FILES,
.name = "LAYOUT_FLEX_FILES", .name = "LAYOUT_FLEX_FILES",
...@@ -2328,7 +2338,6 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = { ...@@ -2328,7 +2338,6 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
.prepare_layoutreturn = ff_layout_prepare_layoutreturn, .prepare_layoutreturn = ff_layout_prepare_layoutreturn,
.sync = pnfs_nfs_generic_sync, .sync = pnfs_nfs_generic_sync,
.prepare_layoutstats = ff_layout_prepare_layoutstats, .prepare_layoutstats = ff_layout_prepare_layoutstats,
.cleanup_layoutstats = ff_layout_cleanup_layoutstats,
}; };
static int __init nfs4flexfilelayout_init(void) static int __init nfs4flexfilelayout_init(void)
......
...@@ -397,10 +397,13 @@ static void ...@@ -397,10 +397,13 @@ static void
nfs42_layoutstat_release(void *calldata) nfs42_layoutstat_release(void *calldata)
{ {
struct nfs42_layoutstat_data *data = calldata; struct nfs42_layoutstat_data *data = calldata;
struct nfs_server *nfss = NFS_SERVER(data->args.inode); struct nfs42_layoutstat_devinfo *devinfo = data->args.devinfo;
int i;
if (nfss->pnfs_curr_ld->cleanup_layoutstats) for (i = 0; i < data->args.num_dev; i++) {
nfss->pnfs_curr_ld->cleanup_layoutstats(data); if (devinfo[i].ld_private.ops && devinfo[i].ld_private.ops->free)
devinfo[i].ld_private.ops->free(&devinfo[i].ld_private);
}
pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout); pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout);
smp_mb__before_atomic(); smp_mb__before_atomic();
......
...@@ -181,8 +181,9 @@ static void encode_layoutstats(struct xdr_stream *xdr, ...@@ -181,8 +181,9 @@ static void encode_layoutstats(struct xdr_stream *xdr,
NFS4_DEVICEID4_SIZE); NFS4_DEVICEID4_SIZE);
/* Encode layoutupdate4 */ /* Encode layoutupdate4 */
*p++ = cpu_to_be32(devinfo->layout_type); *p++ = cpu_to_be32(devinfo->layout_type);
if (devinfo->layoutstats_encode != NULL) if (devinfo->ld_private.ops)
devinfo->layoutstats_encode(xdr, args, devinfo); devinfo->ld_private.ops->encode(xdr, args,
&devinfo->ld_private);
else else
encode_uint32(xdr, 0); encode_uint32(xdr, 0);
} }
......
...@@ -182,7 +182,6 @@ struct pnfs_layoutdriver_type { ...@@ -182,7 +182,6 @@ struct pnfs_layoutdriver_type {
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs4_layoutcommit_args *args); const struct nfs4_layoutcommit_args *args);
int (*prepare_layoutstats) (struct nfs42_layoutstat_args *args); int (*prepare_layoutstats) (struct nfs42_layoutstat_args *args);
void (*cleanup_layoutstats) (struct nfs42_layoutstat_data *data);
}; };
struct pnfs_layout_hdr { struct pnfs_layout_hdr {
......
...@@ -357,8 +357,7 @@ struct nfs42_layoutstat_devinfo { ...@@ -357,8 +357,7 @@ struct nfs42_layoutstat_devinfo {
__u64 write_count; __u64 write_count;
__u64 write_bytes; __u64 write_bytes;
__u32 layout_type; __u32 layout_type;
layoutstats_encode_t layoutstats_encode; struct nfs4_xdr_opaque_data ld_private;
void *layout_private;
}; };
struct nfs42_layoutstat_args { struct nfs42_layoutstat_args {
......
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