Whamcloud - gitweb
LU-5577 obdclass: change cl_fault_io->ft_nob to size_t
[fs/lustre-release.git] / lustre / llite / lcommon_cl.c
index afda860..6865d27 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/fs.h>
-# include <linux/sched.h>
-# include <linux/mm.h>
-# include <linux/quotaops.h>
-# include <linux/highmem.h>
-# include <linux/pagemap.h>
-# include <linux/rbtree.h>
-#else /* __KERNEL__ */
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/queue.h>
-#include <fcntl.h>
-# include <liblustre.h>
-#endif
+#include <libcfs/libcfs.h>
+#include <linux/fs.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/quotaops.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/rbtree.h>
 
 #include <obd.h>
 #include <obd_support.h>
 #include <lustre_fid.h>
-#include <lustre_lite.h>
 #include <lustre_dlm.h>
 #include <lustre_ver.h>
 #include <lustre_mdc.h>
 
 #include <lclient.h>
 
-#ifdef __KERNEL__
-#include "../llite/llite_internal.h"
-#else
-#include "../liblustre/llite_lib.h"
-#endif
+#include "llite_internal.h"
 
 static const struct cl_req_operations ccc_req_ops;
 
@@ -364,13 +347,13 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env,
 }
 
 int ccc_object_init0(const struct lu_env *env,
-                            struct ccc_object *vob,
-                            const struct cl_object_conf *conf)
+                    struct ccc_object *vob,
+                    const struct cl_object_conf *conf)
 {
-        vob->cob_inode = conf->coc_inode;
-        vob->cob_transient_pages = 0;
+       vob->cob_inode = conf->coc_inode;
+       atomic_set(&vob->cob_transient_pages, 0);
        cl_object_page_init(&vob->cob_cl, sizeof(struct ccc_page));
-        return 0;
+       return 0;
 }
 
 int ccc_object_init(const struct lu_env *env, struct lu_object *obj,
@@ -388,7 +371,7 @@ int ccc_object_init(const struct lu_env *env, struct lu_object *obj,
                 const struct cl_object_conf *cconf;
 
                 cconf = lu2cl_conf(conf);
-                CFS_INIT_LIST_HEAD(&vob->cob_pending_list);
+               INIT_LIST_HEAD(&vob->cob_pending_list);
                 lu_object_add(obj, below);
                 result = ccc_object_init0(env, vob, cconf);
         } else
@@ -552,12 +535,6 @@ int ccc_transient_page_prep(const struct lu_env *env,
  *
  */
 
-void ccc_lock_delete(const struct lu_env *env,
-                     const struct cl_lock_slice *slice)
-{
-        CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
-}
-
 void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice)
 {
         struct ccc_lock *clk = cl2ccc_lock(slice);
@@ -565,114 +542,13 @@ void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice)
 }
 
 int ccc_lock_enqueue(const struct lu_env *env,
-                     const struct cl_lock_slice *slice,
-                     struct cl_io *unused, __u32 enqflags)
-{
-        CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
-        return 0;
-}
-
-int ccc_lock_use(const struct lu_env *env, const struct cl_lock_slice *slice)
+                    const struct cl_lock_slice *slice,
+                    struct cl_io *unused, struct cl_sync_io *anchor)
 {
        CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
        return 0;
 }
 
-int ccc_lock_unuse(const struct lu_env *env, const struct cl_lock_slice *slice)
-{
-        CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
-        return 0;
-}
-
-int ccc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice)
-{
-        CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
-        return 0;
-}
-
-/**
- * Implementation of cl_lock_operations::clo_fits_into() methods for ccc
- * layer. This function is executed every time io finds an existing lock in
- * the lock cache while creating new lock. This function has to decide whether
- * cached lock "fits" into io.
- *
- * \param slice lock to be checked
- * \param io    IO that wants a lock.
- *
- * \see lov_lock_fits_into().
- */
-int ccc_lock_fits_into(const struct lu_env *env,
-                       const struct cl_lock_slice *slice,
-                       const struct cl_lock_descr *need,
-                       const struct cl_io *io)
-{
-        const struct cl_lock       *lock  = slice->cls_lock;
-        const struct cl_lock_descr *descr = &lock->cll_descr;
-        const struct ccc_io        *cio   = ccc_env_io(env);
-        int                         result;
-
-        ENTRY;
-        /*
-         * Work around DLM peculiarity: it assumes that glimpse
-         * (LDLM_FL_HAS_INTENT) lock is always LCK_PR, and returns reads lock
-         * when asked for LCK_PW lock with LDLM_FL_HAS_INTENT flag set. Make
-         * sure that glimpse doesn't get CLM_WRITE top-lock, so that it
-         * doesn't enqueue CLM_WRITE sub-locks.
-         */
-        if (cio->cui_glimpse)
-                result = descr->cld_mode != CLM_WRITE;
-
-        /*
-         * Also, don't match incomplete write locks for read, otherwise read
-         * would enqueue missing sub-locks in the write mode.
-         */
-        else if (need->cld_mode != descr->cld_mode)
-                result = lock->cll_state >= CLS_ENQUEUED;
-        else
-                result = 1;
-        RETURN(result);
-}
-
-/**
- * Implements cl_lock_operations::clo_state() method for ccc layer, invoked
- * whenever lock state changes. Transfers object attributes, that might be
- * updated as a result of lock acquiring into inode.
- */
-void ccc_lock_state(const struct lu_env *env,
-                    const struct cl_lock_slice *slice,
-                    enum cl_lock_state state)
-{
-       struct cl_lock *lock = slice->cls_lock;
-       ENTRY;
-
-       /*
-        * Refresh inode attributes when the lock is moving into CLS_HELD
-        * state, and only when this is a result of real enqueue, rather than
-        * of finding lock in the cache.
-        */
-       if (state == CLS_HELD && lock->cll_state < CLS_HELD) {
-               struct cl_object *obj;
-               struct inode     *inode;
-
-               obj   = slice->cls_obj;
-               inode = ccc_object_inode(obj);
-
-               /* vmtruncate() sets the i_size
-                * under both a DLM lock and the
-                * ll_inode_size_lock().  If we don't get the
-                * ll_inode_size_lock() here we can match the DLM lock and
-                * reset i_size.  generic_file_write can then trust the
-                * stale i_size when doing appending writes and effectively
-                * cancel the result of the truncate.  Getting the
-                * ll_inode_size_lock() after the enqueue maintains the DLM
-                * -> ll_inode_size_lock() acquiring order. */
-               if (lock->cll_descr.cld_start == 0 &&
-                   lock->cll_descr.cld_end == CL_PAGE_EOF)
-                       cl_merge_lvb(env, inode);
-       }
-       EXIT;
-}
-
 /*****************************************************************************
  *
  * io operations.
@@ -961,10 +837,8 @@ void ccc_req_attr_set(const struct lu_env *env,
        obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid);
        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID))
                oa->o_parent_oid++;
-#ifdef __KERNEL__
        memcpy(attr->cra_jobid, cl_i2info(inode)->lli_jobid,
-              JOBSTATS_JOBID_SIZE);
-#endif
+              LUSTRE_JOBID_SIZE);
 }
 
 static const struct cl_req_operations ccc_req_ops = {
@@ -1156,9 +1030,7 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
                  * there is no clob in cache with the given fid, so it is
                  * unnecessary to perform lookup-alloc-lookup-insert, just
                  * alloc and insert directly. */
-#ifdef __KERNEL__
                 LASSERT(inode->i_state & I_NEW);
-#endif
                 conf.coc_lu.loc_flags = LOC_F_NEW;
                 clob = cl_object_find(env, lu2cl_dev(site->ls_top_dev),
                                       fid, &conf);