Whamcloud - gitweb
LU-12535 lov: Move page index to top level
[fs/lustre-release.git] / lustre / lov / lov_io.c
index 5ec45bd..464c8f2 100644 (file)
@@ -122,8 +122,10 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
 
        /* obtain new environment */
        sub->sub_env = cl_env_get(&sub->sub_refcheck);
-       if (IS_ERR(sub->sub_env))
+       if (IS_ERR(sub->sub_env)) {
                result = PTR_ERR(sub->sub_env);
+               RETURN(result);
+       }
 
        sub_obj = lovsub2cl(lov_r0(lov, index)->lo_sub[stripe]);
        sub_io  = &sub->sub_io;
@@ -136,6 +138,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
        sub_io->ci_type    = io->ci_type;
        sub_io->ci_no_srvlock = io->ci_no_srvlock;
        sub_io->ci_noatime = io->ci_noatime;
+       sub_io->ci_async_readahead = io->ci_async_readahead;
        sub_io->ci_lock_no_expand = io->ci_lock_no_expand;
        sub_io->ci_ndelay = io->ci_ndelay;
        sub_io->ci_layout_version = io->ci_layout_version;
@@ -188,19 +191,6 @@ out:
  * Lov io operations.
  *
  */
-
-int lov_page_index(const struct cl_page *page)
-{
-       const struct cl_page_slice *slice;
-       ENTRY;
-
-       slice = cl_page_at(page, &lov_device_type);
-       LASSERT(slice != NULL);
-       LASSERT(slice->cpl_obj != NULL);
-
-       RETURN(cl2lov_page(slice)->lps_index);
-}
-
 static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
                              struct cl_io *io)
 {
@@ -448,7 +438,7 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj,
        ++io->ci_ndelay_tried;
        if (io->ci_ndelay && io->ci_ndelay_tried >= comp->lo_mirror_count) {
                set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC)); /* 10ms */
+               schedule_timeout(cfs_time_seconds(1)); /* 10ms */
                if (signal_pending(current))
                        RETURN(-EINTR);
 
@@ -563,7 +553,15 @@ static int lov_io_slice_init(struct lov_io *lio,
         */
        if (cl_io_is_trunc(io)) {
                io->ci_write_intent.e_start = 0;
-               io->ci_write_intent.e_end = io->u.ci_setattr.sa_attr.lvb_size;
+               /* for writes, e_end is endpos, the location of the file
+                * pointer after the write is completed, so it is not accessed.
+                * For truncate, 'end' is the size, and *is* acccessed.
+                * In other words, writes are [start, end), but truncate is
+                * [start, size], where both are included.  So add 1 to the
+                * size when creating the write intent to account for this.
+                */
+               io->ci_write_intent.e_end =
+                       io->u.ci_setattr.sa_attr.lvb_size + 1;
        } else {
                io->ci_write_intent.e_start = lio->lis_pos;
                io->ci_write_intent.e_end = lio->lis_endpos;
@@ -1100,6 +1098,7 @@ static int lov_io_submit(const struct lu_env *env,
        struct lov_io_sub       *sub;
        struct cl_page_list     *plist = &lov_env_info(env)->lti_plist;
        struct cl_page          *page;
+       struct cl_page          *tmp;
        int index;
        int rc = 0;
        ENTRY;
@@ -1125,11 +1124,11 @@ static int lov_io_submit(const struct lu_env *env,
                cl_2queue_init(cl2q);
                cl_page_list_move(&cl2q->c2_qin, qin, page);
 
-               index = lov_page_index(page);
-               while (qin->pl_nr > 0) {
-                       page = cl_page_list_first(qin);
-                       if (index != lov_page_index(page))
-                               break;
+               index = page->cp_lov_index;
+               cl_page_list_for_each_safe(page, tmp, qin) {
+                       /* this page is not on this stripe */
+                       if (index != page->cp_lov_index)
+                               continue;
 
                        cl_page_list_move(&cl2q->c2_qin, qin, page);
                }
@@ -1192,10 +1191,10 @@ static int lov_io_commit_async(const struct lu_env *env,
 
                cl_page_list_move(plist, queue, page);
 
-               index = lov_page_index(page);
+               index = page->cp_lov_index;
                while (queue->pl_nr > 0) {
                        page = cl_page_list_first(queue);
-                       if (index != lov_page_index(page))
+                       if (index != page->cp_lov_index)
                                break;
 
                        cl_page_list_move(plist, queue, page);
@@ -1241,7 +1240,7 @@ static int lov_io_fault_start(const struct lu_env *env,
 
        fio = &ios->cis_io->u.ci_fault;
        lio = cl2lov_io(env, ios);
-       sub = lov_sub_get(env, lio, lov_page_index(fio->ft_page));
+       sub = lov_sub_get(env, lio, fio->ft_page->cp_lov_index);
        sub->sub_io.u.ci_fault.ft_nob = fio->ft_nob;
 
        RETURN(lov_io_start(env, ios));