- ll_clear_file_contended(inode);
-
- /* start and end the lock on the first and last bytes in the page */
- policy_from_vma(&policy, vma, address, CFS_PAGE_SIZE);
-
- CDEBUG(D_MMAP, "nopage vma %p inode %lu, locking ["LPU64", "LPU64"]\n",
- vma, inode->i_ino, policy.l_extent.start, policy.l_extent.end);
-
- mode = mode_from_vma(vma);
- old_mtime = LTIME_S(inode->i_mtime);
-
- lsm = lli->lli_smd;
- rc = ll_extent_lock(fd, inode, lsm, mode, &policy,
- &lockh, LDLM_FL_CBPENDING);
- if (rc != 0)
- RETURN(NULL);
-
- if (vma->vm_flags & VM_EXEC && LTIME_S(inode->i_mtime) != old_mtime)
- CWARN("binary changed. inode %lu\n", inode->i_ino);
-
- lov_stripe_lock(lsm);
- inode_init_lvb(inode, &lvb);
- obd_merge_lvb(ll_i2dtexp(inode), lsm, &lvb, 1);
- kms = lvb.lvb_size;
-
- pgoff = ((address - vma->vm_start) >> CFS_PAGE_SHIFT) + vma->vm_pgoff;
- size = (kms + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
-
- if (pgoff >= size) {
- lov_stripe_unlock(lsm);
- ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
- } else {
- /* XXX change inode size without ll_inode_size_lock() held!
- * there is a race condition with truncate path. (see
- * ll_extent_lock) */
- /* XXX i_size_write() is not used because it is not safe to
- * take the ll_inode_size_lock() due to a potential lock
- * inversion (bug 6077). And since it's not safe to use
- * i_size_write() without a covering mutex we do the
- * assignment directly. It is not critical that the
- * size be correct. */
- /* region is within kms and, hence, within real file size (A).
- * We need to increase i_size to cover the read region so that
- * generic_file_read() will do its job, but that doesn't mean
- * the kms size is _correct_, it is only the _minimum_ size.
- * If someone does a stat they will get the correct size which
- * will always be >= the kms value here. b=11081 */
- if (i_size_read(inode) < kms) {
- inode->i_size = kms;
- CDEBUG(D_INODE, "ino=%lu, updating i_size %llu\n",
- inode->i_ino, i_size_read(inode));
- }
- lov_stripe_unlock(lsm);
- }
-
- /* If mapping is writeable, adjust kms to cover this page,
- * but do not extend kms beyond actual file size.
- * policy.l_extent.end is set to the end of the page by policy_from_vma
- * bug 10919 */
- lov_stripe_lock(lsm);
- if (mode == LCK_PW)
- obd_adjust_kms(ll_i2dtexp(inode), lsm,
- min_t(loff_t, policy.l_extent.end + 1,
- i_size_read(inode)), 0);
- lov_stripe_unlock(lsm);
-
- /* disable VM_SEQ_READ and use VM_RAND_READ to make sure that
- * the kernel will not read other pages not covered by ldlm in
- * filemap_nopage. we do our readahead in ll_readpage.
- */
- rand_read = vma->vm_flags & VM_RAND_READ;
- seq_read = vma->vm_flags & VM_SEQ_READ;
- vma->vm_flags &= ~ VM_SEQ_READ;
- vma->vm_flags |= VM_RAND_READ;