Whamcloud - gitweb
- fixed typos in comments and some alingment in cobd.
authoryury <yury>
Mon, 13 Jun 2005 12:28:32 +0000 (12:28 +0000)
committeryury <yury>
Mon, 13 Jun 2005 12:28:32 +0000 (12:28 +0000)
- added canceling unused locks before disconnecting master/cache exports in cobd_iocontrol()

- added lmv_cancel_unused() to cancel unused locks from llite correctly instead of using
direct ldlm_cli_cancel_unused() on lmv namespace.

- removed not used ll_mdc_cancel_unused()

lustre/cobd/cache_obd.c
lustre/include/linux/lustre_dlm.h
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/osc/osc_request.c

index 0710971..4e56ce0 100644 (file)
@@ -102,7 +102,7 @@ static int cobd_setup(struct obd_device *obd, obd_count len, void *buf)
         
         cobd->master_exp = class_conn2export(&conn);
 
-        /* getting master obd */
+        /* getting cache obd */
         cache_obd = class_name2obd(cobd->cache_name);
         if (!cache_obd) {
                 class_disconnect(cobd->master_exp, 0);
@@ -111,7 +111,7 @@ static int cobd_setup(struct obd_device *obd, obd_count len, void *buf)
                 GOTO(put_names, rc);
         }
 
-        /* connecting master */
+        /* connecting cache */
         memset(&conn, 0, sizeof(conn));
         rc = class_connect(&conn, cache_obd, &obd->obd_uuid);
         if (rc) {
@@ -119,7 +119,8 @@ static int cobd_setup(struct obd_device *obd, obd_count len, void *buf)
                 GOTO(put_names, rc);
         }
         cobd->cache_exp = class_conn2export(&conn);
-        /*default set cache on*/
+        
+        /* default set cache on */
         cobd->cache_on = 1;
         EXIT;
 put_names:
@@ -183,10 +184,12 @@ cobd_get_exp(struct obd_device *obd)
         return cobd->master_exp;
 }
 
-static int client_obd_connect(struct obd_device *obd, struct obd_export *exp,
-                              struct lustre_handle *conn,
-                              struct obd_connect_data *data,
-                              unsigned long flags)
+static int
+client_obd_connect(struct obd_device *obd,
+                   struct obd_export *exp,
+                   struct lustre_handle *conn,
+                   struct obd_connect_data *data,
+                   unsigned long flags)
 { 
         struct obd_device *cli_obd;
         int rc = 0;
@@ -206,9 +209,10 @@ static int client_obd_connect(struct obd_device *obd, struct obd_export *exp,
         RETURN(rc);
 }
 
-static int client_obd_disconnect(struct obd_device *obd,
-                                 struct obd_export *exp,
-                                 unsigned long flags)
+static int
+client_obd_disconnect(struct obd_device *obd,
+                      struct obd_export *exp,
+                      unsigned long flags)
 {
         struct obd_device *cli_obd;
         int rc = 0;
@@ -709,8 +713,8 @@ static int cobd_cancel(struct obd_export *exp,
 }
 
 static int cobd_cancel_unused(struct obd_export *exp,
-                              struct lov_stripe_md *ea, int flags,
-                              void *opaque)
+                              struct lov_stripe_md *ea,
+                              int flags, void *opaque)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_export *cobd_exp;
@@ -724,10 +728,12 @@ static int cobd_cancel_unused(struct obd_export *exp,
         return obd_cancel_unused(cobd_exp, ea, flags, opaque);
 }
 
-static int cobd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
-                       int objcount, struct obd_ioobj *obj,
-                       int niocount, struct niobuf_remote *nb,
-                       struct niobuf_local *res, struct obd_trans_info *oti)
+static int cobd_preprw(int cmd, struct obd_export *exp,
+                       struct obdo *oa, int objcount,
+                       struct obd_ioobj *obj, int niocount,
+                       struct niobuf_remote *nb,
+                       struct niobuf_local *res,
+                       struct obd_trans_info *oti)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_export *cobd_exp;
@@ -738,8 +744,8 @@ static int cobd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                 return -EINVAL;
         }
         cobd_exp = cobd_get_exp(obd);
-        return obd_preprw(cmd, cobd_exp, oa, objcount, obj, niocount, nb, 
-                          res, oti);
+        return obd_preprw(cmd, cobd_exp, oa, objcount, obj,
+                          niocount, nb, res, oti);
 }
 
 static int cobd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
@@ -756,8 +762,8 @@ static int cobd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
                 return -EINVAL;
         }
         cobd_exp = cobd_get_exp(obd);
-        return obd_commitrw(cmd, cobd_exp, oa, objcount, obj, niocount, 
-                            local, oti, rc);
+        return obd_commitrw(cmd, cobd_exp, oa, objcount, obj,
+                            niocount, local, oti, rc);
 }
 
 static int cobd_flush(struct obd_device *obd)
@@ -781,11 +787,24 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp,
                 if (!cobd->cache_on) {
                         struct lustre_handle conn = {0};
 
+                        rc = obd_cancel_unused(cobd->master_real_exp, NULL,
+                                               LDLM_FL_COBD_SWITCH, NULL);
+                        if (rc) {
+                                CWARN("can't cancel unused locks on master export, "
+                                      "err %d\n", rc);
+                        }
+                        
                         rc = client_obd_disconnect(obd, cobd->master_real_exp, 0);
+                        if (rc) {
+                                CWARN("can't disconnect master export, err %d\n",
+                                      rc);
+                        }
+                        
                         rc = client_obd_connect(obd, cobd->cache_exp, &conn,
                                                 NULL, OBD_OPT_REAL_CLIENT);
                         if (rc)
                                 GOTO(out, rc);
+
                         cobd->cache_real_exp = class_conn2export(&conn);
                         cobd->cache_on = 1;
                 }
@@ -800,8 +819,19 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp,
                         cache = class_exp2obd(cobd->cache_exp); 
                         easize = cache->u.cli.cl_max_mds_easize; 
                         cooksize = cache->u.cli.cl_max_mds_cookiesize;
+
+                        rc = obd_cancel_unused(cobd->cache_real_exp, NULL,
+                                               LDLM_FL_COBD_SWITCH, NULL);
+                        if (rc) {
+                                CWARN("can't cancel unused locks on cache export, "
+                                      "err %d\n", rc);
+                        }
                         
                         rc = client_obd_disconnect(obd, cobd->cache_real_exp, 0);
+                        if (rc) {
+                                CWARN("can't disconnect cache export, err %d\n",
+                                      rc);
+                        }
                         rc = client_obd_connect(obd, cobd->master_exp, &conn,
                                                 NULL, OBD_OPT_REAL_CLIENT);
                         if (rc)
@@ -818,6 +848,7 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp,
                 if (cobd->cache_on) {
                         cobd->cache_on = 0;
                         cobd_flush(obd);
+                        cobd->cache_on = 1;
                 } else {
                         CERROR("%s: cache is turned off\n", obd->obd_name);
                 }
index d3e71e2..c0c5ea0 100644 (file)
@@ -73,8 +73,10 @@ typedef enum {
                                          * indefinitely */
 
 /* file & record locking */
-#define LDLM_FL_BLOCK_NOWAIT   0x040000 // server told not to wait if blocked
-#define LDLM_FL_TEST_LOCK      0x080000 // return blocking lock
+#define LDLM_FL_BLOCK_NOWAIT   0x040000 /* server told not to wait if blocked */
+#define LDLM_FL_TEST_LOCK      0x080000 /* return blocking lock */
+#define LDLM_FL_COBD_SWITCH    0x100000 /* not used yet, but logicaly we have to
+                                         * distinguish diff. situations. */ 
 
 /* These are flags that are mapped into the flags and ASTs of blocking locks */
 #define LDLM_AST_DISCARD_DATA  0x80000000 /* Add FL_DISCARD to blocking ASTs */
index bb7ea25..d552db6 100644 (file)
@@ -212,8 +212,6 @@ int ll_objects_destroy(struct ptlrpc_request *request,
 struct inode *ll_iget(struct super_block *sb, ino_t hash,
                       struct lustre_md *lic);
 struct dentry *ll_find_alias(struct inode *, struct dentry *);
-int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
-                         void *opaque);
 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
                         void *data, int flag);
 /* llite/rw.c */
index 465ff67..bf40365 100644 (file)
@@ -181,8 +181,8 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov,
         }
 
         if (proc_lustre_fs_root) {
-                err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
-                                                  lov, lmv);
+                err = lprocfs_register_mountpoint(proc_lustre_fs_root,
+                                                  sb, lov, lmv);
                 if (err < 0)
                         CERROR("could not register mount in /proc/lustre");
         }
@@ -267,11 +267,10 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov,
 
         sb->s_op = &lustre_super_operations;
 
-        /* make root inode
-         * XXX: move this to after cbd setup? */
+        /* make root inode */
         err = md_getattr(sbi->ll_md_exp, &sbi->ll_rootid,
-                         (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID), NULL, 0,
-                         0, &request);
+                         (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID),
+                         NULL, 0, 0, &request);
         if (err) {
                 CERROR("md_getattr failed for root: rc = %d\n", err);
                 GOTO(out_lov, err);
@@ -499,8 +498,8 @@ int ll_fill_super(struct super_block *sb, void *data, int silent)
                 GOTO(out, err = -EINVAL);
         }
         
-        err = lustre_common_fill_super(sb, lmv, lov, async, sec, nllu,
-                                       &remote_flag);
+        err = lustre_common_fill_super(sb, lmv, lov, async, sec,
+                                       nllu, &remote_flag);
         EXIT;
 out:
         if (err)
@@ -879,7 +878,6 @@ void lustre_put_super(struct super_block *sb)
 
 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
 {
-        struct obd_export *md_exp = sbi->ll_md_exp;
         struct lustre_mount_data *lmd = sbi->ll_lmd;
         char *profile = lmd->lmd_profile, *name = NULL;
         struct config_llog_instance cfg;
@@ -890,18 +888,18 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean)
         if (profile == NULL)
                 RETURN(0);
         if (lmd == NULL) {
-                CERROR("Client not mounted with zero-conf; cannot process "
-                       "update log.\n");
+                CERROR("Client not mounted with zero-conf; cannot "
+                       "process update log.\n");
                 RETURN(0);
         }
 
-        rc = ldlm_cli_cancel_unused(md_exp->exp_obd->obd_namespace, NULL,
-                                    LDLM_FL_CONFIG_CHANGE, NULL);
+        rc = obd_cancel_unused(sbi->ll_md_exp, NULL,
+                               LDLM_FL_CONFIG_CHANGE, NULL);
         if (rc != 0)
-                CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
+                CWARN("obd_cancel_unused(mdc): %d\n", rc);
 
-        rc = obd_cancel_unused(sbi->ll_dt_exp, NULL, LDLM_FL_CONFIG_CHANGE,
-                               NULL);
+        rc = obd_cancel_unused(sbi->ll_dt_exp, NULL,
+                               LDLM_FL_CONFIG_CHANGE, NULL);
         if (rc != 0)
                 CWARN("obd_cancel_unused(lov): %d\n", rc);
 
@@ -924,7 +922,7 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean)
 
         CWARN("Applying configuration log %s\n", name);
 
-        ctxt = llog_get_context(&md_exp->exp_obd->obd_llogs,
+        ctxt = llog_get_context(&sbi->ll_md_exp->exp_obd->obd_llogs,
                                 LLOG_CONFIG_REPL_CTXT);
         rc = class_config_process_llog(ctxt, name, &cfg);
         if (rc == 0)
@@ -940,7 +938,7 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean)
                 rc = obd_get_info(sbi->ll_dt_exp, strlen("lovdesc") + 1,
                                   "lovdesc", &valsize, &desc);
 
-                rc = obd_init_ea_size(md_exp,
+                rc = obd_init_ea_size(sbi->ll_md_exp,
                                       obd_size_diskmd(sbi->ll_dt_exp, NULL),
                                       (desc.ld_tgt_count *
                                        sizeof(struct llog_cookie)));
index 8639126..c329318 100644 (file)
@@ -231,19 +231,6 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
         RETURN(0);
 }
 
-int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode,
-                         int flags, void *opaque)
-{
-        struct ll_inode_info *li = ll_i2info(inode);
-        struct ldlm_res_id res_id =
-                { .name = {id_fid(&li->lli_id), id_group(&li->lli_id)} };
-        struct obd_device *obddev = class_conn2obd(conn);
-        ENTRY;
-        
-        RETURN(ldlm_cli_cancel_unused(obddev->obd_namespace, &res_id, flags,
-                                      opaque));
-}
-
 /* Search "inode"'s alias list for a dentry that has the same name and parent as
  * de.  If found, return it.  If not found, return de. */
 struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
index d69c956..ea1358d 100644 (file)
@@ -2094,6 +2094,29 @@ int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa,
         RETURN(err);
 }
 
+static int lmv_cancel_unused(struct obd_export *exp,
+                             struct lov_stripe_md *lsm, 
+                            int flags, void *opaque)
+{
+        struct obd_device *obd = exp->exp_obd;
+        struct lmv_obd *lmv = &obd->u.lmv;
+        int rc = 0, err, i;
+        ENTRY;
+
+        LASSERT(lsm == NULL);
+        
+        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+                if (!lmv->tgts[i].ltd_exp || !lmv->tgts[i].active)
+                        continue;
+                
+                err = obd_cancel_unused(lmv->tgts[i].ltd_exp,
+                                        NULL, flags, opaque);
+                if (!rc)
+                        rc = err;
+        }
+        RETURN(rc);
+}
+
 struct obd_ops lmv_obd_ops = {
         .o_owner                = THIS_MODULE,
         .o_attach               = lmv_attach,
@@ -2115,6 +2138,7 @@ struct obd_ops lmv_obd_ops = {
         .o_notify               = lmv_notify,
         .o_iocontrol            = lmv_iocontrol,
         .o_getready             = lmv_getready,
+        .o_cancel_unused        = lmv_cancel_unused,
 };
 
 struct md_ops lmv_md_ops = {
index 9fa9085..8b3c13a 100644 (file)
@@ -1773,8 +1773,8 @@ static int lov_cancel_unused(struct obd_export *exp,
         lov = &exp->exp_obd->u.lov;
         if (lsm == NULL) {
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-                        int err = obd_cancel_unused(lov->tgts[i].ltd_exp, NULL,
-                                                    flags, opaque);
+                        int err = obd_cancel_unused(lov->tgts[i].ltd_exp,
+                                                    NULL, flags, opaque);
                         if (!rc)
                                 rc = err;
                 }
index 4fcfc0a..5b78b51 100644 (file)
@@ -161,6 +161,17 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         RETURN (0);
 }
 
+static int mdc_cancel_unused(struct obd_export *exp,
+                             struct lov_stripe_md *lsm, 
+                            int flags, void *opaque)
+{
+        struct obd_device *obd = class_exp2obd(exp);
+
+        ENTRY;
+        RETURN(ldlm_cli_cancel_unused(obd->obd_namespace,
+                                      NULL, flags, opaque));
+}
+
 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
                 __u64 valid, const char *ea_name, int ea_namelen,
                 unsigned int ea_size, struct ptlrpc_request **request)
@@ -1483,6 +1494,7 @@ struct obd_ops mdc_obd_ops = {
         .o_set_info      = mdc_set_info,
         .o_get_info      = mdc_get_info,
         .o_brw           = mdc_brw,
+        .o_cancel_unused = mdc_cancel_unused,
         .o_init_ea_size  = mdc_init_ea_size,
 };
 
index f121394..ee2dc0b 100644 (file)
@@ -2604,7 +2604,8 @@ static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md,
 }
 
 static int osc_cancel_unused(struct obd_export *exp,
-                             struct lov_stripe_md *lsm, int flags, void *opaque)
+                             struct lov_stripe_md *lsm,
+                             int flags, void *opaque)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct ldlm_res_id res_id = { .name = {0} }, *resp = NULL;