Whamcloud - gitweb
LU-1346 libcfs: remove cfs_ file wrappers
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 13 Mar 2013 19:46:08 +0000 (14:46 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 15 Mar 2013 06:23:58 +0000 (02:23 -0400)
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>
42 files changed:
build/libcfs_cleanup.sed
libcfs/include/libcfs/darwin/darwin-fs.h
libcfs/include/libcfs/libcfs_kernelcomm.h
libcfs/include/libcfs/linux/linux-fs.h
libcfs/include/libcfs/params_tree.h
libcfs/include/libcfs/posix/libcfs.h
libcfs/include/libcfs/user-lock.h
libcfs/include/libcfs/winnt/winnt-fs.h
libcfs/include/libcfs/winnt/winnt-prim.h
libcfs/libcfs/darwin/darwin-fs.c
libcfs/libcfs/kernel_user_comm.c
libcfs/libcfs/linux/linux-fs.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/user-lock.c
libcfs/libcfs/winnt/winnt-fs.c
libcfs/libcfs/winnt/winnt-module.c
libcfs/libcfs/winnt/winnt-proc.c
lnet/klnds/qswlnd/qswlnd_cb.c
lnet/lnet/acceptor.c
lnet/selftest/winnt/selftest-winnt.c
lnet/ulnds/socklnd/poll.c
lnet/ulnds/socklnd/usocklnd.c
lnet/ulnds/socklnd/usocklnd.h
lustre/include/liblustre.h
lustre/include/linux/lprocfs_status.h
lustre/include/lustre_lib.h
lustre/include/obd.h
lustre/lclient/lcommon_cl.c
lustre/ldlm/ldlm_flock.c
lustre/liblustre/dir.c
lustre/liblustre/tests/sanity.c
lustre/liblustre/tests/test_common.c
lustre/llite/file.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_request.c
lustre/obdclass/obd_mount.c
lustre/obdclass/statfs_pack.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-zfs/osd_index.c
lustre/quota/qmt_pool.c
lustre/utils/liblustreapi.c

index 8b11c19..61a8253 100644 (file)
@@ -4,14 +4,12 @@
 # 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
@@ -49,6 +47,7 @@ s/\bCFS_SPIN_LOCK_UNLOCKED\b/SPIN_LOCK_UNLOCKED/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
@@ -68,24 +67,15 @@ s/\bcfs_fini_rwsem\b/fini_rwsem/g
 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
@@ -112,6 +102,11 @@ s/\bCFS_RW_LOCK_UNLOCKED\b/RW_LOCK_UNLOCKED/g
 
 # 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
@@ -221,48 +216,48 @@ s/\bcfs_fls\b/fls/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
@@ -341,7 +336,7 @@ s/\bcfs_fls\b/fls/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
@@ -349,13 +344,3 @@ s/\bcfs_fls\b/fls/g
 #/#[ \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
index 5fb4884..998823b 100644 (file)
 /*
  * 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
@@ -188,16 +182,11 @@ static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl)
 { 
         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
index 191adde..f7be4b7 100644 (file)
@@ -88,13 +88,13 @@ typedef int (*libcfs_kkuc_cb_t)(__u32 data, void *cb_arg);
 #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
 
index a71eb34..53975ab 100644 (file)
 #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
index 4e1a7fe..1bf8d37 100644 (file)
@@ -201,13 +201,13 @@ typedef void *cfs_param_module_t;
 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;
 
index 95ec2ab..91158bc 100644 (file)
@@ -120,14 +120,8 @@ typedef unsigned long long cfs_cycles_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 */
@@ -496,9 +490,10 @@ static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
 
 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
index 265932f..9460caf 100644 (file)
@@ -143,15 +143,32 @@ static inline int down_trylock(struct semaphore *sem)
  * - 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);
@@ -262,21 +279,6 @@ typedef struct { volatile int counter; } cfs_atomic_t;
 #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
  */
 
index d9cd357..587c308 100644 (file)
@@ -127,41 +127,41 @@ struct file {
 
 };
 
-#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
@@ -276,19 +276,19 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
     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;
@@ -469,9 +469,9 @@ UnmapViewOfFile(
 
 #endif /* __KERNEL__ */
 
-typedef struct {
+struct dentry {
        void    *d;
-} cfs_dentry_t;
+};
 
 /*
  *  misc
index 090adf3..985af01 100644 (file)
@@ -109,7 +109,6 @@ extern void     cfs_symbol_put(const char *);
 extern void     cfs_symbol_clean();
 
 typedef struct file_operations cfs_file_operations_t;
-typedef struct file cfs_file_t;
 
 /*
  * Pseudo device register
@@ -366,34 +365,17 @@ extern cfs_list_t *seq_list_next(void *v, cfs_list_t *head, loff_t *ppos);
  *  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
@@ -950,9 +932,9 @@ void cfs_enter_debugger();
 #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"
index 4bfccb8..88b9b1e 100644 (file)
@@ -87,48 +87,44 @@ vnode_size(vnode_t vp, off_t *sizep, vfs_context_t ctx)
  * 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
@@ -210,31 +206,29 @@ kern_file_size(struct file *fp, off_t *size)
         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;
@@ -251,13 +245,13 @@ kern_file_open(const char * filename, int flags, int mode, int *err)
         * 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");
@@ -267,10 +261,10 @@ frele_internal(cfs_file_t *fp)
 }
 
 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;
@@ -309,7 +303,7 @@ extern void bwillwrite(void);
  * 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;
@@ -365,7 +359,7 @@ kern_file_write (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
  * 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;
@@ -409,7 +403,7 @@ kern_file_read (cfs_file_t *fp, void *buf, size_t nbyte, loff_t *pos)
 }
 
 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();
index 47b9a86..08974d1 100644 (file)
@@ -152,7 +152,7 @@ int libcfs_ukuc_msg_get(lustre_kernelcomm *link, char *buf, int maxsize,
  * @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;
@@ -166,11 +166,11 @@ int libcfs_kkuc_msg_put(cfs_file_t *filp, void *payload)
         }
 
 #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)
@@ -187,10 +187,10 @@ CFS_EXPORT_SYMBOL(libcfs_kkuc_msg_put);
  * 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 */
@@ -201,7 +201,7 @@ static DECLARE_RWSEM(kg_sem);
  * @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;
 
@@ -224,14 +224,14 @@ int libcfs_kkuc_group_add(cfs_file_t *filp, int uid, int group, __u32 data)
         reg->kr_data = data;
 
        down_write(&kg_sem);
-        if (kkuc_groups[group].next == NULL)
-                CFS_INIT_LIST_HEAD(&kkuc_groups[group]);
-        cfs_list_add(&reg->kr_chain, &kkuc_groups[group]);
+       if (kkuc_groups[group].next == NULL)
+               CFS_INIT_LIST_HEAD(&kkuc_groups[group]);
+       cfs_list_add(&reg->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);
 
@@ -261,10 +261,10 @@ int libcfs_kkuc_group_rem(int uid, int group)
                         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);
@@ -285,7 +285,7 @@ int libcfs_kkuc_group_put(int group, void *payload)
                        if (rc == 0)
                                one_success = 1;
                        else if (rc == -EPIPE) {
-                               cfs_put_file(reg->kr_fp);
+                               fput(reg->kr_fp);
                                reg->kr_fp = NULL;
                        }
                }
index e6f324f..21fa32c 100644 (file)
 
 #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;
@@ -74,7 +53,7 @@ cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset)
        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;
@@ -85,6 +64,7 @@ cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset)
 
        return size;
 }
+EXPORT_SYMBOL(filp_user_write);
 
 #if !(CFS_O_CREAT == O_CREAT && CFS_O_EXCL == O_EXCL &&        \
      CFS_O_NOACCESS == O_NOACCESS &&\
@@ -121,16 +101,13 @@ int cfs_oflags2univ(int flags)
        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);
index 23e8336..f31e000 100644 (file)
@@ -681,25 +681,24 @@ void cfs_trace_debug_print(void)
 
 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;
@@ -717,8 +716,8 @@ int cfs_tracefile_dump_all_pages(char *filename)
 
                 __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);
@@ -729,15 +728,15 @@ int cfs_tracefile_dump_all_pages(char *filename)
                 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)
@@ -980,19 +979,19 @@ int cfs_trace_get_debug_mb(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);
@@ -1008,13 +1007,16 @@ static int tracefiled(void *arg)
                 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);
@@ -1033,11 +1035,11 @@ static int tracefiled(void *arg)
 
                         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);
@@ -1045,9 +1047,9 @@ static int tracefiled(void *arg)
                                 __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;
index 1498079..214ca3a 100644 (file)
@@ -153,7 +153,6 @@ void __up(struct semaphore *s)
  * - complete(c)
  * - wait_for_completion(c)
  */
-
 static wait_handler_t wait_handler;
 
 void init_completion_module(wait_handler_t handler)
@@ -168,6 +167,7 @@ int call_wait_handler(int timeout)
        return wait_handler(timeout);
 }
 
+#ifndef HAVE_LIBPTHREAD
 void init_completion(struct completion *c)
 {
        LASSERT(c != NULL);
@@ -175,6 +175,10 @@ void init_completion(struct completion *c)
        cfs_waitq_init(&c->wait);
 }
 
+void fini_completion(struct completion *c)
+{
+}
+
 void complete(struct completion *c)
 {
        LASSERT(c != NULL);
@@ -200,6 +204,7 @@ int wait_for_completion_interruptible(struct completion *c)
        } while (c->done == 0);
        return 0;
 }
+#endif /* HAVE_LIBPTHREAD */
 
 /*
  * rw_semaphore:
@@ -268,7 +273,7 @@ void fini_rwsem(struct rw_semaphore *s)
  * 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;
@@ -276,14 +281,14 @@ void mt_init_completion(mt_completion_t *c)
         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);
@@ -292,7 +297,7 @@ void mt_complete(mt_completion_t *c)
         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);
index 8641380..9a5a2f6 100644 (file)
@@ -41,7 +41,7 @@ const CHAR *dos_file_prefix[] = {
             "\\SystemRoot\\", NULL};
 
 /*
- * cfs_filp_open
+ * filp_open
  *     To open or create a file in kernel mode
  *
  * Arguments:
@@ -51,18 +51,18 @@ const CHAR *dos_file_prefix[] = {
  *   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;
 
@@ -130,42 +130,38 @@ cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err)
     /* 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);
@@ -207,38 +203,29 @@ cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err)
             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);
@@ -249,21 +236,21 @@ cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err)
 
 
 /*
- * 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;
 
@@ -439,11 +426,11 @@ errorout:
 }
 
 /*
- * 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
@@ -456,8 +443,7 @@ errorout:
  * 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;
@@ -491,7 +477,7 @@ int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos)
  *     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
@@ -505,7 +491,7 @@ int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *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;
@@ -535,11 +521,11 @@ int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos)
 }
 
 /*
- * 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
@@ -550,10 +536,8 @@ int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos)
  *   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;
 
@@ -621,11 +605,11 @@ int cfs_filp_fsync(cfs_file_t *fp)
 }
 
 /*
- * 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
@@ -635,7 +619,7 @@ int cfs_filp_fsync(cfs_file_t *fp)
  *   N/A
  */
 
-int cfs_get_file(cfs_file_t *fp)
+int get_file(struct file *fp)
 {
     InterlockedIncrement(&(fp->f_count));
     return 0;
@@ -643,36 +627,35 @@ int cfs_get_file(cfs_file_t *fp)
 
 
 /*
- * 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
@@ -681,9 +664,9 @@ int cfs_put_file(cfs_file_t *fp)
  *   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)
index 781ab12..3a3b3f9 100644 (file)
@@ -93,12 +93,12 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
                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;
 
@@ -111,8 +111,8 @@ libcfs_psdev_open(struct inode *in, cfs_file_t * file)
 }
 
 /* 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;
@@ -125,9 +125,9 @@ libcfs_psdev_release(struct inode *in, cfs_file_t * file)
        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;
 
index 279657a..6a58609 100644 (file)
@@ -1647,22 +1647,20 @@ void remove_proc(void)
  *  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) {
@@ -1689,10 +1687,10 @@ lustre_open_file(char * filename)
 }
 
 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) {
@@ -1708,21 +1706,18 @@ lustre_close_file(cfs_file_t * fh)
 }
 
 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;
@@ -1763,16 +1758,10 @@ lustre_ioctl_file(cfs_file_t * fh, PCFS_PROC_IOCTL devctl)
     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;
@@ -1790,24 +1779,18 @@ lustre_read_file(
 
     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;
+}
 
 
 /*
index dd5ff27..243918b 100644 (file)
@@ -368,18 +368,17 @@ kqswnal_put_idle_tx (kqswnal_tx_t *ktx)
 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);
index 9db3571..9e9b236 100644 (file)
@@ -44,13 +44,9 @@ static int   accept_backlog = 127;
 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
@@ -68,11 +64,6 @@ lnet_accept_magic(__u32 magic, __u32 constant)
 
 #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";
@@ -429,9 +420,9 @@ lnet_acceptor(void *arg)
                 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;
@@ -489,9 +480,9 @@ lnet_acceptor(void *arg)
 
         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
@@ -531,59 +522,59 @@ lnet_acceptor_start(void)
                 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
index c179a5a..dc1797f 100644 (file)
@@ -215,11 +215,11 @@ ProcCreate(
     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;
@@ -249,12 +249,12 @@ ProcClose(
     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);
 
@@ -307,10 +307,10 @@ ProcDeviceControl(
 
         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;
@@ -334,12 +334,12 @@ ProcDeviceControl(
 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) {
@@ -354,7 +354,7 @@ ProcReadWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
         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;
index 3baa11a..127d345 100644 (file)
@@ -201,10 +201,10 @@ usocklnd_poll_thread(void *arg)
                 }
         }
 
-        /* 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 */
index d1e6b7f..cc8c4c8 100644 (file)
@@ -143,7 +143,7 @@ usocklnd_release_poll_states(int n)
                 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);
@@ -286,7 +286,7 @@ usocklnd_base_startup()
                 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 */
@@ -335,7 +335,7 @@ usocklnd_base_shutdown(int n)
         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);
index 0d2b494..ee5c3e1 100644 (file)
@@ -154,8 +154,8 @@ typedef struct {
         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[]
index c01069a..14f3ef6 100644 (file)
@@ -371,7 +371,7 @@ struct nfs_lock_info {
         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 */
@@ -394,16 +394,16 @@ typedef struct file_lock {
         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)))
index 3b67a69..ac2e7fc 100644 (file)
@@ -56,7 +56,7 @@
 #include <linux/statfs.h>
 
 #else
-typedef struct statfs cfs_kstatfs_t;
+#define kstatfs statfs
 #endif
 
 #endif /* LPROCFS_SNMP_H */
index 7bded0f..2ba56ef 100644 (file)
@@ -113,8 +113,8 @@ struct obd_client_handle {
 #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 {
index 5149e4b..d36a871 100644 (file)
@@ -304,7 +304,7 @@ enum llog_ctxt_id {
 #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];
 };
 
 
@@ -314,14 +314,14 @@ struct filter_ext {
 };
 
 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;
 
@@ -749,14 +749,14 @@ struct lmv_obd {
 };
 
 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"
index a6d5d58..cf8b568 100644 (file)
@@ -1313,10 +1313,10 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent)
 
                 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;
 }
 
 /**
index 6b2e34d..f59c354 100644 (file)
@@ -606,7 +606,7 @@ ldlm_flock_interrupted_wait(void *data)
 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;
@@ -705,33 +705,32 @@ granted:
                 /* 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);
 
index 09cdc5c..a13c950 100644 (file)
@@ -141,13 +141,12 @@ void *(*memmover)(void *, const void *, size_t) = memmove;
 
 #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,
index dc41d06..78e19d5 100644 (file)
@@ -394,7 +394,7 @@ int t14(char *name)
         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");
@@ -1363,11 +1363,11 @@ int t55(char *name)
  */
 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");
 
index 1461c31..1395df3 100644 (file)
@@ -363,7 +363,7 @@ void t_grep_v(const char *path, char *str)
 
 void t_ls(int fd, char *buf, int size)
 {
-       cfs_dirent_t *ent;
+       struct dirent64 *ent;
        int rc, pos;
        loff_t base = 0;
 
@@ -371,7 +371,7 @@ void t_ls(int fd, char *buf, int size)
        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;
                }
index 723b8e8..492152c 100644 (file)
@@ -1972,14 +1972,14 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                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:
index 7d4fa12..c0bf17b 100644 (file)
@@ -127,9 +127,10 @@ static int mdc_wr_kuc(struct file *file, const char *buffer,
        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)
index 853143f..772502b 100644 (file)
@@ -1492,11 +1492,11 @@ static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
 #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,
@@ -1590,8 +1590,8 @@ static int mdc_changelog_send_thread(void *csdata)
         }
 
 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);
@@ -1614,11 +1614,11 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
         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 */
@@ -2032,11 +2032,12 @@ static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
                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);
        }
index 55096da..d6b4662 100644 (file)
@@ -2217,7 +2217,7 @@ static void server_umount_begin(struct super_block *sb)
         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);
index 673eade..7284f65 100644 (file)
@@ -49,7 +49,7 @@
 #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;
@@ -63,7 +63,7 @@ void statfs_pack(struct obd_statfs *osfs, cfs_kstatfs_t *sfs)
 }
 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;
index a281d32..1d37fc8 100644 (file)
@@ -2839,7 +2839,7 @@ static int osd_object_sync(const struct lu_env *env, struct dt_object *dt)
 #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
@@ -4110,12 +4110,12 @@ osd_it_append_attrs(struct lu_dirent *ent, int len, __u16 type)
 {
        /* 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);
index 1c36e18..26c41c3 100644 (file)
@@ -534,10 +534,10 @@ struct osd_thread_info {
                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;
index f597e02..f14faf7 100644 (file)
@@ -190,7 +190,7 @@ static inline void osd_it_append_attrs(struct lu_dirent *ent, __u32 attr,
                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;
        }
 
index 685698f..90ce515 100644 (file)
@@ -73,7 +73,7 @@ static inline void qpi_getref(struct qmt_pool_info *pool)
 }
 
 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))
index 3b796de..ee5bbf1 100644 (file)
@@ -1234,7 +1234,7 @@ err:
 }
 
 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)
 
@@ -1278,7 +1278,7 @@ static void find_param_fini(struct find_param *param)
 }
 
 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--;
@@ -1379,10 +1379,10 @@ int llapi_mds_getfileinfo(char *path, DIR *parent,
 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;
 
@@ -2564,7 +2564,7 @@ static int print_failed_tgt(struct find_param *param, char *path, int type)
 }
 
 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. */
@@ -2885,7 +2885,7 @@ int llapi_file_fget_mdtidx(int fd, int *mdtidx)
 }
 
 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;
@@ -2952,7 +2952,7 @@ out:
 }
 
 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;
@@ -3272,7 +3272,7 @@ int llapi_quotactl(char *mnt, struct if_quotactl *qctl)
 }
 
 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;