X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flibcfs.h;h=5fa92dfe811b5a016237a221b860a13781a7a34d;hp=b9ad772925bd471baea597162c1ba1ee2d7049d9;hb=f55fdfff5dede69e6674999fb02c1add513704f0;hpb=fc9de679a4c2294e0cd3b084c8f0dd473342a6b9 diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index b9ad772..5fa92df 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -35,27 +35,29 @@ #include #include +#include +#include +#ifdef HAVE_SCHED_HEADERS +#include +#endif #include +#include #include +#include #include #include #include #include #include -#include #include #include #include -#include #include #include "curproc.h" -#define LIBCFS_VERSION "0.5.0" - -#define PO2_ROUNDUP_TYPED(x, po2, type) (-(-(type)(x) & -(type)(po2))) -#define LOWEST_BIT_SET(x) ((x) & ~((x) - 1)) +#define LIBCFS_VERSION "0.7.1" /* Sparse annotations */ #if !defined(__must_hold) @@ -66,6 +68,8 @@ # endif /* !__CHECKER__ */ #endif /* !__must_hold */ +typedef s32 timeout_t; + /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 @@ -78,48 +82,17 @@ static inline int notifier_from_ioctl_errno(int err) return notifier_from_errno(err) | NOTIFY_STOP_MASK; } -/* - * Defined by platform - */ -int unshare_fs_struct(void); -sigset_t cfs_block_allsigs(void); -sigset_t cfs_block_sigs(unsigned long sigs); -sigset_t cfs_block_sigsinv(unsigned long sigs); -void cfs_restore_sigs(sigset_t); -void cfs_clear_sigpending(void); - -/* - * Random number handling - */ - -/* returns a random 32-bit integer */ -unsigned int cfs_rand(void); -/* seed the generator */ -void cfs_srand(unsigned int, unsigned int); -void cfs_get_random_bytes(void *buf, int size); - int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data); -int libcfs_ioctl(unsigned long cmd, void __user *uparam); - -/* container_of depends on "likely" which is defined in libcfs_private.h */ -static inline void *__container_of(const void *ptr, unsigned long shift) -{ - if (unlikely(IS_ERR(ptr) || ptr == NULL)) - return ERR_CAST(ptr); - else - return (char *)ptr - shift; -} -#define container_of0(ptr, type, member) \ - ((type *)__container_of((ptr), offsetof(type, member))) +extern struct workqueue_struct *cfs_rehash_wq; struct lnet_debugfs_symlink_def { const char *name; const char *target; }; -void lnet_insert_debugfs(struct ctl_table *table, - const struct lnet_debugfs_symlink_def *symlinks); +void lnet_insert_debugfs(struct ctl_table *table); +void lnet_remove_debugfs(struct ctl_table *table); /* helper for sysctl handlers */ int lprocfs_call_handler(void *data, int write, loff_t *ppos, @@ -127,4 +100,42 @@ int lprocfs_call_handler(void *data, int write, loff_t *ppos, int (*handler)(void *data, int write, loff_t pos, void __user *buffer, int len)); +/* + * Memory + */ +#if BITS_PER_LONG == 32 +/* limit to lowmem on 32-bit systems */ +#define NUM_CACHEPAGES \ + min(cfs_totalram_pages(), 1UL << (30 - PAGE_SHIFT) * 3 / 4) +#else +#define NUM_CACHEPAGES cfs_totalram_pages() +#endif + +#define wait_var_event_warning(var, condition, format, ...) \ +do { \ + int counter = 4; \ + might_sleep(); \ + if (condition) \ + break; \ + ___wait_var_event(var, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ + if (schedule_timeout(cfs_time_seconds(1)) == 0)\ + CDEBUG(is_power_of_2(counter++) ? \ + D_WARNING : D_NET, \ + format, ## __VA_ARGS__) \ + ); \ +} while (0) + +/* atomic-context safe vfree */ +void libcfs_vfree_atomic(const void *addr); + +/* interval tree */ + +#ifdef HAVE_INTERVAL_TREE_CACHED +#define interval_tree_root rb_root_cached +#define INTERVAL_TREE_ROOT RB_ROOT_CACHED +#else +#define interval_tree_root rb_root +#define INTERVAL_TREE_ROOT RB_ROOT +#endif /* HAVE_INTERVAL_TREE_CACHED */ + #endif /* _LIBCFS_LIBCFS_H_ */