+ ras_detect_read_pattern(ras, sbi, pos, count, false);
+out_unlock:
+ spin_unlock(&ras->ras_lock);
+}
+
+static bool index_in_stride_window(struct ll_readahead_state *ras,
+ unsigned int index)
+{
+ unsigned long pos = index << PAGE_SHIFT;
+ unsigned long offset;
+
+ if (ras->ras_stride_length == 0 || ras->ras_stride_bytes == 0 ||
+ ras->ras_stride_bytes == ras->ras_stride_length)
+ return false;
+
+ if (pos >= ras->ras_stride_offset) {
+ offset = (pos - ras->ras_stride_offset) %
+ ras->ras_stride_length;
+ if (offset < ras->ras_stride_bytes ||
+ ras->ras_stride_length - offset < PAGE_SIZE)
+ return true;
+ } else if (ras->ras_stride_offset - pos < PAGE_SIZE) {
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * ll_ras_enter() is used to detect read pattern according to
+ * pos and count.
+ *
+ * ras_update() is used to detect cache miss and
+ * reset window or increase window accordingly
+ */
+static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
+ struct ll_readahead_state *ras, unsigned long index,
+ enum ras_update_flags flags)
+{
+ struct ll_ra_info *ra = &sbi->ll_ra_info;
+ bool hit = flags & LL_RAS_HIT;
+
+ ENTRY;
+ spin_lock(&ras->ras_lock);
+
+ if (!hit)
+ CDEBUG(D_READA, DFID " pages at %lu miss.\n",
+ PFID(ll_inode2fid(inode)), index);
+ ll_ra_stats_inc_sbi(sbi, hit ? RA_STAT_HIT : RA_STAT_MISS);
+
+ /*
+ * The readahead window has been expanded to cover whole
+ * file size, we don't care whether ra miss happen or not.
+ * Because we will read whole file to page cache even if
+ * some pages missed.
+ */
+ if (ras->ras_no_miss_check)
+ GOTO(out_unlock, 0);
+
+ if (flags & LL_RAS_MMAP)
+ ras_detect_read_pattern(ras, sbi, index << PAGE_SHIFT,
+ PAGE_SIZE, true);
+
+ if (!hit && ras->ras_window_len &&
+ index < ras->ras_next_readahead &&
+ pos_in_window(index, ras->ras_window_start, 0,
+ ras->ras_window_len)) {
+ ll_ra_stats_inc_sbi(sbi, RA_STAT_MISS_IN_WINDOW);
+ ras->ras_need_increase_window = false;
+
+ if (index_in_stride_window(ras, index) &&
+ stride_io_mode(ras)) {
+ /*
+ * if (index != ras->ras_last_readpage + 1)
+ * ras->ras_consecutive_pages = 0;
+ */