1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Lite I/O page cache routines shared by different kernel revs
6 * Copyright (c) 2001-2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/config.h>
25 #include <linux/kernel.h>
27 #include <linux/string.h>
28 #include <linux/stat.h>
29 #include <linux/errno.h>
30 #include <linux/smp_lock.h>
31 #include <linux/unistd.h>
32 #include <linux/version.h>
33 #include <asm/system.h>
34 #include <asm/uaccess.h>
37 #include <linux/stat.h>
38 #include <asm/uaccess.h>
39 #include <asm/segment.h>
41 #include <linux/pagemap.h>
42 #include <linux/smp_lock.h>
44 #define DEBUG_SUBSYSTEM S_LLITE
46 #include <linux/lustre_mds.h>
47 #include <linux/lustre_lite.h>
48 #include "llite_internal.h"
49 #include <linux/lustre_compat25.h>
51 #ifndef list_for_each_prev_safe
52 #define list_for_each_prev_safe(pos, n, head) \
53 for (pos = (head)->prev, n = pos->prev; pos != (head); \
54 pos = n, n = pos->prev )
57 /* SYNCHRONOUS I/O to object storage for an inode */
58 static int ll_brw(int cmd, struct inode *inode, struct obdo *oa,
59 struct page *page, int flags)
61 struct ll_inode_info *lli = ll_i2info(inode);
62 struct lov_stripe_md *lsm = lli->lli_smd;
68 pg.off = ((obd_off)page->index) << PAGE_SHIFT;
70 if (cmd == OBD_BRW_WRITE && (pg.off + PAGE_SIZE > inode->i_size))
71 pg.count = inode->i_size % PAGE_SIZE;
75 CDEBUG(D_PAGE, "%s %d bytes ino %lu at "LPU64"/"LPX64"\n",
76 cmd & OBD_BRW_WRITE ? "write" : "read", pg.count, inode->i_ino,
79 CERROR("ZERO COUNT: ino %lu: size %p:%Lu(%p:%Lu) idx %lu off "
81 inode->i_ino, inode, inode->i_size, page->mapping->host,
82 page->mapping->host->i_size, page->index, pg.off);
87 if (cmd == OBD_BRW_WRITE)
88 lprocfs_counter_add(ll_i2sbi(inode)->ll_stats,
89 LPROC_LL_BRW_WRITE, pg.count);
91 lprocfs_counter_add(ll_i2sbi(inode)->ll_stats,
92 LPROC_LL_BRW_READ, pg.count);
93 rc = obd_brw(cmd, ll_i2obdexp(inode), oa, lsm, 1, &pg, NULL);
95 obdo_to_inode(inode, oa, OBD_MD_FLBLOCKS);
97 CERROR("error from obd_brw: rc = %d\n", rc);
101 /* this isn't where truncate starts. roughly:
102 * sys_truncate->ll_setattr_raw->vmtruncate->ll_truncate
103 * we grab the lock back in setattr_raw to avoid races. */
104 void ll_truncate(struct inode *inode)
106 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
110 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
111 inode->i_generation, inode);
114 CDEBUG(D_INODE, "truncate on inode %lu with no objects\n",
120 oa.o_id = lsm->lsm_object_id;
121 oa.o_valid = OBD_MD_FLID;
122 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE|OBD_MD_FLMODE|OBD_MD_FLATIME|
123 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
125 CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n",
126 oa.o_id, inode->i_size);
128 /* truncate == punch from new size to absolute end of file */
129 /* NB: obd_punch must be called with i_sem held! It updates the kms! */
130 rc = obd_punch(ll_i2obdexp(inode), &oa, lsm, inode->i_size,
131 OBD_OBJECT_EOF, NULL);
133 CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino);
135 obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
136 OBD_MD_FLATIME | OBD_MD_FLMTIME |
143 __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms);
144 int ll_prepare_write(struct file *file, struct page *page, unsigned from,
147 struct inode *inode = page->mapping->host;
148 struct ll_inode_info *lli = ll_i2info(inode);
149 struct lov_stripe_md *lsm = lli->lli_smd;
150 obd_off offset = ((obd_off)page->index) << PAGE_SHIFT;
157 if (!PageLocked(page))
160 /* Check to see if we should return -EIO right away */
163 pga.count = PAGE_SIZE;
166 oa.o_id = lsm->lsm_object_id;
167 oa.o_mode = inode->i_mode;
168 oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLTYPE;
170 rc = obd_brw(OBD_BRW_CHECK, ll_i2obdexp(inode), &oa, lsm, 1, &pga,
175 if (PageUptodate(page))
178 /* We're completely overwriting an existing page, so _don't_ set it up
179 * to date until commit_write */
180 if (from == 0 && to == PAGE_SIZE) {
181 POISON_PAGE(page, 0x11);
185 /* If are writing to a new page, no need to read old data. The extent
186 * locking will have updated the KMS, and for our purposes here we can
187 * treat it like i_size. */
188 kms = lov_merge_size(lsm, 1);
190 memset(kmap(page), 0, PAGE_SIZE);
192 GOTO(prepare_done, rc = 0);
195 /* XXX could be an async ocp read.. read-ahead? */
196 rc = ll_brw(OBD_BRW_READ, inode, &oa, page, 0);
198 /* bug 1598: don't clobber blksize */
199 oa.o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ);
200 obdo_refresh_inode(inode, &oa, oa.o_valid);
206 SetPageUptodate(page);
211 struct ll_async_page *llap_from_cookie(void *cookie)
213 struct ll_async_page *llap = cookie;
214 if (llap->llap_magic != LLAP_MAGIC)
215 return ERR_PTR(-EINVAL);
219 static int ll_ap_make_ready(void *data, int cmd)
221 struct ll_async_page *llap;
225 llap = llap_from_cookie(data);
229 page = llap->llap_page;
231 LASSERT(cmd != OBD_BRW_READ);
233 /* we're trying to write, but the page is locked.. come back later */
234 if (TryLockPage(page))
237 LL_CDEBUG_PAGE(D_PAGE, page, "made ready\n");
238 page_cache_get(page);
240 /* if we left PageDirty we might get another writepage call
241 * in the future. list walkers are bright enough
242 * to check page dirty so we can leave it on whatever list
243 * its on. XXX also, we're called with the cli list so if
244 * we got the page cache list we'd create a lock inversion
245 * with the removepage path which gets the page lock then the
247 clear_page_dirty(page);
251 /* We have two reasons for giving llite the opportunity to change the
252 * write length of a given queued page as it builds the RPC containing
255 * 1) Further extending writes may have landed in the page cache
256 * since a partial write first queued this page requiring us
257 * to write more from the page cache.
258 * 2) We might have raced with truncate and want to avoid performing
259 * write RPCs that are just going to be thrown away by the
260 * truncate's punch on the storage targets.
262 * The kms serves these purposes as it is set at both truncate and extending
265 static int ll_ap_refresh_count(void *data, int cmd)
267 struct ll_async_page *llap;
268 struct lov_stripe_md *lsm;
273 /* readpage queues with _COUNT_STABLE, shouldn't get here. */
274 LASSERT(cmd != OBD_BRW_READ);
276 llap = llap_from_cookie(data);
278 RETURN(PTR_ERR(llap));
280 page = llap->llap_page;
281 lsm = ll_i2info(page->mapping->host)->lli_smd;
282 kms = lov_merge_size(lsm, 1);
284 /* catch race with truncate */
285 if (((__u64)page->index << PAGE_SHIFT) >= kms)
288 /* catch sub-page write at end of file */
289 if (((__u64)page->index << PAGE_SHIFT) + PAGE_SIZE > kms)
290 return kms % PAGE_SIZE;
295 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
297 struct lov_stripe_md *lsm;
298 obd_flag valid_flags;
300 lsm = ll_i2info(inode)->lli_smd;
302 oa->o_id = lsm->lsm_object_id;
303 oa->o_valid = OBD_MD_FLID;
304 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
305 if (cmd == OBD_BRW_WRITE) {
306 oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH;
307 mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode);
308 oa->o_easize = ll_i2info(inode)->lli_io_epoch;
310 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
313 obdo_from_inode(oa, inode, valid_flags);
316 static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
318 struct ll_async_page *llap;
321 llap = llap_from_cookie(data);
327 ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
331 static struct obd_async_page_ops ll_async_page_ops = {
332 .ap_make_ready = ll_ap_make_ready,
333 .ap_refresh_count = ll_ap_refresh_count,
334 .ap_fill_obdo = ll_ap_fill_obdo,
335 .ap_completion = ll_ap_completion,
338 /* XXX have the exp be an argument? */
339 struct ll_async_page *llap_from_page(struct page *page)
341 struct ll_async_page *llap;
342 struct obd_export *exp;
343 struct inode *inode = page->mapping->host;
344 struct ll_sb_info *sbi = ll_i2sbi(inode);
348 llap = (struct ll_async_page *)page->private;
350 if (llap->llap_magic != LLAP_MAGIC)
351 RETURN(ERR_PTR(-EINVAL));
355 exp = ll_i2obdexp(page->mapping->host);
357 RETURN(ERR_PTR(-EINVAL));
359 OBD_ALLOC(llap, sizeof(*llap));
361 RETURN(ERR_PTR(-ENOMEM));
362 llap->llap_magic = LLAP_MAGIC;
363 rc = obd_prep_async_page(exp, ll_i2info(inode)->lli_smd, NULL, page,
364 (obd_off)page->index << PAGE_SHIFT,
365 &ll_async_page_ops, llap, &llap->llap_cookie);
367 OBD_FREE(llap, sizeof(*llap));
371 CDEBUG(D_CACHE, "llap %p page %p cookie %p obj off "LPU64"\n", llap,
372 page, llap->llap_cookie, (obd_off)page->index << PAGE_SHIFT);
373 /* also zeroing the PRIVBITS low order bitflags */
374 page->private = (unsigned long)llap;
375 llap->llap_page = page;
377 spin_lock(&sbi->ll_lock);
378 sbi->ll_pglist_gen++;
379 list_add_tail(&llap->llap_proc_item, &sbi->ll_pglist);
380 spin_unlock(&sbi->ll_lock);
385 void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
387 /* update our write count to account for i_size increases that may have
388 * happened since we've queued the page for io. */
390 /* be careful not to return success without setting the page Uptodate or
391 * the next pass through prepare_write will read in stale data from disk. */
392 int ll_commit_write(struct file *file, struct page *page, unsigned from,
395 struct inode *inode = page->mapping->host;
396 struct ll_inode_info *lli = ll_i2info(inode);
397 struct lov_stripe_md *lsm = lli->lli_smd;
398 struct obd_export *exp = NULL;
399 struct ll_async_page *llap;
404 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
405 LASSERT(inode == file->f_dentry->d_inode);
406 LASSERT(PageLocked(page));
408 CDEBUG(D_INODE, "inode %p is writing page %p from %d to %d at %lu\n",
409 inode, page, from, to, page->index);
411 llap = llap_from_page(page);
413 RETURN(PTR_ERR(llap));
415 /* queue a write for some time in the future the first time we
417 if (!PageDirty(page)) {
418 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
419 LPROC_LL_DIRTY_MISSES);
421 exp = ll_i2obdexp(inode);
425 /* _make_ready only sees llap once we've unlocked the page */
426 llap->llap_write_queued = 1;
427 rc = obd_queue_async_io(exp, lsm, NULL, llap->llap_cookie,
428 OBD_BRW_WRITE, 0, 0, 0, 0);
429 if (rc != 0) { /* async failed, try sync.. */
430 struct obd_io_group *oig;
435 llap->llap_write_queued = 0;
436 rc = obd_queue_group_io(exp, lsm, NULL, oig,
438 OBD_BRW_WRITE, 0, to, 0,
439 ASYNC_READY | ASYNC_URGENT |
446 rc = obd_trigger_group_io(exp, lsm, NULL, oig);
455 LL_CDEBUG_PAGE(D_PAGE, page, "write queued\n");
456 //llap_write_pending(inode, llap);
458 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
459 LPROC_LL_DIRTY_HITS);
462 /* put the page in the page cache, from now on ll_removepage is
463 * responsible for cleaning up the llap */
464 set_page_dirty(page);
468 size = (((obd_off)page->index) << PAGE_SHIFT) + to;
469 lov_increase_kms(exp, lsm, size);
470 if (size > inode->i_size)
471 inode->i_size = size;
472 SetPageUptodate(page);
477 static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, unsigned long len)
482 spin_lock(&sbi->ll_lock);
483 ret = min(sbi->ll_max_read_ahead_pages - sbi->ll_read_ahead_pages,
485 sbi->ll_read_ahead_pages += ret;
486 spin_unlock(&sbi->ll_lock);
491 static void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
493 spin_lock(&sbi->ll_lock);
494 LASSERTF(sbi->ll_read_ahead_pages >= len, "r_a_p %lu len %lu\n",
495 sbi->ll_read_ahead_pages, len);
496 sbi->ll_read_ahead_pages -= len;
497 spin_unlock(&sbi->ll_lock);
500 /* called for each page in a completed rpc.*/
501 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
503 struct ll_async_page *llap;
507 llap = llap_from_cookie(data);
513 page = llap->llap_page;
514 LASSERT(PageLocked(page));
516 LL_CDEBUG_PAGE(D_PAGE, page, "completing cmd %d with %d\n", cmd, rc);
518 if (cmd == OBD_BRW_READ && llap->llap_defer_uptodate)
519 ll_ra_count_put(ll_i2sbi(page->mapping->host), 1);
522 if (cmd == OBD_BRW_READ) {
523 if (!llap->llap_defer_uptodate)
524 SetPageUptodate(page);
526 llap->llap_write_queued = 0;
528 ClearPageError(page);
530 if (cmd == OBD_BRW_READ)
531 llap->llap_defer_uptodate = 0;
537 if (0 && cmd == OBD_BRW_WRITE) {
538 llap_write_complete(page->mapping->host, llap);
539 ll_try_done_writing(page->mapping->host);
542 page_cache_release(page);
546 /* the kernel calls us here when a page is unhashed from the page cache.
547 * the page will be locked and the kernel is holding a spinlock, so
548 * we need to be careful. we're just tearing down our book-keeping
550 void ll_removepage(struct page *page)
552 struct inode *inode = page->mapping->host;
553 struct obd_export *exp;
554 struct ll_async_page *llap;
555 struct ll_sb_info *sbi = ll_i2sbi(inode);
559 LASSERT(!in_interrupt());
561 /* sync pages or failed read pages can leave pages in the page
562 * cache that don't have our data associated with them anymore */
563 if (page->private == 0) {
568 LL_CDEBUG_PAGE(D_PAGE, page, "being evicted\n");
570 exp = ll_i2obdexp(inode);
572 CERROR("page %p ind %lu gave null export\n", page, page->index);
577 llap = llap_from_page(page);
579 CERROR("page %p ind %lu couldn't find llap: %ld\n", page,
580 page->index, PTR_ERR(llap));
585 //llap_write_complete(inode, llap);
586 rc = obd_teardown_async_page(exp, ll_i2info(inode)->lli_smd, NULL,
589 CERROR("page %p ind %lu failed: %d\n", page, page->index, rc);
591 /* this unconditional free is only safe because the page lock
592 * is providing exclusivity to memory pressure/truncate/writeback..*/
595 spin_lock(&sbi->ll_lock);
596 if (!list_empty(&llap->llap_proc_item))
597 list_del_init(&llap->llap_proc_item);
598 sbi->ll_pglist_gen++;
599 spin_unlock(&sbi->ll_lock);
600 OBD_FREE(llap, sizeof(*llap));
604 static int ll_page_matches(struct page *page, int fd_flags)
606 struct lustre_handle match_lockh = {0};
607 struct inode *inode = page->mapping->host;
608 ldlm_policy_data_t page_extent;
612 if (fd_flags & LL_FILE_GROUP_LOCKED)
615 page_extent.l_extent.start = (__u64)page->index << PAGE_CACHE_SHIFT;
616 page_extent.l_extent.end =
617 page_extent.l_extent.start + PAGE_CACHE_SIZE - 1;
618 flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
619 matches = obd_match(ll_i2sbi(inode)->ll_osc_exp,
620 ll_i2info(inode)->lli_smd, LDLM_EXTENT,
621 &page_extent, LCK_PR | LCK_PW, &flags, inode,
626 static int ll_issue_page_read(struct obd_export *exp,
627 struct ll_async_page *llap,
628 struct obd_io_group *oig, int defer)
630 struct page *page = llap->llap_page;
633 page_cache_get(page);
634 llap->llap_defer_uptodate = defer;
635 rc = obd_queue_group_io(exp, ll_i2info(page->mapping->host)->lli_smd,
636 NULL, oig, llap->llap_cookie, OBD_BRW_READ, 0,
637 PAGE_SIZE, 0, ASYNC_COUNT_STABLE | ASYNC_READY
640 LL_CDEBUG_PAGE(D_ERROR, page, "read queue failed: rc %d\n", rc);
641 page_cache_release(page);
646 #define RAS_CDEBUG(ras) \
647 CDEBUG(D_READA, "lrp %lu c %lu ws %lu wl %lu nra %lu\n", \
648 ras->ras_last_readpage, ras->ras_consecutive, \
649 ras->ras_window_start, ras->ras_window_len, \
650 ras->ras_next_readahead);
652 static int ll_readahead(struct ll_readahead_state *ras,
653 struct obd_export *exp, struct address_space *mapping,
654 struct obd_io_group *oig, int flags)
656 unsigned long i, start = 0, end = 0, reserved;
657 struct ll_async_page *llap;
663 kms = lov_merge_size(ll_i2info(mapping->host)->lli_smd, 1);
667 spin_lock(&ras->ras_lock);
669 if (ras->ras_window_len) {
670 start = ras->ras_next_readahead;
671 end = ras->ras_window_start + ras->ras_window_len - 1;
672 end = min(end, (unsigned long)(kms >> PAGE_CACHE_SHIFT));
673 ras->ras_next_readahead = max(end, end + 1);
678 spin_unlock(&ras->ras_lock);
683 reserved = ll_ra_count_get(ll_i2sbi(mapping->host), end - start + 1);
685 for (i = start; reserved > 0 && i <= end; i++) {
686 /* skip locked pages from previous readpage calls */
687 page = grab_cache_page_nowait(mapping, i);
689 CDEBUG(D_READA, "g_c_p_n failed\n");
693 /* we do this first so that we can see the page in the /proc
695 llap = llap_from_page(page);
696 if (IS_ERR(llap) || llap->llap_defer_uptodate)
699 /* skip completed pages */
700 if (Page_Uptodate(page))
703 /* bail when we hit the end of the lock. */
704 if ((rc = ll_page_matches(page, flags)) <= 0) {
705 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
706 "lock match failed: rc %d\n", rc);
711 rc = ll_issue_page_read(exp, llap, oig, 1);
715 LL_CDEBUG_PAGE(D_READA| D_PAGE, page,
716 "started read-ahead\n");
720 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
721 "skipping read-ahead\n");
725 page_cache_release(page);
728 LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
730 ll_ra_count_put(ll_i2sbi(mapping->host), reserved);
734 static void ras_set_start(struct ll_readahead_state *ras,
737 ras->ras_window_start = index & (~(PTLRPC_MAX_BRW_PAGES - 1));
738 ras->ras_next_readahead = max(ras->ras_window_start,
739 ras->ras_next_readahead);
742 /* called with the ras_lock held or from places where it doesn't matter */
743 static void ras_reset(struct ll_readahead_state *ras,
746 ras->ras_last_readpage = index;
747 ras->ras_consecutive = 1;
748 ras->ras_window_len = 0;
749 ras_set_start(ras, index);
750 ras->ras_next_readahead = ras->ras_window_start;
755 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras)
757 spin_lock_init(&ras->ras_lock);
761 static void ras_update(struct ll_readahead_state *ras,
762 unsigned long index, unsigned long max)
766 spin_lock(&ras->ras_lock);
768 if (index != ras->ras_last_readpage + 1) {
769 ras_reset(ras, index);
773 ras->ras_last_readpage = index;
774 ras->ras_consecutive++;
775 ras_set_start(ras, index);
777 if (ras->ras_consecutive == 2) {
778 ras->ras_window_len = PTLRPC_MAX_BRW_PAGES;
782 /* we need to increase the window sometimes. we'll arbitrarily
783 * do it half-way through the pages in an rpc */
784 if ((index & (PTLRPC_MAX_BRW_PAGES - 1)) ==
785 (PTLRPC_MAX_BRW_PAGES >> 1)) {
786 ras->ras_window_len += PTLRPC_MAX_BRW_PAGES;
787 ras->ras_window_len = min(ras->ras_window_len, max);
793 spin_unlock(&ras->ras_lock);
798 * for now we do our readpage the same on both 2.4 and 2.5. The kernel's
799 * read-ahead assumes it is valid to issue readpage all the way up to
800 * i_size, but our dlm locks make that not the case. We disable the
801 * kernel's read-ahead and do our own by walking ahead in the page cache
802 * checking for dlm lock coverage. the main difference between 2.4 and
803 * 2.6 is how read-ahead gets batched and issued, but we're using our own,
804 * so they look the same.
806 int ll_readpage(struct file *filp, struct page *page)
808 struct ll_file_data *fd = filp->private_data;
809 struct inode *inode = page->mapping->host;
810 struct obd_export *exp;
811 struct ll_async_page *llap;
812 struct obd_io_group *oig = NULL;
816 LASSERT(PageLocked(page));
817 LASSERT(!PageUptodate(page));
818 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),offset="LPX64"\n",
819 inode->i_ino, inode->i_generation, inode,
820 (((obd_off)page->index) << PAGE_SHIFT));
821 LASSERT(atomic_read(&filp->f_dentry->d_inode->i_count) > 0);
827 exp = ll_i2obdexp(inode);
829 GOTO(out, rc = -EINVAL);
831 llap = llap_from_page(page);
833 GOTO(out, rc = PTR_ERR(llap));
835 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
836 ras_update(&fd->fd_ras, page->index,
837 ll_i2sbi(inode)->ll_max_read_ahead_pages);
839 if (llap->llap_defer_uptodate) {
840 rc = ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
843 obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd,
845 LL_CDEBUG_PAGE(D_PAGE, page, "marking uptodate from defer\n");
846 SetPageUptodate(page);
848 GOTO(out_oig, rc = 0);
851 rc = ll_page_matches(page, fd->fd_flags);
853 LL_CDEBUG_PAGE(D_ERROR, page, "lock match failed: rc %d\n", rc);
858 static unsigned long next_print;
859 CDEBUG(D_INODE, "ino %lu page %lu (%llu) didn't match a lock\n",
860 inode->i_ino, page->index,
861 (long long)page->index << PAGE_CACHE_SHIFT);
862 if (time_after(jiffies, next_print)) {
863 CWARN("ino %lu page %lu (%llu) not covered by "
864 "a lock (mmap?). check debug logs.\n",
865 inode->i_ino, page->index,
866 (long long)page->index << PAGE_CACHE_SHIFT);
867 next_print = jiffies + 30 * HZ;
871 rc = ll_issue_page_read(exp, llap, oig, 0);
875 LL_CDEBUG_PAGE(D_PAGE, page, "queued readpage\n");
876 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
877 ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
880 rc = obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd, NULL, oig);