Whamcloud - gitweb
LU-327 cleanup the client import of mgc
[fs/lustre-release.git] / lustre / include / obd_class.h
index 63d4095..3865358 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
@@ -141,8 +144,8 @@ static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
 
 /* Passed as data param to class_config_parse_llog */
 struct config_llog_instance {
-        char *              cfg_instance;
         char *              cfg_obdname;
+        char                cfg_instance[sizeof(void*) * 2 + 1];
         struct super_block *cfg_sb;
         struct obd_uuid     cfg_uuid;
         int                 cfg_last_idx; /* for partial llog processing */
@@ -616,6 +619,31 @@ static inline int obd_cleanup(struct obd_device *obd)
         RETURN(rc);
 }
 
+static inline void obd_cleanup_client_import(struct obd_device *obd)
+{
+        ENTRY;
+
+        /* If we set up but never connected, the
+           client import will not have been cleaned. */
+        cfs_down_write(&obd->u.cli.cl_sem);
+        if (obd->u.cli.cl_import) {
+                struct obd_import *imp;
+                imp = obd->u.cli.cl_import;
+                CDEBUG(D_CONFIG, "%s: client import never connected\n",
+                       obd->obd_name);
+                ptlrpc_invalidate_import(imp);
+                if (imp->imp_rq_pool) {
+                        ptlrpc_free_rq_pool(imp->imp_rq_pool);
+                        imp->imp_rq_pool = NULL;
+                }
+                class_destroy_import(imp);
+                obd->u.cli.cl_import = NULL;
+        }
+        cfs_up_write(&obd->u.cli.cl_sem);
+
+        EXIT;
+}
+
 static inline int
 obd_process_config(struct obd_device *obd, int datalen, void *data)
 {
@@ -1252,31 +1280,38 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         RETURN(rc);
 }
 
-static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
-                           struct lov_stripe_md *ea, obd_size start,
-                           obd_size end, void *capa)
+static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo,
+                                 obd_size start, obd_size end)
 {
+        struct ptlrpc_request_set *set = NULL;
         int rc;
         ENTRY;
 
         OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP);
         EXP_COUNTER_INCREMENT(exp, sync);
 
-        rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end, capa);
+        set =  ptlrpc_prep_set();
+        if (set == NULL)
+                RETURN(-ENOMEM);
+
+        rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
+        if (rc == 0)
+                rc = ptlrpc_set_wait(set);
+        ptlrpc_set_destroy(set);
         RETURN(rc);
 }
 
-static inline int obd_sync_fs(struct obd_export *exp, struct obd_info *oinfo,
-                              int wait)
+static inline int obd_sync(struct obd_export *exp, struct obd_info *oinfo,
+                           obd_size start, obd_size end,
+                           struct ptlrpc_request_set *set)
 {
         int rc;
         ENTRY;
 
-        OBD_CHECK_DT_OP(exp->exp_obd, sync_fs, -EOPNOTSUPP);
+        OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP);
         EXP_COUNTER_INCREMENT(exp, sync);
 
-        rc = OBP(exp->exp_obd, sync_fs)(exp, oinfo, wait);
-
+        rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
         RETURN(rc);
 }
 
@@ -1992,14 +2027,15 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid,
 
 static inline int md_readpage(struct obd_export *exp, const struct lu_fid *fid,
                               struct obd_capa *oc, __u64 offset,
-                              struct page *page,
+                              struct page **pages, unsigned npages,
                               struct ptlrpc_request **request)
 {
         int rc;
         ENTRY;
         EXP_CHECK_MD_OP(exp, readpage);
         EXP_MD_COUNTER_INCREMENT(exp, readpage);
-        rc = MDP(exp->exp_obd, readpage)(exp, fid, oc, offset, page, request);
+        rc = MDP(exp->exp_obd, readpage)(exp, fid, oc, offset, pages, npages,
+                                         request);
         RETURN(rc);
 }