Esempio n. 1
0
/**
 * @brief Removes an entry from a cached directory.
 *
 * This function removes the named entry from a cached directory.  The
 * caller must hold the content lock.
 *
 * @param[in,out] directory The cache entry representing the directory
 * @param[in]     name      The name indicating the entry to remove
 *
 * @retval CACHE_INODE_SUCCESS on success.
 * @retval CACHE_INODE_BAD_TYPE if directory is not a directory.
 * @retval The result of cache_inode_operate_cached_dirent
 *
 */
cache_inode_status_t
cache_inode_remove_cached_dirent(cache_entry_t *directory,
				 const char *name)
{
	cache_inode_status_t status = CACHE_INODE_SUCCESS;

	/* Sanity check */
	if (directory->type != DIRECTORY) {
		status = CACHE_INODE_NOT_A_DIRECTORY;
		return status;
	}

	status =
	    cache_inode_operate_cached_dirent(directory, name, NULL,
					      CACHE_INODE_DIRENT_OP_REMOVE);
	return status;

}
Esempio n. 2
0
cache_inode_status_t
cache_inode_rename_cached_dirent(cache_entry_t *parent,
				 const char *oldname,
				 const char *newname)
{
	cache_inode_status_t status = CACHE_INODE_SUCCESS;

	/* Sanity check */
	if (parent->type != DIRECTORY) {
		status = CACHE_INODE_NOT_A_DIRECTORY;
		return status;
	}

	status =
	    cache_inode_operate_cached_dirent(parent, oldname, newname,
					      CACHE_INODE_DIRENT_OP_RENAME);

	return status;
}
Esempio n. 3
0
/**
 *
 * cache_inode_lookup_cached_dirent: looks up for an dirent in the cached
 * dirent.
 *
 * Looks up for an dirent in the cached dirent. Thus function searches only in
 * the entries listed in the dir_entries array. Some entries may be missing but
 * existing and not be cached (if no readdir was ever performed on the entry for
 * example.
 *
 * @param pentry_parent [IN] directory entry to be looked.
 * @param name [IN] name for the searched entry.
 * @param pclient [INOUT] resource allocated by the client for the nfs
 *        management.
 * @pstatus [OUT] returned status. CACHE_INODE_SUCCESS=entry found,
 *          CACHE_INODE_NOT_FOUND=entry is not in the dirent
 *
 * @return the found entry if its exists and NULL if it is not in the dirent
 * cache.
 *
 */
cache_entry_t *cache_inode_lookup_cached_dirent(cache_entry_t * pentry_parent,
                                                fsal_name_t * pname,
                                                cache_inode_client_t * pclient,
                                                cache_inode_status_t * pstatus)
{
  /* Set the return default to CACHE_INODE_SUCCESS */
  *pstatus = CACHE_INODE_SUCCESS;

  /* Sanity check */
  if(pentry_parent->internal_md.type != DIRECTORY)
    {
      *pstatus = CACHE_INODE_BAD_TYPE;
      return NULL;
    }
  return cache_inode_operate_cached_dirent(pentry_parent, *pname, NULL,
					   pclient,
                                           CACHE_INODE_DIRENT_OP_LOOKUP,
					   pstatus);
}                               /* cache_inode_lookup_cached_dirent */
Esempio n. 4
0
/**
 *
 * cache_inode_remove_cached_dirent: Removes a directory entry to a cached
 * directory.
 *
 * Removes a directory entry to a cached directory. No MT safety managed here !!
 *
 * @param pentry_parent [INOUT] cache entry representing the directory to be
 * managed.
 * @param name [IN] name of the entry to remove.
 * @param ht [IN] hash table used for the cache, unused in this call.
 * @param pclient [INOUT] ressource allocated by the client for the nfs
 * management.
 * @param pstatus [OUT] returned status.
 *
 * @return the same as *pstatus
 *
 */
cache_inode_status_t cache_inode_remove_cached_dirent(
    cache_entry_t * pentry_parent,
    fsal_name_t * pname,
    hash_table_t * ht,
    cache_inode_client_t * pclient,
    cache_inode_status_t * pstatus)
{
  cache_entry_t *removed_pentry = NULL;
  cache_inode_parent_entry_t *parent_iter = NULL;
  cache_inode_parent_entry_t *previous_iter = NULL;
  int found = 0;

  /* Set the return default to CACHE_INODE_SUCCESS */
  *pstatus = CACHE_INODE_SUCCESS;

  /* Sanity check */
  if(pentry_parent->internal_md.type != DIRECTORY)
    {
      *pstatus = CACHE_INODE_BAD_TYPE;
      return *pstatus;
    }

  /* BUGAZOMEU: Ne pas oublier de jarter un dir dont toutes les entrees sont
   * inactives */
  if((removed_pentry = cache_inode_operate_cached_dirent(pentry_parent,
                                                         pname,
                                                         NULL,
							 pclient,
                                                         CACHE_INODE_DIRENT_OP_REMOVE,
                                                         pstatus)) == NULL)
    return *pstatus;

  /* Remove the parent entry from the entry whose dirent is removed */
  for(previous_iter = NULL, parent_iter = removed_pentry->parent_list;
      (parent_iter != NULL) && (parent_iter->parent != NULL);
      previous_iter = parent_iter, parent_iter = parent_iter->next_parent)
    {
      if(parent_iter->parent == pentry_parent)
        {
          found = 1;
          break;
        }
    }

  /* Check for pentry cache inconsistency */
  if(!found)
    {
      *pstatus = CACHE_INODE_INCONSISTENT_ENTRY;
    }
  else
    {
      if(previous_iter == NULL)
        {
          /* this is the first parent */
          removed_pentry->parent_list = parent_iter->next_parent;
        }
      else
        {
          /* This is not the first parent */
          previous_iter->next_parent = parent_iter->next_parent;
        }

      /* It is now time to put parent_iter back to its pool */
      ReleaseToPool(parent_iter, &pclient->pool_parent);

    }
  return CACHE_INODE_SUCCESS;
}                               /* cache_inode_remove_cached_dirent */