1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
5 * Author: Nikita Danilov <nikita@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or modify it under the
10 * terms of version 2 of the GNU General Public License as published by the
11 * Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along
19 * with Lustre; if not, write to the Free Software Foundation, Inc., 675 Mass
20 * Ave, Cambridge, MA 02139, USA.
22 * Implementation of portable time API for user-level.
26 #ifndef __LIBCFS_USER_PRIM_H__
27 #define __LIBCFS_USER_PRIM_H__
29 #ifndef __LIBCFS_LIBCFS_H__
30 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
33 /* Implementations of portable APIs for liblustre */
36 * liblustre is single-threaded, so most "synchronization" APIs are trivial.
41 #include <libcfs/list.h>
44 * Wait Queue. No-op implementation.
47 typedef struct cfs_waitlink {} cfs_waitlink_t;
48 typedef struct cfs_waitq {} cfs_waitq_t;
50 void cfs_waitq_init(struct cfs_waitq *waitq);
51 void cfs_waitlink_init(struct cfs_waitlink *link);
52 void cfs_waitq_add(struct cfs_waitq *waitq, struct cfs_waitlink *link);
53 void cfs_waitq_add_exclusive(struct cfs_waitq *waitq,
54 struct cfs_waitlink *link);
55 void cfs_waitq_forward(struct cfs_waitlink *link, struct cfs_waitq *waitq);
56 void cfs_waitq_del(struct cfs_waitq *waitq, struct cfs_waitlink *link);
57 int cfs_waitq_active(struct cfs_waitq *waitq);
58 void cfs_waitq_signal(struct cfs_waitq *waitq);
59 void cfs_waitq_signal_nr(struct cfs_waitq *waitq, int nr);
60 void cfs_waitq_broadcast(struct cfs_waitq *waitq);
61 void cfs_waitq_wait(struct cfs_waitlink *link);
62 int64_t cfs_waitq_timedwait(struct cfs_waitlink *link, int64_t timeout);
71 * for this moment, liblusre will not rely OST for non-page-aligned write
73 #define LIBLUSTRE_HANDLE_UNALIGNED_PAGE
78 struct list_head list;
79 unsigned long private;
81 /* internally used by liblustre file i/o */
84 #ifdef LIBLUSTRE_HANDLE_UNALIGNED_PAGE
89 typedef struct page cfs_page_t;
91 #define CFS_PAGE_SIZE PAGE_CACHE_SIZE
92 #define CFS_PAGE_SHIFT PAGE_CACHE_SHIFT
93 #define CFS_PAGE_MASK PAGE_CACHE_MASK
95 cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order);
96 void cfs_free_pages(struct page *pg, int what);
98 cfs_page_t *cfs_alloc_page(unsigned int flags);
99 void cfs_free_page(cfs_page_t *pg, int what);
100 void *cfs_page_address(cfs_page_t *pg);
101 void *cfs_kmap(cfs_page_t *pg);
102 void cfs_kunmap(cfs_page_t *pg);
104 #define cfs_get_page(p) __I_should_not_be_called__(at_all)
105 #define cfs_page_count(p) __I_should_not_be_called__(at_all)
106 #define cfs_set_page_count(p, v) __I_should_not_be_called__(at_all)
111 void *cfs_alloc(size_t nr_bytes, u_int32_t flags);
112 void cfs_free(void *addr);
113 void *cfs_alloc_large(size_t nr_bytes);
114 void cfs_free_large(void *addr);
123 #define SLAB_HWCACHE_ALIGN 0
126 cfs_mem_cache_create(const char *, size_t, size_t, unsigned long,
127 void (*)(void *, cfs_mem_cache_t *, unsigned long),
128 void (*)(void *, cfs_mem_cache_t *, unsigned long));
129 int cfs_mem_cache_destroy(cfs_mem_cache_t *c);
130 void *cfs_mem_cache_alloc(cfs_mem_cache_t *c, int gfp);
131 void cfs_mem_cache_free(cfs_mem_cache_t *c, void *addr);
133 typedef int (cfs_read_proc_t)(char *page, char **start, off_t off,
134 int count, int *eof, void *data);
136 struct file; /* forward ref */
137 typedef int (cfs_write_proc_t)(struct file *file, const char *buffer,
138 unsigned long count, void *data);
144 typedef struct cfs_timer {} cfs_timer_t;
147 #define cfs_init_timer(t) do {} while(0)
148 void cfs_timer_init(struct cfs_timer *t, void (*func)(unsigned long), void *arg);
149 void cfs_timer_done(struct cfs_timer *t);
150 void cfs_timer_arm(struct cfs_timer *t, cfs_time_t deadline);
151 void cfs_timer_disarm(struct cfs_timer *t);
152 int cfs_timer_is_armed(struct cfs_timer *t);
154 cfs_time_t cfs_timer_deadline(struct cfs_timer *t);
157 typedef void cfs_psdev_t;
159 static inline int cfs_psdev_register(cfs_psdev_t *foo)
164 static inline int cfs_psdev_deregister(cfs_psdev_t *foo)
172 /* __LIBCFS_USER_PRIM_H__ */
176 * c-indentation-style: "K&R"