Whamcloud - gitweb
LU-3382 build: clean unused link dependencies
[fs/lustre-release.git] / lustre / liblustre / llite_cl.c
index ed8c988..e4ed309 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  *   Copyright (c) 2007 Cluster File Systems, Inc.
  *   Author: Nikita Danilov <nikita@clusterfs.com>
  *
  *   You should have received a copy of the GNU General Public License
  *   along with Lustre; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *   Copyright (c) 2011, 2013, Intel Corporation.
  */
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include <sys/types.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/queue.h>
-#ifndef __CYGWIN__
-# include <sys/statvfs.h>
-#else
-# include <sys/statfs.h>
-#endif
-
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
 #include <liblustre.h>
-
+#include <lclient.h>
+#include <cl_object.h>
+#include <lustre_export.h>
+#include <lustre_lite.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 <cl_object.h>
-
 #include "llite_lib.h"
 
 /*
@@ -57,9 +47,8 @@
 static int   slp_type_init     (struct lu_device_type *t);
 static void  slp_type_fini     (struct lu_device_type *t);
 
-static struct cl_page * slp_page_init(const struct lu_env *env,
-                                     struct cl_object *obj,
-                                     struct cl_page *page, cfs_page_t *vmpage);
+static int slp_page_init(const struct lu_env *env, struct cl_object *obj,
+                        struct cl_page *page, pgoff_t index);
 static int   slp_attr_get     (const struct lu_env *env, struct cl_object *obj,
                                struct cl_attr *attr);
 
@@ -81,7 +70,6 @@ static const struct cl_device_operations      slp_cl_ops;
 static const struct cl_io_operations          ccc_io_ops;
 static const struct lu_device_type_operations slp_device_type_ops;
              //struct lu_device_type            slp_device_type;
-static const struct cl_page_operations        slp_page_ops;
 static const struct cl_page_operations        slp_transient_page_ops;
 static const struct cl_lock_operations        slp_lock_ops;
 
@@ -92,8 +80,8 @@ static const struct cl_lock_operations        slp_lock_ops;
  *
  */
 
-void *slp_session_key_init(const struct lu_context *ctx,
-                                  struct lu_context_key *key)
+static void *slp_session_key_init(const struct lu_context *ctx,
+                                 struct lu_context_key *key)
 {
         struct slp_session *session;
 
@@ -103,8 +91,8 @@ void *slp_session_key_init(const struct lu_context *ctx,
         return session;
 }
 
-void slp_session_key_fini(const struct lu_context *ctx,
-                                 struct lu_context_key *key, void *data)
+static void slp_session_key_fini(const struct lu_context *ctx,
+                                struct lu_context_key *key, void *data)
 {
         struct slp_session *session = data;
         OBD_FREE_PTR(session);
@@ -198,7 +186,7 @@ static const struct lu_device_type_operations slp_device_type_ops = {
         .ldto_device_fini  = ccc_device_fini
 };
 
-struct lu_device_type slp_device_type = {
+static struct lu_device_type slp_device_type = {
         .ldt_tags     = LU_DEVICE_CL,
         .ldt_name     = LUSTRE_SLP_NAME,
         .ldt_ops      = &slp_device_type_ops,
@@ -224,32 +212,26 @@ void slp_global_fini(void)
  *
  */
 
-static struct cl_page *slp_page_init(const struct lu_env *env,
-                                     struct cl_object *obj,
-                                     struct cl_page *page, cfs_page_t *vmpage)
+static int slp_page_init(const struct lu_env *env, struct cl_object *obj,
+                       struct cl_page *page, pgoff_t index)
 {
-        struct ccc_page *cpg;
-        int result;
+       struct ccc_page *cpg = cl_object_page_slice(obj, page);
 
-        CLOBINVRNT(env, obj, ccc_object_invariant(obj));
+       CLOBINVRNT(env, obj, ccc_object_invariant(obj));
 
-        OBD_ALLOC_PTR(cpg);
-        if (cpg != NULL) {
-                cpg->cpg_page = vmpage;
+       cpg->cpg_page = page->cp_vmpage;
 
-                if (page->cp_type == CPT_CACHEABLE) {
-                        LBUG();
-                } else {
-                        struct ccc_object *clobj = cl2ccc(obj);
+       if (page->cp_type == CPT_CACHEABLE) {
+               LBUG();
+       } else {
+               struct ccc_object *clobj = cl2ccc(obj);
 
-                        cl_page_slice_add(page, &cpg->cpg_cl, obj,
-                                          &slp_transient_page_ops);
-                        clobj->cob_transient_pages++;
-                }
-                result = 0;
-        } else
-                result = -ENOMEM;
-        return ERR_PTR(result);
+               cl_page_slice_add(page, &cpg->cpg_cl, obj, index,
+                                 &slp_transient_page_ops);
+               clobj->cob_transient_pages++;
+       }
+
+       return 0;
 }
 
 static int slp_io_init(const struct lu_env *env, struct cl_object *obj,
@@ -301,7 +283,7 @@ static int slp_attr_get(const struct lu_env *env, struct cl_object *obj,
 
 static void slp_page_fini_common(struct ccc_page *cp)
 {
-        cfs_page_t *vmpage = cp->cpg_page;
+       struct page *vmpage = cp->cpg_page;
 
         LASSERT(vmpage != NULL);
         llu_free_user_page(vmpage);
@@ -366,10 +348,8 @@ static const struct cl_page_operations slp_transient_page_ops = {
         .cpo_unassume      = ccc_transient_page_unassume,
         .cpo_disown        = ccc_transient_page_disown,
         .cpo_discard       = ccc_transient_page_discard,
-        .cpo_vmpage        = ccc_page_vmpage,
         .cpo_is_vmlocked   = slp_page_is_vmlocked,
         .cpo_fini          = slp_transient_page_fini,
-        .cpo_is_under_lock = ccc_page_is_under_lock,
         .io = {
                 [CRT_READ] = {
                         .cpo_completion  = slp_page_completion_read,
@@ -488,7 +468,6 @@ static int llu_queue_pio(const struct lu_env *env, struct cl_io *io,
         struct obd_export *exp = llu_i2obdexp(inode);
         struct page *page;
         int  rc = 0, ret_bytes = 0;
-        int local_lock;
         struct cl_page *clp;
         struct cl_2queue *queue;
         ENTRY;
@@ -496,8 +475,6 @@ static int llu_queue_pio(const struct lu_env *env, struct cl_io *io,
         if (!exp)
                 RETURN(-EINVAL);
 
-        local_lock = group->lig_params->lrp_lock_mode != LCK_NL;
-
         queue = &io->ci_queue;
         cl_2queue_init(queue);
 
@@ -507,8 +484,8 @@ static int llu_queue_pio(const struct lu_env *env, struct cl_io *io,
                 unsigned long index, offset, bytes;
 
                 offset = (pos & ~CFS_PAGE_MASK);
-                index = pos >> CFS_PAGE_SHIFT;
-                bytes = CFS_PAGE_SIZE - offset;
+               index = pos >> PAGE_CACHE_SHIFT;
+               bytes = PAGE_CACHE_SIZE - offset;
                 if (bytes > count)
                         bytes = count;
 
@@ -563,7 +540,7 @@ static int llu_queue_pio(const struct lu_env *env, struct cl_io *io,
         if (rc == 0) {
                 enum cl_req_type iot;
                 iot = io->ci_type == CIT_READ ? CRT_READ : CRT_WRITE;
-                rc = cl_io_submit_sync(env, io, iot, queue, CRP_NORMAL, 0);
+               rc = cl_io_submit_sync(env, io, iot, queue, 0);
         }
 
         group->lig_rc = rc;
@@ -576,8 +553,7 @@ static int llu_queue_pio(const struct lu_env *env, struct cl_io *io,
 }
 
 static
-struct llu_io_group * get_io_group(struct inode *inode, int maxpages,
-                                   struct lustre_rw_params *params)
+struct llu_io_group *get_io_group(struct inode *inode, int maxpages)
 {
         struct llu_io_group *group;
 
@@ -585,14 +561,13 @@ struct llu_io_group * get_io_group(struct inode *inode, int maxpages,
         if (!group)
                 return ERR_PTR(-ENOMEM);
 
-        group->lig_params = params;
-
         return group;
 }
 
 static int max_io_pages(ssize_t len, int iovlen)
 {
-        return (((len + CFS_PAGE_SIZE -1) / CFS_PAGE_SIZE) + 2 + iovlen - 1);
+       return ((len + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE) +
+               2 + iovlen - 1;
 }
 
 void put_io_group(struct llu_io_group *group)
@@ -618,7 +593,6 @@ static int slp_io_start(const struct lu_env *env, const struct cl_io_slice *ios)
         loff_t pos;
         long   cnt;
         struct llu_io_group *iogroup;
-        struct lustre_rw_params p = {0};
         int iovidx;
         struct intnl_stat *st = llu_i2stat(inode);
         struct llu_inode_info *lli = llu_i2info(inode);
@@ -635,18 +609,12 @@ static int slp_io_start(const struct lu_env *env, const struct cl_io_slice *ios)
                 pos = io->u.ci_rd.rd.crw_pos;
                 cnt = io->u.ci_rd.rd.crw_count;
         }
-        if (io->u.ci_wr.wr_append) {
-                p.lrp_lock_mode = LCK_PW;
-        } else {
-                p.lrp_brw_flags = OBD_BRW_SRVLOCK;
-                p.lrp_lock_mode = LCK_NL;
-        }
 
-        iogroup = get_io_group(inode, max_io_pages(cnt, cio->cui_nrsegs), &p);
+       iogroup = get_io_group(inode, max_io_pages(cnt, cio->cui_nrsegs));
         if (IS_ERR(iogroup))
                 RETURN(PTR_ERR(iogroup));
 
-        err = ccc_prep_size(env, obj, io, pos, cnt, 0, &exceed);
+        err = ccc_prep_size(env, obj, io, pos, cnt, &exceed);
         if (err != 0 || (write == 0 && exceed != 0))
                 GOTO(out, err);
 
@@ -795,12 +763,7 @@ int cl_sb_fini(struct llu_sb_info *sbi)
                 sbi->ll_site = NULL;
         }
         cl_env_put(env, &refcheck);
-        /*
-         * If mount failed (sbi->ll_cl == NULL), and this there are no other
-         * mounts, stop device types manually (this usually happens
-         * automatically when last device is destroyed).
-         */
-        lu_types_stop();
-        cl_env_cache_purge(~0);
-        RETURN(0);
+       cl_env_cache_purge(~0);
+
+       RETURN(0);
 }