Whamcloud - gitweb
LU-9771 clio: introduce CIT_GLIMPSE for glimpse 82/29082/7
authorJinshan Xiong <jinshan.xiong@intel.com>
Fri, 15 Sep 2017 19:53:50 +0000 (19:53 +0000)
committerJinshan Xiong <jinshan.xiong@intel.com>
Thu, 16 Nov 2017 02:54:13 +0000 (02:54 +0000)
It turned out that it's better to have a standaline I/O context
for glimpse request. In that case, it's easier for glimpse to try
a new mirror if the current one is out of access.

Another problem in this patch is to zero cl_io data structure if
the I/O starts from OSC layer.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Ieeac36d4af38bc04a01affb9e6d3d129bceeb74e
Reviewed-on: https://review.whamcloud.com/29082
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/cl_object.h
lustre/llite/glimpse.c
lustre/llite/vvp_io.c
lustre/lov/lov_io.c
lustre/obdclass/cl_io.c
lustre/osc/osc_cache.c
lustre/osc/osc_internal.h
lustre/osc/osc_lock.c
lustre/osc/osc_page.c

index 185ff8d..33281fc 100644 (file)
@@ -1381,6 +1381,10 @@ enum cl_io_type {
         */
        CIT_FSYNC,
        /**
         */
        CIT_FSYNC,
        /**
+        * glimpse. An io context to acquire glimpse lock.
+        */
+       CIT_GLIMPSE,
+       /**
          * Miscellaneous io. This is used for occasional io activity that
          * doesn't fit into other types. Currently this is used for:
          *
          * Miscellaneous io. This is used for occasional io activity that
          * doesn't fit into other types. Currently this is used for:
          *
@@ -1391,8 +1395,6 @@ enum cl_io_type {
          *     - VM induced page write-out. An io context for writing page out
          *     for memory cleansing;
          *
          *     - VM induced page write-out. An io context for writing page out
          *     for memory cleansing;
          *
-         *     - glimpse. An io context to acquire glimpse lock.
-         *
          *     - grouplock. An io context to acquire group lock.
          *
          * CIT_MISC io is used simply as a context in which locks and pages
          *     - grouplock. An io context to acquire group lock.
          *
          * CIT_MISC io is used simply as a context in which locks and pages
index 76bf3ee..7c9ec0d 100644 (file)
@@ -186,16 +186,19 @@ int cl_glimpse_size0(struct inode *inode, int agl)
          */
         struct lu_env          *env = NULL;
         struct cl_io           *io  = NULL;
          */
         struct lu_env          *env = NULL;
         struct cl_io           *io  = NULL;
-       __u16                   refcheck;
+       __u16                   refcheck;
         int                     result;
 
         ENTRY;
 
         int                     result;
 
         ENTRY;
 
-        result = cl_io_get(inode, &env, &io, &refcheck);
-        if (result > 0) {
-       again:
+       result = cl_io_get(inode, &env, &io, &refcheck);
+       if (result <= 0)
+               RETURN(result);
+
+       do {
+               io->ci_need_restart = 0;
                io->ci_verify_layout = 1;
                io->ci_verify_layout = 1;
-                result = cl_io_init(env, io, CIT_MISC, io->ci_obj);
+               result = cl_io_init(env, io, CIT_GLIMPSE, io->ci_obj);
                 if (result > 0)
                         /*
                          * nothing to do for this io. This currently happens
                 if (result > 0)
                         /*
                          * nothing to do for this io. This currently happens
@@ -204,13 +207,12 @@ int cl_glimpse_size0(struct inode *inode, int agl)
                         result = io->ci_result;
                 else if (result == 0)
                         result = cl_glimpse_lock(env, io, inode, io->ci_obj,
                         result = io->ci_result;
                 else if (result == 0)
                         result = cl_glimpse_lock(env, io, inode, io->ci_obj,
-                                                 agl);
+                                                agl);
 
                OBD_FAIL_TIMEOUT(OBD_FAIL_GLIMPSE_DELAY, 2);
 
                OBD_FAIL_TIMEOUT(OBD_FAIL_GLIMPSE_DELAY, 2);
-                cl_io_fini(env, io);
-               if (unlikely(io->ci_need_restart))
-                       goto again;
-               cl_env_put(env, &refcheck);
-       }
+               cl_io_fini(env, io);
+       } while (unlikely(io->ci_need_restart));
+
+       cl_env_put(env, &refcheck);
        RETURN(result);
 }
        RETURN(result);
 }
index c0dad2d..886b816 100644 (file)
@@ -1408,6 +1408,9 @@ static const struct cl_io_operations vvp_io_ops = {
                        .cio_start      = vvp_io_fsync_start,
                        .cio_fini       = vvp_io_fini
                },
                        .cio_start      = vvp_io_fsync_start,
                        .cio_fini       = vvp_io_fini
                },
+               [CIT_GLIMPSE] = {
+                       .cio_fini       = vvp_io_fini
+               },
                [CIT_MISC] = {
                        .cio_fini       = vvp_io_fini
                },
                [CIT_MISC] = {
                        .cio_fini       = vvp_io_fini
                },
@@ -1476,5 +1479,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj,
                                PFID(lu_object_fid(&obj->co_lu)), result);
        }
 
                                PFID(lu_object_fid(&obj->co_lu)), result);
        }
 
+       io->ci_result = result < 0 ? result : 0;
        RETURN(result);
 }
        RETURN(result);
 }
index acddf1d..8cdfbf4 100644 (file)
@@ -262,6 +262,7 @@ static int lov_io_slice_init(struct lov_io *lio,
                break;
        }
 
                break;
        }
 
+       case CIT_GLIMPSE:
         case CIT_MISC:
                 lio->lis_pos = 0;
                 lio->lis_endpos = OBD_OBJECT_EOF;
         case CIT_MISC:
                 lio->lis_pos = 0;
                 lio->lis_endpos = OBD_OBJECT_EOF;
@@ -377,6 +378,8 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
                io->u.ci_ladvise.li_flags = parent->u.ci_ladvise.li_flags;
                break;
        }
                io->u.ci_ladvise.li_flags = parent->u.ci_ladvise.li_flags;
                break;
        }
+       case CIT_GLIMPSE:
+       case CIT_MISC:
        default:
                break;
        }
        default:
                break;
        }
@@ -1023,6 +1026,9 @@ static const struct cl_io_operations lov_io_ops = {
                        .cio_start     = lov_io_start,
                        .cio_end       = lov_io_end
                },
                        .cio_start     = lov_io_start,
                        .cio_end       = lov_io_end
                },
+               [CIT_GLIMPSE] = {
+                       .cio_fini      = lov_io_fini,
+               },
                [CIT_MISC] = {
                        .cio_fini      = lov_io_fini
                }
                [CIT_MISC] = {
                        .cio_fini      = lov_io_fini
                }
@@ -1105,6 +1111,9 @@ static const struct cl_io_operations lov_empty_io_ops = {
                [CIT_LADVISE] = {
                        .cio_fini   = lov_empty_io_fini
                },
                [CIT_LADVISE] = {
                        .cio_fini   = lov_empty_io_fini
                },
+               [CIT_GLIMPSE] = {
+                       .cio_fini      = lov_empty_io_fini
+               },
                [CIT_MISC] = {
                        .cio_fini      = lov_empty_io_fini
                }
                [CIT_MISC] = {
                        .cio_fini      = lov_empty_io_fini
                }
@@ -1148,6 +1157,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
        default:
                LBUG();
        case CIT_MISC:
        default:
                LBUG();
        case CIT_MISC:
+       case CIT_GLIMPSE:
        case CIT_READ:
                result = 0;
                break;
        case CIT_READ:
                result = 0;
                break;
@@ -1192,6 +1202,7 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
                result = -EOPNOTSUPP;
                break;
        case CIT_MISC:
                result = -EOPNOTSUPP;
                break;
        case CIT_MISC:
+       case CIT_GLIMPSE:
        case CIT_FSYNC:
        case CIT_LADVISE:
        case CIT_DATA_VERSION:
        case CIT_FSYNC:
        case CIT_LADVISE:
        case CIT_DATA_VERSION:
index fc22b2c..54db7ac 100644 (file)
@@ -122,6 +122,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io)
                /* Check ignore layout change conf */
                LASSERT(ergo(io->ci_ignore_layout || !io->ci_verify_layout,
                                !io->ci_need_restart));
                /* Check ignore layout change conf */
                LASSERT(ergo(io->ci_ignore_layout || !io->ci_verify_layout,
                                !io->ci_need_restart));
+       case CIT_GLIMPSE:
                break;
        case CIT_LADVISE:
                break;
                break;
        case CIT_LADVISE:
                break;
index f35d7bf..d5b19e2 100644 (file)
@@ -997,7 +997,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
        if (IS_ERR(env))
                RETURN(PTR_ERR(env));
 
        if (IS_ERR(env))
                RETURN(PTR_ERR(env));
 
-       io  = &osc_env_info(env)->oti_io;
+       io  = osc_env_thread_io(env);
        io->ci_obj = cl_object_top(osc2cl(obj));
        io->ci_ignore_layout = 1;
        rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
        io->ci_obj = cl_object_top(osc2cl(obj));
        io->ci_ignore_layout = 1;
        rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
@@ -3289,7 +3289,7 @@ int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc,
                           pgoff_t start, pgoff_t end, bool discard)
 {
        struct osc_thread_info *info = osc_env_info(env);
                           pgoff_t start, pgoff_t end, bool discard)
 {
        struct osc_thread_info *info = osc_env_info(env);
-       struct cl_io *io = &info->oti_io;
+       struct cl_io *io = osc_env_thread_io(env);
        osc_page_gang_cbt cb;
        int res;
        int result;
        osc_page_gang_cbt cb;
        int res;
        int result;
index 16b8666..20aadc8 100644 (file)
@@ -98,6 +98,14 @@ static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
 
 extern struct lu_device_type osc_device_type;
 
 
 extern struct lu_device_type osc_device_type;
 
+static inline struct cl_io *osc_env_thread_io(const struct lu_env *env)
+{
+       struct cl_io *io = &osc_env_info(env)->oti_io;
+
+       memset(io, 0, sizeof(*io));
+       return io;
+}
+
 static inline int osc_is_object(const struct lu_object *obj)
 {
        return obj->lo_dev->ld_type == &osc_device_type;
 static inline int osc_is_object(const struct lu_object *obj)
 {
        return obj->lo_dev->ld_type == &osc_device_type;
index e9d5ae1..ae62a40 100644 (file)
@@ -623,7 +623,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env,
                                     struct osc_object *oscobj,
                                     struct ldlm_extent *extent)
 {
                                     struct osc_object *oscobj,
                                     struct ldlm_extent *extent)
 {
-       struct cl_io     *io = &osc_env_info(env)->oti_io;
+       struct cl_io     *io = osc_env_thread_io(env);
        struct cl_object *obj = cl_object_top(&oscobj->oo_cl);
        pgoff_t          page_index;
        int              result;
        struct cl_object *obj = cl_object_top(&oscobj->oo_cl);
        pgoff_t          page_index;
        int              result;
index a141681..81d0c52 100644 (file)
@@ -583,7 +583,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
        }
 
        pvec = (struct cl_page **)osc_env_info(env)->oti_pvec;
        }
 
        pvec = (struct cl_page **)osc_env_info(env)->oti_pvec;
-       io = &osc_env_info(env)->oti_io;
+       io = osc_env_thread_io(env);
 
        spin_lock(&cli->cl_lru_list_lock);
        if (force)
 
        spin_lock(&cli->cl_lru_list_lock);
        if (force)