diff options
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r-- | fs/nfs/file.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 63f2071d6445..ae8d02294e46 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -123,11 +123,11 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
123 | filp->f_path.dentry->d_parent->d_name.name, | 123 | filp->f_path.dentry->d_parent->d_name.name, |
124 | filp->f_path.dentry->d_name.name); | 124 | filp->f_path.dentry->d_name.name); |
125 | 125 | ||
126 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | ||
126 | res = nfs_check_flags(filp->f_flags); | 127 | res = nfs_check_flags(filp->f_flags); |
127 | if (res) | 128 | if (res) |
128 | return res; | 129 | return res; |
129 | 130 | ||
130 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | ||
131 | res = nfs_open(inode, filp); | 131 | res = nfs_open(inode, filp); |
132 | return res; | 132 | return res; |
133 | } | 133 | } |
@@ -237,9 +237,9 @@ nfs_file_flush(struct file *file, fl_owner_t id) | |||
237 | dentry->d_parent->d_name.name, | 237 | dentry->d_parent->d_name.name, |
238 | dentry->d_name.name); | 238 | dentry->d_name.name); |
239 | 239 | ||
240 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); | ||
240 | if ((file->f_mode & FMODE_WRITE) == 0) | 241 | if ((file->f_mode & FMODE_WRITE) == 0) |
241 | return 0; | 242 | return 0; |
242 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); | ||
243 | 243 | ||
244 | /* Flush writes to the server and return any errors */ | 244 | /* Flush writes to the server and return any errors */ |
245 | return nfs_do_fsync(ctx, inode); | 245 | return nfs_do_fsync(ctx, inode); |
@@ -262,9 +262,11 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, | |||
262 | (unsigned long) count, (unsigned long) pos); | 262 | (unsigned long) count, (unsigned long) pos); |
263 | 263 | ||
264 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | 264 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
265 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); | 265 | if (!result) { |
266 | if (!result) | ||
267 | result = generic_file_aio_read(iocb, iov, nr_segs, pos); | 266 | result = generic_file_aio_read(iocb, iov, nr_segs, pos); |
267 | if (result > 0) | ||
268 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result); | ||
269 | } | ||
268 | return result; | 270 | return result; |
269 | } | 271 | } |
270 | 272 | ||
@@ -282,8 +284,11 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos, | |||
282 | (unsigned long) count, (unsigned long long) *ppos); | 284 | (unsigned long) count, (unsigned long long) *ppos); |
283 | 285 | ||
284 | res = nfs_revalidate_mapping(inode, filp->f_mapping); | 286 | res = nfs_revalidate_mapping(inode, filp->f_mapping); |
285 | if (!res) | 287 | if (!res) { |
286 | res = generic_file_splice_read(filp, ppos, pipe, count, flags); | 288 | res = generic_file_splice_read(filp, ppos, pipe, count, flags); |
289 | if (res > 0) | ||
290 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, res); | ||
291 | } | ||
287 | return res; | 292 | return res; |
288 | } | 293 | } |
289 | 294 | ||
@@ -596,6 +601,7 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
596 | { | 601 | { |
597 | struct dentry * dentry = iocb->ki_filp->f_path.dentry; | 602 | struct dentry * dentry = iocb->ki_filp->f_path.dentry; |
598 | struct inode * inode = dentry->d_inode; | 603 | struct inode * inode = dentry->d_inode; |
604 | unsigned long written = 0; | ||
599 | ssize_t result; | 605 | ssize_t result; |
600 | size_t count = iov_length(iov, nr_segs); | 606 | size_t count = iov_length(iov, nr_segs); |
601 | 607 | ||
@@ -622,14 +628,18 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
622 | if (!count) | 628 | if (!count) |
623 | goto out; | 629 | goto out; |
624 | 630 | ||
625 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); | ||
626 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); | 631 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); |
632 | if (result > 0) | ||
633 | written = result; | ||
634 | |||
627 | /* Return error values for O_DSYNC and IS_SYNC() */ | 635 | /* Return error values for O_DSYNC and IS_SYNC() */ |
628 | if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) { | 636 | if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) { |
629 | int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode); | 637 | int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode); |
630 | if (err < 0) | 638 | if (err < 0) |
631 | result = err; | 639 | result = err; |
632 | } | 640 | } |
641 | if (result > 0) | ||
642 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written); | ||
633 | out: | 643 | out: |
634 | return result; | 644 | return result; |
635 | 645 | ||
@@ -644,6 +654,7 @@ static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe, | |||
644 | { | 654 | { |
645 | struct dentry *dentry = filp->f_path.dentry; | 655 | struct dentry *dentry = filp->f_path.dentry; |
646 | struct inode *inode = dentry->d_inode; | 656 | struct inode *inode = dentry->d_inode; |
657 | unsigned long written = 0; | ||
647 | ssize_t ret; | 658 | ssize_t ret; |
648 | 659 | ||
649 | dprintk("NFS splice_write(%s/%s, %lu@%llu)\n", | 660 | dprintk("NFS splice_write(%s/%s, %lu@%llu)\n", |
@@ -654,14 +665,17 @@ static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe, | |||
654 | * The combination of splice and an O_APPEND destination is disallowed. | 665 | * The combination of splice and an O_APPEND destination is disallowed. |
655 | */ | 666 | */ |
656 | 667 | ||
657 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); | ||
658 | |||
659 | ret = generic_file_splice_write(pipe, filp, ppos, count, flags); | 668 | ret = generic_file_splice_write(pipe, filp, ppos, count, flags); |
669 | if (ret > 0) | ||
670 | written = ret; | ||
671 | |||
660 | if (ret >= 0 && nfs_need_sync_write(filp, inode)) { | 672 | if (ret >= 0 && nfs_need_sync_write(filp, inode)) { |
661 | int err = nfs_do_fsync(nfs_file_open_context(filp), inode); | 673 | int err = nfs_do_fsync(nfs_file_open_context(filp), inode); |
662 | if (err < 0) | 674 | if (err < 0) |
663 | ret = err; | 675 | ret = err; |
664 | } | 676 | } |
677 | if (ret > 0) | ||
678 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written); | ||
665 | return ret; | 679 | return ret; |
666 | } | 680 | } |
667 | 681 | ||