Nfs readdir

From Linux NFS

Revision as of 19:26, 2 July 2010 by Amschuma (Talk | contribs)
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
  • Block silly renames from running
  • call nfs_revalidate_mapping (fs/nfs/inode.c) to validate the page cache
    • if there is an error revalidating the cache, goto out
  • 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 (EBADCOOKIE), 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
    • if searching results in a too small error (ETOOSMALL) and if we are doing a readdir plus
      • clear the "NFS_INO_ADVISE_RDPLUS" flag contained in the nfs_inode
      • "zap" the cache (invalidate the nfs_inode)
    • if res indicates any other error, break out of the loop
    • add the page to the cache
      • break out of the loop if there is a problem adding the page to the cache
  • out:
    • unblock (allow) silly renames
    • set response is non zero, set it equal to zero
  • out_alloc_failed:
    • free file handle and attr structs in my_entry
    • print a message stating what is being returned
    • return the response code
Personal tools