All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] More short subjects for 2.6.34
@ 2010-02-01 19:17 Chuck Lever
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

Here are some performance metric accounting fixes to consider for
2.6.34.  Also, a close(2) optimization for O_DIRECT files.

---

Chuck Lever (5):
      NFS: Make close(2) asynchronous when closing NFS O_DIRECT files
      NFS: Improve NFS iostat byte count accuracy for writes
      NFS: Account for NFS bytes read via the splice API
      NFS: Fix byte accounting for generic NFS reads
      NFS: Proper accounting for NFS VFS calls


 fs/nfs/file.c  |   30 ++++++++++++++++++++++--------
 fs/nfs/inode.c |    7 +------
 2 files changed, 23 insertions(+), 14 deletions(-)

-- 
Chuck Lever

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

* [PATCH 1/5] NFS: Proper accounting for NFS VFS calls
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-02-01 19:17   ` Chuck Lever
  2010-02-01 19:17   ` [PATCH 2/5] NFS: Fix byte accounting for generic NFS reads Chuck Lever
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

Nit: The VFSOPEN and VFSFLUSH counters are function call counters.
Count every call to these routines.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 6b89132..f028e7d 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -123,11 +123,11 @@ nfs_file_open(struct inode *inode, struct file *filp)
 			filp->f_path.dentry->d_parent->d_name.name,
 			filp->f_path.dentry->d_name.name);
 
+	nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 	res = nfs_check_flags(filp->f_flags);
 	if (res)
 		return res;
 
-	nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 	res = nfs_open(inode, filp);
 	return res;
 }
@@ -237,9 +237,9 @@ nfs_file_flush(struct file *file, fl_owner_t id)
 			dentry->d_parent->d_name.name,
 			dentry->d_name.name);
 
+	nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
 	if ((file->f_mode & FMODE_WRITE) == 0)
 		return 0;
-	nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
 
 	/* Flush writes to the server and return any errors */
 	return nfs_do_fsync(ctx, inode);


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

* [PATCH 2/5] NFS: Fix byte accounting for generic NFS reads
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-02-01 19:17   ` [PATCH 1/5] NFS: Proper accounting for NFS VFS calls Chuck Lever
@ 2010-02-01 19:17   ` Chuck Lever
  2010-02-01 19:17   ` [PATCH 3/5] NFS: Account for NFS bytes read via the splice API Chuck Lever
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

Currently, the NFS I/O counters count the number of bytes requested
by applications, rather than the number of bytes actually read by the
system calls.

The number of bytes requested for reads is actually not that useful,
because the value is usually a buffer size for reads.  That is, that
requested number is usually a maximum, and frequently doesn't reflect
the actual number of bytes read.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/file.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index f028e7d..3c65a6b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -262,9 +262,11 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
 		(unsigned long) count, (unsigned long) pos);
 
 	result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
-	nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count);
-	if (!result)
+	if (!result) {
 		result = generic_file_aio_read(iocb, iov, nr_segs, pos);
+		if (result > 0)
+			nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result);
+	}
 	return result;
 }
 


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

* [PATCH 3/5] NFS: Account for NFS bytes read via the splice API
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-02-01 19:17   ` [PATCH 1/5] NFS: Proper accounting for NFS VFS calls Chuck Lever
  2010-02-01 19:17   ` [PATCH 2/5] NFS: Fix byte accounting for generic NFS reads Chuck Lever
@ 2010-02-01 19:17   ` Chuck Lever
  2010-02-01 19:17   ` [PATCH 4/5] NFS: Improve NFS iostat byte count accuracy for writes Chuck Lever
  2010-02-01 19:17   ` [PATCH 5/5] NFS: Make close(2) asynchronous when closing NFS O_DIRECT files Chuck Lever
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

Bytes read via the splice API should be accounted for in the NFS
performance statistics.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/file.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 3c65a6b..64278c8 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -284,8 +284,11 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos,
 		(unsigned long) count, (unsigned long long) *ppos);
 
 	res = nfs_revalidate_mapping(inode, filp->f_mapping);
-	if (!res)
+	if (!res) {
 		res = generic_file_splice_read(filp, ppos, pipe, count, flags);
+		if (res > 0)
+			nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, res);
+	}
 	return res;
 }
 


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

* [PATCH 4/5] NFS: Improve NFS iostat byte count accuracy for writes
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-02-01 19:17   ` [PATCH 3/5] NFS: Account for NFS bytes read via the splice API Chuck Lever
@ 2010-02-01 19:17   ` Chuck Lever
  2010-02-01 19:17   ` [PATCH 5/5] NFS: Make close(2) asynchronous when closing NFS O_DIRECT files Chuck Lever
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

The bytes counted by the performance counters for NFS writes should
reflect write and sync errors.  If the write(2) system call reports
an error, the bytes should not be counted.  And, if the write is
short, the actual number of bytes that was written should be counted,
not the number of bytes that was requested.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/file.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 64278c8..1fc8175 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -599,6 +599,7 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
 {
 	struct dentry * dentry = iocb->ki_filp->f_path.dentry;
 	struct inode * inode = dentry->d_inode;
+	unsigned long written = 0;
 	ssize_t result;
 	size_t count = iov_length(iov, nr_segs);
 
@@ -625,14 +626,18 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
 	if (!count)
 		goto out;
 
-	nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
 	result = generic_file_aio_write(iocb, iov, nr_segs, pos);
+	if (result > 0)
+		written = result;
+
 	/* Return error values for O_DSYNC and IS_SYNC() */
 	if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) {
 		int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode);
 		if (err < 0)
 			result = err;
 	}
+	if (result > 0)
+		nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
 out:
 	return result;
 
@@ -647,6 +652,7 @@ static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
 {
 	struct dentry *dentry = filp->f_path.dentry;
 	struct inode *inode = dentry->d_inode;
+	unsigned long written = 0;
 	ssize_t ret;
 
 	dprintk("NFS splice_write(%s/%s, %lu@%llu)\n",
@@ -657,14 +663,17 @@ static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
 	 * The combination of splice and an O_APPEND destination is disallowed.
 	 */
 
-	nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
-
 	ret = generic_file_splice_write(pipe, filp, ppos, count, flags);
+	if (ret > 0)
+		written = ret;
+
 	if (ret >= 0 && nfs_need_sync_write(filp, inode)) {
 		int err = nfs_do_fsync(nfs_file_open_context(filp), inode);
 		if (err < 0)
 			ret = err;
 	}
+	if (ret > 0)
+		nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
 	return ret;
 }
 


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

* [PATCH 5/5] NFS: Make close(2) asynchronous when closing NFS O_DIRECT files
       [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-02-01 19:17   ` [PATCH 4/5] NFS: Improve NFS iostat byte count accuracy for writes Chuck Lever
@ 2010-02-01 19:17   ` Chuck Lever
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-02-01 19:17 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

For NFSv2 and v3:

O_DIRECT writes are always synchronous, and aren't cached, so nothing
should be flushed when closing an NFS O_DIRECT file descriptor.  Thus
there are no write errors to report on close(2).

In addition, there's no cached data to verify on the next open(2),
so we don't need clean GETATTR results at close time to compare with.

Thus, there's no need for the nfs_revalidate_inode() call when closing
an NFS O_DIRECT file.  This reduces the number of synchronous
on-the-wire requests for a simple open-write-close of an NFS O_DIRECT
file by roughly 20%.

For NFSv4:

Call nfs4_do_close() with wait set to zero when closing an NFS
O_DIRECT file.  The CLOSE will go on the wire, but the application
won't wait for it to complete.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/inode.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index faa0918..873717f 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -620,11 +620,6 @@ void put_nfs_open_context(struct nfs_open_context *ctx)
 	__put_nfs_open_context(ctx, 0);
 }
 
-static void put_nfs_open_context_sync(struct nfs_open_context *ctx)
-{
-	__put_nfs_open_context(ctx, 1);
-}
-
 /*
  * Ensure that mmap has a recent RPC credential for use when writing out
  * shared pages
@@ -671,7 +666,7 @@ static void nfs_file_clear_open_context(struct file *filp)
 		spin_lock(&inode->i_lock);
 		list_move_tail(&ctx->list, &NFS_I(inode)->open_files);
 		spin_unlock(&inode->i_lock);
-		put_nfs_open_context_sync(ctx);
+		__put_nfs_open_context(ctx, filp->f_flags & O_DIRECT ? 0 : 1);
 	}
 }
 


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

end of thread, other threads:[~2010-02-01 19:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-01 19:17 [PATCH 0/5] More short subjects for 2.6.34 Chuck Lever
     [not found] ` <20100201191415.20189.39710.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-02-01 19:17   ` [PATCH 1/5] NFS: Proper accounting for NFS VFS calls Chuck Lever
2010-02-01 19:17   ` [PATCH 2/5] NFS: Fix byte accounting for generic NFS reads Chuck Lever
2010-02-01 19:17   ` [PATCH 3/5] NFS: Account for NFS bytes read via the splice API Chuck Lever
2010-02-01 19:17   ` [PATCH 4/5] NFS: Improve NFS iostat byte count accuracy for writes Chuck Lever
2010-02-01 19:17   ` [PATCH 5/5] NFS: Make close(2) asynchronous when closing NFS O_DIRECT files Chuck Lever

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.