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 int ll_write_count(struct page *page)
213 struct inode *inode = page->mapping->host;
215 /* catch race with truncate */
216 if (((loff_t)page->index << PAGE_SHIFT) >= inode->i_size)
219 /* catch sub-page write at end of file */
220 if (((loff_t)page->index << PAGE_SHIFT) + PAGE_SIZE > inode->i_size)
221 return inode->i_size % PAGE_SIZE;
226 struct ll_async_page *llap_from_cookie(void *cookie)
228 struct ll_async_page *llap = cookie;
229 if (llap->llap_magic != LLAP_MAGIC)
230 return ERR_PTR(-EINVAL);
234 static int ll_ap_make_ready(void *data, int cmd)
236 struct ll_async_page *llap;
240 llap = llap_from_cookie(data);
244 page = llap->llap_page;
246 if (cmd == OBD_BRW_READ)
249 /* we're trying to write, but the page is locked.. come back later */
250 if (TryLockPage(page))
253 LL_CDEBUG_PAGE(D_PAGE, page, "made ready\n");
254 page_cache_get(page);
256 /* if we left PageDirty we might get another writepage call
257 * in the future. list walkers are bright enough
258 * to check page dirty so we can leave it on whatever list
259 * its on. XXX also, we're called with the cli list so if
260 * we got the page cache list we'd create a lock inversion
261 * with the removepage path which gets the page lock then the
263 clear_page_dirty(page);
267 static int ll_ap_refresh_count(void *data, int cmd)
269 struct ll_async_page *llap;
272 /* readpage queues with _COUNT_STABLE, shouldn't get here. */
273 LASSERT(cmd != OBD_BRW_READ);
275 llap = llap_from_cookie(data);
277 RETURN(PTR_ERR(llap));
279 return ll_write_count(llap->llap_page);
282 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
284 struct lov_stripe_md *lsm;
285 obd_flag valid_flags;
287 lsm = ll_i2info(inode)->lli_smd;
289 oa->o_id = lsm->lsm_object_id;
290 oa->o_valid = OBD_MD_FLID;
291 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
292 if (cmd == OBD_BRW_WRITE) {
293 oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH;
294 mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode);
295 oa->o_easize = ll_i2info(inode)->lli_io_epoch;
297 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
300 obdo_from_inode(oa, inode, valid_flags);
303 static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
305 struct ll_async_page *llap;
308 llap = llap_from_cookie(data);
314 ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
318 static struct obd_async_page_ops ll_async_page_ops = {
319 .ap_make_ready = ll_ap_make_ready,
320 .ap_refresh_count = ll_ap_refresh_count,
321 .ap_fill_obdo = ll_ap_fill_obdo,
322 .ap_completion = ll_ap_completion,
325 /* XXX have the exp be an argument? */
326 struct ll_async_page *llap_from_page(struct page *page)
328 struct ll_async_page *llap;
329 struct obd_export *exp;
330 struct inode *inode = page->mapping->host;
331 struct ll_sb_info *sbi = ll_i2sbi(inode);
335 llap = (struct ll_async_page *)page->private;
337 if (llap->llap_magic != LLAP_MAGIC)
338 RETURN(ERR_PTR(-EINVAL));
342 exp = ll_i2obdexp(page->mapping->host);
344 RETURN(ERR_PTR(-EINVAL));
346 OBD_ALLOC(llap, sizeof(*llap));
348 RETURN(ERR_PTR(-ENOMEM));
349 llap->llap_magic = LLAP_MAGIC;
350 rc = obd_prep_async_page(exp, ll_i2info(inode)->lli_smd, NULL, page,
351 (obd_off)page->index << PAGE_SHIFT,
352 &ll_async_page_ops, llap, &llap->llap_cookie);
354 OBD_FREE(llap, sizeof(*llap));
358 CDEBUG(D_CACHE, "llap %p page %p cookie %p obj off "LPU64"\n", llap,
359 page, llap->llap_cookie, (obd_off)page->index << PAGE_SHIFT);
360 /* also zeroing the PRIVBITS low order bitflags */
361 page->private = (unsigned long)llap;
362 llap->llap_page = page;
364 spin_lock(&sbi->ll_pglist_lock);
365 sbi->ll_pglist_gen++;
366 list_add_tail(&llap->llap_proc_item, &sbi->ll_pglist);
367 spin_unlock(&sbi->ll_pglist_lock);
372 void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
374 /* update our write count to account for i_size increases that may have
375 * happened since we've queued the page for io. */
377 /* be careful not to return success without setting the page Uptodate or
378 * the next pass through prepare_write will read in stale data from disk. */
379 int ll_commit_write(struct file *file, struct page *page, unsigned from,
382 struct inode *inode = page->mapping->host;
383 struct ll_inode_info *lli = ll_i2info(inode);
384 struct lov_stripe_md *lsm = lli->lli_smd;
385 struct obd_export *exp = NULL;
386 struct ll_async_page *llap;
391 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
392 LASSERT(inode == file->f_dentry->d_inode);
393 LASSERT(PageLocked(page));
395 CDEBUG(D_INODE, "inode %p is writing page %p from %d to %d at %lu\n",
396 inode, page, from, to, page->index);
398 llap = llap_from_page(page);
400 RETURN(PTR_ERR(llap));
402 /* queue a write for some time in the future the first time we
404 if (!PageDirty(page)) {
405 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
406 LPROC_LL_DIRTY_MISSES);
408 exp = ll_i2obdexp(inode);
412 /* _make_ready only sees llap once we've unlocked the page */
413 llap->llap_write_queued = 1;
414 rc = obd_queue_async_io(exp, lsm, NULL, llap->llap_cookie,
415 OBD_BRW_WRITE, 0, 0, 0, 0);
416 if (rc != 0) { /* async failed, try sync.. */
417 struct obd_io_group *oig;
422 llap->llap_write_queued = 0;
423 rc = obd_queue_group_io(exp, lsm, NULL, oig,
425 OBD_BRW_WRITE, 0, to, 0,
426 ASYNC_READY | ASYNC_URGENT |
433 rc = obd_trigger_group_io(exp, lsm, NULL, oig);
442 LL_CDEBUG_PAGE(D_PAGE, page, "write queued\n");
443 //llap_write_pending(inode, llap);
445 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
446 LPROC_LL_DIRTY_HITS);
449 /* put the page in the page cache, from now on ll_removepage is
450 * responsible for cleaning up the llap */
451 set_page_dirty(page);
455 size = (((obd_off)page->index) << PAGE_SHIFT) + to;
456 lov_increase_kms(exp, lsm, size);
457 if (size > inode->i_size)
458 inode->i_size = size;
459 SetPageUptodate(page);
464 /* the kernel calls us here when a page is unhashed from the page cache.
465 * the page will be locked and the kernel is holding a spinlock, so
466 * we need to be careful. we're just tearing down our book-keeping
468 void ll_removepage(struct page *page)
470 struct inode *inode = page->mapping->host;
471 struct obd_export *exp;
472 struct ll_async_page *llap;
473 struct ll_sb_info *sbi = ll_i2sbi(inode);
477 LASSERT(!in_interrupt());
479 /* sync pages or failed read pages can leave pages in the page
480 * cache that don't have our data associated with them anymore */
481 if (page->private == 0) {
486 LL_CDEBUG_PAGE(D_PAGE, page, "being evicted\n");
488 exp = ll_i2obdexp(inode);
490 CERROR("page %p ind %lu gave null export\n", page, page->index);
495 llap = llap_from_page(page);
497 CERROR("page %p ind %lu couldn't find llap: %ld\n", page,
498 page->index, PTR_ERR(llap));
503 //llap_write_complete(inode, llap);
504 rc = obd_teardown_async_page(exp, ll_i2info(inode)->lli_smd, NULL,
507 CERROR("page %p ind %lu failed: %d\n", page, page->index, rc);
509 /* this unconditional free is only safe because the page lock
510 * is providing exclusivity to memory pressure/truncate/writeback..*/
513 spin_lock(&sbi->ll_pglist_lock);
514 if (!list_empty(&llap->llap_proc_item))
515 list_del_init(&llap->llap_proc_item);
516 sbi->ll_pglist_gen++;
517 spin_unlock(&sbi->ll_pglist_lock);
518 OBD_FREE(llap, sizeof(*llap));
522 static int ll_page_matches(struct page *page)
524 struct lustre_handle match_lockh = {0};
525 struct inode *inode = page->mapping->host;
526 ldlm_policy_data_t page_extent;
530 page_extent.l_extent.start = (__u64)page->index << PAGE_CACHE_SHIFT;
531 page_extent.l_extent.end =
532 page_extent.l_extent.start + PAGE_CACHE_SIZE - 1;
533 flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
534 matches = obd_match(ll_i2sbi(inode)->ll_osc_exp,
535 ll_i2info(inode)->lli_smd, LDLM_EXTENT,
536 &page_extent, LCK_PR | LCK_PW, &flags, inode,
541 static int ll_issue_page_read(struct obd_export *exp,
542 struct ll_async_page *llap,
543 struct obd_io_group *oig, int defer)
545 struct page *page = llap->llap_page;
548 page_cache_get(page);
549 llap->llap_defer_uptodate = defer;
550 rc = obd_queue_group_io(exp, ll_i2info(page->mapping->host)->lli_smd,
551 NULL, oig, llap->llap_cookie, OBD_BRW_READ, 0,
552 PAGE_SIZE, 0, ASYNC_COUNT_STABLE);
554 LL_CDEBUG_PAGE(D_ERROR, page, "read queue failed: rc %d\n", rc);
555 page_cache_release(page);
560 #define LL_RA_MIN(inode) ((unsigned long)PTL_MD_MAX_PAGES / 2)
561 #define LL_RA_MAX(inode) ((ll_i2info(inode)->lli_smd->lsm_xfersize * 3) >> \
564 static void ll_readahead(struct ll_readahead_state *ras,
565 struct obd_export *exp, struct address_space *mapping,
566 struct obd_io_group *oig)
568 unsigned long i, start, end;
569 struct ll_async_page *llap;
573 if (mapping->host->i_size == 0)
576 spin_lock(&ras->ras_lock);
578 /* make sure to issue a window's worth of read-ahead pages */
580 start = end - ras->ras_window;
584 /* but don't iterate over pages that we've already issued. this
585 * will set start to end + 1 if we've already read-ahead up to
586 * ras_last sothe for() won't be entered */
587 if (ras->ras_next_index > start)
588 start = ras->ras_next_index;
590 ras->ras_next_index = end + 1;
592 CDEBUG(D_READA, "ni %lu last %lu win %lu: reading from %lu to %lu\n",
593 ras->ras_next_index, ras->ras_last, ras->ras_window,
596 spin_unlock(&ras->ras_lock);
598 /* clamp to filesize */
599 i = (mapping->host->i_size - 1) >> PAGE_CACHE_SHIFT;
602 for (i = start; i <= end; i++) {
603 /* grab_cache_page_nowait returns null if this races with
604 * truncating the page (page->mapping == NULL) */
605 page = grab_cache_page_nowait(mapping, i);
609 /* the book-keeping above promises that we've tried
610 * all the indices from start to end, so we don't
611 * stop if anyone returns an error. This may not be good. */
612 if (Page_Uptodate(page))
615 if ((rc = ll_page_matches(page)) <= 0) {
616 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
617 "lock match failed: rc %d\n", rc);
621 llap = llap_from_page(page);
622 if (IS_ERR(llap) || llap->llap_defer_uptodate)
625 rc = ll_issue_page_read(exp, llap, oig, 1);
627 LL_CDEBUG_PAGE(D_PAGE, page, "started read-ahead\n");
630 LL_CDEBUG_PAGE(D_PAGE, page, "skipping read-ahead\n");
634 page_cache_release(page);
638 /* called with the ras_lock held or from places where it doesn't matter */
639 static void ll_readahead_set(struct inode *inode,
640 struct ll_readahead_state *ras,
643 ras->ras_next_index = index;
644 if (ras->ras_next_index != ~0UL)
645 ras->ras_next_index++;
646 ras->ras_window = LL_RA_MIN(inode);
647 ras->ras_last = ras->ras_next_index + ras->ras_window;
648 if (ras->ras_last < ras->ras_next_index)
649 ras->ras_last = ~0UL;
650 CDEBUG(D_READA, "ni %lu last %lu win %lu: set %lu\n",
651 ras->ras_next_index, ras->ras_last, ras->ras_window,
655 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras)
657 spin_lock_init(&ras->ras_lock);
658 ll_readahead_set(inode, ras, 0);
661 static void ll_readahead_update(struct inode *inode,
662 struct ll_readahead_state *ras,
663 unsigned long index, int hit)
665 unsigned long issued_start, new_last;
667 spin_lock(&ras->ras_lock);
669 /* we're interested in noticing the index's relation to the
670 * previously issued read-ahead pages */
671 issued_start = ras->ras_next_index - ras->ras_window - 1;
672 if (issued_start > ras->ras_next_index)
675 CDEBUG(D_READA, "ni %lu last %lu win %lu: %s ind %lu start %lu\n",
676 ras->ras_next_index, ras->ras_last, ras->ras_window,
677 hit ? "hit" : "miss", index, issued_start);
679 index == ras->ras_next_index && index == ras->ras_last + 1) {
680 /* special case the kernel's read-ahead running into the
681 * page just beyond our read-ahead window as an extension
682 * of our read-ahead. sigh. wishing it was easier to
683 * turn off 2.4's read-ahead. */
684 ras->ras_window = min(LL_RA_MAX(inode), ras->ras_window + 1);
686 ras->ras_next_index = index + 1;
687 ras->ras_last = index;
689 (index > issued_start || ras->ras_next_index >= index)) {
690 /* deal with a miss way out of the window. we interpret
691 * this as a seek and restart the window */
692 ll_readahead_set(inode, ras, index);
695 issued_start <= index && index < ras->ras_next_index) {
696 /* a miss inside the window? surely its memory pressure
697 * evicting our read pages before the app can see them.
698 * we shrink the window aggressively */
699 unsigned long old_window = ras->ras_window;
701 ras->ras_window = max(ras->ras_window / 2, LL_RA_MIN(inode));
702 ras->ras_last -= old_window - ras->ras_window;
703 if (ras->ras_next_index > ras->ras_last)
704 ras->ras_next_index = ras->ras_last + 1;
705 CDEBUG(D_READA, "ni %lu last %lu win %lu: miss inside\n",
706 ras->ras_next_index, ras->ras_last, ras->ras_window);
709 issued_start <= index && index < ras->ras_next_index) {
710 /* a hit inside the window. grow the window by twice the
711 * number of pages that are satisified within the window. */
712 ras->ras_window = min(LL_RA_MAX(inode), ras->ras_window + 2);
714 /* we want the next readahead pass to issue a windows worth
715 * beyond where the app currently is */
716 new_last = index + ras->ras_window;
717 if (new_last > ras->ras_last)
718 ras->ras_last = new_last;
720 CDEBUG(D_READA, "ni %lu last %lu win %lu: extended window/last\n",
721 ras->ras_next_index, ras->ras_last, ras->ras_window);
724 spin_unlock(&ras->ras_lock);
728 * for now we do our readpage the same on both 2.4 and 2.5. The kernel's
729 * read-ahead assumes it is valid to issue readpage all the way up to
730 * i_size, but our dlm locks make that not the case. We disable the
731 * kernel's read-ahead and do our own by walking ahead in the page cache
732 * checking for dlm lock coverage. the main difference between 2.4 and
733 * 2.6 is how read-ahead gets batched and issued, but we're using our own,
734 * so they look the same.
736 int ll_readpage(struct file *filp, struct page *page)
738 struct ll_file_data *fd = filp->private_data;
739 struct inode *inode = page->mapping->host;
740 struct obd_export *exp;
741 struct ll_async_page *llap;
742 struct obd_io_group *oig = NULL;
746 LASSERT(PageLocked(page));
747 LASSERT(!PageUptodate(page));
748 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),offset="LPX64"\n",
749 inode->i_ino, inode->i_generation, inode,
750 (((obd_off)page->index) << PAGE_SHIFT));
751 LASSERT(atomic_read(&filp->f_dentry->d_inode->i_count) > 0);
757 exp = ll_i2obdexp(inode);
759 GOTO(out, rc = -EINVAL);
761 llap = llap_from_page(page);
763 GOTO(out, rc = PTR_ERR(llap));
765 if (llap->llap_defer_uptodate) {
766 ll_readahead_update(inode, &fd->fd_ras, page->index, 1);
767 ll_readahead(&fd->fd_ras, exp, page->mapping, oig);
768 obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd, NULL,
770 LL_CDEBUG_PAGE(D_PAGE, page, "marking uptodate from defer\n");
771 SetPageUptodate(page);
773 GOTO(out_oig, rc = 0);
776 ll_readahead_update(inode, &fd->fd_ras, page->index, 0);
778 rc = ll_page_matches(page);
780 LL_CDEBUG_PAGE(D_ERROR, page, "lock match failed: rc %d\n", rc);
785 static unsigned long next_print;
786 CDEBUG(D_INODE, "ino %lu page %lu (%llu) didn't match a lock\n",
787 inode->i_ino, page->index,
788 (long long)page->index << PAGE_CACHE_SHIFT);
789 if (time_after(jiffies, next_print)) {
790 CERROR("ino %lu page %lu (%llu) not covered by "
791 "a lock (mmap?). check debug logs.\n",
792 inode->i_ino, page->index,
793 (long long)page->index << PAGE_CACHE_SHIFT);
794 ldlm_dump_all_namespaces();
795 if (next_print == 0) {
796 CERROR("%s\n", portals_debug_dumpstack());
797 portals_debug_dumplog();
799 next_print = jiffies + 30 * HZ;
803 rc = ll_issue_page_read(exp, llap, oig, 0);
807 LL_CDEBUG_PAGE(D_PAGE, page, "queued readpage\n");
808 if ((ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD))
809 ll_readahead(&fd->fd_ras, exp, page->mapping, oig);
811 rc = obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd, NULL, oig);
823 /* this is for read pages. we issue them as ready but not urgent. when
824 * someone waits on them we fire them off, hopefully merged with adjacent
825 * reads that were queued by read-ahead. */
826 int ll_sync_page(struct page *page)
828 struct obd_export *exp;
829 struct ll_async_page *llap;
833 /* we're using a low bit flag to signify that a queued read should
834 * be issued once someone goes to lock it. it is also cleared
835 * as the page is built into an RPC */
836 if (!test_and_clear_bit(LL_PRIVBITS_READ, &page->private))
839 /* careful to only deref page->mapping after checking the bit */
840 exp = ll_i2obdexp(page->mapping->host);
844 llap = llap_from_page(page);
846 RETURN(PTR_ERR(llap));
848 LL_CDEBUG_PAGE(D_PAGE, page, "setting ready|urgent\n");
850 rc = obd_set_async_flags(exp, ll_i2info(page->mapping->host)->lli_smd,
851 NULL, llap->llap_cookie,
852 ASYNC_READY|ASYNC_URGENT);