nfs-ganesha 1.4
Functions

cache_inode_readdir.c File Reference

Reads the content of a directory. More...

#include "abstract_atomic.h"
#include "log.h"
#include "HashData.h"
#include "HashTable.h"
#include "fsal.h"
#include "cache_inode.h"
#include "cache_inode_lru.h"
#include "cache_inode_avl.h"
#include "cache_inode_weakref.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <time.h>
#include <pthread.h>
#include <assert.h>

Go to the source code of this file.

Functions

cache_inode_status_t cache_inode_invalidate_all_cached_dirent (cache_entry_t *entry, cache_inode_status_t *status)
 Invalidates all cached entries for a directory.
cache_inode_status_t cache_inode_operate_cached_dirent (cache_entry_t *directory, fsal_name_t *name, fsal_name_t *newname, cache_inode_dirent_op_t dirent_op)
 Perform an operation on it on a cached entry.
cache_inode_status_t cache_inode_add_cached_dirent (cache_entry_t *parent, fsal_name_t *name, cache_entry_t *entry, cache_inode_dir_entry_t **dir_entry, cache_inode_status_t *status)
 Adds a directory entry to a cached directory.
cache_inode_status_t cache_inode_remove_cached_dirent (cache_entry_t *directory, fsal_name_t *name, cache_inode_status_t *status)
 Removes an entry from a cached directory.
cache_inode_status_t cache_inode_readdir_populate (cache_entry_t *directory, fsal_op_context_t *context, cache_inode_status_t *status)
 Cache complete directory contents.
cache_inode_status_t cache_inode_readdir (cache_entry_t *directory, uint64_t cookie, unsigned int *nbfound, bool_t *eod_met, fsal_op_context_t *context, cache_inode_readdir_cb_t cb, void *cb_opaque, cache_inode_status_t *status)
 Reads a directory.

Detailed Description

Reads the content of a directory.

Author:
Author:
deniel
Date:
Date:
2006/01/24 11:43:05
Version:
Revision:
1.50

Reads the content of a directory, also includes support functions for cached directories.

Definition in file cache_inode_readdir.c.


Function Documentation

cache_inode_status_t cache_inode_add_cached_dirent ( cache_entry_t parent,
fsal_name_t name,
cache_entry_t entry,
cache_inode_dir_entry_t **  dir_entry,
cache_inode_status_t status 
)

Adds a directory entry to a cached directory.

This function adds a new directory entry to a directory. Directory entries have only weak references, so they do not prevent recycling or freeing the entry they locate. This function may be called either once (for handling creation) or iteratively in directory population.

Parameters:
[in,out]parentCache entry of the directory being updated
[in]nameThe name to add to the entry
[in]entryThe cache entry associated with name
[out]dir_entryThe directory entry newly added (optional)
[out]statusSame as return value
Returns:
CACHE_INODE_SUCCESS or errors on failure.

Definition at line 260 of file cache_inode_readdir.c.

cache_inode_status_t cache_inode_invalidate_all_cached_dirent ( cache_entry_t entry,
cache_inode_status_t status 
)

Invalidates all cached entries for a directory.

Invalidates all the entries for a cached directory. The content lock must be held when this function is called.

Parameters:
[in,out]entryThe directory to be managed
[out]statusReturned status.
Returns:
the same as *status

Definition at line 76 of file cache_inode_readdir.c.

cache_inode_status_t cache_inode_operate_cached_dirent ( cache_entry_t directory,
fsal_name_t name,
fsal_name_t newname,
cache_inode_dirent_op_t  dirent_op 
)

Perform an operation on it on a cached entry.

This function looks up an entry in the drectory cache and performs the indicated operation. If the directory has not been populated, it will not return not found errors.

The caller must hold the content lock on the directory.

Parameters:
[in]directoryThe directory to be operated upon
[in]nameThe name of the relevant entry
[in]newnameThe new name for renames
[in]dirent_opThe operation (LOOKUP, REMOVE, or RENAME) to perform
Return values:
CACHE_INODE_SUCCESSon success or failure in an unpopulated directory.
CACHE_INODE_BAD_TYPEif the supplied cache entry is not a directory.
CACHE_INODE_NOT_FOUNDon lookup failure in a populated directory.
CACHE_INODE_ENTRY_EXISTSon rename collission in a populated directory.

Definition at line 126 of file cache_inode_readdir.c.

cache_inode_status_t cache_inode_readdir ( cache_entry_t directory,
uint64_t  cookie,
unsigned int *  nbfound,
bool_t *  eod_met,
fsal_op_context_t context,
cache_inode_readdir_cb_t  cb,
void *  cb_opaque,
cache_inode_status_t status 
)

Reads a directory.

This function iterates over the cached directory entries (possibly after populating the cache) and invokes a supplied callback function for each one.

The caller must not hold the attribute or content locks on directory.

Parameters:
[in]directoryThe directory to be read
[in]cookieStarting cookie for the readdir operation
[out]nbfoundNumber of entries returned.
[out]eod_metWhether the end of directory was met
[in]contextFSAL credentials
[in]cbThe callback function to receive entries
[in]cb_opaqueA pointer passed as the first argument to cb
[out]statusReturned status
Return values:
CACHE_INODE_SUCCESSif operation is a success
CACHE_INODE_BAD_TYPEif entry is not related to a directory

Definition at line 601 of file cache_inode_readdir.c.

cache_inode_status_t cache_inode_readdir_populate ( cache_entry_t directory,
fsal_op_context_t context,
cache_inode_status_t status 
)

Cache complete directory contents.

This function reads a complete directory from the FSAL and caches both the names and filess. The content lock must be held on the directory being read.

Parameters:
[in]directoryEntry for the parent directory to be read
[in]contextFSAL credentials
[out]statusReturned status

Definition at line 374 of file cache_inode_readdir.c.

cache_inode_status_t cache_inode_remove_cached_dirent ( cache_entry_t directory,
fsal_name_t name,
cache_inode_status_t status 
)

Removes an entry from a cached directory.

This function removes the named entry from a cached directory. The caller must hold the content lock.

Parameters:
[in,out]directoryThe cache entry representing the directory
[in]nameThe name indicating the entry to remove
[out]statusReturned status
Return values:
CACHE_INODE_SUCCESSon success.
CACHE_INODE_BAD_TYPEif directory is not a directory.
Theresult of cache_inode_operate_cached_dirent

Definition at line 337 of file cache_inode_readdir.c.