linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold
  2012-05-23  9:02 [PATCH 1/4] NFSv4.1 mdsthreshold attribute xdr andros
@ 2012-05-23  9:02 ` andros
  2012-05-23 18:19   ` Myklebust, Trond
  0 siblings, 1 reply; 5+ messages in thread
From: andros @ 2012-05-23  9:02 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Andy Adamson

From: Andy Adamson <andros@netapp.com>

Keep track of the number of bytes read or written, including those queued
up to be flushed. For use by mdsthreshold i/o size hints.

No locking needed as this is used as hint information.

Signed-off-by: Andy Adamson <andros@netapp.com>
---
 fs/nfs/file.c          |    8 ++++++--
 fs/nfs/inode.c         |    2 ++
 fs/nfs/pnfs.c          |    3 +++
 include/linux/nfs_fs.h |    3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 8eda8a6..c4cc096 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -203,8 +203,10 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
 	result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
 	if (!result) {
 		result = generic_file_aio_read(iocb, iov, nr_segs, pos);
-		if (result > 0)
+		if (result > 0) {
+			NFS_I(inode)->read_io += result;
 			nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result);
+		}
 	}
 	return result;
 }
@@ -613,8 +615,10 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
 		if (err < 0)
 			result = err;
 	}
-	if (result > 0)
+	if (result > 0) {
+		NFS_I(inode)->write_io += written;
 		nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
+	}
 out:
 	return result;
 
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 889f7e5..a6f5fbb 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -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;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index cbcb6ae..6620606 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -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;
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index ca4a707..c6954ac 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -201,6 +201,9 @@ struct nfs_inode {
 
 	/* pNFS layout information */
 	struct pnfs_layout_hdr *layout;
+	/* how many bytes have been written/read and how many bytes queued up */
+	__u64 write_io;
+	__u64 read_io;
 #endif /* CONFIG_NFS_V4*/
 #ifdef CONFIG_NFS_FSCACHE
 	struct fscache_cookie	*fscache;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold
  2012-05-23  9:02 ` [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold andros
@ 2012-05-23 18:19   ` Myklebust, Trond
  2012-05-23 18:41     ` Adamson, Andy
  0 siblings, 1 reply; 5+ messages in thread
From: Myklebust, Trond @ 2012-05-23 18:19 UTC (permalink / raw)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IHN0cnVjdCBuZnNfaW5vZGUgew0KPiAgDQo+ICAJLyogcE5GUyBsYXlvdXQgaW5mb3Jt
YXRpb24gKi8NCj4gIAlzdHJ1Y3QgcG5mc19sYXlvdXRfaGRyICpsYXlvdXQ7DQo+ICsJLyogaG93
IG1hbnkgYnl0ZXMgaGF2ZSBiZWVuIHdyaXR0ZW4vcmVhZCBhbmQgaG93IG1hbnkgYnl0ZXMgcXVl
dWVkIHVwICovDQo+ICsJX191NjQgd3JpdGVfaW87DQo+ICsJX191NjQgcmVhZF9pbzsNCj4gICNl
bmRpZiAvKiBDT05GSUdfTkZTX1Y0Ki8NCg0KXl5eXiBUaGlzIGRvZXNuJ3QgbG9vayBhcyBpZiBp
dCB3aWxsIGNvbXBpbGUgd2l0aG91dCBDT05GSUdfTkZTX1Y0Lg0KDQo+ICAjaWZkZWYgQ09ORklH
X05GU19GU0NBQ0hFDQo+ICAJc3RydWN0IGZzY2FjaGVfY29va2llCSpmc2NhY2hlOw0KDQotLSAN
ClRyb25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0K
VHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQoNCg==

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold
  2012-05-23 18:19   ` Myklebust, Trond
@ 2012-05-23 18:41     ` Adamson, Andy
  0 siblings, 0 replies; 5+ messages in thread
From: Adamson, Andy @ 2012-05-23 18:41 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: Adamson, Andy, linux-nfs@vger.kernel.org


On May 23, 2012, at 2:19 PM, Myklebust, Trond wrote:

> On Wed, 2012-05-23 at 05:02 -0400, andros@netapp.com wrote:
>> From: Andy Adamson <andros@netapp.com>
>> 
>> Keep track of the number of bytes read or written, including those queued
>> up to be flushed. For use by mdsthreshold i/o size hints.
>> 
>> No locking needed as this is used as hint information.
>> 
>> Signed-off-by: Andy Adamson <andros@netapp.com>
>> ---
>> fs/nfs/file.c          |    8 ++++++--
>> fs/nfs/inode.c         |    2 ++
>> fs/nfs/pnfs.c          |    3 +++
>> include/linux/nfs_fs.h |    3 +++
>> 4 files changed, 14 insertions(+), 2 deletions(-)
>> 
>> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
>> index 8eda8a6..c4cc096 100644
>> --- a/fs/nfs/file.c
>> +++ b/fs/nfs/file.c
>> @@ -203,8 +203,10 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
>> 	result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
>> 	if (!result) {
>> 		result = generic_file_aio_read(iocb, iov, nr_segs, pos);
>> -		if (result > 0)
>> +		if (result > 0) {
>> +			NFS_I(inode)->read_io += result;
> 
> Should we perhaps rather do this from nfs_readpages(), nfs_readpage()
> and nfs_direct_read()?
> 
> If we do it here in nfs_file_read, we miss mmaped reads, O_DIRECT reads,
> as well as splice reads.

Well that's not good.

> We also count read cache hits where we don't
> have to actually access the server.

OK.

> 
>> 			nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result);
>> +		}
>> 	}
>> 	return result;
>> }
>> @@ -613,8 +615,10 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
>> 		if (err < 0)
>> 			result = err;
>> 	}
>> -	if (result > 0)
>> +	if (result > 0) {
>> +		NFS_I(inode)->write_io += written;
> 
> For the same reason, perhaps we should move this to
> nfs_direct_write_schedule_iovec(), and nfs_write_end().
> 
>> 		nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
>> +	}
>> out:
>> 	return result;
>> 
>> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
>> index 889f7e5..a6f5fbb 100644
>> --- a/fs/nfs/inode.c
>> +++ b/fs/nfs/inode.c
>> @@ -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;
>> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
>> index cbcb6ae..6620606 100644
>> --- a/fs/nfs/pnfs.c
>> +++ b/fs/nfs/pnfs.c
>> @@ -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;
>> diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
>> index ca4a707..c6954ac 100644
>> --- a/include/linux/nfs_fs.h
>> +++ b/include/linux/nfs_fs.h
>> @@ -201,6 +201,9 @@ struct nfs_inode {
>> 
>> 	/* pNFS layout information */
>> 	struct pnfs_layout_hdr *layout;
>> +	/* how many bytes have been written/read and how many bytes queued up */
>> +	__u64 write_io;
>> +	__u64 read_io;
>> #endif /* CONFIG_NFS_V4*/
> 
> ^^^^ This doesn't look as if it will compile without CONFIG_NFS_V4.

I'll fix and resend. Thanks for the review :)

-->Andy

> 
>> #ifdef CONFIG_NFS_FSCACHE
>> 	struct fscache_cookie	*fscache;
> 
> -- 
> Trond Myklebust
> Linux NFS client maintainer
> 
> NetApp
> Trond.Myklebust@netapp.com
> www.netapp.com
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 0/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold
@ 2012-05-24 17:13 andros
  2012-05-24 17:13 ` [PATCH 3/4] " andros
  0 siblings, 1 reply; 5+ messages in thread
From: andros @ 2012-05-24 17:13 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Andy Adamson

From: Andy Adamson <andros@netapp.com>

Only resending NFSv4.1 add nfs_inode book keeping for mdsthreshold. 
Responded to Trond's comments.
I have not tested the directio nor the memmap io cases. The regular file
i/o works as intended.

Andy Adamson (4):
  NFSv4.1 mdsthreshold attribute xdr
  NFSv4.1 cache mdsthreshold values on OPEN
  NFSv4.1 add nfs_inode book keeping for mdsthreshold
  NFSv4.1 test the mdsthreshold hint parameters

 fs/nfs/direct.c         |    2 +
 fs/nfs/file.c           |    1 +
 fs/nfs/inode.c          |    4 ++
 fs/nfs/nfs4proc.c       |   38 ++++++++++++--
 fs/nfs/nfs4xdr.c        |  125 ++++++++++++++++++++++++++++++++++++++++++++++-
 fs/nfs/pnfs.c           |   94 +++++++++++++++++++++++++++++++++++
 fs/nfs/pnfs.h           |   21 ++++++++
 fs/nfs/read.c           |    2 +
 include/linux/nfs4.h    |    7 +++
 include/linux/nfs_fs.h  |    4 ++
 include/linux/nfs_xdr.h |   10 ++++
 11 files changed, 301 insertions(+), 7 deletions(-)

-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold
  2012-05-24 17:13 [PATCH 0/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold andros
@ 2012-05-24 17:13 ` andros
  0 siblings, 0 replies; 5+ messages in thread
From: andros @ 2012-05-24 17:13 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Andy Adamson

From: Andy Adamson <andros@netapp.com>

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>
---
 fs/nfs/direct.c        |    2 ++
 fs/nfs/file.c          |    1 +
 fs/nfs/inode.c         |    2 ++
 fs/nfs/pnfs.c          |    3 +++
 fs/nfs/read.c          |    2 ++
 include/linux/nfs_fs.h |    3 +++
 6 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index c47a46e..23d170b 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -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
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 8eda8a6..56311ca 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -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;
 }
 
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 889f7e5..a6f5fbb 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -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;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index cbcb6ae..6620606 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -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;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 2cfdd77..86ced78 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -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:
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index ca4a707..9d44860 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -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
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-24 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 17:13 [PATCH 0/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold andros
2012-05-24 17:13 ` [PATCH 3/4] " andros
  -- strict thread matches above, loose matches on Subject: below --
2012-05-23  9:02 [PATCH 1/4] NFSv4.1 mdsthreshold attribute xdr andros
2012-05-23  9:02 ` [PATCH 3/4] NFSv4.1 add nfs_inode book keeping for mdsthreshold andros
2012-05-23 18:19   ` Myklebust, Trond
2012-05-23 18:41     ` Adamson, Andy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).