Nfs readdir

From Linux NFS

Revision as of 18:55, 2 July 2010 by Amschuma (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

nfs_readdir()

  • fs/nfs/dir.c
  • dentry defined in include/linux/dcache.h
  • file defined in include/linux/fs.h
  • path defined in include/linux/path.h
  • nfs_entry defined in /include/linux/nfs_xdr.h


  • make a new dentry: my_entry
    • set the cookie to the previous file, allocate a file handle and attribute struct, mark that we are not at the end of the file
    • If allocations failed, goto out_alloc_failed to free memory and print a warning


  • call nfs_revalidate_mapping (fs/nfs/inode.c) to validate the page cache
    • if there is an error revalidating the cache, goto out to allow silly renames and free fattr / filehandle structs
  • Begin a loop over directory entries
  • while we have not reached the end of the directory file:
    • Search the page cache for the requested page (dir.c: readdir_search_pagecache)
    • if searching results in a bad cookie, it could mean that we are at the end of the directory or that the file has been deleted
      • ask the server fore the next file and add to the page cache using filldir (dir.c: uncached_readdir)
      • if the response is good, go to the beginning of the while loop and look up the next entry, otherwise break out of the loop and return
Personal tools