Whamcloud - gitweb
LU-3540 lod: update recovery thread
[fs/lustre-release.git] / lustre / lod / lod_lov.c
index 6b352e8..7054876 100644 (file)
@@ -6,13 +6,13 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 only,
  * as published by the Free Software Foundation.
-
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License version 2 for more details.  A copy is
  * included in the COPYING file that accompanied this code.
-
+ *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
  * http://www.gnu.org/licenses/gpl-2.0.html
@@ -253,7 +253,6 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
                                           OBD_CONNECT_LRU_RESIZE |
 #endif
                                           OBD_CONNECT_MDS |
-                                          OBD_CONNECT_OSS_CAPA |
                                           OBD_CONNECT_REQPORTAL |
                                           OBD_CONNECT_SKIP_ORPHAN |
                                           OBD_CONNECT_FID |
@@ -270,17 +269,12 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
                for_ost = false;
                data->ocd_ibits_known = MDS_INODELOCK_UPDATE;
                data->ocd_connect_flags |= OBD_CONNECT_ACL |
-                                          OBD_CONNECT_MDS_CAPA |
-                                          OBD_CONNECT_OSS_CAPA |
                                           OBD_CONNECT_IBITS |
                                           OBD_CONNECT_MDS_MDS |
                                           OBD_CONNECT_FID |
                                           OBD_CONNECT_AT |
                                           OBD_CONNECT_FULL20 |
                                           OBD_CONNECT_LFSCK;
-               /* XXX set MDS-MDS flags, remove this when running this
-                * on client*/
-               data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS;
                spin_lock(&imp->imp_lock);
                imp->imp_server_timeout = 1;
                spin_unlock(&imp->imp_lock);
@@ -352,7 +346,7 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
                }
        }
 
-       if (!strcmp(LUSTRE_OSC_NAME, type)) {
+       if (for_ost) {
                /* pool and qos are not supported for MDS stack yet */
                rc = lod_ost_pool_add(&lod->lod_pool_info, index,
                                      lod->lod_osts_size);
@@ -384,13 +378,25 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
        if (lod->lod_recovery_completed)
                ldev->ld_ops->ldo_recovery_complete(env, ldev);
 
+       if (!for_ost && lod->lod_initialized) {
+               rc = lod_sub_init_llog(env, lod, tgt_desc->ltd_tgt);
+               if (rc != 0) {
+                       CERROR("%s: cannot start llog on %s:rc = %d\n",
+                              lod2obd(lod)->obd_name, osp, rc);
+                       GOTO(out_pool, rc);
+               }
+       }
+
        rc = lfsck_add_target(env, lod->lod_child, d, exp, index, for_ost);
-       if (rc != 0)
+       if (rc != 0) {
                CERROR("Fail to add LFSCK target: name = %s, type = %s, "
                       "index = %u, rc = %d\n", osp, type, index, rc);
-
+               GOTO(out_fini_llog, rc);
+       }
        RETURN(rc);
-
+out_fini_llog:
+       lod_sub_fini_llog(env, tgt_desc->ltd_tgt,
+                         tgt_desc->ltd_recovery_thread);
 out_pool:
        lod_ost_pool_remove(&lod->lod_pool_info, index);
 out_mutex:
@@ -426,6 +432,13 @@ static void __lod_del_device(const struct lu_env *env, struct lod_device *lod,
        lfsck_del_target(env, lod->lod_child, LTD_TGT(ltd, idx)->ltd_tgt,
                         idx, for_ost);
 
+       if (!for_ost && LTD_TGT(ltd, idx)->ltd_recovery_thread != NULL) {
+               struct ptlrpc_thread *thread;
+
+               thread = LTD_TGT(ltd, idx)->ltd_recovery_thread;
+               OBD_FREE_PTR(thread);
+       }
+
        if (LTD_TGT(ltd, idx)->ltd_reap == 0) {
                LTD_TGT(ltd, idx)->ltd_reap = 1;
                ltd->ltd_death_row++;
@@ -673,10 +686,12 @@ int lod_generate_and_set_lovea(const struct lu_env *env,
 
        info->lti_buf.lb_buf = lmm;
        info->lti_buf.lb_len = lmm_size;
-       rc = dt_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV, 0,
-                         th, BYPASS_CAPA);
-       if (rc < 0)
+       rc = lod_sub_object_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV,
+                                     0, th);
+       if (rc < 0) {
                lod_object_free_striping(env, lo);
+               RETURN(rc);
+       }
 
        RETURN(rc);
 }
@@ -712,7 +727,7 @@ int lod_get_ea(const struct lu_env *env, struct lod_object *lo,
 repeat:
                info->lti_buf.lb_buf = info->lti_ea_store;
                info->lti_buf.lb_len = info->lti_ea_store_size;
-               rc = dt_xattr_get(env, next, &info->lti_buf, name, BYPASS_CAPA);
+               rc = dt_xattr_get(env, next, &info->lti_buf, name);
        }
 
        /* if object is not striped or inaccessible */
@@ -721,8 +736,7 @@ repeat:
 
        if (rc == -ERANGE) {
                /* EA doesn't fit, reallocate new buffer */
-               rc = dt_xattr_get(env, next, &LU_BUF_NULL, name,
-                                 BYPASS_CAPA);
+               rc = dt_xattr_get(env, next, &LU_BUF_NULL, name);
                if (rc == -ENODATA || rc == -ENOENT)
                        RETURN(0);
                else if (rc < 0)
@@ -739,72 +753,6 @@ repeat:
 }
 
 /**
- * Store default striping.
- *
- * Store default striping for the files in the given directory. The data
- * are stored in the LOD-object representing the directory (ldo_def_* fields).
- * If default striping matches virtual fs-wide default striping, then we
- * store nothing. This mean that the files in the directory will be created
- * with filesystem-wide default striping. The transaction must be started.
- *
- * \param[in] env              execution environment for this thread
- * \param[in] dt               dt object representing directory in LOD layer
- * \param[in] th               transaction handle
- *
- * \retval                     0 if stored successfully or no need to store
- * \retval                     negative error number on failure
- */
-int lod_store_def_striping(const struct lu_env *env, struct dt_object *dt,
-                          struct thandle *th)
-{
-       struct lod_thread_info  *info = lod_env_info(env);
-       struct lod_object       *lo = lod_dt_obj(dt);
-       struct dt_object        *next = dt_object_child(dt);
-       struct lov_user_md_v3   *v3;
-       int                      rc;
-       ENTRY;
-
-       if (S_ISDIR(dt->do_lu.lo_header->loh_attr))
-               RETURN(-ENOTDIR);
-       /*
-        * store striping defaults into new directory
-        * used to implement defaults inheritance
-        */
-
-       /* probably nothing to inherite */
-       if (lo->ldo_striping_cached == 0)
-               RETURN(0);
-
-       if (LOVEA_DELETE_VALUES(lo->ldo_def_stripe_size, lo->ldo_def_stripenr,
-                               lo->ldo_def_stripe_offset))
-               RETURN(0);
-
-       v3 = info->lti_ea_store;
-       if (info->lti_ea_store_size < sizeof(*v3)) {
-               rc = lod_ea_store_resize(info, sizeof(*v3));
-               if (rc != 0)
-                       RETURN(rc);
-               v3 = info->lti_ea_store;
-       }
-       memset(v3, 0, sizeof(*v3));
-       v3->lmm_magic = cpu_to_le32(LOV_USER_MAGIC_V3);
-       v3->lmm_stripe_count = cpu_to_le16(lo->ldo_def_stripenr);
-       v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset);
-       v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size);
-       if (lo->ldo_pool != NULL) {
-               strlcpy(v3->lmm_pool_name, lo->ldo_pool,
-                       sizeof(v3->lmm_pool_name));
-               v3->lmm_pool_name[sizeof(v3->lmm_pool_name) - 1] = '\0';
-       }
-       info->lti_buf.lb_buf = v3;
-       info->lti_buf.lb_len = sizeof(*v3);
-       rc = dt_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV, 0, th,
-                       BYPASS_CAPA);
-
-       RETURN(rc);
-}
-
-/**
  * Verify the target index is present in the current configuration.
  *
  * \param[in] md               LOD device where the target table is stored
@@ -1058,6 +1006,9 @@ int lod_load_striping_locked(const struct lu_env *env, struct lod_object *lo)
                 */
                rc = lod_parse_dir_striping(env, lo, buf);
        }
+
+       if (rc == 0)
+               lo->ldo_striping_cached = 1;
 out:
        RETURN(rc);
 }
@@ -1127,7 +1078,7 @@ int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf,
        LASSERT(sizeof(*lum) < sizeof(*lum3));
 
        if (buf->lb_len < sizeof(*lum)) {
-               CDEBUG(D_IOCTL, "buf len %zd too small for lov_user_md\n",
+               CDEBUG(D_IOCTL, "buf len %zu too small for lov_user_md\n",
                       buf->lb_len);
                GOTO(out, rc = -EINVAL);
        }
@@ -1188,7 +1139,7 @@ int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf,
 
        stripe_count = le16_to_cpu(lum->lmm_stripe_count);
        if (buf->lb_len != lum_size) {
-               CDEBUG(D_IOCTL, "invalid buf len %zd for lov_user_md with "
+               CDEBUG(D_IOCTL, "invalid buf len %zu for lov_user_md with "
                       "magic %#x and stripe_count %u\n",
                       buf->lb_len, magic, stripe_count);
                GOTO(out, rc = -EINVAL);
@@ -1199,7 +1150,7 @@ int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf,
 
        lum3 = buf->lb_buf;
        if (buf->lb_len < sizeof(*lum3)) {
-               CDEBUG(D_IOCTL, "buf len %zd too small for lov_user_md_v3\n",
+               CDEBUG(D_IOCTL, "buf len %zu too small for lov_user_md_v3\n",
                       buf->lb_len);
                GOTO(out, rc = -EINVAL);
        }