Replace file relevant wrappers with kernel API.
Affected primitives:
file, dentry, dirent, kstatfs, filp_size, filp_poff,
filp_open, do_fsync, filp_close, filp_read, filp_write,
filp_fsync, get_file, fget, fput, file_count, flock_t,
flock_type, flock_set_type, flock_pid, flock_set_pid,
flock_start, flock_set_start, flock_end, flock_set_end.
completion, init_completion, fini_completion,
wait_for_completion, complete
Change some API implementations of darwin/winnt to make it be
consistent with linux kernel API such as filp_open/filp_close etc.
Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ibe00df71c658aeb5dda854481f6ab5c181b3de7b
Reviewed-on: http://review.whamcloud.com/2830
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
# Migrate libcfs to emulate Linux kernel APIs.
# http://jira.whamcloud.com/browse/LU-1346
-# remove extra blank line
-# /^$/{N;/^\n$/D}
################################################################################
# lock - spinlock, rw_semaphore, rwlock, completion, semaphore, mutex
# - lock_kernel, unlock_kernel, lockdep
-# spinlok
+# spinlock
/typedef *spinlock_t *cfs_spinlock_t;/d
s/\bcfs_spinlock_t\b/spinlock_t/g
s/\bcfs_spin_lock_init\b/spin_lock_init/g
/#[ \t]*define[ \t]*\bSPIN_LOCK_UNLOCKED\b[ \t]*\bSPIN_LOCK_UNLOCKED\b/d
# rw_semaphore
+s/\bcfs_semaphore\b/semaphore/g
s/\bcfs_rw_semaphore_t\b/struct rw_semaphore/g
s/\bcfs_init_rwsem\b/init_rwsem/g
/#[ \t]*define[ \t]*\binit_rwsem\b *( *\w* *)[ \t]*\binit_rwsem\b *( *\w* *)/d
s/\bCFS_DECLARE_RWSEM\b/DECLARE_RWSEM/g
/#[ \t]*define[ \t]*\bDECLARE_RWSEM\b *( *\w* *)[ \t]*\bDECLARE_RWSEM\b *( *\w* *)/d
-s/\bcfs_semaphore\b/semaphore/g
-s/\bcfs_rw_semaphore\b/rw_semaphore/g
-s/\bcfs_init_completion_module\b/init_completion_module/g
-s/\bcfs_call_wait_handler\b/call_wait_handler/g
-s/\bcfs_wait_handler_t\b/wait_handler_t/g
-s/\bcfs_mt_completion_t\b/mt_completion_t/g
-s/\bcfs_mt_init_completion\b/mt_init_completion/g
-s/\bcfs_mt_wait_for_completion\b/mt_wait_for_completion/g
-s/\bcfs_mt_complete\b/mt_complete/g
-s/\bcfs_mt_fini_completion\b/mt_fini_completion/g
-s/\bcfs_mt_atomic_t\b/mt_atomic_t/g
-s/\bcfs_mt_atomic_read\b/mt_atomic_read/g
-s/\bcfs_mt_atomic_set\b/mt_atomic_set/g
-s/\bcfs_mt_atomic_dec_and_test\b/mt_atomic_dec_and_test/g
-s/\bcfs_mt_atomic_inc\b/mt_atomic_inc/g
-s/\bcfs_mt_atomic_dec\b/mt_atomic_dec/g
-s/\bcfs_mt_atomic_add\b/mt_atomic_add/g
-s/\bcfs_mt_atomic_sub\b/mt_atomic_sub/g
+#finish this with other atomics
+#s/\bcfs_mt_atomic_t\b/atomic_t/g
+#s/\bcfs_mt_atomic_read\b/atomic_read/g
+#s/\bcfs_mt_atomic_set\b/atomic_set/g
+#s/\bcfs_mt_atomic_dec_and_test\b/atomic_dec_and_test/g
+#s/\bcfs_mt_atomic_inc\b/atomic_inc/g
+#s/\bcfs_mt_atomic_dec\b/atomic_dec/g
+#s/\bcfs_mt_atomic_add\b/atomic_add/g
+#s/\bcfs_mt_atomic_sub\b/atomic_sub/g
# rwlock
/typedef *rwlock_t *cfs_rwlock_t;/d
# completion
s/\bcfs_completion_t\b/struct completion/g
+s/\bcfs_mt_completion_t\b/struct completion/g
+s/\bcfs_mt_init_completion\b/init_completion/g
+s/\bcfs_mt_wait_for_completion\b/wait_for_completion/g
+s/\bcfs_mt_complete\b/complete/g
+s/\bcfs_mt_fini_completion\b/fini_completion/g
s/\bCFS_DECLARE_COMPLETION\b/DECLARE_COMPLETION/g
/#[ \t]*define[ \t]*\bDECLARE_COMPLETION\b *( *\w* *)[ \t]*\bDECLARE_COMPLETION\b *( *\w* *)/d
s/\bCFS_INIT_COMPLETION\b/INIT_COMPLETION/g
################################################################################
# file operations
-#s/\bcfs_file_t\b/file_t/g
-#s/\bcfs_dentry_t\b/dentry_t/g
-#s/\bcfs_dirent_t\b/dirent_t/g
-#s/\bcfs_kstatfs_t\b/kstatfs_t/g
-#s/\bcfs_filp_size\b/filp_size/g
-#s/\bcfs_filp_poff\b/filp_poff/g
-#s/\bcfs_filp_open\b/filp_open/g
-#/#[ \t]*define[ \t]*\bfilp_open\b *( *\w* *, *\w* *, *\w* *)[ \t]*\bfilp_open\b *( *\w* *, *\w* *, *\w* *)/d
-#s/\bcfs_do_fsync\b/do_fsync/g
-#s/\bcfs_filp_close\b/filp_close/g
-#/#[ \t]*define[ \t]*\bfilp_close\b *( *\w* *, *\w* *)[ \t]*\bfilp_close\b *( *\w* *, *\w* *)/d
-#s/\bcfs_filp_read\b/filp_read/g
-#s/\bcfs_filp_write\b/filp_write/g
-#s/\bcfs_filp_fsync\b/filp_fsync/g
-#s/\bcfs_get_file\b/get_file/g
-#/#[ \t]*define[ \t]*\bget_file\b *( *\w* *)[ \t]*\bget_file\b *( *\w* *)/d
-#s/\bcfs_get_fd\b/fget/g
-#/#[ \t]*define[ \t]*\bfget\b *( *\w* *)[ \t]*\bfget\b *( *\w* *)/d
-#s/\bcfs_put_file\b/fput/g
-#/#[ \t]*define[ \t]*\bfput\b *( *\w* *)[ \t]*\bfput\b *( *\w* *)/d
-#s/\bcfs_file_count\b/file_count/g
-#/#[ \t]*define[ \t]*\bfile_count\b *( *\w* *)[ \t]*\bfile_count\b *( *\w* *)/d
-#s/\bCFS_INT_LIMIT\b/INT_LIMIT/g
-#s/\bCFS_OFFSET_MAX\b/OFFSET_MAX/g
-#s/\bcfs_flock_t\b/flock_t/g
-#s/\bcfs_flock_type\b/flock_type/g
-#s/\bcfs_flock_set_type\b/flock_set_type/g
-#s/\bcfs_flock_pid\b/flock_pid/g
-#s/\bcfs_flock_set_pid\b/flock_set_pid/g
-#s/\bcfs_flock_start\b/flock_start/g
-#s/\bcfs_flock_set_start\b/flock_set_start/g
-#s/\bcfs_flock_end\b/flock_end/g
-#s/\bcfs_flock_set_end\b/flock_set_end/g
-#s/\bcfs_user_write\b/user_write/g
-#s/\bCFS_IFSHIFT\b/IFSHIFT/g
-#s/\bCFS_IFTODT\b/IFTODT/g
-#s/\bCFS_DTTOIF\b/DTTOIF/g
+s/\bcfs_file_t\b/struct file/g
+s/\bcfs_dentry_t\b/struct dentry/g
+s/\bcfs_dirent_t\b/struct dirent64/g
+s/\bcfs_kstatfs_t\b/struct kstatfs/g
+s/\bcfs_filp_size\b/filp_size/g
+s/\bcfs_filp_poff\b/filp_poff/g
+s/\bcfs_filp_open\b/filp_open/g
+/#[ \t]*define[ \t]*\bfilp_open\b *( *\w* *, *\w* *, *\w* *)[ \t]*\bfilp_open\b *( *\w* *, *\w* *, *\w* *)/d
+s/\bcfs_do_fsync\b/do_fsync/g
+s/\bcfs_filp_close\b/filp_close/g
+/#[ \t]*define[ \t]*\bfilp_close\b *( *\w* *, *\w* *)[ \t]*\bfilp_close\b *( *\w* *, *\w* *)/d
+s/\bcfs_filp_read\b/filp_read/g
+s/\bcfs_filp_write\b/filp_write/g
+s/\bcfs_filp_fsync\b/filp_fsync/g
+s/\bcfs_get_file\b/get_file/g
+/#[ \t]*define[ \t]*\bget_file\b *( *\w* *)[ \t]*\bget_file\b *( *\w* *)/d
+s/\bcfs_get_fd\b/fget/g
+/#[ \t]*define[ \t]*\bfget\b *( *\w* *)[ \t]*\bfget\b *( *\w* *)/d
+s/\bcfs_put_file\b/fput/g
+/#[ \t]*define[ \t]*\bfput\b *( *\w* *)[ \t]*\bfput\b *( *\w* *)/d
+s/\bcfs_file_count\b/file_count/g
+/#[ \t]*define[ \t]*\bfile_count\b *( *\w* *)[ \t]*\bfile_count\b *( *\w* *)/d
+s/\bCFS_INT_LIMIT\b/INT_LIMIT/g
+s/\bCFS_OFFSET_MAX\b/OFFSET_MAX/g
+s/\bcfs_flock_t\b/struct file_lock/g
+s/\bcfs_flock_type\b/flock_type/g
+s/\bcfs_flock_set_type\b/flock_set_type/g
+s/\bcfs_flock_pid\b/flock_pid/g
+s/\bcfs_flock_set_pid\b/flock_set_pid/g
+s/\bcfs_flock_start\b/flock_start/g
+s/\bcfs_flock_set_start\b/flock_set_start/g
+s/\bcfs_flock_end\b/flock_end/g
+s/\bcfs_flock_set_end\b/flock_set_end/g
+s/\bcfs_user_write\b/user_write/g
+s/\bCFS_IFSHIFT\b/IFSHIFT/g
+s/\bCFS_IFTODT\b/IFTODT/g
+s/\bCFS_DTTOIF\b/DTTOIF/g
################################################################################
# memory operations
-#s/\bcfs_page_t\b/page_t/g
+#s/\bcfs_page_t\b/struct page/g
#s/\bCFS_PAGE_SIZE\b/PAGE_CACHE_SIZE/g
#/#[ \t]*define[ \t]*\bPAGE_CACHE_SIZE\b[ \t]*\bPAGE_CACHE_SIZE\b/d
#s/\bCFS_PAGE_SHIFT\b/PAGE_CACHE_SHIFT/g
#/#[ \t]*define[ \t]*\bSLAB_NOFS\b[ \t]*\bSLAB_NOFS\b/d
#s/\bcfs_shrinker\b/shrinker/g
#/#[ \t]*define[ \t]*\bshrinker\b[ \t]*\bshrinker\b/d
-#s/\bcfs_shrinker_t\b/shrinker_t/g
+#s/\bcfs_shrinker_t\b/struct shrinkert/g
#/typedef[ \t]*\bshrinker_t\b[ \t]*\bshrinker_t\b/d
#s/\bcfs_set_shrinker\b/set_shrinker/g
#/#[ \t]*define[ \t]*\bset_shrinker\b *( *\w* *, *\w* *)[ \t]*\bset_shrinker\b *( *\w* *, *\w* *)/d
#/#[ \t]*define[ \t]*\bremove_shrinker\b *( *\w* *)[ \t]*\bremove_shrinker\b *( *\w* *)/d
#s/\bCFS_DEFAULT_SEEKS\b/DEFAULT_SEEKS/g
#/#[ \t]*define[ \t]*\bDEFAULT_SEEKS\b[ \t]*\bDEFAULT_SEEKS\b/d
-
-
-#s/\bcfs_\b//g
-#s/\bCFS_\b//g
-#/typedef[ \t]*\b\b[ \t]*\b\b/d
-#/#[ \t]*define[ \t]*\b\b[ \t]*\b\b/d
-#/#[ \t]*define[ \t]*\b\b *( *)[ \t]*\b\b *( *)/d
-#/#[ \t]*define[ \t]*\b\b *( *\w* *)[ \t]*\b\b *( *\w* *)/d
-#/#[ \t]*define[ \t]*\b\b *( *\w* *, *\w* *)[ \t]*\b\b *( *\w* *, *\w* *)/d
-#/#[ \t]*define[ \t]*\b\b *( *\w* *, *\w* *, *\w* *)[ \t]*\b\b *( *\w* *, *\w* *, *\w* *)/d
/*
* Kernel file descriptor
*/
-typedef struct cfs_kern_file {
+struct file {
int f_flags;
vnode_t f_vp;
vfs_context_t f_ctxt;
-} cfs_file_t;
-
-#else
-
-typedef struct file cfs_file_t;
-
+};
#endif
-int kern_file_size(cfs_file_t *fp, off_t *size);
-#define cfs_filp_size(fp) \
+int kern_file_size(struct file *fp, off_t *size);
+#define filp_size(fp) \
({ \
off_t __size; \
kern_file_size((fp), &__size); \
__size; \
})
-#define cfs_filp_poff(fp) (NULL)
-
-cfs_file_t *kern_file_open(const char *name, int flags, int mode, int *err);
-int kern_file_close(cfs_file_t *fp);
-int kern_file_read(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
-int kern_file_write(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
-int kern_file_sync(cfs_file_t *fp);
-
-#define cfs_filp_open(n, f, m, e) kern_file_open(n, f, m, e)
-#define cfs_filp_close(f) kern_file_close(f)
-#define cfs_filp_read(f, b, n, p) kern_file_read(f, b, n, p)
-#define cfs_filp_write(f, b, n, p) kern_file_write(f, b, n, p)
-#define cfs_filp_fsync(f) kern_file_sync(f)
-
-int ref_file(cfs_file_t *fp);
-int rele_file(cfs_file_t *fp);
-int file_count(cfs_file_t *fp);
-#define cfs_get_file(f) ref_file(f)
-#define cfs_put_file(f) rele_file(f)
-#define cfs_file_count(f) file_count(f)
-
-#define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
-#define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
-
-typedef struct flock cfs_flock_t;
-#define cfs_flock_type(fl) ((fl)->l_type)
-#define cfs_flock_set_type(fl, type) do { (fl)->l_type = (type); } while(0)
-#define cfs_flock_pid(fl) ((fl)->l_pid)
-#define cfs_flock_set_pid(fl, pid) do { (fl)->l_pid = (pid); } while(0)
-#define cfs_flock_start(fl) ((fl)->l_start)
-#define cfs_flock_set_start(fl, start) do { (fl)->l_start = (start); } while(0)
-
-static inline loff_t cfs_flock_end(cfs_flock_t *fl)
+#define filp_poff(fp) (NULL)
+
+struct file *kern_file_open(const char *name, int flags, int mode);
+int kern_file_close(struct file *fp);
+int kern_file_read(struct file *fp, void *buf, size_t nbytes, off_t *pos);
+int kern_file_write(struct file *fp, void *buf, size_t nbytes, off_t *pos);
+int kern_file_sync(struct file *fp);
+
+#define filp_open(n, f, m) kern_file_open(n, f, m)
+#define filp_close(f, i) kern_file_close(f)
+#define filp_read(f, b, n, p) kern_file_read(f, b, n, p)
+#define filp_write(f, b, n, p) kern_file_write(f, b, n, p)
+#define filp_fsync(f) kern_file_sync(f)
+
+int ref_file(struct file *fp);
+int rele_file(struct file *fp);
+int file_count(struct file *fp);
+#define get_file(f) ref_file(f)
+#define fput(f) rele_file(f)
+
+#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
+#define OFFSET_MAX INT_LIMIT(loff_t)
+
+#define file_lock flock
+#define flock_type(fl) ((fl)->l_type)
+#define flock_set_type(fl, type) do { (fl)->l_type = (type); } while (0)
+#define flock_pid(fl) ((fl)->l_pid)
+#define flock_set_pid(fl, pid) do { (fl)->l_pid = (pid); } while (0)
+#define flock_start(fl) ((fl)->l_start)
+#define flock_set_start(fl, st) do { (fl)->l_start = (st); } while (0)
+
+static inline loff_t flock_end(struct file_lock *fl)
{
- return (fl->l_len == 0 ? CFS_OFFSET_MAX: (fl->l_start + fl->l_len));
+ return (fl->l_len == 0 ? OFFSET_MAX : (fl->l_start + fl->l_len));
}
-static inline void cfs_flock_set_end(cfs_flock_t *fl, loff_t end)
+static inline void flock_set_end(struct file_lock *fl, loff_t end)
{
- if (end == CFS_OFFSET_MAX)
- fl->l_len = 0;
- else
- fl->l_len = end - fl->l_start;
+ if (end == OFFSET_MAX)
+ fl->l_len = 0;
+ else
+ fl->l_len = end - fl->l_start;
}
#define ATTR_MODE 0x0001
{
return acl;
}
-
-#else /* !__KERNEL__ */
-
-typedef struct file cfs_file_t;
-
#endif /* END __KERNEL__ */
-typedef struct {
+struct dentry {
void *d;
-} cfs_dentry_t;
+};
#ifndef O_SYNC
#define O_SYNC 0
#define KUC_GRP_MAX KUC_GRP_HSM
/* Kernel methods */
-extern int libcfs_kkuc_msg_put(cfs_file_t *fp, void *payload);
+extern int libcfs_kkuc_msg_put(struct file *fp, void *payload);
extern int libcfs_kkuc_group_put(int group, void *payload);
-extern int libcfs_kkuc_group_add(cfs_file_t *fp, int uid, int group,
- __u32 data);
+extern int libcfs_kkuc_group_add(struct file *fp, int uid, int group,
+ __u32 data);
extern int libcfs_kkuc_group_rem(int uid, int group);
extern int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func,
- void *cb_arg);
+ void *cb_arg);
#define LK_FLG_STOP 0x01
#include <linux/mount.h>
#include <linux/backing-dev.h>
-typedef struct file cfs_file_t;
-typedef struct dentry cfs_dentry_t;
-typedef struct dirent64 cfs_dirent_t;
-typedef struct kstatfs cfs_kstatfs_t;
+#define filp_size(f) \
+ (i_size_read((f)->f_dentry->d_inode))
+#define filp_poff(f) \
+ (&(f)->f_pos)
-#define cfs_filp_size(f) (i_size_read((f)->f_dentry->d_inode))
-#define cfs_filp_poff(f) (&(f)->f_pos)
-
-/*
- * XXX Do we need to parse flags and mode in cfs_filp_open?
- */
-cfs_file_t *cfs_filp_open (const char *name, int flags, int mode, int *err);
#ifdef HAVE_FILE_FSYNC_4ARGS
-# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, 0, LLONG_MAX, flag))
+# define do_fsync(fp, flag) \
+ ((fp)->f_op->fsync(fp, 0, LLONG_MAX, flag))
#elif defined(HAVE_FILE_FSYNC_2ARGS)
-# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, flag))
+# define do_fsync(fp, flag) \
+ ((fp)->f_op->fsync(fp, flag))
#else
-# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, (fp)->f_dentry, flag))
+# define do_fsync(fp, flag) \
+ ((fp)->f_op->fsync(fp, (fp)->f_dentry, flag))
#endif
-#define cfs_filp_close(f) filp_close(f, NULL)
-#define cfs_filp_read(fp, buf, size, pos) (fp)->f_op->read((fp), (buf), (size), pos)
-#define cfs_filp_write(fp, buf, size, pos) (fp)->f_op->write((fp), (buf), (size), pos)
-#define cfs_filp_fsync(fp) cfs_do_fsync(fp, 1)
-#define cfs_get_file(f) get_file(f)
-#define cfs_get_fd(x) fget(x)
-#define cfs_put_file(f) fput(f)
-#define cfs_file_count(f) file_count(f)
+#define filp_read(fp, buf, size, pos) \
+ ((fp)->f_op->read((fp), (buf), (size), pos))
-typedef struct file_lock cfs_flock_t;
-#define cfs_flock_type(fl) ((fl)->fl_type)
-#define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
-#define cfs_flock_pid(fl) ((fl)->fl_pid)
-#define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
-#define cfs_flock_start(fl) ((fl)->fl_start)
-#define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
-#define cfs_flock_end(fl) ((fl)->fl_end)
-#define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
+#define filp_write(fp, buf, size, pos) \
+ ((fp)->f_op->write((fp), (buf), (size), pos))
-ssize_t cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset);
+#define filp_fsync(fp) \
+ do_fsync(fp, 1)
-#define CFS_IFSHIFT 12
+#define flock_type(fl) ((fl)->fl_type)
+#define flock_set_type(fl, type) do { (fl)->fl_type = (type); } while (0)
+#define flock_pid(fl) ((fl)->fl_pid)
+#define flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while (0)
+#define flock_start(fl) ((fl)->fl_start)
+#define flock_set_start(fl, st) do { (fl)->fl_start = (st); } while (0)
+#define flock_end(fl) ((fl)->fl_end)
+#define flock_set_end(fl, end) do { (fl)->fl_end = (end); } while (0)
-#define CFS_IFTODT(type) (((type) & S_IFMT) >> CFS_IFSHIFT)
-#define CFS_DTTOIF(dirtype) ((dirtype) << CFS_IFSHIFT)
+ssize_t filp_user_write(struct file *filp, const void *buf, size_t count,
+ loff_t *offset);
+
+#ifndef IFSHIFT
+#define IFSHIFT 12
+#endif
+
+#ifndef IFTODT
+#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT)
+#endif
+#ifndef DTTOIF
+#define DTTOIF(dirtype) ((dirtype) << IFSHIFT)
+#endif
#endif
typedef void *cfs_poll_table_t;
typedef struct cfs_param_file_ops {
- cfs_param_module_t owner;
- int (*open) (cfs_inode_t *, cfs_file_t *);
- loff_t (*llseek)(cfs_file_t *, loff_t, int);
- int (*release) (cfs_inode_t *, cfs_param_file_t *);
- unsigned int (*poll) (cfs_file_t *, cfs_poll_table_t *);
- ssize_t (*write) (cfs_file_t *, const char *, size_t, loff_t *);
- ssize_t (*read)(cfs_file_t *, char *, size_t, loff_t *);
+ cfs_param_module_t owner;
+ int (*open) (cfs_inode_t *, struct file *);
+ loff_t (*llseek)(struct file *, loff_t, int);
+ int (*release) (cfs_inode_t *, cfs_param_file_t *);
+ unsigned int (*poll) (struct file *, cfs_poll_table_t *);
+ ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
+ ssize_t (*read)(struct file *, char *, size_t, loff_t *);
} cfs_param_file_ops_t;
typedef cfs_param_file_ops_t *cfs_lproc_filep_t;
#include <mntent.h>
#endif
-typedef struct file cfs_file_t;
-typedef struct dentry cfs_dentry_t;
-#ifdef __linux__
-typedef struct dirent64 cfs_dirent_t;
-#endif
-
-#define cfs_get_fd(x) NULL
-#define cfs_put_file(f) do {} while (0)
+#define fget(x) NULL
+#define fput(f) do {} while (0)
#ifdef __linux__
/* Userpace byte flipping */
typedef ssize_t (*read_actor_t)();
-#define CFS_IFSHIFT 12
-
-#define CFS_IFTODT(type) (((type) & S_IFMT) >> CFS_IFSHIFT)
-#define CFS_DTTOIF(dirtype) ((dirtype) << CFS_IFSHIFT)
+# ifndef IFTODT
+# define IFSHIFT 12
+# define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT)
+# define DTTOIF(dirtype) ((dirtype) << IFSHIFT)
+# endif
#endif
* - wait_for_completion(c)
* - wait_for_completion_interruptible(c)
*/
+#ifdef HAVE_LIBPTHREAD
+#include <pthread.h>
+
+/*
+ * Multi-threaded user space completion APIs
+ */
+
+struct completion {
+ int c_done;
+ pthread_cond_t c_cond;
+ pthread_mutex_t c_mut;
+};
+
+#else /* !HAVE_LIBPTHREAD */
+
struct completion {
- unsigned int done;
- cfs_waitq_t wait;
+ unsigned int done;
+ cfs_waitq_t wait;
};
+#endif /* HAVE_LIBPTHREAD */
typedef int (*wait_handler_t) (int timeout);
void init_completion_module(wait_handler_t handler);
int call_wait_handler(int timeout);
void init_completion(struct completion *c);
+void fini_completion(struct completion *c);
void complete(struct completion *c);
void wait_for_completion(struct completion *c);
int wait_for_completion_interruptible(struct completion *c);
#include <pthread.h>
/*
- * Multi-threaded user space completion APIs
- */
-
-typedef struct {
- int c_done;
- pthread_cond_t c_cond;
- pthread_mutex_t c_mut;
-} mt_completion_t;
-
-void mt_init_completion(mt_completion_t *c);
-void mt_fini_completion(mt_completion_t *c);
-void mt_complete(mt_completion_t *c);
-void mt_wait_for_completion(mt_completion_t *c);
-
-/*
* Multi-threaded user space atomic APIs
*/
};
-#define cfs_filp_size(f) ((f)->f_size)
-#define cfs_filp_poff(f) (&(f)->f_pos)
-
-cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err);
-int cfs_filp_close(cfs_file_t *fp);
-int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
-int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
-int cfs_filp_fsync(cfs_file_t *fp);
-int cfs_get_file(cfs_file_t *fp);
-int cfs_put_file(cfs_file_t *fp);
-int cfs_file_count(cfs_file_t *fp);
-#define cfs_filp_unlink(x, y) (KdBreakPoint(),0)
+#define filp_size(f) ((f)->f_size)
+#define filp_poff(f) (&(f)->f_pos)
+
+struct file *filp_open(const char *name, int flags, int mode);
+int filp_close(struct file *fp, void *id);
+int filp_read(struct file *fp, void *buf, size_t nbytes, loff_t *pos);
+int filp_write(struct file *fp, void *buf, size_t nbytes, loff_t *pos);
+int filp_fsync(struct file *fp);
+int get_file(struct file *fp);
+int fput(struct file *fp);
+int file_count(struct file *fp);
+#define cfs_filp_unlink(x, y) (KdBreakPoint(), 0)
/*
* CFS_FLOCK routines
*/
-typedef struct file_lock{
- int fl_type;
- pid_t fl_pid;
- size_t fl_len;
- off_t fl_start;
- off_t fl_end;
-} cfs_flock_t;
-
-#define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
-#define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
-
-#define cfs_flock_type(fl) ((fl)->fl_type)
-#define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
-#define cfs_flock_pid(fl) ((fl)->fl_pid)
-#define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
-#define cfs_flock_start(fl) ((fl)->fl_start)
-#define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
-#define cfs_flock_end(fl) ((fl)->fl_end)
-#define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
+struct file_lock {
+ int fl_type;
+ pid_t fl_pid;
+ size_t fl_len;
+ off_t fl_start;
+ off_t fl_end;
+};
+
+#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
+#define OFFSET_MAX INT_LIMIT(loff_t)
+
+#define flock_type(fl) ((fl)->fl_type)
+#define flock_set_type(fl, type) do { (fl)->fl_type = (type); } while (0)
+#define flock_pid(fl) ((fl)->fl_pid)
+#define flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while (0)
+#define flock_start(fl) ((fl)->fl_start)
+#define flock_set_start(fl, st) do { (fl)->fl_start = (st); } while (0)
+#define flock_end(fl) ((fl)->fl_end)
+#define flock_set_end(fl, end) do { (fl)->fl_end = (end); } while (0)
#define ATTR_MODE 0x0001
#define ATTR_UID 0x0002
inode->i_size = i_size;
}
-typedef struct cfs_kstatfs {
- u64 f_type;
- long f_bsize;
- u64 f_blocks;
- u64 f_bfree;
- u64 f_bavail;
- u64 f_files;
- u64 f_ffree;
- __u32 f_fsid;
- long f_namelen;
- long f_frsize;
- long f_spare[5];
-} cfs_kstatfs_t;
+struct kstatfs {
+ u64 f_type;
+ long f_bsize;
+ u64 f_blocks;
+ u64 f_bfree;
+ u64 f_bavail;
+ u64 f_files;
+ u64 f_ffree;
+ __u32 f_fsid;
+ long f_namelen;
+ long f_frsize;
+ long f_spare[5];
+};
struct super_block {
void * s_fs_info;
#endif /* __KERNEL__ */
-typedef struct {
+struct dentry {
void *d;
-} cfs_dentry_t;
+};
/*
* misc
extern void cfs_symbol_clean();
typedef struct file_operations cfs_file_operations_t;
-typedef struct file cfs_file_t;
/*
* Pseudo device register
* declaration of proc kernel process routines
*/
-cfs_file_t *
-lustre_open_file(char * filename);
+struct file *lustre_open_file(char *filename);
-int
-lustre_close_file(cfs_file_t * fh);
+int lustre_close_file(struct file *fh);
-int
-lustre_do_ioctl( cfs_file_t * fh,
- unsigned long cmd,
- ulong_ptr_t arg );
+int lustre_do_ioctl(struct file *fh, unsigned long cmd, ulong_ptr_t arg);
-int
-lustre_ioctl_file( cfs_file_t * fh,
- PCFS_PROC_IOCTL devctl);
-
-size_t
-lustre_read_file( cfs_file_t * fh,
- loff_t offl,
- size_t size,
- char * buf
- );
-
-size_t
-lustre_write_file( cfs_file_t * fh,
- loff_t off,
- size_t size,
- char * buf
- );
+int lustre_ioctl_file(struct file *fh, PCFS_PROC_IOCTL devctl);
+
+size_t lustre_read_file(struct file *fh, loff_t offl, size_t size, char *buf);
+
+size_t lustre_write_file(struct file *fh, loff_t off, size_t size, char *buf);
/*
* Wait Queue
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2)
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3)
-typedef struct file {
- int foo;
-} cfs_file_t;
+struct file {
+ int foo;
+};
#include "../user-prim.h"
#include "../user-lock.h"
* not so important to implement for MT.
*/
int
-kern_file_size(struct cfs_kern_file *fp, off_t *psize)
+kern_file_size(struct cfs_kern_file *fp, off_t *psize)
{
- int error;
- off_t size;
+ int error;
+ off_t size;
- error = vnode_size(fp->f_vp, &size, fp->f_ctxt);
- if (error)
- return error;
+ error = vnode_size(fp->f_vp, &size, fp->f_ctxt);
+ if (error)
+ return error;
- if (psize)
- *psize = size;
- return 0;
+ if (psize)
+ *psize = size;
+ return 0;
}
struct cfs_kern_file *
-kern_file_open(const char * filename, int uflags, int mode, int *err)
+kern_file_open(const char *filename, int uflags, int mode)
{
- struct cfs_kern_file *fp;
- vnode_t vp;
- int error;
-
- fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file), M_TEMP, M_WAITOK);
- if (fp == NULL) {
- if (err != NULL)
- *err = -ENOMEM;
- return NULL;
- }
- fp->f_flags = FFLAGS(uflags);
- fp->f_ctxt = vfs_context_create(NULL);
-
- if ((error = vnode_open(filename, fp->f_flags,
- mode, 0, &vp, fp->f_ctxt))){
- if (err != NULL)
- *err = -error;
- _FREE(fp, M_TEMP);
- } else {
- if (err != NULL)
- *err = 0;
- fp->f_vp = vp;
- }
+ struct cfs_kern_file *fp;
+ vnode_t vp;
+ int error;
+
+ fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file),
+ M_TEMP, M_WAITOK);
+ if (fp == NULL)
+ return ERR_PTR(-ENOMEM);
+
+ fp->f_flags = FFLAGS(uflags);
+ fp->f_ctxt = vfs_context_create(NULL);
- return fp;
+ error = vnode_open(filename, fp->f_flags, mode, 0, &vp, fp->f_ctxt);
+ if (error != 0) {
+ _FREE(fp, M_TEMP);
+ return ERR_PTR(-error);
+ } else {
+ fp->f_vp = vp;
+ }
+
+ return fp;
}
int
return 0;
}
-cfs_file_t *
-kern_file_open(const char * filename, int flags, int mode, int *err)
+struct file *
+kern_file_open(const char *filename, int flags, int mode)
{
- struct nameidata nd;
- cfs_file_t *fp;
+ struct nameidata nd;
+ struct file *fp;
register struct vnode *vp;
int rc;
extern struct fileops vnops;
extern int nfiles;
- CFS_DECL_CONE_DATA;
+ CFS_DECL_CONE_DATA;
- CFS_CONE_IN;
+ CFS_CONE_IN;
nfiles++;
- MALLOC_ZONE(fp, cfs_file_t *, sizeof(cfs_file_t), M_FILE, M_WAITOK|M_ZERO);
- bzero(fp, sizeof(cfs_file_t));
+ MALLOC_ZONE(fp, struct file *, sizeof(file_t), M_FILE, M_WAITOK|M_ZERO);
+ bzero(fp, sizeof(*fp));
fp->f_count = 1;
- LIST_CIRCLE(fp, f_list);
+ LIST_CIRCLE(fp, f_list);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)filename, current_proc());
if ((rc = vn_open(&nd, flags, mode)) != 0){
- printf("filp_open failed at (%d)\n", rc);
- if (err != NULL)
- *err = rc;
- FREE_ZONE(fp, sizeof *fp, M_FILE);
- CFS_CONE_EX;
- return NULL;
+ printf("filp_open failed at (%d)\n", rc);
+ FREE_ZONE(fp, sizeof(*fp), M_FILE);
+ CFS_CONE_EX;
+ return ERR_PTR(rc);
}
vp = nd.ni_vp;
fp->f_flag = flags & FMASK;
* we should release the lock before return
*/
VOP_UNLOCK(vp, 0, current_proc());
- CFS_CONE_EX;
+ CFS_CONE_EX;
return fp;
}
static int
-frele_internal(cfs_file_t *fp)
+frele_internal(struct file *fp)
{
if (fp->f_count == (short)0xffff)
panic("frele of lustre: stale");
}
int
-kern_file_close (cfs_file_t *fp)
+kern_file_close(struct file *fp)
{
struct vnode *vp;
- CFS_DECL_CONE_DATA;
+ CFS_DECL_CONE_DATA;
if (fp == NULL)
return 0;
* Write buffer to filp inside kernel
*/
int
-kern_file_write (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
+kern_file_write(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
{
struct uio auio;
struct iovec aiov;
* Read from filp inside kernel
*/
int
-kern_file_read (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
+kern_file_read(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
{
struct uio auio;
struct iovec aiov;
}
int
-kern_file_sync (cfs_file_t *fp)
+kern_file_sync(struct file *fp)
{
struct vnode *vp = (struct vnode *)fp->f_data;
struct proc *p = current_proc();
* @param payload Payload data. First field of payload is always
* struct kuc_hdr
*/
-int libcfs_kkuc_msg_put(cfs_file_t *filp, void *payload)
+int libcfs_kkuc_msg_put(struct file *filp, void *payload)
{
struct kuc_hdr *kuch = (struct kuc_hdr *)payload;
int rc = -ENOSYS;
}
#ifdef __KERNEL__
- {
- loff_t offset = 0;
- rc = cfs_user_write(filp, (char *)payload, kuch->kuc_msglen,
- &offset);
- }
+ {
+ loff_t offset = 0;
+ rc = filp_user_write(filp, payload, kuch->kuc_msglen,
+ &offset);
+ }
#endif
if (rc < 0)
* group from any fs */
/** A single group reigstration has a uid and a file pointer */
struct kkuc_reg {
- cfs_list_t kr_chain;
- int kr_uid;
- cfs_file_t *kr_fp;
- __u32 kr_data;
+ cfs_list_t kr_chain;
+ int kr_uid;
+ struct file *kr_fp;
+ __u32 kr_data;
};
static cfs_list_t kkuc_groups[KUC_GRP_MAX+1] = {};
/* Protect message sending against remove and adds */
* @param uid identidier for this receiver
* @param group group number
*/
-int libcfs_kkuc_group_add(cfs_file_t *filp, int uid, int group, __u32 data)
+int libcfs_kkuc_group_add(struct file *filp, int uid, int group, __u32 data)
{
struct kkuc_reg *reg;
reg->kr_data = data;
down_write(&kg_sem);
- if (kkuc_groups[group].next == NULL)
- CFS_INIT_LIST_HEAD(&kkuc_groups[group]);
- cfs_list_add(®->kr_chain, &kkuc_groups[group]);
+ if (kkuc_groups[group].next == NULL)
+ CFS_INIT_LIST_HEAD(&kkuc_groups[group]);
+ cfs_list_add(®->kr_chain, &kkuc_groups[group]);
up_write(&kg_sem);
- CDEBUG(D_KUC, "Added uid=%d fp=%p to group %d\n", uid, filp, group);
+ CDEBUG(D_KUC, "Added uid=%d fp=%p to group %d\n", uid, filp, group);
- return 0;
+ return 0;
}
CFS_EXPORT_SYMBOL(libcfs_kkuc_group_add);
CDEBUG(D_KUC, "Removed uid=%d fp=%p from group %d\n",
reg->kr_uid, reg->kr_fp, group);
if (reg->kr_fp != NULL)
- cfs_put_file(reg->kr_fp);
- cfs_free(reg);
- }
- }
+ fput(reg->kr_fp);
+ cfs_free(reg);
+ }
+ }
up_write(&kg_sem);
RETURN(0);
if (rc == 0)
one_success = 1;
else if (rc == -EPIPE) {
- cfs_put_file(reg->kr_fp);
+ fput(reg->kr_fp);
reg->kr_fp = NULL;
}
}
#include <libcfs/libcfs.h>
-cfs_file_t *
-cfs_filp_open (const char *name, int flags, int mode, int *err)
-{
- /* XXX
- * Maybe we need to handle flags and mode in the future
- */
- cfs_file_t *filp = NULL;
-
- filp = filp_open(name, flags, mode);
- if (IS_ERR(filp)) {
- int rc;
-
- rc = PTR_ERR(filp);
- printk(KERN_ERR "LustreError: can't open %s file: err %d\n",
- name, rc);
- if (err)
- *err = rc;
- filp = NULL;
- }
- return filp;
-}
-
/* write a userspace buffer to disk.
* NOTE: this returns 0 on success, not the number of bytes written. */
ssize_t
-cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset)
+filp_user_write(struct file *filp, const void *buf, size_t count,
+ loff_t *offset)
{
mm_segment_t fs;
ssize_t size = 0;
fs = get_fs();
set_fs(KERNEL_DS);
while ((ssize_t)count > 0) {
- size = vfs_write(filp, (const char __user *)buf, count, offset);
+ size = vfs_write(filp, (const void __user *)buf, count, offset);
if (size < 0)
break;
count -= size;
return size;
}
+EXPORT_SYMBOL(filp_user_write);
#if !(CFS_O_CREAT == O_CREAT && CFS_O_EXCL == O_EXCL && \
CFS_O_NOACCESS == O_NOACCESS &&\
return (flags);
}
#endif
+EXPORT_SYMBOL(cfs_oflags2univ);
-/*
+/*
* XXX Liang: we don't need cfs_univ2oflags() now.
*/
int cfs_univ2oflags(int flags)
{
return (flags);
}
-
-EXPORT_SYMBOL(cfs_filp_open);
-EXPORT_SYMBOL(cfs_user_write);
-EXPORT_SYMBOL(cfs_oflags2univ);
EXPORT_SYMBOL(cfs_univ2oflags);
int cfs_tracefile_dump_all_pages(char *filename)
{
- struct page_collection pc;
- cfs_file_t *filp;
- struct cfs_trace_page *tage;
- struct cfs_trace_page *tmp;
- int rc;
+ struct page_collection pc;
+ struct file *filp;
+ struct cfs_trace_page *tage;
+ struct cfs_trace_page *tmp;
+ int rc;
- CFS_DECL_MMSPACE;
+ CFS_DECL_MMSPACE;
- cfs_tracefile_write_lock();
+ cfs_tracefile_write_lock();
- filp = cfs_filp_open(filename,
- O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600, &rc);
- if (!filp) {
- if (rc != -EEXIST)
- printk(CFS_KERN_ERR
- "LustreError: can't open %s for dump: rc %d\n",
- filename, rc);
- goto out;
- }
+ filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600);
+ if (IS_ERR(filp)) {
+ rc = PTR_ERR(filp);
+ filp = NULL;
+ printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n",
+ filename, rc);
+ goto out;
+ }
spin_lock_init(&pc.pc_lock);
pc.pc_want_daemon_pages = 1;
__LASSERT_TAGE_INVARIANT(tage);
- rc = cfs_filp_write(filp, cfs_page_address(tage->page),
- tage->used, cfs_filp_poff(filp));
+ rc = filp_write(filp, cfs_page_address(tage->page),
+ tage->used, filp_poff(filp));
if (rc != (int)tage->used) {
printk(CFS_KERN_WARNING "wanted to write %u but wrote "
"%d\n", tage->used, rc);
cfs_list_del(&tage->linkage);
cfs_tage_free(tage);
}
- CFS_MMSPACE_CLOSE;
- rc = cfs_filp_fsync(filp);
- if (rc)
- printk(CFS_KERN_ERR "sync returns %d\n", rc);
- close:
- cfs_filp_close(filp);
- out:
- cfs_tracefile_write_unlock();
- return rc;
+ CFS_MMSPACE_CLOSE;
+ rc = filp_fsync(filp);
+ if (rc)
+ printk(CFS_KERN_ERR "sync returns %d\n", rc);
+close:
+ filp_close(filp, NULL);
+out:
+ cfs_tracefile_write_unlock();
+ return rc;
}
void cfs_trace_flush_pages(void)
static int tracefiled(void *arg)
{
- struct page_collection pc;
- struct tracefiled_ctl *tctl = arg;
- struct cfs_trace_page *tage;
- struct cfs_trace_page *tmp;
- cfs_file_t *filp;
- int last_loop = 0;
- int rc;
+ struct page_collection pc;
+ struct tracefiled_ctl *tctl = arg;
+ struct cfs_trace_page *tage;
+ struct cfs_trace_page *tmp;
+ struct file *filp;
+ int last_loop = 0;
+ int rc;
- CFS_DECL_MMSPACE;
+ CFS_DECL_MMSPACE;
- /* we're started late enough that we pick up init's fs context */
- /* this is so broken in uml? what on earth is going on? */
- cfs_daemonize("ktracefiled");
+ /* we're started late enough that we pick up init's fs context */
+ /* this is so broken in uml? what on earth is going on? */
+ cfs_daemonize("ktracefiled");
spin_lock_init(&pc.pc_lock);
complete(&tctl->tctl_start);
filp = NULL;
cfs_tracefile_read_lock();
if (cfs_tracefile[0] != 0) {
- filp = cfs_filp_open(cfs_tracefile,
- O_CREAT | O_RDWR | O_LARGEFILE,
- 0600, &rc);
- if (!(filp))
- printk(CFS_KERN_WARNING "couldn't open %s: "
- "%d\n", cfs_tracefile, rc);
- }
+ filp = filp_open(cfs_tracefile,
+ O_CREAT | O_RDWR | O_LARGEFILE,
+ 0600);
+ if (IS_ERR(filp)) {
+ rc = PTR_ERR(filp);
+ filp = NULL;
+ printk(CFS_KERN_WARNING "couldn't open %s: "
+ "%d\n", cfs_tracefile, rc);
+ }
+ }
cfs_tracefile_read_unlock();
if (filp == NULL) {
put_pages_on_daemon_list(&pc);
if (f_pos >= (off_t)cfs_tracefile_size)
f_pos = 0;
- else if (f_pos > (off_t)cfs_filp_size(filp))
- f_pos = cfs_filp_size(filp);
+ else if (f_pos > (off_t)filp_size(filp))
+ f_pos = filp_size(filp);
- rc = cfs_filp_write(filp, cfs_page_address(tage->page),
- tage->used, &f_pos);
+ rc = filp_write(filp, cfs_page_address(tage->page),
+ tage->used, &f_pos);
if (rc != (int)tage->used) {
printk(CFS_KERN_WARNING "wanted to write %u "
"but wrote %d\n", tage->used, rc);
__LASSERT(cfs_list_empty(&pc.pc_pages));
}
}
- CFS_MMSPACE_CLOSE;
+ CFS_MMSPACE_CLOSE;
- cfs_filp_close(filp);
+ filp_close(filp, NULL);
put_pages_on_daemon_list(&pc);
if (!cfs_list_empty(&pc.pc_pages)) {
int i;
* - complete(c)
* - wait_for_completion(c)
*/
-
static wait_handler_t wait_handler;
void init_completion_module(wait_handler_t handler)
return wait_handler(timeout);
}
+#ifndef HAVE_LIBPTHREAD
void init_completion(struct completion *c)
{
LASSERT(c != NULL);
cfs_waitq_init(&c->wait);
}
+void fini_completion(struct completion *c)
+{
+}
+
void complete(struct completion *c)
{
LASSERT(c != NULL);
} while (c->done == 0);
return 0;
}
+#endif /* HAVE_LIBPTHREAD */
/*
* rw_semaphore:
* Multi-threaded user space completion
*/
-void mt_init_completion(mt_completion_t *c)
+void init_completion(struct completion *c)
{
LASSERT(c != NULL);
c->c_done = 0;
pthread_cond_init(&c->c_cond, NULL);
}
-void mt_fini_completion(mt_completion_t *c)
+void fini_completion(struct completion *c)
{
LASSERT(c != NULL);
pthread_mutex_destroy(&c->c_mut);
pthread_cond_destroy(&c->c_cond);
}
-void mt_complete(mt_completion_t *c)
+void complete(struct completion *c)
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
pthread_mutex_unlock(&c->c_mut);
}
-void mt_wait_for_completion(mt_completion_t *c)
+void wait_for_completion(struct completion *c)
{
LASSERT(c != NULL);
pthread_mutex_lock(&c->c_mut);
"\\SystemRoot\\", NULL};
/*
- * cfs_filp_open
+ * filp_open
* To open or create a file in kernel mode
*
* Arguments:
* err: error code
*
* Return Value:
- * the pointer to the cfs_file_t or NULL if it fails
+ * the pointer to the struct file or NULL if it fails
*
- * Notes:
+ * Notes:
* N/A
*/
#define is_drv_letter_valid(x) (((x) >= 0 && (x) <= 9) || \
( ((x)|0x20) <= 'z' && ((x)|0x20) >= 'a'))
-cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err)
+struct file *filp_open(const char *name, int flags, int mode, int *err)
{
- cfs_file_t * fp = NULL;
+ struct file *fp = NULL;
NTSTATUS Status;
/* Initialize the unicode path name for the specified file */
NameLength = (USHORT)strlen(name);
- /* Check file & path name */
- if (name[0] != '\\') {
- if (NameLength < 1 || name[1] != ':' || !is_drv_letter_valid(name[0])) {
- /* invalid file path name */
- if (err) *err = -EINVAL;
- return NULL;
- }
- PrefixLength = (USHORT)strlen(dos_file_prefix[0]);
- } else {
- int i, j;
- for (i=0; i < 3 && dos_file_prefix[i] != NULL; i++) {
- j = strlen(dos_file_prefix[i]);
- if (NameLength > j && _strnicmp(dos_file_prefix[i], name, j) == 0) {
- break;
- }
- }
- if (i >= 3) {
- if (err) *err = -EINVAL;
- return NULL;
- }
- }
-
- AnsiString = cfs_alloc( sizeof(CHAR) * (NameLength + PrefixLength + 1),
- CFS_ALLOC_ZERO);
- if (NULL == AnsiString) {
- if (err) *err = -ENOMEM;
- return NULL;
- }
-
- UnicodeString = cfs_alloc( sizeof(WCHAR) * (NameLength + PrefixLength + 1),
- CFS_ALLOC_ZERO);
- if (NULL == UnicodeString) {
- if (err) *err = -ENOMEM;
- cfs_free(AnsiString);
- return NULL;
- }
+ /* Check file & path name */
+ if (name[0] != '\\') {
+ if (NameLength < 1 || name[1] != ':' ||
+ !is_drv_letter_valid(name[0])) {
+ /* invalid file path name */
+ return ERR_PTR(-EINVAL);
+ }
+ PrefixLength = (USHORT)strlen(dos_file_prefix[0]);
+ } else {
+ int i, j;
+ for (i = 0; i < 3 && dos_file_prefix[i] != NULL; i++) {
+ j = strlen(dos_file_prefix[i]);
+ if (NameLength > j &&
+ _strnicmp(dos_file_prefix[i], name, j) == 0)
+ break;
+ }
+ if (i >= 3)
+ return ERR_PTR(-EINVAL);
+ }
+
+ AnsiString = cfs_alloc(sizeof(CHAR) * (NameLength + PrefixLength + 1),
+ CFS_ALLOC_ZERO);
+ if (NULL == AnsiString)
+ return ERR_PTR(-ENOMEM);
+
+ UnicodeString =
+ cfs_alloc(sizeof(WCHAR) * (NameLength + PrefixLength + 1),
+ CFS_ALLOC_ZERO);
+ if (NULL == UnicodeString) {
+ cfs_free(AnsiString);
+ return ERR_PTR(-ENOMEM);
+ }
if (PrefixLength) {
RtlCopyMemory(&AnsiString[0], dos_file_prefix[0], PrefixLength);
NULL,
0 );
- /* Check the returned status of IoStatus... */
- if (!NT_SUCCESS(IoStatus.Status)) {
- if (err) {
- *err = cfs_error_code(IoStatus.Status);
- }
- cfs_free(UnicodeString);
- cfs_free(AnsiString);
- return NULL;
- }
+ /* Check the returned status of IoStatus... */
+ if (!NT_SUCCESS(IoStatus.Status)) {
+ cfs_free(UnicodeString);
+ cfs_free(AnsiString);
+ return ERR_PTR(cfs_error_code(IoStatus.Status));
+ }
- /* Allocate the cfs_file_t: libcfs file object */
- fp = cfs_alloc(sizeof(cfs_file_t) + NameLength, CFS_ALLOC_ZERO);
+ /* Allocate the file_t: libcfs file object */
+ fp = cfs_alloc(sizeof(*fp) + NameLength, CFS_ALLOC_ZERO);
- if (NULL == fp) {
- Status = ZwClose(FileHandle);
- ASSERT(NT_SUCCESS(Status));
- if (err) {
- *err = -ENOMEM;
- }
- cfs_free(UnicodeString);
- cfs_free(AnsiString);
- return NULL;
- }
+ if (NULL == fp) {
+ Status = ZwClose(FileHandle);
+ ASSERT(NT_SUCCESS(Status));
+ cfs_free(UnicodeString);
+ cfs_free(AnsiString);
+ return ERR_PTR(-ENOMEM);
+ }
fp->f_handle = FileHandle;
strcpy(fp->f_name, name);
fp->f_flags = flags;
fp->f_mode = (mode_t)mode;
fp->f_count = 1;
- if (err) {
- *err = 0;
- }
/* free the memory of temporary name strings */
cfs_free(UnicodeString);
/*
- * cfs_filp_close
+ * filp_close
* To close the opened file and release the filp structure
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file structure
*
* Return Value:
* ZERO: on success
* Non-Zero: on failure
*
- * Notes:
+ * Notes:
* N/A
*/
-int cfs_filp_close(cfs_file_t *fp)
+int filp_close(file_t *fp, void *id)
{
NTSTATUS Status;
}
/*
- * cfs_filp_read
+ * filp_read
* To read data from the opened file
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
* buf: pointer to the buffer to contain the data
* nbytes: size in bytes to be read from the file
* pos: offset in file where reading starts, if pos
* Notes:
* N/A
*/
-
-int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos)
+int filp_read(struct file *fp, void *buf, size_t nbytes, loff_t *pos)
{
LARGE_INTEGER offset;
NTSTATUS status;
* To write specified data to the opened file
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
* buf: pointer to the buffer containing the data
* nbytes: size in bytes to be written to the file
* pos: offset in file where writing starts, if pos
* N/A
*/
-int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos)
+int filp_write(struct file *fp, void *buf, size_t nbytes, loff_t *pos)
{
LARGE_INTEGER offset;
NTSTATUS status;
}
/*
- * cfs_filp_fsync
+ * filp_fsync
* To sync the dirty data of the file to disk
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
*
* Return Value:
* Zero: in success case
* we must allocate our own Irp and issue it to the file
* system driver.
*/
-
-int cfs_filp_fsync(cfs_file_t *fp)
+int filp_fsync(struct file *fp)
{
-
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
}
/*
- * cfs_get_file
+ * get_file
* To increase the reference of the file object
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
*
* Return Value:
* Zero: in success case
* N/A
*/
-int cfs_get_file(cfs_file_t *fp)
+int get_file(struct file *fp)
{
InterlockedIncrement(&(fp->f_count));
return 0;
/*
- * cfs_put_file
+ * fput
* To decrease the reference of the file object
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
*
* Return Value:
* Zero: in success case
* Non-Zero: in failure case
*
- * Notes:
+ * Notes:
* N/A
*/
-int cfs_put_file(cfs_file_t *fp)
+int fput(struct file *fp)
{
- if (InterlockedDecrement(&(fp->f_count)) == 0) {
- cfs_filp_close(fp);
- }
+ if (InterlockedDecrement(&(fp->f_count)) == 0)
+ filp_close(fp, NULL);
- return 0;
+ return 0;
}
/*
- * cfs_file_count
+ * file_count
* To query the reference count of the file object
*
* Arguments:
- * fp: the pointer of the cfs_file_t strcture
+ * fp: the pointer of the file strcture
*
* Return Value:
* the reference count of the file object
* N/A
*/
-int cfs_file_count(cfs_file_t *fp)
+int file_count(struct file *fp)
{
- return (int)(fp->f_count);
+ return (int)(fp->f_count);
}
struct dentry *dget(struct dentry *de)
return -EFAULT;
return 0;
}
-
-extern struct cfs_psdev_ops libcfs_psdev_ops;
-static int
-libcfs_psdev_open(struct inode *in, cfs_file_t * file)
-{
+extern struct cfs_psdev_ops libcfs_psdev_ops;
+
+static int
+libcfs_psdev_open(struct inode *in, struct file *file)
+{
struct libcfs_device_userstate **pdu = NULL;
int rc = 0;
}
/* called when closing /dev/device */
-static int
-libcfs_psdev_release(struct inode *in, cfs_file_t * file)
+static int
+libcfs_psdev_release(struct inode *in, struct file *file)
{
struct libcfss_device_userstate *pdu;
int rc = 0;
return rc;
}
-static int
-libcfs_ioctl(cfs_file_t * file, unsigned int cmd, ulong_ptr_t arg)
-{
+static int
+libcfs_ioctl(struct file *file, unsigned int cmd, ulong_ptr_t arg)
+{
struct cfs_psdev_file pfile;
int rc = 0;
* proc process routines of kernel space
*/
-cfs_file_t *
-lustre_open_file(char * filename)
+struct file *
+lustre_open_file(char *filename)
{
- int rc = 0;
- cfs_file_t * fh = NULL;
- cfs_proc_entry_t * fp = NULL;
+ int rc = 0;
+ struct file *fh = NULL;
+ cfs_proc_entry_t *fp = NULL;
- fp = search_proc_entry(filename, cfs_proc_root);
- if (!fp) {
- return NULL;
- }
+ fp = search_proc_entry(filename, cfs_proc_root);
+ if (fp == NULL)
+ return NULL;
- fh = cfs_alloc(sizeof(cfs_file_t), CFS_ALLOC_ZERO);
- if (!fh) {
- return NULL;
- }
+ fh = cfs_alloc(sizeof(*fh), CFS_ALLOC_ZERO);
+ if (fh == NULL)
+ return NULL;
fh->f_inode = cfs_alloc(sizeof(struct inode), CFS_ALLOC_ZERO);
if (!fh->f_inode) {
}
int
-lustre_close_file(cfs_file_t * fh)
+lustre_close_file(struct file *fh)
{
- int rc = 0;
- cfs_proc_entry_t * fp = NULL;
+ int rc = 0;
+ cfs_proc_entry_t *fp = NULL;
fp = (cfs_proc_entry_t *) fh->f_inode->i_priv;
if (fh->f_op->release) {
}
int
-lustre_do_ioctl( cfs_file_t * fh,
- unsigned long cmd,
- ulong_ptr_t arg )
+lustre_do_ioctl(struct file *fh, unsigned long cmd, ulong_ptr_t arg)
{
- int rc = 0;
+ int rc = 0;
- if (fh->f_op->ioctl) {
- rc = (fh->f_op->ioctl)(fh, cmd, arg);
- }
+ if (fh->f_op->ioctl)
+ rc = (fh->f_op->ioctl)(fh, cmd, arg);
- return rc;
+ return rc;
}
-
+
int
-lustre_ioctl_file(cfs_file_t * fh, PCFS_PROC_IOCTL devctl)
+lustre_ioctl_file(struct file *fh, PCFS_PROC_IOCTL devctl)
{
int rc = 0;
ulong_ptr_t data;
rc = lustre_do_ioctl(fh, devctl->cmd, data);
return rc;
-}
-
+}
size_t
-lustre_read_file(
- cfs_file_t * fh,
- loff_t off,
- size_t size,
- char * buf
- )
+lustre_read_file(struct file *fh, loff_t off, size_t size, char *buf)
{
size_t rc = 0;
off_t low, high;
return rc;
}
-
size_t
-lustre_write_file(
- cfs_file_t * fh,
- loff_t off,
- size_t size,
- char * buf
- )
+lustre_write_file(struct file *fh, loff_t off, size_t size, char *buf)
{
- size_t rc = 0;
- off = 0;
- if (fh->f_op->write) {
- rc = (fh->f_op->write)(fh, buf, size, &off);
- }
+ size_t rc = 0;
- return rc;
-}
+ off = 0;
+ if (fh->f_op->write)
+ rc = (fh->f_op->write)(fh, buf, size, &off);
+
+ return rc;
+}
/*
kqswnal_tx_t *
kqswnal_get_idle_tx (void)
{
- unsigned long flags;
- kqswnal_tx_t *ktx;
+ unsigned long flags;
+ kqswnal_tx_t *ktx;
- cfs_spin_lock_irqsave (&kqswnal_data.kqn_idletxd_lock, flags);
+ spin_lock_irqsave(&kqswnal_data.kqn_idletxd_lock, flags);
- if (kqswnal_data.kqn_shuttingdown ||
- cfs_list_empty (&kqswnal_data.kqn_idletxds)) {
- cfs_spin_unlock_irqrestore (&kqswnal_data.kqn_idletxd_lock,
- flags);
+ if (kqswnal_data.kqn_shuttingdown ||
+ cfs_list_empty(&kqswnal_data.kqn_idletxds)) {
+ spin_unlock_irqrestore(&kqswnal_data.kqn_idletxd_lock, flags);
- return NULL;
- }
+ return NULL;
+ }
ktx = cfs_list_entry (kqswnal_data.kqn_idletxds.next, kqswnal_tx_t,
ktx_list);
static int accept_timeout = 5;
struct {
- int pta_shutdown;
- cfs_socket_t *pta_sock;
-#ifdef __KERNEL__
+ int pta_shutdown;
+ cfs_socket_t *pta_sock;
struct completion pta_signal;
-#else
- mt_completion_t pta_signal;
-#endif
} lnet_acceptor_state;
int
#ifdef __KERNEL__
-#define mt_init_completion(c) init_completion(c)
-#define mt_wait_for_completion(c) wait_for_completion(c)
-#define mt_complete(c) complete(c)
-#define mt_fini_completion(c) fini_completion(c)
-
EXPORT_SYMBOL(lnet_acceptor_port);
static char *accept = "secure";
LCONSOLE(0, "Accept %s, port %d\n", accept_type, accept_port);
}
- /* set init status and unblock parent */
- lnet_acceptor_state.pta_shutdown = rc;
- mt_complete(&lnet_acceptor_state.pta_signal);
+ /* set init status and unblock parent */
+ lnet_acceptor_state.pta_shutdown = rc;
+ complete(&lnet_acceptor_state.pta_signal);
if (rc != 0)
return rc;
CDEBUG(D_NET, "Acceptor stopping\n");
- /* unblock lnet_acceptor_stop() */
- mt_complete(&lnet_acceptor_state.pta_signal);
- return 0;
+ /* unblock lnet_acceptor_stop() */
+ complete(&lnet_acceptor_state.pta_signal);
+ return 0;
}
static inline int
return 0;
#endif
- mt_init_completion(&lnet_acceptor_state.pta_signal);
- rc = accept2secure(accept_type, &secure);
- if (rc <= 0) {
- mt_fini_completion(&lnet_acceptor_state.pta_signal);
- return rc;
- }
+ init_completion(&lnet_acceptor_state.pta_signal);
+ rc = accept2secure(accept_type, &secure);
+ if (rc <= 0) {
+ fini_completion(&lnet_acceptor_state.pta_signal);
+ return rc;
+ }
- if (lnet_count_acceptor_nis() == 0) /* not required */
- return 0;
+ if (lnet_count_acceptor_nis() == 0) /* not required */
+ return 0;
- rc2 = cfs_create_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure, 0);
- if (rc2 < 0) {
- CERROR("Can't start acceptor thread: %d\n", rc);
- mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ rc2 = cfs_create_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure, 0);
+ if (rc2 < 0) {
+ CERROR("Can't start acceptor thread: %d\n", rc);
+ fini_completion(&lnet_acceptor_state.pta_signal);
- return -ESRCH;
- }
+ return -ESRCH;
+ }
- /* wait for acceptor to startup */
- mt_wait_for_completion(&lnet_acceptor_state.pta_signal);
+ /* wait for acceptor to startup */
+ wait_for_completion(&lnet_acceptor_state.pta_signal);
- if (!lnet_acceptor_state.pta_shutdown) {
- /* started OK */
- LASSERT (lnet_acceptor_state.pta_sock != NULL);
- return 0;
- }
+ if (!lnet_acceptor_state.pta_shutdown) {
+ /* started OK */
+ LASSERT(lnet_acceptor_state.pta_sock != NULL);
+ return 0;
+ }
- LASSERT (lnet_acceptor_state.pta_sock == NULL);
- mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ LASSERT(lnet_acceptor_state.pta_sock == NULL);
+ fini_completion(&lnet_acceptor_state.pta_signal);
- return -ENETDOWN;
+ return -ENETDOWN;
}
void
lnet_acceptor_stop(void)
{
- if (lnet_acceptor_state.pta_sock == NULL) /* not running */
- return;
+ if (lnet_acceptor_state.pta_sock == NULL) /* not running */
+ return;
- lnet_acceptor_state.pta_shutdown = 1;
- libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
+ lnet_acceptor_state.pta_shutdown = 1;
+ libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
- /* block until acceptor signals exit */
- mt_wait_for_completion(&lnet_acceptor_state.pta_signal);
+ /* block until acceptor signals exit */
+ wait_for_completion(&lnet_acceptor_state.pta_signal);
- mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ fini_completion(&lnet_acceptor_state.pta_signal);
}
#else /* single-threaded user-space */
int
lnet_acceptor_start(void)
{
- return 0;
+ return 0;
}
void
IN PIRP Irp
)
{
- NTSTATUS Status;
- PIO_STACK_LOCATION IrpSp;
+ NTSTATUS Status;
+ PIO_STACK_LOCATION IrpSp;
- FILE_FULL_EA_INFORMATION * ea;
- cfs_file_t * fp;
+ FILE_FULL_EA_INFORMATION *ea;
+ struct file *fp;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
ea = (PFILE_FULL_EA_INFORMATION) Irp->AssociatedIrp.SystemBuffer;
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- PIO_STACK_LOCATION IrpSp;
+ PIO_STACK_LOCATION IrpSp;
- cfs_file_t * fp;
+ struct file *fp;
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
- fp = (cfs_file_t *) IrpSp->FileObject->FsContext;
+ IrpSp = IoGetCurrentIrpStackLocation(Irp);
+ fp = (file_t *) IrpSp->FileObject->FsContext;
ASSERT(fp != NULL);
ASSERT(IrpSp->FileObject->FsContext2 == fp->private_data);
case IOCTL_LIBCFS_ENTRY:
{
- int rc = 0;
- cfs_file_t * fp;
+ int rc = 0;
+ struct file *fp;
- fp = (cfs_file_t *) IrpSp->FileObject->FsContext;
+ fp = (struct file *)IrpSp->FileObject->FsContext;
if (!fp) {
rc = -EINVAL;
NTSTATUS
ProcReadWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
- PIO_STACK_LOCATION IrpSp;
- NTSTATUS Status;
+ PIO_STACK_LOCATION IrpSp;
+ NTSTATUS Status;
- cfs_file_t * fp;
- int rc;
- PCHAR buf;
+ struct file *fp;
+ int rc;
+ PCHAR buf;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
if (Irp->MdlAddress) {
Status = STATUS_SUCCESS;
rc = 0;
} else {
- fp = (cfs_file_t *) IrpSp->FileObject->FsContext;
+ fp = (struct file *)IrpSp->FileObject->FsContext;
if (!fp) {
Status = STATUS_INVALID_PARAMETER;
}
}
- /* unblock usocklnd_shutdown() */
- mt_complete(&pt_data->upt_completion);
+ /* unblock usocklnd_shutdown() */
+ complete(&pt_data->upt_completion);
- return 0;
+ return 0;
}
/* Returns 0 on success, <0 else */
libcfs_sock_release(pt->upt_notifier[1]);
pthread_mutex_destroy(&pt->upt_pollrequests_lock);
- mt_fini_completion(&pt->upt_completion);
+ fini_completion(&pt->upt_completion);
LIBCFS_FREE (pt->upt_pollfd,
sizeof(struct pollfd) * pt->upt_npollfd);
CFS_INIT_LIST_HEAD (&pt->upt_pollrequests);
CFS_INIT_LIST_HEAD (&pt->upt_stale_list);
pthread_mutex_init(&pt->upt_pollrequests_lock, NULL);
- mt_init_completion(&pt->upt_completion);
+ init_completion(&pt->upt_completion);
}
/* Initialize peer hash list */
for (i = 0; i < n; i++) {
usock_pollthread_t *pt = &usock_data.ud_pollthreads[i];
usocklnd_wakeup_pollthread(i);
- mt_wait_for_completion(&pt->upt_completion);
+ wait_for_completion(&pt->upt_completion);
}
pthread_rwlock_destroy(&usock_data.ud_peers_lock);
cfs_list_t upt_pollrequests; /* list of poll requests */
pthread_mutex_t upt_pollrequests_lock; /* serialize */
int upt_errno; /* non-zero if errored */
- mt_completion_t upt_completion; /* wait/signal facility for
- * syncronizing shutdown */
+ struct completion upt_completion; /* wait/signal facility for
+ * syncronizing shutdown */
} usock_pollthread_t;
/* Number of elements in upt_pollfd[], upt_idx2conn[] and upt_fd2idx[]
void *host;
};
-typedef struct file_lock {
+struct file_lock {
struct file_lock *fl_next; /* singly linked list for this inode */
cfs_list_t fl_link; /* doubly linked list of all locks */
cfs_list_t fl_block; /* circular list of blocked processes */
union {
struct nfs_lock_info nfs_fl;
} fl_u;
-} cfs_flock_t;
-
-#define cfs_flock_type(fl) ((fl)->fl_type)
-#define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
-#define cfs_flock_pid(fl) ((fl)->fl_pid)
-#define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
-#define cfs_flock_start(fl) ((fl)->fl_start)
-#define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
-#define cfs_flock_end(fl) ((fl)->fl_end)
-#define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
+};
+
+#define flock_type(fl) ((fl)->fl_type)
+#define flock_set_type(fl, type) do { (fl)->fl_type = (type); } while (0)
+#define flock_pid(fl) ((fl)->fl_pid)
+#define flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while (0)
+#define flock_start(fl) ((fl)->fl_start)
+#define flock_set_start(fl, st) do { (fl)->fl_start = (st); } while (0)
+#define flock_end(fl) ((fl)->fl_end)
+#define flock_set_end(fl, end) do { (fl)->fl_end = (end); } while (0)
#ifndef OFFSET_MAX
#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
#include <linux/statfs.h>
#else
-typedef struct statfs cfs_kstatfs_t;
+#define kstatfs statfs
#endif
#endif /* LPROCFS_SNMP_H */
#define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed
/* statfs_pack.c */
-void statfs_pack(struct obd_statfs *osfs, cfs_kstatfs_t *sfs);
-void statfs_unpack(cfs_kstatfs_t *sfs, struct obd_statfs *osfs);
+void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
+void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
/* l_lock.c */
struct lustre_lock {
#define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
struct filter_subdirs {
- cfs_dentry_t *dentry[FILTER_SUBDIR_COUNT];
+ struct dentry *dentry[FILTER_SUBDIR_COUNT];
};
};
struct filter_obd {
- /* NB this field MUST be first */
- struct obd_device_target fo_obt;
- const char *fo_fstype;
-
- int fo_group_count;
- cfs_dentry_t *fo_dentry_O;
- cfs_dentry_t **fo_dentry_O_groups;
- struct filter_subdirs *fo_dentry_O_sub;
+ /* NB this field MUST be first */
+ struct obd_device_target fo_obt;
+ const char *fo_fstype;
+
+ int fo_group_count;
+ struct dentry *fo_dentry_O;
+ struct dentry **fo_dentry_O_groups;
+ struct filter_subdirs *fo_dentry_O_sub;
struct mutex fo_init_lock; /* group initialization lock*/
int fo_committed_group;
};
struct niobuf_local {
- __u64 lnb_file_offset;
- __u32 lnb_page_offset;
- __u32 len;
- __u32 flags;
- cfs_page_t *page;
- cfs_dentry_t *dentry;
- int lnb_grant_used;
- int rc;
+ __u64 lnb_file_offset;
+ __u32 lnb_page_offset;
+ __u32 len;
+ __u32 flags;
+ cfs_page_t *page;
+ struct dentry *dentry;
+ int lnb_grant_used;
+ int rc;
};
#define LUSTRE_FLD_NAME "fld"
len = le16_to_cpu(ent->lde_namelen);
len = (len + align) & ~align;
- lt = (void *) ent->lde_name + len;
- type = CFS_IFTODT(le16_to_cpu(lt->lt_type));
- }
- return type;
+ lt = (void *)ent->lde_name + len;
+ type = IFTODT(le16_to_cpu(lt->lt_type));
+ }
+ return type;
}
/**
int
ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
{
- cfs_flock_t *getlk = lock->l_ast_data;
+ struct file_lock *getlk = lock->l_ast_data;
struct obd_device *obd;
struct obd_import *imp = NULL;
struct ldlm_flock_wait_data fwd;
/* fcntl(F_GETLK) request */
/* The old mode was saved in getlk->fl_type so that if the mode
* in the lock changes we can decref the appropriate refcount.*/
- ldlm_flock_destroy(lock, cfs_flock_type(getlk),
- LDLM_FL_WAIT_NOREPROC);
- switch (lock->l_granted_mode) {
- case LCK_PR:
- cfs_flock_set_type(getlk, F_RDLCK);
- break;
- case LCK_PW:
- cfs_flock_set_type(getlk, F_WRLCK);
- break;
- default:
- cfs_flock_set_type(getlk, F_UNLCK);
- }
- cfs_flock_set_pid(getlk,
- (pid_t)lock->l_policy_data.l_flock.pid);
- cfs_flock_set_start(getlk,
- (loff_t)lock->l_policy_data.l_flock.start);
- cfs_flock_set_end(getlk,
- (loff_t)lock->l_policy_data.l_flock.end);
- } else {
+ ldlm_flock_destroy(lock, flock_type(getlk),
+ LDLM_FL_WAIT_NOREPROC);
+ switch (lock->l_granted_mode) {
+ case LCK_PR:
+ flock_set_type(getlk, F_RDLCK);
+ break;
+ case LCK_PW:
+ flock_set_type(getlk, F_WRLCK);
+ break;
+ default:
+ flock_set_type(getlk, F_UNLCK);
+ }
+ flock_set_pid(getlk, (pid_t)lock->l_policy_data.l_flock.pid);
+ flock_set_start(getlk,
+ (loff_t)lock->l_policy_data.l_flock.start);
+ flock_set_end(getlk,
+ (loff_t)lock->l_policy_data.l_flock.end);
+ } else {
__u64 noreproc = LDLM_FL_WAIT_NOREPROC;
- /* We need to reprocess the lock to do merges or splits
- * with existing locks owned by this process. */
- ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL);
- }
- unlock_res_and_lock(lock);
- RETURN(0);
+ /* We need to reprocess the lock to do merges or splits
+ * with existing locks owned by this process. */
+ ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL);
+ }
+ unlock_res_and_lock(lock);
+ RETURN(0);
}
EXPORT_SYMBOL(ldlm_flock_completion_ast);
#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
#define ROUND_UP64(x) (((x)+sizeof(__u64)-1) & ~(sizeof(__u64)-1))
-static int filldir(char *buf, int buflen,
- const char *name, int namelen, loff_t offset,
- ino_t ino, unsigned int d_type, int *filled)
+static int filldir(char *buf, int buflen, const char *name, int namelen,
+ loff_t offset, ino_t ino, unsigned int d_type, int *filled)
{
- cfs_dirent_t *dirent = (cfs_dirent_t *) (buf + *filled);
- cfs_dirent_t holder;
- int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namelen + 1);
+ struct dirent64 *dirent = (struct dirent64 *)(buf + *filled);
+ struct dirent64 holder;
+ int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namelen + 1);
/*
* @buf is not guaranteed to be properly aligned. To work around,
char buf[1024];
const int nfiles = 256;
char *prefix = "test14_filename_long_prefix_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA___";
- cfs_dirent_t *ent;
+ struct dirent64 *ent;
int fd, i, rc, pos, index;
loff_t base = 0;
ENTER(">1 block(4k) directory readdir");
*/
int t56(char *name)
{
- int fd;
- size_t nbytes;
- off_t basep = 0;
- long rc = 0;
- cfs_dirent_t dir;
+ int fd;
+ size_t nbytes;
+ off_t basep = 0;
+ long rc = 0;
+ struct dirent64 dir;
ENTER("getdirentries should fail if nbytes is too small");
void t_ls(int fd, char *buf, int size)
{
- cfs_dirent_t *ent;
+ struct dirent64 *ent;
int rc, pos;
loff_t base = 0;
while ((rc = getdirentries64(fd, buf, size, &base)) > 0) {
pos = 0;
while (pos < rc) {
- ent = (cfs_dirent_t *) ((char*) buf + pos);
+ ent = (struct dirent64 *)((char *)buf + pos);
printf("%s\n", ent->d_name);
pos += ent->d_reclen;
}
if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */
RETURN(-EPERM);
- file2 = cfs_get_fd(lsl.sl_fd);
+ file2 = fget(lsl.sl_fd);
if (file2 == NULL)
RETURN(-EBADF);
rc = -EPERM;
if ((file2->f_flags & O_ACCMODE) != 0) /* O_WRONLY or O_RDWR */
rc = ll_swap_layout(file, file2, &lsl);
- cfs_put_file(file2);
+ fput(file2);
RETURN(rc);
}
case LL_IOC_LOV_GETSTRIPE:
if (fd == 0) {
rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
} else {
- cfs_file_t *fp = cfs_get_fd(fd);
+ struct file *fp = fget(fd);
+
rc = libcfs_kkuc_msg_put(fp, lh);
- cfs_put_file(fp);
+ fput(fp);
}
OBD_FREE(lh, len);
if (rc < 0)
#define D_CHANGELOG 0
struct changelog_show {
- __u64 cs_startrec;
- __u32 cs_flags;
- cfs_file_t *cs_fp;
- char *cs_buf;
- struct obd_device *cs_obd;
+ __u64 cs_startrec;
+ __u32 cs_flags;
+ struct file *cs_fp;
+ char *cs_buf;
+ struct obd_device *cs_obd;
};
static int changelog_show_cb(const struct lu_env *env, struct llog_handle *llh,
}
out:
- cfs_put_file(cs->cs_fp);
- if (llh)
+ fput(cs->cs_fp);
+ if (llh)
llog_cat_close(NULL, llh);
if (ctxt)
llog_ctxt_put(ctxt);
if (!cs)
return -ENOMEM;
- cs->cs_obd = obd;
- cs->cs_startrec = icc->icc_recno;
- /* matching cfs_put_file in mdc_changelog_send_thread */
- cs->cs_fp = cfs_get_fd(icc->icc_id);
- cs->cs_flags = icc->icc_flags;
+ cs->cs_obd = obd;
+ cs->cs_startrec = icc->icc_recno;
+ /* matching fput in mdc_changelog_send_thread */
+ cs->cs_fp = fget(icc->icc_id);
+ cs->cs_flags = icc->icc_flags;
/* New thread because we should return to user app before
writing into our pipe */
if (rc == 0)
rc = mdc_ioc_hsm_ct_unregister(imp);
} else {
- cfs_file_t *fp = cfs_get_fd(lk->lk_wfd);
+ struct file *fp = fget(lk->lk_wfd);
+
rc = libcfs_kkuc_group_add(fp, lk->lk_uid, lk->lk_group,
lk->lk_data);
if (rc && fp)
- cfs_put_file(fp);
+ fput(fp);
if (rc == 0)
rc = mdc_ioc_hsm_ct_register(imp, archive);
}
EXIT;
}
-static int server_statfs (struct dentry *dentry, cfs_kstatfs_t *buf)
+static int server_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
struct lustre_sb_info *lsi = s2lsi(sb);
#include <obd_support.h>
#include <obd_class.h>
-void statfs_pack(struct obd_statfs *osfs, cfs_kstatfs_t *sfs)
+void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs)
{
memset(osfs, 0, sizeof(*osfs));
osfs->os_type = sfs->f_type;
}
EXPORT_SYMBOL(statfs_pack);
-void statfs_unpack(cfs_kstatfs_t *sfs, struct obd_statfs *osfs)
+void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs)
{
memset(sfs, 0, sizeof(*sfs));
sfs->f_type = osfs->os_type;
#ifndef HAVE_FILE_FSYNC_4ARGS
mutex_lock(&inode->i_mutex);
#endif
- rc = cfs_do_fsync(file, 0);
+ rc = do_fsync(file, 0);
#ifndef HAVE_FILE_FSYNC_4ARGS
mutex_unlock(&inode->i_mutex);
#endif
{
/* check if file type is required */
if (ent->lde_attrs & LUDA_TYPE) {
- int align = sizeof(struct luda_type) - 1;
struct luda_type *lt;
+ int align = sizeof(*lt) - 1;
len = (len + align) & ~align;
lt = (struct luda_type *)(ent->lde_name + len);
- lt->lt_type = cpu_to_le16(CFS_DTTOIF(type));
+ lt->lt_type = cpu_to_le16(DTTOIF(type));
}
ent->lde_attrs = cpu_to_le32(ent->lde_attrs);
struct osd_it_quota oti_it_quota;
};
- /** pre-allocated buffer used by oti_it_ea, size OSD_IT_EA_BUFSIZE */
- void *oti_it_ea_buf;
+ /** pre-allocated buffer used by oti_it_ea, size OSD_IT_EA_BUFSIZE */
+ void *oti_it_ea_buf;
- cfs_kstatfs_t oti_ksfs;
+ struct kstatfs oti_ksfs;
/** IAM iterator for index operation. */
struct iam_iterator oti_idx_it;
len = (len + align) & ~align;
lt = (void *)ent->lde_name + len;
- lt->lt_type = cpu_to_le16(CFS_DTTOIF(type));
+ lt->lt_type = cpu_to_le16(DTTOIF(type));
ent->lde_attrs |= LUDA_TYPE;
}
}
static inline void qpi_putref(const struct lu_env *env,
- struct qmt_pool_info *pool)
+ struct qmt_pool_info *pool)
{
LASSERT(atomic_read(&pool->qpi_ref) > 0);
if (cfs_atomic_dec_and_test(&pool->qpi_ref))
}
typedef int (semantic_func_t)(char *path, DIR *parent, DIR *d,
- void *data, cfs_dirent_t *de);
+ void *data, struct dirent64 *de);
#define OBD_NOT_FOUND (-1)
}
static int cb_common_fini(char *path, DIR *parent, DIR *d, void *data,
- cfs_dirent_t *de)
+ struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
param->depth--;
static int llapi_semantic_traverse(char *path, int size, DIR *parent,
semantic_func_t sem_init,
semantic_func_t sem_fini, void *data,
- cfs_dirent_t *de)
+ struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
- cfs_dirent_t *dent;
+ struct dirent64 *dent;
int len, ret;
DIR *d, *p = NULL;
}
static int cb_find_init(char *path, DIR *parent, DIR *dir,
- void *data, cfs_dirent_t *de)
+ void *data, struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
int decision = 1; /* 1 is accepted; -1 is rejected. */
}
static int cb_get_mdt_index(char *path, DIR *parent, DIR *d, void *data,
- cfs_dirent_t *de)
+ struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
int ret = 0;
}
static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
- cfs_dirent_t *de)
+ struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
int ret = 0;
}
static int cb_quotachown(char *path, DIR *parent, DIR *d, void *data,
- cfs_dirent_t *de)
+ struct dirent64 *de)
{
struct find_param *param = (struct find_param *)data;
lstat_t *st;