#ifdef __KERNEL__
# include <libcfs/libcfs.h>
# include <linux/module.h>
-# include <linux/jbd.h>
-# include <asm/div64.h>
+# include <linux/math64.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"
if (cache == NULL)
RETURN(ERR_PTR(-ENOMEM));
- CFS_INIT_LIST_HEAD(&cache->fci_entries_head);
- CFS_INIT_LIST_HEAD(&cache->fci_lru);
+ INIT_LIST_HEAD(&cache->fci_entries_head);
+ INIT_LIST_HEAD(&cache->fci_lru);
cache->fci_cache_count = 0;
rwlock_init(&cache->fci_lock);
void fld_cache_entry_delete(struct fld_cache *cache,
struct fld_cache_entry *node)
{
- cfs_list_del(&node->fce_list);
- cfs_list_del(&node->fce_lru);
+ list_del(&node->fce_list);
+ list_del(&node->fce_lru);
cache->fci_cache_count--;
OBD_FREE_PTR(node);
}
struct fld_cache_entry *f_next;
struct lu_seq_range *c_range;
struct lu_seq_range *n_range;
- cfs_list_t *head = &cache->fci_entries_head;
+ struct list_head *head = &cache->fci_entries_head;
ENTRY;
restart_fixup:
- cfs_list_for_each_entry_safe(f_curr, f_next, head, fce_list) {
+ list_for_each_entry_safe(f_curr, f_next, head, fce_list) {
c_range = &f_curr->fce_range;
n_range = &f_next->fce_range;
*/
static inline void fld_cache_entry_add(struct fld_cache *cache,
struct fld_cache_entry *f_new,
- cfs_list_t *pos)
+ struct list_head *pos)
{
- cfs_list_add(&f_new->fce_list, pos);
- cfs_list_add(&f_new->fce_lru, &cache->fci_lru);
+ list_add(&f_new->fce_list, pos);
+ list_add(&f_new->fce_lru, &cache->fci_lru);
- cache->fci_cache_count++;
- fld_fix_new_list(cache);
+ cache->fci_cache_count++;
+ fld_fix_new_list(cache);
}
/**
static int fld_cache_shrink(struct fld_cache *cache)
{
struct fld_cache_entry *flde;
- cfs_list_t *curr;
+ struct list_head *curr;
int num = 0;
ENTRY;
while (cache->fci_cache_count + cache->fci_threshold >
cache->fci_cache_size && curr != &cache->fci_lru) {
- flde = cfs_list_entry(curr, struct fld_cache_entry, fce_lru);
+ flde = list_entry(curr, struct fld_cache_entry, fce_lru);
curr = curr->prev;
fld_cache_entry_delete(cache, flde);
num++;
* 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;
{
struct fld_cache_entry *f_curr;
struct fld_cache_entry *n;
- cfs_list_t *head;
- cfs_list_t *prev = NULL;
+ struct list_head *head;
+ struct list_head *prev = NULL;
const seqno_t new_start = f_new->fce_range.lsr_start;
const seqno_t new_end = f_new->fce_range.lsr_end;
__u32 new_flags = f_new->fce_range.lsr_flags;
head = &cache->fci_entries_head;
- cfs_list_for_each_entry_safe(f_curr, n, head, fce_list) {
+ list_for_each_entry_safe(f_curr, n, head, fce_list) {
/* add list if next is end of list */
if (new_end < f_curr->fce_range.lsr_start ||
(new_end == f_curr->fce_range.lsr_start &&
{
struct fld_cache_entry *flde;
struct fld_cache_entry *tmp;
- cfs_list_t *head;
+ struct list_head *head;
head = &cache->fci_entries_head;
- cfs_list_for_each_entry_safe(flde, tmp, head, fce_list) {
+ list_for_each_entry_safe(flde, tmp, head, fce_list) {
/* add list if next is end of list */
if (range->lsr_start == flde->fce_range.lsr_start ||
(range->lsr_end == flde->fce_range.lsr_end &&
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;
+ struct list_head *head;
head = &cache->fci_entries_head;
- cfs_list_for_each_entry(flde, head, fce_list) {
+ list_for_each_entry(flde, head, fce_list) {
if (range->lsr_start == flde->fce_range.lsr_start ||
(range->lsr_end == flde->fce_range.lsr_end &&
range->lsr_flags == flde->fce_range.lsr_flags)) {
/**
* 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;
read_lock(&cache->fci_lock);
got = fld_cache_entry_lookup_nolock(cache, range);
read_unlock(&cache->fci_lock);
+
RETURN(got);
}
{
struct fld_cache_entry *flde;
struct fld_cache_entry *prev = NULL;
- cfs_list_t *head;
+ struct list_head *head;
ENTRY;
read_lock(&cache->fci_lock);
head = &cache->fci_entries_head;
cache->fci_stat.fst_count++;
- cfs_list_for_each_entry(flde, head, fce_list) {
+ 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;
}
read_unlock(&cache->fci_lock);
RETURN(-ENOENT);
}
-