#define DEBUG_SUBSYSTEM S_CLASS
#include <libcfs/libcfs.h>
-
-#ifdef __KERNEL__
-# include <linux/module.h>
-#endif
-
-/* hash_long() */
-#include <libcfs/libcfs_hash.h>
+#include <linux/module.h>
+#include <libcfs/libcfs_hash.h> /* hash_long() */
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_disk.h>
cfs_hash_bd_t bd;
cfs_hash_bd_t bd2;
struct list_head dispose;
- int did_sth;
- int start;
+ int did_sth;
+ unsigned int start;
int count;
int bnr;
- int i;
+ unsigned int i;
if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU))
RETURN(0);
* the dispose list, removing them from LRU and hash table.
*/
start = s->ls_purge_start;
- bnr = (nr == ~0) ? -1 : nr / CFS_HASH_NBKT(s->ls_obj_hash) + 1;
+ bnr = (nr == ~0) ? -1 : nr / (int)CFS_HASH_NBKT(s->ls_obj_hash) + 1;
again:
/*
* It doesn't make any sense to make purge threads parallel, that can
* drained), and moreover, lookup has to wait until object is freed.
*/
- init_waitqueue_entry_current(waiter);
- add_wait_queue(&bkt->lsb_marche_funebre, waiter);
- set_current_state(TASK_UNINTERRUPTIBLE);
- lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_DEATH_RACE);
+ if (likely(waiter != NULL)) {
+ init_waitqueue_entry_current(waiter);
+ add_wait_queue(&bkt->lsb_marche_funebre, waiter);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_DEATH_RACE);
+ }
+
return ERR_PTR(-EAGAIN);
}
wait_queue_t wait;
while (1) {
+ if (conf != NULL && conf->loc_flags & LOC_F_NOWAIT) {
+ obj = lu_object_find_try(env, dev, f, conf, NULL);
+
+ return obj;
+ }
+
obj = lu_object_find_try(env, dev, f, conf, &wait);
if (obj != ERR_PTR(-EAGAIN))
return obj;
/**
* Return desired hash table order.
*/
-static int lu_htable_order(struct lu_device *top)
+static unsigned long lu_htable_order(struct lu_device *top)
{
- unsigned long cache_size;
- int bits;
+ unsigned long cache_size;
+ unsigned long bits;
/*
* For ZFS based OSDs the cache should be disabled by default. This
struct lu_site_bkt_data *bkt;
cfs_hash_bd_t bd;
char name[16];
- int bits;
- int i;
+ unsigned long bits;
+ unsigned int i;
ENTRY;
memset(s, 0, sizeof *s);
mutex_init(&s->ls_purge_mutex);
bits = lu_htable_order(top);
- snprintf(name, 16, "lu_site_%s", top->ld_type->ldt_name);
- for (bits = min(max(LU_SITE_BITS_MIN, bits), LU_SITE_BITS_MAX);
+ snprintf(name, sizeof(name), "lu_site_%s", top->ld_type->ldt_name);
+ for (bits = clamp_t(typeof(bits), bits,
+ LU_SITE_BITS_MIN, LU_SITE_BITS_MAX);
bits >= LU_SITE_BITS_MIN; bits--) {
s->ls_obj_hash = cfs_hash_create(name, bits, bits,
bits - LU_SITE_BKT_BITS,
}
if (s->ls_obj_hash == NULL) {
- CERROR("failed to create lu_site hash with bits: %d\n", bits);
+ CERROR("failed to create lu_site hash with bits: %lu\n", bits);
return -ENOMEM;
}
*/
int lu_context_key_register(struct lu_context_key *key)
{
- int result;
- int i;
+ int result;
+ unsigned int i;
LASSERT(key->lct_init != NULL);
LASSERT(key->lct_fini != NULL);
static void keys_fini(struct lu_context *ctx)
{
- int i;
+ unsigned int i;
if (ctx->lc_value == NULL)
return;
static int keys_fill(struct lu_context *ctx)
{
- int i;
+ unsigned int i;
LINVRNT(ctx->lc_value != NULL);
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
*/
void lu_context_exit(struct lu_context *ctx)
{
- int i;
+ unsigned int i;
LINVRNT(ctx->lc_state == LCS_ENTERED);
ctx->lc_state = LCS_LEFT;
static void lu_site_stats_get(cfs_hash_t *hs,
lu_site_stats_t *stats, int populated)
{
- cfs_hash_bd_t bd;
- int i;
+ cfs_hash_bd_t bd;
+ unsigned int i;
cfs_hash_for_each_bucket(hs, &bd, i) {
struct lu_site_bkt_data *bkt = cfs_hash_bd_extra_get(hs, &bd);
}
}
-#ifdef __KERNEL__
static unsigned long lu_cache_shrink_count(struct shrinker *sk,
struct shrink_control *sc)
void lu_context_keys_dump(void)
{
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
struct lu_context_key *key;
}
}
EXPORT_SYMBOL(lu_context_keys_dump);
-#endif /* __KERNEL__ */
/**
* Initialization of global lu_* data.
}
EXPORT_SYMBOL(lu_buf_free);
-void lu_buf_alloc(struct lu_buf *buf, int size)
+void lu_buf_alloc(struct lu_buf *buf, size_t size)
{
LASSERT(buf);
LASSERT(buf->lb_buf == NULL);
}
EXPORT_SYMBOL(lu_buf_alloc);
-void lu_buf_realloc(struct lu_buf *buf, int size)
+void lu_buf_realloc(struct lu_buf *buf, size_t size)
{
lu_buf_free(buf);
lu_buf_alloc(buf, size);
}
EXPORT_SYMBOL(lu_buf_realloc);
-struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len)
+struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len)
{
if (buf->lb_buf == NULL && buf->lb_len == 0)
lu_buf_alloc(buf, len);
* old buffer remains unchanged on error
* \retval 0 or -ENOMEM
*/
-int lu_buf_check_and_grow(struct lu_buf *buf, int len)
+int lu_buf_check_and_grow(struct lu_buf *buf, size_t len)
{
char *ptr;