#ifdef __KERNEL__
# include <libcfs/libcfs.h>
# include <linux/module.h>
-# include <linux/jbd.h>
# include <asm/div64.h>
#else /* __KERNEL__ */
# include <liblustre.h>
# include <libcfs/list.h>
#endif
-#include <obd.h>
-#include <obd_class.h>
-#include <lustre_ver.h>
#include <obd_support.h>
-#include <lprocfs_status.h>
-
-#include <dt_object.h>
-#include <md_object.h>
-#include <lustre_req_layout.h>
#include <lustre_fld.h>
#include "fld_internal.h"
CFS_INIT_LIST_HEAD(&cache->fci_lru);
cache->fci_cache_count = 0;
- spin_lock_init(&cache->fci_lock);
+ rwlock_init(&cache->fci_lock);
- strncpy(cache->fci_name, name,
+ strlcpy(cache->fci_name, name,
sizeof(cache->fci_name));
cache->fci_cache_size = cache_size;
{
ENTRY;
- spin_lock(&cache->fci_lock);
+ write_lock(&cache->fci_lock);
cache->fci_cache_size = 0;
fld_cache_shrink(cache);
- spin_unlock(&cache->fci_lock);
+ write_unlock(&cache->fci_lock);
EXIT;
}
* entry accordingly.
*/
-void fld_cache_punch_hole(struct fld_cache *cache,
- struct fld_cache_entry *f_curr,
- struct fld_cache_entry *f_new)
+static void fld_cache_punch_hole(struct fld_cache *cache,
+ struct fld_cache_entry *f_curr,
+ struct fld_cache_entry *f_new)
{
const struct lu_seq_range *range = &f_new->fce_range;
const seqno_t new_start = range->lsr_start;
struct fld_cache_entry *fldt;
ENTRY;
- OBD_ALLOC_GFP(fldt, sizeof *fldt, CFS_ALLOC_ATOMIC);
+ OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC);
if (!fldt) {
OBD_FREE_PTR(f_new);
EXIT;
__u32 new_flags = f_new->fce_range.lsr_flags;
ENTRY;
- LASSERT_SPIN_LOCKED(&cache->fci_lock);
-
/*
* Duplicate entries are eliminated in insert op.
* So we don't need to search new entry before starting
if (IS_ERR(flde))
RETURN(PTR_ERR(flde));
- spin_lock(&cache->fci_lock);
+ write_lock(&cache->fci_lock);
rc = fld_cache_insert_nolock(cache, flde);
- spin_unlock(&cache->fci_lock);
+ write_unlock(&cache->fci_lock);
if (rc)
OBD_FREE_PTR(flde);
struct fld_cache_entry *tmp;
cfs_list_t *head;
- LASSERT_SPIN_LOCKED(&cache->fci_lock);
head = &cache->fci_entries_head;
cfs_list_for_each_entry_safe(flde, tmp, head, fce_list) {
/* add list if next is end of list */
void fld_cache_delete(struct fld_cache *cache,
const struct lu_seq_range *range)
{
- spin_lock(&cache->fci_lock);
+ write_lock(&cache->fci_lock);
fld_cache_delete_nolock(cache, range);
- spin_unlock(&cache->fci_lock);
+ write_unlock(&cache->fci_lock);
}
-struct fld_cache_entry
-*fld_cache_entry_lookup_nolock(struct fld_cache *cache,
- struct lu_seq_range *range)
+struct fld_cache_entry *
+fld_cache_entry_lookup_nolock(struct fld_cache *cache,
+ const struct lu_seq_range *range)
{
struct fld_cache_entry *flde;
struct fld_cache_entry *got = NULL;
cfs_list_t *head;
- LASSERT_SPIN_LOCKED(&cache->fci_lock);
head = &cache->fci_entries_head;
cfs_list_for_each_entry(flde, head, fce_list) {
if (range->lsr_start == flde->fce_range.lsr_start ||
/**
* lookup \a seq sequence for range in fld cache.
*/
-struct fld_cache_entry
-*fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range)
+struct fld_cache_entry *
+fld_cache_entry_lookup(struct fld_cache *cache,
+ const struct lu_seq_range *range)
{
struct fld_cache_entry *got = NULL;
ENTRY;
- spin_lock(&cache->fci_lock);
+ read_lock(&cache->fci_lock);
got = fld_cache_entry_lookup_nolock(cache, range);
- spin_unlock(&cache->fci_lock);
+ read_unlock(&cache->fci_lock);
+
RETURN(got);
}
cfs_list_t *head;
ENTRY;
- spin_lock(&cache->fci_lock);
+ read_lock(&cache->fci_lock);
head = &cache->fci_entries_head;
cache->fci_stat.fst_count++;
cfs_list_for_each_entry(flde, head, fce_list) {
if (flde->fce_range.lsr_start > seq) {
if (prev != NULL)
- memcpy(range, prev, sizeof(*range));
+ *range = prev->fce_range;
break;
}
if (range_within(&flde->fce_range, seq)) {
*range = flde->fce_range;
- /* update position of this entry in lru list. */
- cfs_list_move(&flde->fce_lru, &cache->fci_lru);
cache->fci_stat.fst_cache++;
- spin_unlock(&cache->fci_lock);
+ read_unlock(&cache->fci_lock);
RETURN(0);
}
}
- spin_unlock(&cache->fci_lock);
+ read_unlock(&cache->fci_lock);
RETURN(-ENOENT);
}
-