libcfsdir = $(includedir)/libcfs
EXTRA_DIST = \
- bitmap.h \
libcfs.h \
libcfs_cpu.h \
libcfs_crypto.h \
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, 2014, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- */
-#ifndef _LIBCFS_BITMAP_H_
-#define _LIBCFS_BITMAP_H_
-
-#include <linux/interrupt.h>
-#include <libcfs/libcfs_private.h>
-
-struct cfs_bitmap {
- unsigned int size;
- unsigned long data[0];
-};
-
-#define CFS_BITMAP_SIZE(nbits) \
- (BITS_TO_LONGS(nbits) * sizeof(long) + sizeof(struct cfs_bitmap))
-
-static inline
-struct cfs_bitmap *CFS_ALLOCATE_BITMAP(int size)
-{
- struct cfs_bitmap *ptr;
-
- LIBCFS_ALLOC(ptr, CFS_BITMAP_SIZE(size));
- if (ptr == NULL)
- RETURN(ptr);
-
- ptr->size = size;
-
- RETURN(ptr);
-}
-
-static inline void CFS_RESET_BITMAP(struct cfs_bitmap *bitmap)
-{
- if (bitmap->size > 0) {
- int nbits = bitmap->size;
-
- memset(bitmap, 0, CFS_BITMAP_SIZE(nbits));
- bitmap->size = nbits;
- }
-}
-
-#define CFS_FREE_BITMAP(ptr) LIBCFS_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
-
-static inline
-void cfs_bitmap_set(struct cfs_bitmap *bitmap, int nbit)
-{
- set_bit(nbit, bitmap->data);
-}
-
-static inline
-void cfs_bitmap_clear(struct cfs_bitmap *bitmap, int nbit)
-{
- test_and_clear_bit(nbit, bitmap->data);
-}
-
-static inline
-int cfs_bitmap_check(struct cfs_bitmap *bitmap, int nbit)
-{
- return test_bit(nbit, bitmap->data);
-}
-
-static inline
-int cfs_bitmap_test_and_clear(struct cfs_bitmap *bitmap, int nbit)
-{
- return test_and_clear_bit(nbit, bitmap->data);
-}
-
-/* return 0 is bitmap has none set bits */
-static inline
-int cfs_bitmap_check_empty(struct cfs_bitmap *bitmap)
-{
- return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
-}
-
-static inline
-void cfs_bitmap_copy(struct cfs_bitmap *new, struct cfs_bitmap *old)
-{
- size_t newsize;
-
- LASSERT(new->size >= old->size);
- newsize = new->size;
- memcpy(new, old, CFS_BITMAP_SIZE(old->size));
- new->size = newsize;
-}
-
-#define cfs_foreach_bit(bitmap, pos) \
- for ((pos) = find_first_bit((bitmap)->data, bitmap->size); \
- (pos) < (bitmap)->size; \
- (pos) = find_next_bit((bitmap)->data, (bitmap)->size, (pos) + 1))
-
-#endif
#include <uapi/linux/lnet/libcfs_ioctl.h>
#include <libcfs/libcfs_debug.h>
#include <libcfs/libcfs_private.h>
-#include <libcfs/bitmap.h>
#include <libcfs/libcfs_cpu.h>
#include <libcfs/libcfs_string.h>
#include <libcfs/libcfs_workitem.h>
/** uid/gid list string of the rule. */
char *tr_ids_str;
/** Opcode bitmap of the rule. */
- struct cfs_bitmap *tr_opcodes;
+ unsigned long *tr_opcodes;
+ u32 tr_opcodes_cnt;
/** Opcode list string of the rule.*/
char *tr_opcodes_str;
/** Condition list of the rule.*/
struct nrs_tbf_expression {
enum nrs_tbf_field te_field;
struct list_head te_cond;
- struct cfs_bitmap *te_opcodes;
+ unsigned long *te_opcodes;
+ u32 te_opcodes_cnt;
struct list_head te_linkage;
};
#include <uapi/linux/lustre/lustre_idl.h>
#include <lustre_lib.h>
-#include <libcfs/bitmap.h>
#ifdef HAVE_SERVER_SUPPORT
# include <lu_target.h>
# include <obd_target.h>
nrs_tbf_jobid_list_free(&expr->te_cond);
break;
case NRS_TBF_FIELD_OPCODE:
- CFS_FREE_BITMAP(expr->te_opcodes);
+ bitmap_free(expr->te_opcodes);
break;
case NRS_TBF_FIELD_UID:
case NRS_TBF_FIELD_GID:
}
static int
-nrs_tbf_opcode_list_parse(char *str, int len, struct cfs_bitmap **bitmaptr);
+nrs_tbf_opcode_list_parse(char *str, int len, unsigned long **bitmaptr);
static int
nrs_tbf_id_list_parse(char *str, int len, struct list_head *id_list,
enum nrs_tbf_flag tif);
case NRS_TBF_FIELD_JOBID:
return nrs_tbf_jobid_list_match(&expr->te_cond, cli->tc_jobid);
case NRS_TBF_FIELD_OPCODE:
- return cfs_bitmap_check(expr->te_opcodes, cli->tc_opcode);
+ return test_bit(cli->tc_opcode, expr->te_opcodes);
case NRS_TBF_FIELD_UID:
case NRS_TBF_FIELD_GID:
return nrs_tbf_id_list_match(&expr->te_cond, cli->tc_id);
static void nrs_tbf_opcode_rule_fini(struct nrs_tbf_rule *rule)
{
- if (rule->tr_opcodes != NULL)
- CFS_FREE_BITMAP(rule->tr_opcodes);
+ if (rule->tr_opcodes)
+ bitmap_free(rule->tr_opcodes);
LASSERT(rule->tr_opcodes_str != NULL);
OBD_FREE(rule->tr_opcodes_str, strlen(rule->tr_opcodes_str) + 1);
#define MAX_OPCODE_LEN 32
static int
-nrs_tbf_opcode_set_bit(const struct cfs_lstr *id, struct cfs_bitmap *opcodes)
+nrs_tbf_opcode_set_bit(const struct cfs_lstr *id, unsigned long *opcodes)
{
int op = 0;
char opcode_str[MAX_OPCODE_LEN];
if (op < 0)
return -EINVAL;
- cfs_bitmap_set(opcodes, op);
+ set_bit(op, opcodes);
return 0;
}
static int
-nrs_tbf_opcode_list_parse(char *str, int len, struct cfs_bitmap **bitmaptr)
+nrs_tbf_opcode_list_parse(char *str, int len, unsigned long **bitmaptr)
{
- struct cfs_bitmap *opcodes;
+ unsigned long *opcodes;
struct cfs_lstr src;
struct cfs_lstr res;
int rc = 0;
- ENTRY;
- opcodes = CFS_ALLOCATE_BITMAP(LUSTRE_MAX_OPCODES);
- if (opcodes == NULL)
+ ENTRY;
+ opcodes = bitmap_zalloc(LUSTRE_MAX_OPCODES, GFP_KERNEL);
+ if (!opcodes)
return -ENOMEM;
src.ls_str = str;
if (rc == 0 && bitmaptr)
*bitmaptr = opcodes;
else
- CFS_FREE_BITMAP(opcodes);
+ bitmap_free(opcodes);
RETURN(rc);
}
if (rule->tr_opcodes == NULL)
return 0;
- return cfs_bitmap_check(rule->tr_opcodes, cli->tc_opcode);
+ return test_bit(cli->tc_opcode, rule->tr_opcodes);
}
static int nrs_tbf_opcode_rule_init(struct ptlrpc_nrs_policy *policy,