Whamcloud - gitweb
LU-13199 lustre: remove cl_{offset,index,page_size} helpers 26/37426/4
authorWang Shilong <wshilong@ddn.com>
Tue, 4 Feb 2020 10:35:20 +0000 (18:35 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 May 2023 07:03:10 +0000 (07:03 +0000)
These helpers could be replaced with PAGE_SIZE and PAGE_SHIFT calculation
directly which avoid CPU overhead.

Change-Id: I624136d4399a03e599f09f00a77b86de045f19e9
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/37426
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
16 files changed:
lustre/include/cl_object.h
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/llite/llite_mmap.c
lustre/llite/rw.c
lustre/llite/rw26.c
lustre/llite/vvp_io.c
lustre/lov/lov_io.c
lustre/lov/lov_lock.c
lustre/lov/lov_page.c
lustre/mdc/mdc_dev.c
lustre/obdclass/cl_page.c
lustre/osc/osc_cache.c
lustre/osc/osc_io.c
lustre/osc/osc_lock.c
lustre/osc/osc_page.c

index dc371ce..b4c138f 100644 (file)
@@ -2242,8 +2242,6 @@ void    cl_page_discard(const struct lu_env *env, struct cl_io *io,
 void    cl_page_delete(const struct lu_env *env, struct cl_page *pg);
 void   cl_page_touch(const struct lu_env *env, const struct cl_page *pg,
                      size_t to);
-loff_t  cl_offset(const struct cl_object *obj, pgoff_t idx);
-pgoff_t cl_index(const struct cl_object *obj, loff_t offset);
 
 void cl_lock_print(const struct lu_env *env, void *cookie,
                   lu_printer_t printer, const struct cl_lock *lock);
index 845907b..6c4073e 100644 (file)
@@ -3605,8 +3605,8 @@ int ll_file_lock_ahead(struct file *file, struct llapi_lu_ladvise *ladvise)
 
                descr->cld_obj   = io->ci_obj;
                /* Convert byte offsets to pages */
-               descr->cld_start = cl_index(io->ci_obj, start);
-               descr->cld_end   = cl_index(io->ci_obj, end);
+               descr->cld_start = start >> PAGE_SHIFT;
+               descr->cld_end   = end >> PAGE_SHIFT;
                descr->cld_mode  = cl_mode;
                /* CEF_MUST is used because we do not want to convert a
                 * lockahead request to a lockless lock */
index 9a6e896..f525b96 100644 (file)
@@ -2050,8 +2050,8 @@ int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset,
        lock = vvp_env_lock(env);
        descr = &lock->cll_descr;
        descr->cld_obj   = io->ci_obj;
-       descr->cld_start = cl_index(io->ci_obj, from);
-       descr->cld_end   = cl_index(io->ci_obj, from + PAGE_SIZE - 1);
+       descr->cld_start = from >> PAGE_SHIFT;
+       descr->cld_end   = (from + PAGE_SIZE - 1) >> PAGE_SHIFT;
        descr->cld_mode  = CLM_WRITE;
        descr->cld_enq_flags = CEF_MUST | CEF_NONBLOCK;
 
index 48ecd21..a0ddda6 100644 (file)
@@ -456,7 +456,7 @@ out:
        if (vmf->page && result == VM_FAULT_LOCKED) {
                ll_rw_stats_tally(ll_i2sbi(file_inode(vma->vm_file)),
                                  current->pid, vma->vm_file->private_data,
-                                 cl_offset(NULL, vmf->page->index), PAGE_SIZE,
+                                 vmf->page->index << PAGE_SHIFT, PAGE_SIZE,
                                  READ);
                ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)),
                                   LPROC_LL_FAULT,
@@ -536,7 +536,7 @@ out:
        if (result == VM_FAULT_LOCKED) {
                ll_rw_stats_tally(ll_i2sbi(file_inode(vma->vm_file)),
                                  current->pid, vma->vm_file->private_data,
-                                 cl_offset(NULL, vmf->page->index), PAGE_SIZE,
+                                 vmf->page->index << PAGE_SHIFT, PAGE_SIZE,
                                  WRITE);
                ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)),
                                   LPROC_LL_MKWRITE,
index 3c6cb49..7493b42 100644 (file)
@@ -1513,7 +1513,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
         cl_io_fini(env, io);
 
        if (redirtied && wbc->sync_mode == WB_SYNC_ALL) {
-               loff_t offset = cl_offset(clob, vmpage->index);
+               loff_t offset = vmpage->index << PAGE_SHIFT;
 
                /* Flush page failed because the extent is being written out.
                 * Wait for the write of extent to be finished to avoid
@@ -1695,9 +1695,9 @@ int ll_io_read_page(const struct lu_env *env, struct cl_io *io,
 
        /* mmap does not set the ci_rw fields */
        if (!mmap) {
-               io_start_index = cl_index(io->ci_obj, io->u.ci_rw.crw_pos);
-               io_end_index = cl_index(io->ci_obj, io->u.ci_rw.crw_pos +
-                                       io->u.ci_rw.crw_count - 1);
+               io_start_index = io->u.ci_rw.crw_pos >> PAGE_SHIFT;
+               io_end_index = (io->u.ci_rw.crw_pos +
+                               io->u.ci_rw.crw_count - 1) >> PAGE_SHIFT;
        } else {
                io_start_index = cl_page_index(page);
                io_end_index = cl_page_index(page);
index 9c26704..5e78e23 100644 (file)
@@ -379,7 +379,7 @@ ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, size_t size,
        cl_2queue_init(queue);
        for (i = 0; i < pv->ldp_count; i++) {
                LASSERT(!(offset & (PAGE_SIZE - 1)));
-               page = cl_page_find(env, obj, cl_index(obj, offset),
+               page = cl_page_find(env, obj, offset >> PAGE_SHIFT,
                                    pv->ldp_pages[i], CPT_TRANSIENT);
                if (IS_ERR(page)) {
                        rc = PTR_ERR(page);
@@ -652,8 +652,8 @@ static int ll_prepare_partial_page(const struct lu_env *env, struct cl_io *io,
 {
        struct cl_attr *attr   = vvp_env_thread_attr(env);
        struct cl_object *obj  = io->ci_obj;
-       loff_t          offset = cl_offset(obj, cl_page_index(pg));
-       int             result;
+       loff_t offset = cl_page_index(pg) << PAGE_SHIFT;
+       int result;
        ENTRY;
 
        cl_object_attr_lock(obj);
index 9f2715b..e66d8bc 100644 (file)
@@ -244,10 +244,8 @@ static int vvp_io_one_lock(const struct lu_env *env, struct cl_io *io,
                           __u32 enqflags, enum cl_lock_mode mode,
                           loff_t start, loff_t end)
 {
-       struct cl_object *obj = io->ci_obj;
-
        return vvp_io_one_lock_index(env, io, enqflags, mode,
-                                    cl_index(obj, start), cl_index(obj, end));
+                                    start >> PAGE_SHIFT, end >> PAGE_SHIFT);
 }
 
 static int vvp_io_write_iter_init(const struct lu_env *env,
@@ -492,10 +490,8 @@ static int vvp_mmap_locks(const struct lu_env *env,
                        policy_from_vma(&policy, vma, addr, count);
                        descr->cld_mode = vvp_mode_from_vma(vma);
                        descr->cld_obj = ll_i2info(inode)->lli_clob;
-                       descr->cld_start = cl_index(descr->cld_obj,
-                                                   policy.l_extent.start);
-                       descr->cld_end = cl_index(descr->cld_obj,
-                                                 policy.l_extent.end);
+                       descr->cld_start = policy.l_extent.start >> PAGE_SHIFT;
+                       descr->cld_end = policy.l_extent.end >> PAGE_SHIFT;
                        descr->cld_enq_flags = flags;
                        result = cl_io_lock_alloc_add(env, io, descr);
 
@@ -872,7 +868,7 @@ static int vvp_io_read_start(const struct lu_env *env,
        /* initialize read-ahead window once per syscall */
        if (!vio->vui_ra_valid) {
                vio->vui_ra_valid = true;
-               vio->vui_ra_start_idx = cl_index(obj, pos);
+               vio->vui_ra_start_idx = pos >> PAGE_SHIFT;
                vio->vui_ra_pages = 0;
                page_offset = pos & ~PAGE_MASK;
                if (page_offset) {
@@ -1500,8 +1496,8 @@ static int vvp_io_fault_start(const struct lu_env *env,
        trunc_sem_down_read_nowait(&lli->lli_trunc_sem);
 
         /* offset of the last byte on the page */
-        offset = cl_offset(obj, fio->ft_index + 1) - 1;
-        LASSERT(cl_index(obj, offset) == fio->ft_index);
+       offset = ((fio->ft_index + 1) << PAGE_SHIFT) - 1;
+       LASSERT((offset >> PAGE_SHIFT) == fio->ft_index);
        result = vvp_prep_size(env, obj, io, 0, offset + 1, NULL);
        if (result != 0)
                RETURN(result);
@@ -1534,7 +1530,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
                 GOTO(out, result = +1);
         }
 
-       last_index = cl_index(obj, size - 1);
+       last_index = (size - 1) >> PAGE_SHIFT;
 
        if (fio->ft_mkwrite ) {
                /*
@@ -1642,7 +1638,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
                 /*
                  * Last page is mapped partially.
                  */
-                fio->ft_nob = size - cl_offset(obj, fio->ft_index);
+               fio->ft_nob = size - (fio->ft_index << PAGE_SHIFT);
         else
                fio->ft_nob = PAGE_SIZE;
 
index 99d53be..da31186 100644 (file)
@@ -525,8 +525,8 @@ static int lov_io_slice_init(struct lov_io *lio,
        case CIT_FAULT: {
                pgoff_t index = io->u.ci_fault.ft_index;
 
-               lio->lis_pos = cl_offset(io->ci_obj, index);
-               lio->lis_endpos = cl_offset(io->ci_obj, index + 1);
+               lio->lis_pos = index << PAGE_SHIFT;
+               lio->lis_endpos = (index + 1) << PAGE_SHIFT;
                break;
        }
 
@@ -710,12 +710,11 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
                break;
        }
        case CIT_FAULT: {
-               struct cl_object *obj = parent->ci_obj;
-               loff_t off = cl_offset(obj, parent->u.ci_fault.ft_index);
+               loff_t off = parent->u.ci_fault.ft_index << PAGE_SHIFT;
 
                io->u.ci_fault = parent->u.ci_fault;
                off = lov_size_to_stripe(lsm, index, off, stripe);
-               io->u.ci_fault.ft_index = cl_index(obj, off);
+               io->u.ci_fault.ft_index = off >> PAGE_SHIFT;
                break;
        }
        case CIT_FSYNC: {
@@ -1156,7 +1155,6 @@ static int lov_io_read_ahead(const struct lu_env *env,
 {
        struct lov_io           *lio = cl2lov_io(env, ios);
        struct lov_object       *loo = lio->lis_object;
-       struct cl_object        *obj = lov2cl(loo);
        struct lov_layout_raid0 *r0;
        struct lov_io_sub       *sub;
        loff_t                   offset;
@@ -1168,7 +1166,7 @@ static int lov_io_read_ahead(const struct lu_env *env,
        int                      rc;
        ENTRY;
 
-       offset = cl_offset(obj, start);
+       offset = start << PAGE_SHIFT;
        index = lov_io_layout_at(lio, offset);
        if (index < 0 || !lsm_entry_inited(loo->lo_lsm, index) ||
            lsm_entry_is_foreign(loo->lo_lsm, index))
@@ -1190,8 +1188,7 @@ static int lov_io_read_ahead(const struct lu_env *env,
 
        lov_stripe_offset(loo->lo_lsm, index, offset, stripe, &suboff);
        rc = cl_io_read_ahead(sub->sub_env, &sub->sub_io,
-                             cl_index(lovsub2cl(r0->lo_sub[stripe]), suboff),
-                             ra);
+                             suboff >> PAGE_SHIFT, ra);
 
        CDEBUG(D_READA, DFID " cra_end = %lu, stripes = %d, rc = %d\n",
               PFID(lu_object_fid(lov2lu(loo))), ra->cra_end_idx,
@@ -1213,7 +1210,7 @@ static int lov_io_read_ahead(const struct lu_env *env,
                                                   ra_end, stripe);
 
        /* boundary of current component */
-       ra_end = cl_index(obj, (loff_t)lov_io_extent(lio, index)->e_end);
+       ra_end = lov_io_extent(lio, index)->e_end >> PAGE_SHIFT;
        if (ra_end != CL_PAGE_EOF && ra->cra_end_idx >= ra_end)
                ra->cra_end_idx = ra_end - 1;
 
@@ -1476,7 +1473,7 @@ static int lov_io_fault_start(const struct lu_env *env,
         * refer to another mirror of an old IO.
         */
        if (lov_is_flr(lio->lis_object)) {
-               offset = cl_offset(ios->cis_obj, fio->ft_index);
+               offset = fio->ft_index << PAGE_SHIFT;;
                entry = lov_io_layout_at(lio, offset);
                if (entry < 0) {
                        CERROR(DFID": page fault index %lu invalid component: "
index 40777f3..d9d162e 100644 (file)
@@ -131,11 +131,11 @@ static struct lov_lock *lov_lock_sub_init(const struct lu_env *env,
 
        LASSERT(ergo(is_trunc, lio->lis_trunc_stripe_index != NULL));
 
-       ext.e_start = cl_offset(obj, lock->cll_descr.cld_start);
+       ext.e_start = lock->cll_descr.cld_start << PAGE_SHIFT;
        if (lock->cll_descr.cld_end == CL_PAGE_EOF)
                ext.e_end = OBD_OBJECT_EOF;
        else
-               ext.e_end  = cl_offset(obj, lock->cll_descr.cld_end + 1);
+               ext.e_end  = (lock->cll_descr.cld_end + 1) << PAGE_SHIFT;
 
        nr = 0;
        lov_foreach_io_layout(index, lio, &ext) {
@@ -182,8 +182,8 @@ init_sublock:
                        descr = &lls->sub_lock.cll_descr;
                        LASSERT(descr->cld_obj == NULL);
                        descr->cld_obj   = lovsub2cl(r0->lo_sub[i]);
-                       descr->cld_start = cl_index(descr->cld_obj, start);
-                       descr->cld_end   = cl_index(descr->cld_obj, end);
+                       descr->cld_start = start >> PAGE_SHIFT;
+                       descr->cld_end   = end >> PAGE_SHIFT;
                        descr->cld_mode  = lock->cll_descr.cld_mode;
                        descr->cld_gid   = lock->cll_descr.cld_gid;
                        descr->cld_enq_flags = lock->cll_descr.cld_enq_flags;
index 000f8ca..5812d43 100644 (file)
@@ -75,7 +75,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
        stripe_cached = lio->lis_cached_entry != LIS_CACHE_ENTRY_NONE &&
                        page->cp_type == CPT_TRANSIENT;
 
-       offset = cl_offset(obj, index);
+       offset = index << PAGE_SHIFT;
 
        if (stripe_cached) {
                entry = lio->lis_cached_entry;
@@ -126,7 +126,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
        cl_object_for_each(o, subobj) {
                if (o->co_ops->coo_page_init) {
                        rc = o->co_ops->coo_page_init(sub->sub_env, o, page,
-                                                     cl_index(subobj, suboff));
+                                                     suboff >> PAGE_SHIFT);
                        if (rc != 0)
                                break;
                }
@@ -136,18 +136,18 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
 }
 
 int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
-                       struct cl_page *page, pgoff_t index)
+                       struct cl_page *cl_page, pgoff_t index)
 {
        void *addr;
 
        ENTRY;
-       BUILD_BUG_ON(!__same_type(page->cp_lov_index, CP_LOV_INDEX_EMPTY));
-       page->cp_lov_index = CP_LOV_INDEX_EMPTY;
+       BUILD_BUG_ON(!__same_type(cl_page->cp_lov_index, CP_LOV_INDEX_EMPTY));
+       cl_page->cp_lov_index = CP_LOV_INDEX_EMPTY;
 
-       addr = kmap(page->cp_vmpage);
+       addr = kmap(cl_page->cp_vmpage);
        memset(addr, 0, PAGE_SIZE);
-       kunmap(page->cp_vmpage);
-       SetPageUptodate(page->cp_vmpage);
+       kunmap(cl_page->cp_vmpage);
+       SetPageUptodate(cl_page->cp_vmpage);
        RETURN(0);
 }
 
index e96e49f..b235a8a 100644 (file)
@@ -341,7 +341,7 @@ static int mdc_dlm_canceling(const struct lu_env *env,
                struct cl_attr *attr = &osc_env_info(env)->oti_attr;
 
                /* Destroy pages covered by the extent of the DLM lock */
-               result = mdc_lock_flush(env, cl2osc(obj), cl_index(obj, 0),
+               result = mdc_lock_flush(env, cl2osc(obj), 0,
                                        CL_PAGE_EOF, mode, discard);
                /* Losing a lock, set KMS to 0.
                 * NB: assumed that DOM lock covers whole data on MDT.
@@ -501,7 +501,7 @@ static void mdc_lock_granted(const struct lu_env *env, struct osc_lock *oscl,
                /* extend the lock extent, otherwise it will have problem when
                 * we decide whether to grant a lockless lock. */
                descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode);
-               descr->cld_start = cl_index(descr->cld_obj, 0);
+               descr->cld_start = 0;
                descr->cld_end = CL_PAGE_EOF;
 
                /* no lvb update for matched lock */
index 8593731..9d07df9 100644 (file)
@@ -1142,24 +1142,6 @@ void cl_page_print(const struct lu_env *env, void *cookie,
 EXPORT_SYMBOL(cl_page_print);
 
 /**
- * Converts a byte offset within object \a obj into a page index.
- */
-loff_t cl_offset(const struct cl_object *obj, pgoff_t idx)
-{
-       return (loff_t)idx << PAGE_SHIFT;
-}
-EXPORT_SYMBOL(cl_offset);
-
-/**
- * Converts a page index into a byte offset within object \a obj.
- */
-pgoff_t cl_index(const struct cl_object *obj, loff_t offset)
-{
-       return offset >> PAGE_SHIFT;
-}
-EXPORT_SYMBOL(cl_index);
-
-/**
  * Adds page slice to the compound page.
  *
  * This is called by cl_object_operations::coo_page_init() methods to add a
index 20765d7..4de0298 100644 (file)
@@ -229,8 +229,8 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
                struct ldlm_extent *extent;
 
                extent = &ext->oe_dlmlock->l_policy_data.l_extent;
-               if (!(extent->start <= cl_offset(osc2cl(obj), ext->oe_start) &&
-                     extent->end   >= cl_offset(osc2cl(obj), ext->oe_max_end)))
+               if (!(extent->start <= ext->oe_start << PAGE_SHIFT &&
+                     extent->end >= ext->oe_max_end << PAGE_SHIFT))
                        GOTO(out, rc = 100);
 
                if (!(ext->oe_dlmlock->l_granted_mode & (LCK_PW | LCK_GROUP)))
@@ -1279,10 +1279,10 @@ static int osc_refresh_count(const struct lu_env *env,
        if (result < 0)
                return result;
        kms = attr->cat_kms;
-       if (cl_offset(obj, index) >= kms)
+       if (index << PAGE_SHIFT >= kms)
                /* catch race with truncate */
                return 0;
-       else if (cl_offset(obj, index + 1) > kms)
+       else if ((index + 1) << PAGE_SHIFT > kms)
                /* catch sub-page write at end of file */
                return kms & ~PAGE_MASK;
        else
@@ -2702,8 +2702,8 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj,
        ENTRY;
 
        /* pages with index greater or equal to index will be truncated. */
-       index = cl_index(osc2cl(obj), size);
-       partial = size > cl_offset(osc2cl(obj), index);
+       index = size >> PAGE_SHIFT;
+       partial = size > (index << PAGE_SHIFT);
 
 again:
        osc_object_lock(obj);
@@ -3172,12 +3172,12 @@ static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
                                        tmp->l_policy_data.l_extent.start;
 
                                /* no lock covering this page */
-                               if (index < cl_index(osc2cl(osc), start)) {
+                               if (index < start >> PAGE_SHIFT) {
                                        /* no lock at @index,
                                         * first lock at @start
                                         */
                                        info->oti_ng_index =
-                                               cl_index(osc2cl(osc), start);
+                                               start >> PAGE_SHIFT;
                                        discard = true;
                                } else {
                                        /* Cache the first-non-overlapped
@@ -3188,7 +3188,7 @@ static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
                                         * pages.
                                         */
                                        info->oti_fn_index =
-                                               cl_index(osc2cl(osc), end + 1);
+                                               (end + 1) >> PAGE_SHIFT;
                                        if (end == OBD_OBJECT_EOF)
                                                info->oti_fn_index =
                                                        CL_PAGE_EOF;
index 90437ed..fa11066 100644 (file)
@@ -96,16 +96,16 @@ static int osc_io_read_ahead(const struct lu_env *env,
                }
 
                ra->cra_rpc_pages = osc_cli(osc)->cl_max_pages_per_rpc;
-               ra->cra_end_idx = cl_index(osc2cl(osc),
-                                          dlmlock->l_policy_data.l_extent.end);
+               ra->cra_end_idx =
+                       dlmlock->l_policy_data.l_extent.end >> PAGE_SHIFT;
                ra->cra_release = osc_read_ahead_release;
                ra->cra_dlmlock = dlmlock;
                ra->cra_oio = oio;
                if (ra->cra_end_idx != CL_PAGE_EOF)
                        ra->cra_contention = true;
-               ra->cra_end_idx = min_t(pgoff_t, ra->cra_end_idx,
-                                       cl_index(osc2cl(osc),
-                                                oinfo->loi_kms - 1));
+               ra->cra_end_idx = min_t(pgoff_t,
+                                       ra->cra_end_idx,
+                                       (oinfo->loi_kms - 1) >> PAGE_SHIFT);
                result = 0;
        }
 
@@ -273,7 +273,7 @@ void osc_page_touch_at(const struct lu_env *env, struct cl_object *obj,
        ENTRY;
 
        /* offset within stripe */
-       kms = cl_offset(obj, idx) + to;
+       kms = (idx << PAGE_SHIFT) + to;
 
        cl_object_attr_lock(obj);
        CDEBUG(D_INODE, "stripe KMS %sincreasing %llu->%llu %llu\n",
@@ -539,9 +539,9 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
        int     partial;
        pgoff_t start;
 
-        clob    = oio->oi_cl.cis_obj;
-        start   = cl_index(clob, size);
-        partial = cl_offset(clob, start) < size;
+       clob = oio->oi_cl.cis_obj;
+       start = size >> PAGE_SHIFT;
+       partial = (start << PAGE_SHIFT) < size;
 
         /*
          * Complain if there are pages in the truncated region.
@@ -561,8 +561,8 @@ int osc_punch_start(const struct lu_env *env, struct cl_io *io,
                    struct cl_object *obj)
 {
        struct osc_object *osc = cl2osc(obj);
-       pgoff_t pg_start = cl_index(obj, io->u.ci_setattr.sa_falloc_offset);
-       pgoff_t pg_end = cl_index(obj, io->u.ci_setattr.sa_falloc_end - 1);
+       pgoff_t pg_start = io->u.ci_setattr.sa_falloc_offset >> PAGE_SHIFT;
+       pgoff_t pg_end = (io->u.ci_setattr.sa_falloc_end - 1) >> PAGE_SHIFT;
        int rc;
 
        ENTRY;
@@ -961,8 +961,8 @@ int osc_io_fsync_start(const struct lu_env *env,
        struct cl_fsync_io *fio = &io->u.ci_fsync;
        struct cl_object   *obj = slice->cis_obj;
        struct osc_object  *osc = cl2osc(obj);
-       pgoff_t start  = cl_index(obj, fio->fi_start);
-       pgoff_t end    = cl_index(obj, fio->fi_end);
+       pgoff_t start  = fio->fi_start >> PAGE_SHIFT;
+       pgoff_t end    = fio->fi_end >> PAGE_SHIFT;
        int     result = 0;
        ENTRY;
 
@@ -999,8 +999,8 @@ void osc_io_fsync_end(const struct lu_env *env,
 {
        struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync;
        struct cl_object   *obj = slice->cis_obj;
-       pgoff_t start = cl_index(obj, fio->fi_start);
-       pgoff_t end   = cl_index(obj, fio->fi_end);
+       pgoff_t start = fio->fi_start >> PAGE_SHIFT;
+       pgoff_t end   = fio->fi_end >> PAGE_SHIFT;
        int result = 0;
 
        if (fio->fi_mode == CL_FSYNC_LOCAL) {
index 6453b31..8ed9766 100644 (file)
@@ -238,8 +238,8 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *oscl,
                /* extend the lock extent, otherwise it will have problem when
                 * we decide whether to grant a lockless lock. */
                descr->cld_mode  = osc_ldlm2cl_lock(dlmlock->l_granted_mode);
-               descr->cld_start = cl_index(descr->cld_obj, ext->start);
-               descr->cld_end   = cl_index(descr->cld_obj, ext->end);
+               descr->cld_start = ext->start >> PAGE_SHIFT;
+               descr->cld_end   = ext->end >> PAGE_SHIFT;
                descr->cld_gid   = ext->gid;
 
                /* no lvb update for matched lock */
@@ -427,8 +427,8 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env,
 
                /* Destroy pages covered by the extent of the DLM lock */
                result = osc_lock_flush(cl2osc(obj),
-                                       cl_index(obj, extent->start),
-                                       cl_index(obj, extent->end),
+                                       extent->start >> PAGE_SHIFT,
+                                       extent->end >> PAGE_SHIFT,
                                        mode, discard);
 
                /* losing a lock, update kms */
@@ -672,10 +672,10 @@ static unsigned long osc_lock_weight(const struct lu_env *env,
        if (result != 0)
                RETURN(1);
 
-       page_index = cl_index(obj, start);
+       page_index = start >> PAGE_SHIFT;
 
        if (!osc_page_gang_lookup(env, io, oscobj,
-                                 page_index, cl_index(obj, end),
+                                 page_index, end >> PAGE_SHIFT,
                                  weigh_cb, (void *)&page_index))
                result = 1;
        cl_io_fini(env, io);
@@ -1171,9 +1171,9 @@ void osc_lock_set_writer(const struct lu_env *env, const struct cl_io *io,
                return;
 
        if (likely(io->ci_type == CIT_WRITE)) {
-               io_start = cl_index(obj, io->u.ci_rw.crw_pos);
-               io_end = cl_index(obj, io->u.ci_rw.crw_pos +
-                                               io->u.ci_rw.crw_count - 1);
+               io_start = io->u.ci_rw.crw_pos >> PAGE_SHIFT;
+               io_end = (io->u.ci_rw.crw_pos +
+                         io->u.ci_rw.crw_count - 1) >> PAGE_SHIFT;
        } else {
                LASSERT(cl_io_is_mkwrite(io));
                io_start = io_end = io->u.ci_fault.ft_index;
index c5928a0..8be11a2 100644 (file)
@@ -106,8 +106,8 @@ void osc_index2policy(union ldlm_policy_data *policy,
                      const struct cl_object *obj, pgoff_t start, pgoff_t end)
 {
        memset(policy, 0, sizeof *policy);
-       policy->l_extent.start = cl_offset(obj, start);
-       policy->l_extent.end   = cl_offset(obj, end + 1) - 1;
+       policy->l_extent.start = start << PAGE_SHIFT;
+       policy->l_extent.end = ((end + 1) << PAGE_SHIFT) - 1;
 }
 
 static int osc_page_print(const struct lu_env *env,
@@ -251,7 +251,7 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj,
 
        INIT_LIST_HEAD(&opg->ops_lru);
 
-       result = osc_prep_async_page(osc, opg, cl_page, cl_offset(obj, index));
+       result = osc_prep_async_page(osc, opg, cl_page, index << PAGE_SHIFT);
        if (result != 0)
                return result;