diff options
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r-- | fs/nfs/file.c | 117 |
1 files changed, 43 insertions, 74 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 1e6bfdbc1aff..e2fcacf07de3 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -65,9 +65,7 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
65 | { | 65 | { |
66 | int res; | 66 | int res; |
67 | 67 | ||
68 | dprintk("NFS: open file(%s/%s)\n", | 68 | dprintk("NFS: open file(%pD2)\n", filp); |
69 | filp->f_path.dentry->d_parent->d_name.name, | ||
70 | filp->f_path.dentry->d_name.name); | ||
71 | 69 | ||
72 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | 70 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); |
73 | res = nfs_check_flags(filp->f_flags); | 71 | res = nfs_check_flags(filp->f_flags); |
@@ -81,9 +79,7 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
81 | int | 79 | int |
82 | nfs_file_release(struct inode *inode, struct file *filp) | 80 | nfs_file_release(struct inode *inode, struct file *filp) |
83 | { | 81 | { |
84 | dprintk("NFS: release(%s/%s)\n", | 82 | dprintk("NFS: release(%pD2)\n", filp); |
85 | filp->f_path.dentry->d_parent->d_name.name, | ||
86 | filp->f_path.dentry->d_name.name); | ||
87 | 83 | ||
88 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); | 84 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); |
89 | return nfs_release(inode, filp); | 85 | return nfs_release(inode, filp); |
@@ -123,10 +119,8 @@ force_reval: | |||
123 | 119 | ||
124 | loff_t nfs_file_llseek(struct file *filp, loff_t offset, int whence) | 120 | loff_t nfs_file_llseek(struct file *filp, loff_t offset, int whence) |
125 | { | 121 | { |
126 | dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", | 122 | dprintk("NFS: llseek file(%pD2, %lld, %d)\n", |
127 | filp->f_path.dentry->d_parent->d_name.name, | 123 | filp, offset, whence); |
128 | filp->f_path.dentry->d_name.name, | ||
129 | offset, whence); | ||
130 | 124 | ||
131 | /* | 125 | /* |
132 | * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate | 126 | * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate |
@@ -150,12 +144,9 @@ EXPORT_SYMBOL_GPL(nfs_file_llseek); | |||
150 | int | 144 | int |
151 | nfs_file_flush(struct file *file, fl_owner_t id) | 145 | nfs_file_flush(struct file *file, fl_owner_t id) |
152 | { | 146 | { |
153 | struct dentry *dentry = file->f_path.dentry; | 147 | struct inode *inode = file_inode(file); |
154 | struct inode *inode = dentry->d_inode; | ||
155 | 148 | ||
156 | dprintk("NFS: flush(%s/%s)\n", | 149 | dprintk("NFS: flush(%pD2)\n", file); |
157 | dentry->d_parent->d_name.name, | ||
158 | dentry->d_name.name); | ||
159 | 150 | ||
160 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); | 151 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); |
161 | if ((file->f_mode & FMODE_WRITE) == 0) | 152 | if ((file->f_mode & FMODE_WRITE) == 0) |
@@ -177,15 +168,14 @@ ssize_t | |||
177 | nfs_file_read(struct kiocb *iocb, const struct iovec *iov, | 168 | nfs_file_read(struct kiocb *iocb, const struct iovec *iov, |
178 | unsigned long nr_segs, loff_t pos) | 169 | unsigned long nr_segs, loff_t pos) |
179 | { | 170 | { |
180 | struct dentry * dentry = iocb->ki_filp->f_path.dentry; | 171 | struct inode *inode = file_inode(iocb->ki_filp); |
181 | struct inode * inode = dentry->d_inode; | ||
182 | ssize_t result; | 172 | ssize_t result; |
183 | 173 | ||
184 | if (iocb->ki_filp->f_flags & O_DIRECT) | 174 | if (iocb->ki_filp->f_flags & O_DIRECT) |
185 | return nfs_file_direct_read(iocb, iov, nr_segs, pos, true); | 175 | return nfs_file_direct_read(iocb, iov, nr_segs, pos, true); |
186 | 176 | ||
187 | dprintk("NFS: read(%s/%s, %lu@%lu)\n", | 177 | dprintk("NFS: read(%pD2, %lu@%lu)\n", |
188 | dentry->d_parent->d_name.name, dentry->d_name.name, | 178 | iocb->ki_filp, |
189 | (unsigned long) iov_length(iov, nr_segs), (unsigned long) pos); | 179 | (unsigned long) iov_length(iov, nr_segs), (unsigned long) pos); |
190 | 180 | ||
191 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | 181 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
@@ -203,13 +193,11 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos, | |||
203 | struct pipe_inode_info *pipe, size_t count, | 193 | struct pipe_inode_info *pipe, size_t count, |
204 | unsigned int flags) | 194 | unsigned int flags) |
205 | { | 195 | { |
206 | struct dentry *dentry = filp->f_path.dentry; | 196 | struct inode *inode = file_inode(filp); |
207 | struct inode *inode = dentry->d_inode; | ||
208 | ssize_t res; | 197 | ssize_t res; |
209 | 198 | ||
210 | dprintk("NFS: splice_read(%s/%s, %lu@%Lu)\n", | 199 | dprintk("NFS: splice_read(%pD2, %lu@%Lu)\n", |
211 | dentry->d_parent->d_name.name, dentry->d_name.name, | 200 | filp, (unsigned long) count, (unsigned long long) *ppos); |
212 | (unsigned long) count, (unsigned long long) *ppos); | ||
213 | 201 | ||
214 | res = nfs_revalidate_mapping(inode, filp->f_mapping); | 202 | res = nfs_revalidate_mapping(inode, filp->f_mapping); |
215 | if (!res) { | 203 | if (!res) { |
@@ -224,12 +212,10 @@ EXPORT_SYMBOL_GPL(nfs_file_splice_read); | |||
224 | int | 212 | int |
225 | nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | 213 | nfs_file_mmap(struct file * file, struct vm_area_struct * vma) |
226 | { | 214 | { |
227 | struct dentry *dentry = file->f_path.dentry; | 215 | struct inode *inode = file_inode(file); |
228 | struct inode *inode = dentry->d_inode; | ||
229 | int status; | 216 | int status; |
230 | 217 | ||
231 | dprintk("NFS: mmap(%s/%s)\n", | 218 | dprintk("NFS: mmap(%pD2)\n", file); |
232 | dentry->d_parent->d_name.name, dentry->d_name.name); | ||
233 | 219 | ||
234 | /* Note: generic_file_mmap() returns ENOSYS on nommu systems | 220 | /* Note: generic_file_mmap() returns ENOSYS on nommu systems |
235 | * so we call that before revalidating the mapping | 221 | * so we call that before revalidating the mapping |
@@ -258,15 +244,12 @@ EXPORT_SYMBOL_GPL(nfs_file_mmap); | |||
258 | int | 244 | int |
259 | nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync) | 245 | nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync) |
260 | { | 246 | { |
261 | struct dentry *dentry = file->f_path.dentry; | ||
262 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 247 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
263 | struct inode *inode = dentry->d_inode; | 248 | struct inode *inode = file_inode(file); |
264 | int have_error, do_resend, status; | 249 | int have_error, do_resend, status; |
265 | int ret = 0; | 250 | int ret = 0; |
266 | 251 | ||
267 | dprintk("NFS: fsync file(%s/%s) datasync %d\n", | 252 | dprintk("NFS: fsync file(%pD2) datasync %d\n", file, datasync); |
268 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
269 | datasync); | ||
270 | 253 | ||
271 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); | 254 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); |
272 | do_resend = test_and_clear_bit(NFS_CONTEXT_RESEND_WRITES, &ctx->flags); | 255 | do_resend = test_and_clear_bit(NFS_CONTEXT_RESEND_WRITES, &ctx->flags); |
@@ -371,10 +354,8 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping, | |||
371 | struct page *page; | 354 | struct page *page; |
372 | int once_thru = 0; | 355 | int once_thru = 0; |
373 | 356 | ||
374 | dfprintk(PAGECACHE, "NFS: write_begin(%s/%s(%ld), %u@%lld)\n", | 357 | dfprintk(PAGECACHE, "NFS: write_begin(%pD2(%ld), %u@%lld)\n", |
375 | file->f_path.dentry->d_parent->d_name.name, | 358 | file, mapping->host->i_ino, len, (long long) pos); |
376 | file->f_path.dentry->d_name.name, | ||
377 | mapping->host->i_ino, len, (long long) pos); | ||
378 | 359 | ||
379 | start: | 360 | start: |
380 | /* | 361 | /* |
@@ -414,10 +395,8 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
414 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 395 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
415 | int status; | 396 | int status; |
416 | 397 | ||
417 | dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n", | 398 | dfprintk(PAGECACHE, "NFS: write_end(%pD2(%ld), %u@%lld)\n", |
418 | file->f_path.dentry->d_parent->d_name.name, | 399 | file, mapping->host->i_ino, len, (long long) pos); |
419 | file->f_path.dentry->d_name.name, | ||
420 | mapping->host->i_ino, len, (long long) pos); | ||
421 | 400 | ||
422 | /* | 401 | /* |
423 | * Zero any uninitialised parts of the page, and then mark the page | 402 | * Zero any uninitialised parts of the page, and then mark the page |
@@ -601,22 +580,21 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
601 | { | 580 | { |
602 | struct page *page = vmf->page; | 581 | struct page *page = vmf->page; |
603 | struct file *filp = vma->vm_file; | 582 | struct file *filp = vma->vm_file; |
604 | struct dentry *dentry = filp->f_path.dentry; | 583 | struct inode *inode = file_inode(filp); |
605 | unsigned pagelen; | 584 | unsigned pagelen; |
606 | int ret = VM_FAULT_NOPAGE; | 585 | int ret = VM_FAULT_NOPAGE; |
607 | struct address_space *mapping; | 586 | struct address_space *mapping; |
608 | 587 | ||
609 | dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n", | 588 | dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD2(%ld), offset %lld)\n", |
610 | dentry->d_parent->d_name.name, dentry->d_name.name, | 589 | filp, filp->f_mapping->host->i_ino, |
611 | filp->f_mapping->host->i_ino, | ||
612 | (long long)page_offset(page)); | 590 | (long long)page_offset(page)); |
613 | 591 | ||
614 | /* make sure the cache has finished storing the page */ | 592 | /* make sure the cache has finished storing the page */ |
615 | nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page); | 593 | nfs_fscache_wait_on_page_write(NFS_I(inode), page); |
616 | 594 | ||
617 | lock_page(page); | 595 | lock_page(page); |
618 | mapping = page_file_mapping(page); | 596 | mapping = page_file_mapping(page); |
619 | if (mapping != dentry->d_inode->i_mapping) | 597 | if (mapping != inode->i_mapping) |
620 | goto out_unlock; | 598 | goto out_unlock; |
621 | 599 | ||
622 | wait_on_page_writeback(page); | 600 | wait_on_page_writeback(page); |
@@ -659,22 +637,21 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode) | |||
659 | ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | 637 | ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, |
660 | unsigned long nr_segs, loff_t pos) | 638 | unsigned long nr_segs, loff_t pos) |
661 | { | 639 | { |
662 | struct dentry * dentry = iocb->ki_filp->f_path.dentry; | 640 | struct file *file = iocb->ki_filp; |
663 | struct inode * inode = dentry->d_inode; | 641 | struct inode *inode = file_inode(file); |
664 | unsigned long written = 0; | 642 | unsigned long written = 0; |
665 | ssize_t result; | 643 | ssize_t result; |
666 | size_t count = iov_length(iov, nr_segs); | 644 | size_t count = iov_length(iov, nr_segs); |
667 | 645 | ||
668 | result = nfs_key_timeout_notify(iocb->ki_filp, inode); | 646 | result = nfs_key_timeout_notify(file, inode); |
669 | if (result) | 647 | if (result) |
670 | return result; | 648 | return result; |
671 | 649 | ||
672 | if (iocb->ki_filp->f_flags & O_DIRECT) | 650 | if (file->f_flags & O_DIRECT) |
673 | return nfs_file_direct_write(iocb, iov, nr_segs, pos, true); | 651 | return nfs_file_direct_write(iocb, iov, nr_segs, pos, true); |
674 | 652 | ||
675 | dprintk("NFS: write(%s/%s, %lu@%Ld)\n", | 653 | dprintk("NFS: write(%pD2, %lu@%Ld)\n", |
676 | dentry->d_parent->d_name.name, dentry->d_name.name, | 654 | file, (unsigned long) count, (long long) pos); |
677 | (unsigned long) count, (long long) pos); | ||
678 | 655 | ||
679 | result = -EBUSY; | 656 | result = -EBUSY; |
680 | if (IS_SWAPFILE(inode)) | 657 | if (IS_SWAPFILE(inode)) |
@@ -682,8 +659,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
682 | /* | 659 | /* |
683 | * O_APPEND implies that we must revalidate the file length. | 660 | * O_APPEND implies that we must revalidate the file length. |
684 | */ | 661 | */ |
685 | if (iocb->ki_filp->f_flags & O_APPEND) { | 662 | if (file->f_flags & O_APPEND) { |
686 | result = nfs_revalidate_file_size(inode, iocb->ki_filp); | 663 | result = nfs_revalidate_file_size(inode, file); |
687 | if (result) | 664 | if (result) |
688 | goto out; | 665 | goto out; |
689 | } | 666 | } |
@@ -697,8 +674,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
697 | written = result; | 674 | written = result; |
698 | 675 | ||
699 | /* Return error values for O_DSYNC and IS_SYNC() */ | 676 | /* Return error values for O_DSYNC and IS_SYNC() */ |
700 | if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) { | 677 | if (result >= 0 && nfs_need_sync_write(file, inode)) { |
701 | int err = vfs_fsync(iocb->ki_filp, 0); | 678 | int err = vfs_fsync(file, 0); |
702 | if (err < 0) | 679 | if (err < 0) |
703 | result = err; | 680 | result = err; |
704 | } | 681 | } |
@@ -717,14 +694,12 @@ ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe, | |||
717 | struct file *filp, loff_t *ppos, | 694 | struct file *filp, loff_t *ppos, |
718 | size_t count, unsigned int flags) | 695 | size_t count, unsigned int flags) |
719 | { | 696 | { |
720 | struct dentry *dentry = filp->f_path.dentry; | 697 | struct inode *inode = file_inode(filp); |
721 | struct inode *inode = dentry->d_inode; | ||
722 | unsigned long written = 0; | 698 | unsigned long written = 0; |
723 | ssize_t ret; | 699 | ssize_t ret; |
724 | 700 | ||
725 | dprintk("NFS splice_write(%s/%s, %lu@%llu)\n", | 701 | dprintk("NFS splice_write(%pD2, %lu@%llu)\n", |
726 | dentry->d_parent->d_name.name, dentry->d_name.name, | 702 | filp, (unsigned long) count, (unsigned long long) *ppos); |
727 | (unsigned long) count, (unsigned long long) *ppos); | ||
728 | 703 | ||
729 | /* | 704 | /* |
730 | * The combination of splice and an O_APPEND destination is disallowed. | 705 | * The combination of splice and an O_APPEND destination is disallowed. |
@@ -883,10 +858,8 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
883 | int ret = -ENOLCK; | 858 | int ret = -ENOLCK; |
884 | int is_local = 0; | 859 | int is_local = 0; |
885 | 860 | ||
886 | dprintk("NFS: lock(%s/%s, t=%x, fl=%x, r=%lld:%lld)\n", | 861 | dprintk("NFS: lock(%pD2, t=%x, fl=%x, r=%lld:%lld)\n", |
887 | filp->f_path.dentry->d_parent->d_name.name, | 862 | filp, fl->fl_type, fl->fl_flags, |
888 | filp->f_path.dentry->d_name.name, | ||
889 | fl->fl_type, fl->fl_flags, | ||
890 | (long long)fl->fl_start, (long long)fl->fl_end); | 863 | (long long)fl->fl_start, (long long)fl->fl_end); |
891 | 864 | ||
892 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); | 865 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); |
@@ -923,10 +896,8 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | |||
923 | struct inode *inode = filp->f_mapping->host; | 896 | struct inode *inode = filp->f_mapping->host; |
924 | int is_local = 0; | 897 | int is_local = 0; |
925 | 898 | ||
926 | dprintk("NFS: flock(%s/%s, t=%x, fl=%x)\n", | 899 | dprintk("NFS: flock(%pD2, t=%x, fl=%x)\n", |
927 | filp->f_path.dentry->d_parent->d_name.name, | 900 | filp, fl->fl_type, fl->fl_flags); |
928 | filp->f_path.dentry->d_name.name, | ||
929 | fl->fl_type, fl->fl_flags); | ||
930 | 901 | ||
931 | if (!(fl->fl_flags & FL_FLOCK)) | 902 | if (!(fl->fl_flags & FL_FLOCK)) |
932 | return -ENOLCK; | 903 | return -ENOLCK; |
@@ -960,9 +931,7 @@ EXPORT_SYMBOL_GPL(nfs_flock); | |||
960 | */ | 931 | */ |
961 | int nfs_setlease(struct file *file, long arg, struct file_lock **fl) | 932 | int nfs_setlease(struct file *file, long arg, struct file_lock **fl) |
962 | { | 933 | { |
963 | dprintk("NFS: setlease(%s/%s, arg=%ld)\n", | 934 | dprintk("NFS: setlease(%pD2, arg=%ld)\n", file, arg); |
964 | file->f_path.dentry->d_parent->d_name.name, | ||
965 | file->f_path.dentry->d_name.name, arg); | ||
966 | return -EINVAL; | 935 | return -EINVAL; |
967 | } | 936 | } |
968 | EXPORT_SYMBOL_GPL(nfs_setlease); | 937 | EXPORT_SYMBOL_GPL(nfs_setlease); |