Whamcloud - gitweb
LU-12704 lov: check all entries in lov_flush_composite
[fs/lustre-release.git] / lustre / lov / lov_object.c
index 629f5e6..846d454 100644 (file)
@@ -1061,15 +1061,25 @@ static int lov_flush_composite(const struct lu_env *env,
                               struct ldlm_lock *lock)
 {
        struct lov_object *lov = cl2lov(obj);
-       struct lovsub_object *lovsub;
+       struct lov_layout_entry *lle;
+       int rc = -ENODATA;
 
        ENTRY;
 
-       if (!lsme_is_dom(lov->lo_lsm->lsm_entries[0]))
-               RETURN(-EINVAL);
+       lov_foreach_layout_entry(lov, lle) {
+               if (!lsme_is_dom(lle->lle_lsme))
+                       continue;
+               rc = cl_object_flush(env, lovsub2cl(lle->lle_dom.lo_dom), lock);
+               break;
+       }
+
+       RETURN(rc);
+}
 
-       lovsub = lov->u.composite.lo_entries[0].lle_dom.lo_dom;
-       RETURN(cl_object_flush(env, lovsub2cl(lovsub), lock));
+static int lov_flush_empty(const struct lu_env *env, struct cl_object *obj,
+                          struct ldlm_lock *lock)
+{
+       return 0;
 }
 
 const static struct lov_layout_operations lov_dispatch[] = {
@@ -1082,6 +1092,7 @@ const static struct lov_layout_operations lov_dispatch[] = {
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_empty,
                .llo_getattr   = lov_attr_get_empty,
+               .llo_flush     = lov_flush_empty,
        },
        [LLT_RELEASED] = {
                .llo_init      = lov_init_released,
@@ -1092,6 +1103,7 @@ const static struct lov_layout_operations lov_dispatch[] = {
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_released,
                .llo_getattr   = lov_attr_get_empty,
+               .llo_flush     = lov_flush_empty,
        },
        [LLT_COMP] = {
                .llo_init      = lov_init_composite,
@@ -1113,6 +1125,7 @@ const static struct lov_layout_operations lov_dispatch[] = {
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_empty,
                .llo_getattr   = lov_attr_get_empty,
+               .llo_flush     = lov_flush_empty,
        },
 };
 
@@ -2081,18 +2094,8 @@ static int lov_object_layout_get(const struct lu_env *env,
 
        cl->cl_size = lov_comp_md_size(lsm);
        cl->cl_layout_gen = lsm->lsm_layout_gen;
-       cl->cl_dom_comp_size = 0;
        cl->cl_is_released = lsm->lsm_is_released;
-       if (lsm_is_composite(lsm->lsm_magic)) {
-               struct lov_stripe_md_entry *lsme = lsm->lsm_entries[0];
-
-               cl->cl_is_composite = true;
-
-               if (lsme_is_dom(lsme))
-                       cl->cl_dom_comp_size = lsme->lsme_extent.e_end;
-       } else {
-               cl->cl_is_composite = false;
-       }
+       cl->cl_is_composite = lsm_is_composite(lsm->lsm_magic);
 
        rc = lov_lsm_pack(lsm, buf->lb_buf, buf->lb_len);
        lov_lsm_put(lsm);
@@ -2119,7 +2122,8 @@ static loff_t lov_object_maxbytes(struct cl_object *obj)
 static int lov_object_flush(const struct lu_env *env, struct cl_object *obj,
                            struct ldlm_lock *lock)
 {
-       return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_flush, env, obj, lock);
+       return LOV_2DISPATCH_MAYLOCK(cl2lov(obj), llo_flush, true, env, obj,
+                                    lock);
 }
 
 static const struct cl_object_operations lov_ops = {