aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2006-03-20 13:44:24 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:24 -0500
commit1e7cb3dc12dbbac690d78c84f9c7cb11132ed121 (patch)
treea6bc36250a6fe5a754b464099a50baf98ce36e78 /fs/nfs/dir.c
parente95b85ec9d8c8ad4667f746aa4c9d22c281efc44 (diff)
NFS: directory trace messages
Reuse NFSDBG_DIRCACHE and NFSDBG_LOOKUPCACHE to provide additional diagnostic messages that trace the operation of the NFS client's directory behavior. A few new messages are now generated when NFSDBG_VFS is active, as well, to trace normal VFS activity. This compromise provides better trace debugging for those who use pre-built kernels, without adding a lot of extra noise to the standard debug settings. Test-plan: Enable NFS trace debugging with flags 1, 2, or 4. You should be able to see different types of trace messages with each flag setting. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c96
1 files changed, 66 insertions, 30 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 151b8dd0ac3b..609185a15c99 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -130,6 +130,9 @@ nfs_opendir(struct inode *inode, struct file *filp)
130{ 130{
131 int res = 0; 131 int res = 0;
132 132
133 dfprintk(VFS, "NFS: opendir(%s/%ld)\n",
134 inode->i_sb->s_id, inode->i_ino);
135
133 lock_kernel(); 136 lock_kernel();
134 /* Call generic open code in order to cache credentials */ 137 /* Call generic open code in order to cache credentials */
135 if (!res) 138 if (!res)
@@ -173,7 +176,9 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
173 unsigned long timestamp; 176 unsigned long timestamp;
174 int error; 177 int error;
175 178
176 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);
177 182
178 again: 183 again:
179 timestamp = jiffies; 184 timestamp = jiffies;
@@ -245,7 +250,8 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
245 status; 250 status;
246 251
247 while((status = dir_decode(desc)) == 0) { 252 while((status = dir_decode(desc)) == 0) {
248 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);
249 if (entry->prev_cookie == *desc->dir_cookie) 255 if (entry->prev_cookie == *desc->dir_cookie)
250 break; 256 break;
251 if (loop_count++ > 200) { 257 if (loop_count++ > 200) {
@@ -253,7 +259,6 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
253 schedule(); 259 schedule();
254 } 260 }
255 } 261 }
256 dfprintk(VFS, "NFS: find_dirent() returns %d\n", status);
257 return status; 262 return status;
258} 263}
259 264
@@ -277,7 +282,8 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
277 if (status) 282 if (status)
278 break; 283 break;
279 284
280 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);
281 287
282 if (desc->file->f_pos == desc->current_index) { 288 if (desc->file->f_pos == desc->current_index) {
283 *desc->dir_cookie = entry->cookie; 289 *desc->dir_cookie = entry->cookie;
@@ -289,7 +295,6 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
289 schedule(); 295 schedule();
290 } 296 }
291 } 297 }
292 dfprintk(VFS, "NFS: find_dirent_index() returns %d\n", status);
293 return status; 298 return status;
294} 299}
295 300
@@ -304,7 +309,9 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
304 struct page *page; 309 struct page *page;
305 int status; 310 int status;
306 311
307 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);
308 315
309 page = read_cache_page(inode->i_mapping, desc->page_index, 316 page = read_cache_page(inode->i_mapping, desc->page_index,
310 (filler_t *)nfs_readdir_filler, desc); 317 (filler_t *)nfs_readdir_filler, desc);
@@ -325,7 +332,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
325 if (status < 0) 332 if (status < 0)
326 dir_page_release(desc); 333 dir_page_release(desc);
327 out: 334 out:
328 dfprintk(VFS, "NFS: find_dirent_page() returns %d\n", status); 335 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, status);
329 return status; 336 return status;
330 read_error: 337 read_error:
331 page_cache_release(page); 338 page_cache_release(page);
@@ -347,13 +354,15 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
347 354
348 /* Always search-by-index from the beginning of the cache */ 355 /* Always search-by-index from the beginning of the cache */
349 if (*desc->dir_cookie == 0) { 356 if (*desc->dir_cookie == 0) {
350 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);
351 desc->page_index = 0; 359 desc->page_index = 0;
352 desc->entry->cookie = desc->entry->prev_cookie = 0; 360 desc->entry->cookie = desc->entry->prev_cookie = 0;
353 desc->entry->eof = 0; 361 desc->entry->eof = 0;
354 desc->current_index = 0; 362 desc->current_index = 0;
355 } else 363 } else
356 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);
357 366
358 for (;;) { 367 for (;;) {
359 res = find_dirent_page(desc); 368 res = find_dirent_page(desc);
@@ -366,7 +375,8 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
366 schedule(); 375 schedule();
367 } 376 }
368 } 377 }
369 dfprintk(VFS, "NFS: readdir_search_pagecache() returned %d\n", res); 378
379 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, res);
370 return res; 380 return res;
371} 381}
372 382
@@ -391,7 +401,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
391 int loop_count = 0, 401 int loop_count = 0,
392 res; 402 res;
393 403
394 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);
395 406
396 for(;;) { 407 for(;;) {
397 unsigned d_type = DT_UNKNOWN; 408 unsigned d_type = DT_UNKNOWN;
@@ -428,7 +439,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
428 dir_page_release(desc); 439 dir_page_release(desc);
429 if (dentry != NULL) 440 if (dentry != NULL)
430 dput(dentry); 441 dput(dentry);
431 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);
432 return res; 444 return res;
433} 445}
434 446
@@ -454,7 +466,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
454 struct page *page = NULL; 466 struct page *page = NULL;
455 int status; 467 int status;
456 468
457 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);
458 471
459 page = alloc_page(GFP_HIGHUSER); 472 page = alloc_page(GFP_HIGHUSER);
460 if (!page) { 473 if (!page) {
@@ -486,7 +499,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
486 desc->entry->cookie = desc->entry->prev_cookie = 0; 499 desc->entry->cookie = desc->entry->prev_cookie = 0;
487 desc->entry->eof = 0; 500 desc->entry->eof = 0;
488 out: 501 out:
489 dfprintk(VFS, "NFS: uncached_readdir() returns %d\n", status); 502 dfprintk(DIRCACHE, "NFS: %s: returns %d\n",
503 __FUNCTION__, status);
490 return status; 504 return status;
491 out_release: 505 out_release:
492 dir_page_release(desc); 506 dir_page_release(desc);
@@ -508,6 +522,9 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
508 struct nfs_fattr fattr; 522 struct nfs_fattr fattr;
509 long res; 523 long res;
510 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);
511 nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); 528 nfs_inc_stats(inode, NFSIOS_VFSGETDENTS);
512 529
513 lock_kernel(); 530 lock_kernel();
@@ -569,9 +586,12 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
569 } 586 }
570 } 587 }
571 unlock_kernel(); 588 unlock_kernel();
572 if (res < 0) 589 if (res > 0)
573 return res; 590 res = 0;
574 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;
575} 595}
576 596
577loff_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)
@@ -602,6 +622,10 @@ out:
602 */ 622 */
603int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) 623int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync)
604{ 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
605 return 0; 629 return 0;
606} 630}
607 631
@@ -726,8 +750,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
726 } 750 }
727 751
728 if (is_bad_inode(inode)) { 752 if (is_bad_inode(inode)) {
729 dfprintk(VFS, "nfs_lookup_validate: %s/%s has dud inode\n", 753 dfprintk(LOOKUPCACHE, "%s: %s/%s has dud inode\n",
730 dentry->d_parent->d_name.name, dentry->d_name.name); 754 __FUNCTION__, dentry->d_parent->d_name.name,
755 dentry->d_name.name);
731 goto out_bad; 756 goto out_bad;
732 } 757 }
733 758
@@ -759,6 +784,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
759 out_valid: 784 out_valid:
760 unlock_kernel(); 785 unlock_kernel();
761 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);
762 return 1; 790 return 1;
763out_zap_parent: 791out_zap_parent:
764 nfs_zap_caches(dir); 792 nfs_zap_caches(dir);
@@ -775,6 +803,9 @@ out_zap_parent:
775 d_drop(dentry); 803 d_drop(dentry);
776 unlock_kernel(); 804 unlock_kernel();
777 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);
778 return 0; 809 return 0;
779} 810}
780 811
@@ -917,6 +948,9 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
917 struct dentry *res = NULL; 948 struct dentry *res = NULL;
918 int error; 949 int error;
919 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
920 /* Check that we are indeed trying to open this file */ 954 /* Check that we are indeed trying to open this file */
921 if (!is_atomic_open(dir, nd)) 955 if (!is_atomic_open(dir, nd))
922 goto no_open; 956 goto no_open;
@@ -1124,8 +1158,8 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1124 int error; 1158 int error;
1125 int open_flags = 0; 1159 int open_flags = 0;
1126 1160
1127 dfprintk(VFS, "NFS: create(%s/%ld, %s\n", dir->i_sb->s_id, 1161 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1128 dir->i_ino, dentry->d_name.name); 1162 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1129 1163
1130 attr.ia_mode = mode; 1164 attr.ia_mode = mode;
1131 attr.ia_valid = ATTR_MODE; 1165 attr.ia_valid = ATTR_MODE;
@@ -1158,8 +1192,8 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1158 struct iattr attr; 1192 struct iattr attr;
1159 int status; 1193 int status;
1160 1194
1161 dfprintk(VFS, "NFS: mknod(%s/%ld, %s\n", dir->i_sb->s_id, 1195 dfprintk(VFS, "NFS: mknod(%s/%ld), %s\n",
1162 dir->i_ino, dentry->d_name.name); 1196 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1163 1197
1164 if (!new_valid_dev(rdev)) 1198 if (!new_valid_dev(rdev))
1165 return -EINVAL; 1199 return -EINVAL;
@@ -1191,8 +1225,8 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1191 struct iattr attr; 1225 struct iattr attr;
1192 int error; 1226 int error;
1193 1227
1194 dfprintk(VFS, "NFS: mkdir(%s/%ld, %s\n", dir->i_sb->s_id, 1228 dfprintk(VFS, "NFS: mkdir(%s/%ld), %s\n",
1195 dir->i_ino, dentry->d_name.name); 1229 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1196 1230
1197 attr.ia_valid = ATTR_MODE; 1231 attr.ia_valid = ATTR_MODE;
1198 attr.ia_mode = mode | S_IFDIR; 1232 attr.ia_mode = mode | S_IFDIR;
@@ -1217,8 +1251,8 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
1217{ 1251{
1218 int error; 1252 int error;
1219 1253
1220 dfprintk(VFS, "NFS: rmdir(%s/%ld, %s\n", dir->i_sb->s_id, 1254 dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
1221 dir->i_ino, dentry->d_name.name); 1255 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1222 1256
1223 lock_kernel(); 1257 lock_kernel();
1224 nfs_begin_data_update(dir); 1258 nfs_begin_data_update(dir);
@@ -1274,8 +1308,8 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
1274 sillycounter++; 1308 sillycounter++;
1275 sprintf(suffix, "%*.*x", countersize, countersize, sillycounter); 1309 sprintf(suffix, "%*.*x", countersize, countersize, sillycounter);
1276 1310
1277 dfprintk(VFS, "trying to rename %s to %s\n", 1311 dfprintk(VFS, "NFS: trying to rename %s to %s\n",
1278 dentry->d_name.name, silly); 1312 dentry->d_name.name, silly);
1279 1313
1280 sdentry = lookup_one_len(silly, dentry->d_parent, slen); 1314 sdentry = lookup_one_len(silly, dentry->d_parent, slen);
1281 /* 1315 /*
@@ -1687,13 +1721,15 @@ force_lookup:
1687 res = PTR_ERR(cred); 1721 res = PTR_ERR(cred);
1688 unlock_kernel(); 1722 unlock_kernel();
1689out: 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);
1690 return res; 1726 return res;
1691out_notsup: 1727out_notsup:
1692 res = nfs_revalidate_inode(NFS_SERVER(inode), inode); 1728 res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
1693 if (res == 0) 1729 if (res == 0)
1694 res = generic_permission(inode, mask, NULL); 1730 res = generic_permission(inode, mask, NULL);
1695 unlock_kernel(); 1731 unlock_kernel();
1696 return res; 1732 goto out;
1697} 1733}
1698 1734
1699/* 1735/*