NFSv4.1 add nfs_inode book keeping for mdsthreshold
authorAndy Adamson <andros@netapp.com>
Thu, 24 May 2012 17:13:24 +0000 (13:13 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 24 May 2012 20:15:48 +0000 (16:15 -0400)
Keep track of the number of bytes read or written via buffered, direct, and
mem-mapped i/o for use by mdsthreshold size_io hints.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/direct.c
fs/nfs/file.c
fs/nfs/inode.c
fs/nfs/pnfs.c
fs/nfs/read.c
include/linux/nfs_fs.h

index c47a46eaf9057be136cab8b97346462b085bcc95..23d170bc44f4b88bea2016983bb7fa7daa2a0ae5 100644 (file)
@@ -447,6 +447,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov,
        result = nfs_direct_read_schedule_iovec(dreq, iov, nr_segs, pos);
        if (!result)
                result = nfs_direct_wait(dreq);
+       NFS_I(inode)->read_io += result;
 out_release:
        nfs_direct_req_release(dreq);
 out:
@@ -785,6 +786,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
                pos += vec->iov_len;
        }
        nfs_pageio_complete(&desc);
+       NFS_I(dreq->inode)->write_io += desc.pg_bytes_written;
 
        /*
         * If no bytes were started, return the error, and let the
index 8eda8a6644c3d918230a80c3f78e3aed5e09b057..56311ca5f9f8183d3aa8c3aa8c9922db05ee32a3 100644 (file)
@@ -424,6 +424,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
 
        if (status < 0)
                return status;
+       NFS_I(mapping->host)->write_io += copied;
        return copied;
 }
 
index 889f7e5e92e11ef8ad98bf967568cfadd4376340..a6f5fbbe9b9c3c0e3a6d4d6851e32004d6b224e7 100644 (file)
@@ -323,6 +323,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                inode->i_gid = -2;
                inode->i_blocks = 0;
                memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
+               nfsi->write_io = 0;
+               nfsi->read_io = 0;
 
                nfsi->read_cache_jiffies = fattr->time_start;
                nfsi->attr_gencount = fattr->gencount;
index cbcb6aea58a38594e8d964812d078ffb46dc5f01..6620606f2687b427f08813377a87201199e038ad 100644 (file)
@@ -395,6 +395,9 @@ mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
        dprintk("%s:Begin lo %p\n", __func__, lo);
 
        if (list_empty(&lo->plh_segs)) {
+               /* Reset MDS Threshold I/O counters */
+               NFS_I(lo->plh_inode)->write_io = 0;
+               NFS_I(lo->plh_inode)->read_io = 0;
                if (!test_and_set_bit(NFS_LAYOUT_DESTROYED, &lo->plh_flags))
                        put_layout_hdr_locked(lo);
                return 0;
index 2cfdd778541118861a68acb6eabba9ba63318503..86ced78362142119328ad827138c0c716668aeac 100644 (file)
@@ -152,6 +152,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
        nfs_pageio_init_read(&pgio, inode, &nfs_async_read_completion_ops);
        nfs_pageio_add_request(&pgio, new);
        nfs_pageio_complete(&pgio);
+       NFS_I(inode)->read_io += pgio.pg_bytes_written;
        return 0;
 }
 
@@ -656,6 +657,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
        ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
 
        nfs_pageio_complete(&pgio);
+       NFS_I(inode)->read_io += pgio.pg_bytes_written;
        npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
        nfs_add_stats(inode, NFSIOS_READPAGES, npages);
 read_complete:
index ce910cb7d7615f544957f3182dcae57759f06b12..b23cfc120edb46c5b285de63edeff61fb03242ec 100644 (file)
@@ -202,6 +202,9 @@ struct nfs_inode {
        /* pNFS layout information */
        struct pnfs_layout_hdr *layout;
 #endif /* CONFIG_NFS_V4*/
+       /* how many bytes have been written/read and how many bytes queued up */
+       __u64 write_io;
+       __u64 read_io;
 #ifdef CONFIG_NFS_FSCACHE
        struct fscache_cookie   *fscache;
 #endif