Whamcloud - gitweb
LU-10438 flr: layout truncate compatibility 86/30786/8
authorBobi Jam <bobijam.xu@intel.com>
Wed, 10 Jan 2018 04:18:29 +0000 (12:18 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 14 Feb 2018 00:51:06 +0000 (00:51 +0000)
In PFL design, client issues [0, size) intent to MDS to instantiate
objects in this extent. While in FLR design, the intent serves two
purposes: 1) make objects across [size, EOF) on other mirrors stale,
and 2) instantiate objects in the chosen write mirror. And original
FLR chose to use [size, EOF) as the extent of truncate write intent
request.

This patch reverts the choice, and still uses [0, size) as the
truncate write intent extent.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: I12d90320ba704f01457670f864d78fe764233000
Reviewed-on: https://review.whamcloud.com/30786
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/lov/lov_io.c

index 9e098c3..9aff034 100644 (file)
@@ -5453,15 +5453,6 @@ static int lod_declare_update_plain(const struct lu_env *env,
                        GOTO(out, rc);
        }
 
-       if (layout->li_opc == LAYOUT_INTENT_TRUNC) {
-               /**
-                * trunc transfers [size, eof) in the intent extent, while
-                * we'd instantiated components covers [0, size).
-                */
-               layout->li_extent.e_end = layout->li_extent.e_start;
-               layout->li_extent.e_start = 0;
-       }
-
        /* Make sure defined layout covers the requested write range. */
        lod_comp = &lo->ldo_comp_entries[lo->ldo_comp_cnt - 1];
        if (lo->ldo_comp_cnt > 1 &&
@@ -5636,18 +5627,23 @@ static int lod_declare_update_rdonly(const struct lu_env *env,
        CDEBUG(D_LAYOUT, DFID": picked mirror %u as primary\n",
               PFID(lod_object_fid(lo)), lo->ldo_mirrors[picked].lme_id);
 
-       /* stale overlapping components from other mirrors */
-       lod_stale_components(lo, picked, &extent);
-
-       /* instantiate components for the picked mirror, start from 0 */
        if (layout->li_opc == LAYOUT_INTENT_TRUNC) {
                /**
-                * trunc transfers [size, eof) in the intent extent, we'd
-                * stale components overlapping [size, eof), while we'd
-                * instantiated components covers [0, size).
+                * trunc transfers [0, size) in the intent extent, we'd
+                * stale components overlapping [size, eof).
                 */
-               extent.e_end = extent.e_start;
+               extent.e_start = extent.e_end;
+               extent.e_end = OBD_OBJECT_EOF;
        }
+
+       /* stale overlapping components from other mirrors */
+       lod_stale_components(lo, picked, &extent);
+
+       /* restore truncate intent extent */
+       if (layout->li_opc == LAYOUT_INTENT_TRUNC)
+               extent.e_end = extent.e_start;
+
+       /* instantiate components for the picked mirror, start from 0 */
        extent.e_start = 0;
 
        lod_foreach_mirror_comp(lod_comp, lo, picked) {
@@ -5751,19 +5747,23 @@ static int lod_declare_update_write_pending(const struct lu_env *env,
                CDEBUG(D_LAYOUT, DFID": intent to write: "DEXT"\n",
                       PFID(lod_object_fid(lo)), PEXT(&extent));
 
+               if (mlc->mlc_intent->li_opc == LAYOUT_INTENT_TRUNC) {
+                       /**
+                        * trunc transfers [0, size) in the intent extent, we'd
+                        * stale components overlapping [size, eof).
+                        */
+                       extent.e_start = extent.e_end;
+                       extent.e_end = OBD_OBJECT_EOF;
+               }
                /* 1. stale overlapping components */
                lod_stale_components(lo, primary, &extent);
 
                /* 2. find out the components need instantiating.
                 * instantiate [0, mlc->mlc_intent->e_end) */
-               if (mlc->mlc_intent->li_opc == LAYOUT_INTENT_TRUNC) {
-                       /**
-                        * trunc transfers [size, eof) in the intent extent,
-                        * we'd stale components overlapping [size, eof),
-                        * while we'd instantiated components covers [0, size).
-                        */
+
+               /* restore truncate intent extent */
+               if (mlc->mlc_intent->li_opc == LAYOUT_INTENT_TRUNC)
                        extent.e_end = extent.e_start;
-               }
                extent.e_start = 0;
 
                lod_foreach_mirror_comp(lod_comp, lo, primary) {
index 6ac8dc7..4c4f32f 100644 (file)
@@ -365,6 +365,16 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj,
                       PFID(lu_object_fid(lov2lu(obj))),
                       lio->lis_pos, lio->lis_endpos);
 
+               if (cl_io_is_trunc(io)) {
+                       /**
+                        * for truncate, we uses [size, EOF) to judge whether
+                        * a write intent needs to be send, but we need to
+                        * restore the write extent to [0, size).
+                        */
+                       io->ci_write_intent.e_start = 0;
+                       io->ci_write_intent.e_end =
+                                       io->u.ci_setattr.sa_attr.lvb_size;
+               }
                /* stop cl_io_init() loop */
                RETURN(1);
        }
@@ -449,7 +459,6 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj,
 static int lov_io_slice_init(struct lov_io *lio,
                             struct lov_object *obj, struct cl_io *io)
 {
-       struct lu_extent ext;
        int index;
        int result = 0;
        ENTRY;
@@ -539,19 +548,18 @@ static int lov_io_slice_init(struct lov_io *lio,
              (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0)))
                GOTO(out, result = 0);
 
-       io->ci_write_intent.e_start = lio->lis_pos;
-       io->ci_write_intent.e_end = lio->lis_endpos;
-
-       ext = io->ci_write_intent;
        /* for truncate, it only needs to instantiate the components
         * before the truncated size. */
        if (cl_io_is_trunc(io)) {
-               ext.e_start = 0;
-               ext.e_end = io->u.ci_setattr.sa_attr.lvb_size;
+               io->ci_write_intent.e_start = 0;
+               io->ci_write_intent.e_end = io->u.ci_setattr.sa_attr.lvb_size;
+       } else {
+               io->ci_write_intent.e_start = lio->lis_pos;
+               io->ci_write_intent.e_end = lio->lis_endpos;
        }
 
        index = 0;
-       lov_foreach_io_layout(index, lio, &ext) {
+       lov_foreach_io_layout(index, lio, &io->ci_write_intent) {
                if (!lsm_entry_inited(obj->lo_lsm, index)) {
                        io->ci_need_write_intent = 1;
                        break;