aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c114
1 files changed, 79 insertions, 35 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index a1554bead692..06c48b385c94 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -34,6 +34,7 @@
34 34
35#include "nfs4_fs.h" 35#include "nfs4_fs.h"
36#include "delegation.h" 36#include "delegation.h"
37#include "iostat.h"
37 38
38#define NFS_PARANOIA 1 39#define NFS_PARANOIA 1
39/* #define NFS_DEBUG_VERBOSE 1 */ 40/* #define NFS_DEBUG_VERBOSE 1 */
@@ -129,6 +130,9 @@ nfs_opendir(struct inode *inode, struct file *filp)
129{ 130{
130 int res = 0; 131 int res = 0;
131 132
133 dfprintk(VFS, "NFS: opendir(%s/%ld)\n",
134 inode->i_sb->s_id, inode->i_ino);
135
132 lock_kernel(); 136 lock_kernel();
133 /* Call generic open code in order to cache credentials */ 137 /* Call generic open code in order to cache credentials */
134 if (!res) 138 if (!res)
@@ -172,7 +176,9 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
172 unsigned long timestamp; 176 unsigned long timestamp;
173 int error; 177 int error;
174 178
175 dfprintk(VFS, "NFS: nfs_readdir_filler() reading cookie %Lu into page %lu.\n", (long long)desc->entry->cookie, page->index); 179 dfprintk(DIRCACHE, "NFS: %s: reading cookie %Lu into page %lu\n",
180 __FUNCTION__, (long long)desc->entry->cookie,
181 page->index);
176 182
177 again: 183 again:
178 timestamp = jiffies; 184 timestamp = jiffies;
@@ -244,7 +250,8 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
244 status; 250 status;
245 251
246 while((status = dir_decode(desc)) == 0) { 252 while((status = dir_decode(desc)) == 0) {
247 dfprintk(VFS, "NFS: found cookie %Lu\n", (unsigned long long)entry->cookie); 253 dfprintk(DIRCACHE, "NFS: %s: examining cookie %Lu\n",
254 __FUNCTION__, (unsigned long long)entry->cookie);
248 if (entry->prev_cookie == *desc->dir_cookie) 255 if (entry->prev_cookie == *desc->dir_cookie)
249 break; 256 break;
250 if (loop_count++ > 200) { 257 if (loop_count++ > 200) {
@@ -252,7 +259,6 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
252 schedule(); 259 schedule();
253 } 260 }
254 } 261 }
255 dfprintk(VFS, "NFS: find_dirent() returns %d\n", status);
256 return status; 262 return status;
257} 263}
258 264
@@ -276,7 +282,8 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
276 if (status) 282 if (status)
277 break; 283 break;
278 284
279 dfprintk(VFS, "NFS: found cookie %Lu at index %Ld\n", (unsigned long long)entry->cookie, desc->current_index); 285 dfprintk(DIRCACHE, "NFS: found cookie %Lu at index %Ld\n",
286 (unsigned long long)entry->cookie, desc->current_index);
280 287
281 if (desc->file->f_pos == desc->current_index) { 288 if (desc->file->f_pos == desc->current_index) {
282 *desc->dir_cookie = entry->cookie; 289 *desc->dir_cookie = entry->cookie;
@@ -288,7 +295,6 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
288 schedule(); 295 schedule();
289 } 296 }
290 } 297 }
291 dfprintk(VFS, "NFS: find_dirent_index() returns %d\n", status);
292 return status; 298 return status;
293} 299}
294 300
@@ -303,7 +309,9 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
303 struct page *page; 309 struct page *page;
304 int status; 310 int status;
305 311
306 dfprintk(VFS, "NFS: find_dirent_page() searching directory page %ld\n", desc->page_index); 312 dfprintk(DIRCACHE, "NFS: %s: searching page %ld for target %Lu\n",
313 __FUNCTION__, desc->page_index,
314 (long long) *desc->dir_cookie);
307 315
308 page = read_cache_page(inode->i_mapping, desc->page_index, 316 page = read_cache_page(inode->i_mapping, desc->page_index,
309 (filler_t *)nfs_readdir_filler, desc); 317 (filler_t *)nfs_readdir_filler, desc);
@@ -324,7 +332,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
324 if (status < 0) 332 if (status < 0)
325 dir_page_release(desc); 333 dir_page_release(desc);
326 out: 334 out:
327 dfprintk(VFS, "NFS: find_dirent_page() returns %d\n", status); 335 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, status);
328 return status; 336 return status;
329 read_error: 337 read_error:
330 page_cache_release(page); 338 page_cache_release(page);
@@ -346,13 +354,15 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
346 354
347 /* Always search-by-index from the beginning of the cache */ 355 /* Always search-by-index from the beginning of the cache */
348 if (*desc->dir_cookie == 0) { 356 if (*desc->dir_cookie == 0) {
349 dfprintk(VFS, "NFS: readdir_search_pagecache() searching for offset %Ld\n", (long long)desc->file->f_pos); 357 dfprintk(DIRCACHE, "NFS: readdir_search_pagecache() searching for offset %Ld\n",
358 (long long)desc->file->f_pos);
350 desc->page_index = 0; 359 desc->page_index = 0;
351 desc->entry->cookie = desc->entry->prev_cookie = 0; 360 desc->entry->cookie = desc->entry->prev_cookie = 0;
352 desc->entry->eof = 0; 361 desc->entry->eof = 0;
353 desc->current_index = 0; 362 desc->current_index = 0;
354 } else 363 } else
355 dfprintk(VFS, "NFS: readdir_search_pagecache() searching for cookie %Lu\n", (unsigned long long)*desc->dir_cookie); 364 dfprintk(DIRCACHE, "NFS: readdir_search_pagecache() searching for cookie %Lu\n",
365 (unsigned long long)*desc->dir_cookie);
356 366
357 for (;;) { 367 for (;;) {
358 res = find_dirent_page(desc); 368 res = find_dirent_page(desc);
@@ -365,7 +375,8 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
365 schedule(); 375 schedule();
366 } 376 }
367 } 377 }
368 dfprintk(VFS, "NFS: readdir_search_pagecache() returned %d\n", res); 378
379 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, res);
369 return res; 380 return res;
370} 381}
371 382
@@ -390,7 +401,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
390 int loop_count = 0, 401 int loop_count = 0,
391 res; 402 res;
392 403
393 dfprintk(VFS, "NFS: nfs_do_filldir() filling starting @ cookie %Lu\n", (long long)entry->cookie); 404 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling starting @ cookie %Lu\n",
405 (unsigned long long)entry->cookie);
394 406
395 for(;;) { 407 for(;;) {
396 unsigned d_type = DT_UNKNOWN; 408 unsigned d_type = DT_UNKNOWN;
@@ -427,7 +439,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
427 dir_page_release(desc); 439 dir_page_release(desc);
428 if (dentry != NULL) 440 if (dentry != NULL)
429 dput(dentry); 441 dput(dentry);
430 dfprintk(VFS, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", (unsigned long long)*desc->dir_cookie, res); 442 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n",
443 (unsigned long long)*desc->dir_cookie, res);
431 return res; 444 return res;
432} 445}
433 446
@@ -453,7 +466,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
453 struct page *page = NULL; 466 struct page *page = NULL;
454 int status; 467 int status;
455 468
456 dfprintk(VFS, "NFS: uncached_readdir() searching for cookie %Lu\n", (unsigned long long)*desc->dir_cookie); 469 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n",
470 (unsigned long long)*desc->dir_cookie);
457 471
458 page = alloc_page(GFP_HIGHUSER); 472 page = alloc_page(GFP_HIGHUSER);
459 if (!page) { 473 if (!page) {
@@ -485,7 +499,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
485 desc->entry->cookie = desc->entry->prev_cookie = 0; 499 desc->entry->cookie = desc->entry->prev_cookie = 0;
486 desc->entry->eof = 0; 500 desc->entry->eof = 0;
487 out: 501 out:
488 dfprintk(VFS, "NFS: uncached_readdir() returns %d\n", status); 502 dfprintk(DIRCACHE, "NFS: %s: returns %d\n",
503 __FUNCTION__, status);
489 return status; 504 return status;
490 out_release: 505 out_release:
491 dir_page_release(desc); 506 dir_page_release(desc);
@@ -507,6 +522,11 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
507 struct nfs_fattr fattr; 522 struct nfs_fattr fattr;
508 long res; 523 long res;
509 524
525 dfprintk(VFS, "NFS: readdir(%s/%s) starting at cookie %Lu\n",
526 dentry->d_parent->d_name.name, dentry->d_name.name,
527 (long long)filp->f_pos);
528 nfs_inc_stats(inode, NFSIOS_VFSGETDENTS);
529
510 lock_kernel(); 530 lock_kernel();
511 531
512 res = nfs_revalidate_inode(NFS_SERVER(inode), inode); 532 res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
@@ -566,9 +586,12 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
566 } 586 }
567 } 587 }
568 unlock_kernel(); 588 unlock_kernel();
569 if (res < 0) 589 if (res > 0)
570 return res; 590 res = 0;
571 return 0; 591 dfprintk(VFS, "NFS: readdir(%s/%s) returns %ld\n",
592 dentry->d_parent->d_name.name, dentry->d_name.name,
593 res);
594 return res;
572} 595}
573 596
574loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) 597loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
@@ -599,6 +622,10 @@ out:
599 */ 622 */
600int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) 623int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync)
601{ 624{
625 dfprintk(VFS, "NFS: fsync_dir(%s/%s) datasync %d\n",
626 dentry->d_parent->d_name.name, dentry->d_name.name,
627 datasync);
628
602 return 0; 629 return 0;
603} 630}
604 631
@@ -713,6 +740,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
713 parent = dget_parent(dentry); 740 parent = dget_parent(dentry);
714 lock_kernel(); 741 lock_kernel();
715 dir = parent->d_inode; 742 dir = parent->d_inode;
743 nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE);
716 inode = dentry->d_inode; 744 inode = dentry->d_inode;
717 745
718 if (!inode) { 746 if (!inode) {
@@ -722,8 +750,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
722 } 750 }
723 751
724 if (is_bad_inode(inode)) { 752 if (is_bad_inode(inode)) {
725 dfprintk(VFS, "nfs_lookup_validate: %s/%s has dud inode\n", 753 dfprintk(LOOKUPCACHE, "%s: %s/%s has dud inode\n",
726 dentry->d_parent->d_name.name, dentry->d_name.name); 754 __FUNCTION__, dentry->d_parent->d_name.name,
755 dentry->d_name.name);
727 goto out_bad; 756 goto out_bad;
728 } 757 }
729 758
@@ -755,6 +784,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
755 out_valid: 784 out_valid:
756 unlock_kernel(); 785 unlock_kernel();
757 dput(parent); 786 dput(parent);
787 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n",
788 __FUNCTION__, dentry->d_parent->d_name.name,
789 dentry->d_name.name);
758 return 1; 790 return 1;
759out_zap_parent: 791out_zap_parent:
760 nfs_zap_caches(dir); 792 nfs_zap_caches(dir);
@@ -771,6 +803,9 @@ out_zap_parent:
771 d_drop(dentry); 803 d_drop(dentry);
772 unlock_kernel(); 804 unlock_kernel();
773 dput(parent); 805 dput(parent);
806 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
807 __FUNCTION__, dentry->d_parent->d_name.name,
808 dentry->d_name.name);
774 return 0; 809 return 0;
775} 810}
776 811
@@ -844,6 +879,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
844 879
845 dfprintk(VFS, "NFS: lookup(%s/%s)\n", 880 dfprintk(VFS, "NFS: lookup(%s/%s)\n",
846 dentry->d_parent->d_name.name, dentry->d_name.name); 881 dentry->d_parent->d_name.name, dentry->d_name.name);
882 nfs_inc_stats(dir, NFSIOS_VFSLOOKUP);
847 883
848 res = ERR_PTR(-ENAMETOOLONG); 884 res = ERR_PTR(-ENAMETOOLONG);
849 if (dentry->d_name.len > NFS_SERVER(dir)->namelen) 885 if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
@@ -865,9 +901,9 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
865 res = ERR_PTR(error); 901 res = ERR_PTR(error);
866 goto out_unlock; 902 goto out_unlock;
867 } 903 }
868 res = ERR_PTR(-EACCES);
869 inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); 904 inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr);
870 if (!inode) 905 res = (struct dentry *)inode;
906 if (IS_ERR(res))
871 goto out_unlock; 907 goto out_unlock;
872no_entry: 908no_entry:
873 res = d_add_unique(dentry, inode); 909 res = d_add_unique(dentry, inode);
@@ -912,6 +948,9 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
912 struct dentry *res = NULL; 948 struct dentry *res = NULL;
913 int error; 949 int error;
914 950
951 dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
952 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
953
915 /* Check that we are indeed trying to open this file */ 954 /* Check that we are indeed trying to open this file */
916 if (!is_atomic_open(dir, nd)) 955 if (!is_atomic_open(dir, nd))
917 goto no_open; 956 goto no_open;
@@ -1057,7 +1096,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
1057 return NULL; 1096 return NULL;
1058 dentry->d_op = NFS_PROTO(dir)->dentry_ops; 1097 dentry->d_op = NFS_PROTO(dir)->dentry_ops;
1059 inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr); 1098 inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr);
1060 if (!inode) { 1099 if (IS_ERR(inode)) {
1061 dput(dentry); 1100 dput(dentry);
1062 return NULL; 1101 return NULL;
1063 } 1102 }
@@ -1095,9 +1134,9 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1095 if (error < 0) 1134 if (error < 0)
1096 goto out_err; 1135 goto out_err;
1097 } 1136 }
1098 error = -ENOMEM;
1099 inode = nfs_fhget(dentry->d_sb, fhandle, fattr); 1137 inode = nfs_fhget(dentry->d_sb, fhandle, fattr);
1100 if (inode == NULL) 1138 error = PTR_ERR(inode);
1139 if (IS_ERR(inode))
1101 goto out_err; 1140 goto out_err;
1102 d_instantiate(dentry, inode); 1141 d_instantiate(dentry, inode);
1103 return 0; 1142 return 0;
@@ -1119,8 +1158,8 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1119 int error; 1158 int error;
1120 int open_flags = 0; 1159 int open_flags = 0;
1121 1160
1122 dfprintk(VFS, "NFS: create(%s/%ld, %s\n", dir->i_sb->s_id, 1161 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1123 dir->i_ino, dentry->d_name.name); 1162 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1124 1163
1125 attr.ia_mode = mode; 1164 attr.ia_mode = mode;
1126 attr.ia_valid = ATTR_MODE; 1165 attr.ia_valid = ATTR_MODE;
@@ -1153,8 +1192,8 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1153 struct iattr attr; 1192 struct iattr attr;
1154 int status; 1193 int status;
1155 1194
1156 dfprintk(VFS, "NFS: mknod(%s/%ld, %s\n", dir->i_sb->s_id, 1195 dfprintk(VFS, "NFS: mknod(%s/%ld), %s\n",
1157 dir->i_ino, dentry->d_name.name); 1196 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1158 1197
1159 if (!new_valid_dev(rdev)) 1198 if (!new_valid_dev(rdev))
1160 return -EINVAL; 1199 return -EINVAL;
@@ -1186,8 +1225,8 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1186 struct iattr attr; 1225 struct iattr attr;
1187 int error; 1226 int error;
1188 1227
1189 dfprintk(VFS, "NFS: mkdir(%s/%ld, %s\n", dir->i_sb->s_id, 1228 dfprintk(VFS, "NFS: mkdir(%s/%ld), %s\n",
1190 dir->i_ino, dentry->d_name.name); 1229 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1191 1230
1192 attr.ia_valid = ATTR_MODE; 1231 attr.ia_valid = ATTR_MODE;
1193 attr.ia_mode = mode | S_IFDIR; 1232 attr.ia_mode = mode | S_IFDIR;
@@ -1212,8 +1251,8 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
1212{ 1251{
1213 int error; 1252 int error;
1214 1253
1215 dfprintk(VFS, "NFS: rmdir(%s/%ld, %s\n", dir->i_sb->s_id, 1254 dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
1216 dir->i_ino, dentry->d_name.name); 1255 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1217 1256
1218 lock_kernel(); 1257 lock_kernel();
1219 nfs_begin_data_update(dir); 1258 nfs_begin_data_update(dir);
@@ -1241,6 +1280,7 @@ static int nfs_sillyrename(struct inode *dir, struct dentry *dentry)
1241 dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n", 1280 dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n",
1242 dentry->d_parent->d_name.name, dentry->d_name.name, 1281 dentry->d_parent->d_name.name, dentry->d_name.name,
1243 atomic_read(&dentry->d_count)); 1282 atomic_read(&dentry->d_count));
1283 nfs_inc_stats(dir, NFSIOS_SILLYRENAME);
1244 1284
1245#ifdef NFS_PARANOIA 1285#ifdef NFS_PARANOIA
1246if (!dentry->d_inode) 1286if (!dentry->d_inode)
@@ -1268,8 +1308,8 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
1268 sillycounter++; 1308 sillycounter++;
1269 sprintf(suffix, "%*.*x", countersize, countersize, sillycounter); 1309 sprintf(suffix, "%*.*x", countersize, countersize, sillycounter);
1270 1310
1271 dfprintk(VFS, "trying to rename %s to %s\n", 1311 dfprintk(VFS, "NFS: trying to rename %s to %s\n",
1272 dentry->d_name.name, silly); 1312 dentry->d_name.name, silly);
1273 1313
1274 sdentry = lookup_one_len(silly, dentry->d_parent, slen); 1314 sdentry = lookup_one_len(silly, dentry->d_parent, slen);
1275 /* 1315 /*
@@ -1640,6 +1680,8 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
1640 struct rpc_cred *cred; 1680 struct rpc_cred *cred;
1641 int res = 0; 1681 int res = 0;
1642 1682
1683 nfs_inc_stats(inode, NFSIOS_VFSACCESS);
1684
1643 if (mask == 0) 1685 if (mask == 0)
1644 goto out; 1686 goto out;
1645 /* Is this sys_access() ? */ 1687 /* Is this sys_access() ? */
@@ -1679,13 +1721,15 @@ force_lookup:
1679 res = PTR_ERR(cred); 1721 res = PTR_ERR(cred);
1680 unlock_kernel(); 1722 unlock_kernel();
1681out: 1723out:
1724 dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n",
1725 inode->i_sb->s_id, inode->i_ino, mask, res);
1682 return res; 1726 return res;
1683out_notsup: 1727out_notsup:
1684 res = nfs_revalidate_inode(NFS_SERVER(inode), inode); 1728 res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
1685 if (res == 0) 1729 if (res == 0)
1686 res = generic_permission(inode, mask, NULL); 1730 res = generic_permission(inode, mask, NULL);
1687 unlock_kernel(); 1731 unlock_kernel();
1688 return res; 1732 goto out;
1689} 1733}
1690 1734
1691/* 1735/*