NFS: Fix up read of mirror stats
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 3 Oct 2016 22:13:20 +0000 (18:13 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 3 Dec 2016 20:37:44 +0000 (15:37 -0500)
Need to lock while reading in order to ensure 64-bit reads are correct.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/flexfilelayout/flexfilelayout.c

index f61df164156787ddffef4c0139759e463ecb9552..c18afd5cc0bb45f0a7cd9c1ce700cf7433ba73cc 100644 (file)
@@ -2250,10 +2250,12 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
                memcpy(&devinfo->dev_id, &dev->deviceid, NFS4_DEVICEID4_SIZE);
                devinfo->offset = 0;
                devinfo->length = NFS4_MAX_UINT64;
+               spin_lock(&mirror->lock);
                devinfo->read_count = mirror->read_stat.io_stat.ops_completed;
                devinfo->read_bytes = mirror->read_stat.io_stat.bytes_completed;
                devinfo->write_count = mirror->write_stat.io_stat.ops_completed;
                devinfo->write_bytes = mirror->write_stat.io_stat.bytes_completed;
+               spin_unlock(&mirror->lock);
                devinfo->layout_type = LAYOUT_FLEX_FILES;
                devinfo->layoutstats_encode = ff_layout_encode_layoutstats;
                devinfo->layout_private = mirror;