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.disk_offset = pg.page_offset = ((obd_off)page->index) << PAGE_SHIFT;
70 if (cmd == OBD_BRW_WRITE &&
71 (pg.disk_offset + PAGE_SIZE > inode->i_size))
72 pg.count = inode->i_size % PAGE_SIZE;
76 CDEBUG(D_PAGE, "%s %d bytes ino %lu at "LPU64"/"LPX64"\n",
77 cmd & OBD_BRW_WRITE ? "write" : "read", pg.count, inode->i_ino,
78 pg.disk_offset, pg.disk_offset);
80 CERROR("ZERO COUNT: ino %lu: size %p:%Lu(%p:%Lu) idx %lu off "
81 LPU64"\n", inode->i_ino, inode, inode->i_size,
82 page->mapping->host, page->mapping->host->i_size,
83 page->index, pg.disk_offset);
88 if (cmd == OBD_BRW_WRITE)
89 lprocfs_counter_add(ll_i2sbi(inode)->ll_stats,
90 LPROC_LL_BRW_WRITE, pg.count);
92 lprocfs_counter_add(ll_i2sbi(inode)->ll_stats,
93 LPROC_LL_BRW_READ, pg.count);
94 rc = obd_brw(cmd, ll_i2obdexp(inode), oa, lsm, 1, &pg, NULL);
96 obdo_to_inode(inode, oa, OBD_MD_FLBLOCKS);
98 CERROR("error from obd_brw: rc = %d\n", rc);
102 /* this isn't where truncate starts. roughly:
103 * sys_truncate->ll_setattr_raw->vmtruncate->ll_truncate
104 * we grab the lock back in setattr_raw to avoid races. */
105 void ll_truncate(struct inode *inode)
107 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
111 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
112 inode->i_generation, inode);
115 CDEBUG(D_INODE, "truncate on inode %lu with no objects\n",
121 oa.o_id = lsm->lsm_object_id;
122 oa.o_valid = OBD_MD_FLID;
123 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE|OBD_MD_FLMODE|OBD_MD_FLATIME|
124 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
126 CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n",
127 oa.o_id, inode->i_size);
129 /* truncate == punch from new size to absolute end of file */
130 /* NB: obd_punch must be called with i_sem held! It updates the kms! */
131 rc = obd_punch(ll_i2obdexp(inode), &oa, lsm, inode->i_size,
132 OBD_OBJECT_EOF, NULL);
134 CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino);
136 obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
137 OBD_MD_FLATIME | OBD_MD_FLMTIME |
144 __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms);
145 int ll_prepare_write(struct file *file, struct page *page, unsigned from,
148 struct inode *inode = page->mapping->host;
149 struct ll_inode_info *lli = ll_i2info(inode);
150 struct lov_stripe_md *lsm = lli->lli_smd;
151 obd_off offset = ((obd_off)page->index) << PAGE_SHIFT;
158 LASSERT(PageLocked(page));
159 (void)llap_cast_private(page); /* assertion */
161 /* Check to see if we should return -EIO right away */
163 pga.disk_offset = pga.page_offset = offset;
164 pga.count = PAGE_SIZE;
167 oa.o_id = lsm->lsm_object_id;
168 oa.o_mode = inode->i_mode;
169 oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLTYPE;
171 rc = obd_brw(OBD_BRW_CHECK, ll_i2obdexp(inode), &oa, lsm, 1, &pga,
176 if (PageUptodate(page))
179 /* We're completely overwriting an existing page, so _don't_ set it up
180 * to date until commit_write */
181 if (from == 0 && to == PAGE_SIZE) {
182 POISON_PAGE(page, 0x11);
186 /* If are writing to a new page, no need to read old data. The extent
187 * locking will have updated the KMS, and for our purposes here we can
188 * treat it like i_size. */
189 kms = lov_merge_size(lsm, 1);
191 memset(kmap(page), 0, PAGE_SIZE);
193 GOTO(prepare_done, rc = 0);
196 /* XXX could be an async ocp read.. read-ahead? */
197 rc = ll_brw(OBD_BRW_READ, inode, &oa, page, 0);
199 /* bug 1598: don't clobber blksize */
200 oa.o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ);
201 obdo_refresh_inode(inode, &oa, oa.o_valid);
207 SetPageUptodate(page);
212 struct ll_async_page *llap_from_cookie(void *cookie)
214 struct ll_async_page *llap = cookie;
215 if (llap->llap_magic != LLAP_MAGIC)
216 return ERR_PTR(-EINVAL);
220 static int ll_ap_make_ready(void *data, int cmd)
222 struct ll_async_page *llap;
226 llap = llap_from_cookie(data);
230 page = llap->llap_page;
232 LASSERT(cmd != OBD_BRW_READ);
234 /* we're trying to write, but the page is locked.. come back later */
235 if (TryLockPage(page))
238 LL_CDEBUG_PAGE(D_PAGE, page, "made ready\n");
239 page_cache_get(page);
241 /* if we left PageDirty we might get another writepage call
242 * in the future. list walkers are bright enough
243 * to check page dirty so we can leave it on whatever list
244 * its on. XXX also, we're called with the cli list so if
245 * we got the page cache list we'd create a lock inversion
246 * with the removepage path which gets the page lock then the
248 clear_page_dirty(page);
252 /* We have two reasons for giving llite the opportunity to change the
253 * write length of a given queued page as it builds the RPC containing
256 * 1) Further extending writes may have landed in the page cache
257 * since a partial write first queued this page requiring us
258 * to write more from the page cache.
259 * 2) We might have raced with truncate and want to avoid performing
260 * write RPCs that are just going to be thrown away by the
261 * truncate's punch on the storage targets.
263 * The kms serves these purposes as it is set at both truncate and extending
266 static int ll_ap_refresh_count(void *data, int cmd)
268 struct ll_async_page *llap;
269 struct lov_stripe_md *lsm;
274 /* readpage queues with _COUNT_STABLE, shouldn't get here. */
275 LASSERT(cmd != OBD_BRW_READ);
277 llap = llap_from_cookie(data);
279 RETURN(PTR_ERR(llap));
281 page = llap->llap_page;
282 lsm = ll_i2info(page->mapping->host)->lli_smd;
283 kms = lov_merge_size(lsm, 1);
285 /* catch race with truncate */
286 if (((__u64)page->index << PAGE_SHIFT) >= kms)
289 /* catch sub-page write at end of file */
290 if (((__u64)page->index << PAGE_SHIFT) + PAGE_SIZE > kms)
291 return kms % PAGE_SIZE;
296 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
298 struct lov_stripe_md *lsm;
299 obd_flag valid_flags;
301 lsm = ll_i2info(inode)->lli_smd;
303 oa->o_id = lsm->lsm_object_id;
304 oa->o_valid = OBD_MD_FLID;
305 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
306 if (cmd == OBD_BRW_WRITE) {
307 oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH;
308 mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode);
309 oa->o_easize = ll_i2info(inode)->lli_io_epoch;
311 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
314 obdo_from_inode(oa, inode, valid_flags);
317 static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
319 struct ll_async_page *llap;
322 llap = llap_from_cookie(data);
328 ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
332 static struct obd_async_page_ops ll_async_page_ops = {
333 .ap_make_ready = ll_ap_make_ready,
334 .ap_refresh_count = ll_ap_refresh_count,
335 .ap_fill_obdo = ll_ap_fill_obdo,
336 .ap_completion = ll_ap_completion,
339 struct ll_async_page *llap_cast_private(struct page *page)
341 struct ll_async_page *llap = (struct ll_async_page *)page->private;
343 LASSERTF(llap == NULL || llap->llap_magic == LLAP_MAGIC,
344 "page %p private %lu gave magic %d which != %d\n",
345 page, page->private, llap->llap_magic, LLAP_MAGIC);
350 /* XXX have the exp be an argument? */
351 struct ll_async_page *llap_from_page(struct page *page)
353 struct ll_async_page *llap;
354 struct obd_export *exp;
355 struct inode *inode = page->mapping->host;
356 struct ll_sb_info *sbi = ll_i2sbi(inode);
360 llap = llap_cast_private(page);
364 exp = ll_i2obdexp(page->mapping->host);
366 RETURN(ERR_PTR(-EINVAL));
368 OBD_ALLOC(llap, sizeof(*llap));
370 RETURN(ERR_PTR(-ENOMEM));
371 llap->llap_magic = LLAP_MAGIC;
372 rc = obd_prep_async_page(exp, ll_i2info(inode)->lli_smd, NULL, page,
373 (obd_off)page->index << PAGE_SHIFT,
374 &ll_async_page_ops, llap, &llap->llap_cookie);
376 OBD_FREE(llap, sizeof(*llap));
380 CDEBUG(D_CACHE, "llap %p page %p cookie %p obj off "LPU64"\n", llap,
381 page, llap->llap_cookie, (obd_off)page->index << PAGE_SHIFT);
382 /* also zeroing the PRIVBITS low order bitflags */
383 page->private = (unsigned long)llap;
384 llap->llap_page = page;
386 spin_lock(&sbi->ll_lock);
387 sbi->ll_pglist_gen++;
388 list_add_tail(&llap->llap_proc_item, &sbi->ll_pglist);
389 spin_unlock(&sbi->ll_lock);
394 void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
396 /* update our write count to account for i_size increases that may have
397 * happened since we've queued the page for io. */
399 /* be careful not to return success without setting the page Uptodate or
400 * the next pass through prepare_write will read in stale data from disk. */
401 int ll_commit_write(struct file *file, struct page *page, unsigned from,
404 struct inode *inode = page->mapping->host;
405 struct ll_inode_info *lli = ll_i2info(inode);
406 struct lov_stripe_md *lsm = lli->lli_smd;
407 struct obd_export *exp = NULL;
408 struct ll_async_page *llap;
413 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
414 LASSERT(inode == file->f_dentry->d_inode);
415 LASSERT(PageLocked(page));
417 CDEBUG(D_INODE, "inode %p is writing page %p from %d to %d at %lu\n",
418 inode, page, from, to, page->index);
420 llap = llap_from_page(page);
422 RETURN(PTR_ERR(llap));
424 /* queue a write for some time in the future the first time we
426 if (!PageDirty(page)) {
427 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
428 LPROC_LL_DIRTY_MISSES);
430 exp = ll_i2obdexp(inode);
434 /* _make_ready only sees llap once we've unlocked the page */
435 llap->llap_write_queued = 1;
436 rc = obd_queue_async_io(exp, lsm, NULL, llap->llap_cookie,
437 OBD_BRW_WRITE, 0, 0, 0, 0);
438 if (rc != 0) { /* async failed, try sync.. */
439 struct obd_io_group *oig;
444 llap->llap_write_queued = 0;
445 rc = obd_queue_group_io(exp, lsm, NULL, oig,
447 OBD_BRW_WRITE, 0, to, 0,
448 ASYNC_READY | ASYNC_URGENT |
455 rc = obd_trigger_group_io(exp, lsm, NULL, oig);
464 LL_CDEBUG_PAGE(D_PAGE, page, "write queued\n");
465 //llap_write_pending(inode, llap);
467 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
468 LPROC_LL_DIRTY_HITS);
471 /* put the page in the page cache, from now on ll_removepage is
472 * responsible for cleaning up the llap */
473 set_page_dirty(page);
477 size = (((obd_off)page->index) << PAGE_SHIFT) + to;
478 lov_increase_kms(exp, lsm, size);
479 if (size > inode->i_size)
480 inode->i_size = size;
481 SetPageUptodate(page);
486 static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, unsigned long len)
491 spin_lock(&sbi->ll_lock);
492 ret = min(sbi->ll_max_read_ahead_pages - sbi->ll_read_ahead_pages,
494 sbi->ll_read_ahead_pages += ret;
495 spin_unlock(&sbi->ll_lock);
500 static void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
502 spin_lock(&sbi->ll_lock);
503 LASSERTF(sbi->ll_read_ahead_pages >= len, "r_a_p %lu len %lu\n",
504 sbi->ll_read_ahead_pages, len);
505 sbi->ll_read_ahead_pages -= len;
506 spin_unlock(&sbi->ll_lock);
509 /* called for each page in a completed rpc.*/
510 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
512 struct ll_async_page *llap;
516 llap = llap_from_cookie(data);
522 page = llap->llap_page;
523 LASSERT(PageLocked(page));
525 LL_CDEBUG_PAGE(D_PAGE, page, "completing cmd %d with %d\n", cmd, rc);
527 if (cmd == OBD_BRW_READ && llap->llap_defer_uptodate)
528 ll_ra_count_put(ll_i2sbi(page->mapping->host), 1);
531 if (cmd == OBD_BRW_READ) {
532 if (!llap->llap_defer_uptodate)
533 SetPageUptodate(page);
535 llap->llap_write_queued = 0;
537 ClearPageError(page);
539 if (cmd == OBD_BRW_READ)
540 llap->llap_defer_uptodate = 0;
546 if (0 && cmd == OBD_BRW_WRITE) {
547 llap_write_complete(page->mapping->host, llap);
548 ll_try_done_writing(page->mapping->host);
551 page_cache_release(page);
555 /* the kernel calls us here when a page is unhashed from the page cache.
556 * the page will be locked and the kernel is holding a spinlock, so
557 * we need to be careful. we're just tearing down our book-keeping
559 void ll_removepage(struct page *page)
561 struct inode *inode = page->mapping->host;
562 struct obd_export *exp;
563 struct ll_async_page *llap;
564 struct ll_sb_info *sbi = ll_i2sbi(inode);
568 LASSERT(!in_interrupt());
570 /* sync pages or failed read pages can leave pages in the page
571 * cache that don't have our data associated with them anymore */
572 if (page->private == 0) {
577 LL_CDEBUG_PAGE(D_PAGE, page, "being evicted\n");
579 exp = ll_i2obdexp(inode);
581 CERROR("page %p ind %lu gave null export\n", page, page->index);
586 llap = llap_from_page(page);
588 CERROR("page %p ind %lu couldn't find llap: %ld\n", page,
589 page->index, PTR_ERR(llap));
594 //llap_write_complete(inode, llap);
595 rc = obd_teardown_async_page(exp, ll_i2info(inode)->lli_smd, NULL,
598 CERROR("page %p ind %lu failed: %d\n", page, page->index, rc);
600 /* this unconditional free is only safe because the page lock
601 * is providing exclusivity to memory pressure/truncate/writeback..*/
604 spin_lock(&sbi->ll_lock);
605 if (!list_empty(&llap->llap_proc_item))
606 list_del_init(&llap->llap_proc_item);
607 sbi->ll_pglist_gen++;
608 spin_unlock(&sbi->ll_lock);
609 OBD_FREE(llap, sizeof(*llap));
613 static int ll_page_matches(struct page *page, int fd_flags)
615 struct lustre_handle match_lockh = {0};
616 struct inode *inode = page->mapping->host;
617 ldlm_policy_data_t page_extent;
621 if (fd_flags & LL_FILE_GROUP_LOCKED)
624 page_extent.l_extent.start = (__u64)page->index << PAGE_CACHE_SHIFT;
625 page_extent.l_extent.end =
626 page_extent.l_extent.start + PAGE_CACHE_SIZE - 1;
627 flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
628 matches = obd_match(ll_i2sbi(inode)->ll_osc_exp,
629 ll_i2info(inode)->lli_smd, LDLM_EXTENT,
630 &page_extent, LCK_PR | LCK_PW, &flags, inode,
635 static int ll_issue_page_read(struct obd_export *exp,
636 struct ll_async_page *llap,
637 struct obd_io_group *oig, int defer)
639 struct page *page = llap->llap_page;
642 page_cache_get(page);
643 llap->llap_defer_uptodate = defer;
644 rc = obd_queue_group_io(exp, ll_i2info(page->mapping->host)->lli_smd,
645 NULL, oig, llap->llap_cookie, OBD_BRW_READ, 0,
646 PAGE_SIZE, 0, ASYNC_COUNT_STABLE | ASYNC_READY
649 LL_CDEBUG_PAGE(D_ERROR, page, "read queue failed: rc %d\n", rc);
650 page_cache_release(page);
655 #define RAS_CDEBUG(ras) \
656 CDEBUG(D_READA, "lrp %lu c %lu ws %lu wl %lu nra %lu\n", \
657 ras->ras_last_readpage, ras->ras_consecutive, \
658 ras->ras_window_start, ras->ras_window_len, \
659 ras->ras_next_readahead);
661 static int ll_readahead(struct ll_readahead_state *ras,
662 struct obd_export *exp, struct address_space *mapping,
663 struct obd_io_group *oig, int flags)
665 unsigned long i, start = 0, end = 0, reserved;
666 struct ll_async_page *llap;
672 kms = lov_merge_size(ll_i2info(mapping->host)->lli_smd, 1);
676 spin_lock(&ras->ras_lock);
678 if (ras->ras_window_len) {
679 start = ras->ras_next_readahead;
680 end = ras->ras_window_start + ras->ras_window_len - 1;
681 end = min(end, (unsigned long)(kms >> PAGE_CACHE_SHIFT));
682 ras->ras_next_readahead = max(end, end + 1);
687 spin_unlock(&ras->ras_lock);
692 reserved = ll_ra_count_get(ll_i2sbi(mapping->host), end - start + 1);
694 for (i = start; reserved > 0 && i <= end; i++) {
695 /* skip locked pages from previous readpage calls */
696 page = grab_cache_page_nowait(mapping, i);
698 CDEBUG(D_READA, "g_c_p_n failed\n");
702 /* we do this first so that we can see the page in the /proc
704 llap = llap_from_page(page);
705 if (IS_ERR(llap) || llap->llap_defer_uptodate)
708 /* skip completed pages */
709 if (Page_Uptodate(page))
712 /* bail when we hit the end of the lock. */
713 if ((rc = ll_page_matches(page, flags)) <= 0) {
714 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
715 "lock match failed: rc %d\n", rc);
720 rc = ll_issue_page_read(exp, llap, oig, 1);
724 LL_CDEBUG_PAGE(D_READA| D_PAGE, page,
725 "started read-ahead\n");
729 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
730 "skipping read-ahead\n");
734 page_cache_release(page);
737 LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
739 ll_ra_count_put(ll_i2sbi(mapping->host), reserved);
743 static void ras_set_start(struct ll_readahead_state *ras,
746 ras->ras_window_start = index & (~(PTLRPC_MAX_BRW_PAGES - 1));
747 ras->ras_next_readahead = max(ras->ras_window_start,
748 ras->ras_next_readahead);
751 /* called with the ras_lock held or from places where it doesn't matter */
752 static void ras_reset(struct ll_readahead_state *ras,
755 ras->ras_last_readpage = index;
756 ras->ras_consecutive = 1;
757 ras->ras_window_len = 0;
758 ras_set_start(ras, index);
759 ras->ras_next_readahead = ras->ras_window_start;
764 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras)
766 spin_lock_init(&ras->ras_lock);
770 static void ras_update(struct ll_readahead_state *ras,
771 unsigned long index, unsigned long max)
775 spin_lock(&ras->ras_lock);
777 if (index != ras->ras_last_readpage + 1) {
778 ras_reset(ras, index);
782 ras->ras_last_readpage = index;
783 ras->ras_consecutive++;
784 ras_set_start(ras, index);
786 if (ras->ras_consecutive == 2) {
787 ras->ras_window_len = PTLRPC_MAX_BRW_PAGES;
791 /* we need to increase the window sometimes. we'll arbitrarily
792 * do it half-way through the pages in an rpc */
793 if ((index & (PTLRPC_MAX_BRW_PAGES - 1)) ==
794 (PTLRPC_MAX_BRW_PAGES >> 1)) {
795 ras->ras_window_len += PTLRPC_MAX_BRW_PAGES;
796 ras->ras_window_len = min(ras->ras_window_len, max);
802 spin_unlock(&ras->ras_lock);
807 * for now we do our readpage the same on both 2.4 and 2.5. The kernel's
808 * read-ahead assumes it is valid to issue readpage all the way up to
809 * i_size, but our dlm locks make that not the case. We disable the
810 * kernel's read-ahead and do our own by walking ahead in the page cache
811 * checking for dlm lock coverage. the main difference between 2.4 and
812 * 2.6 is how read-ahead gets batched and issued, but we're using our own,
813 * so they look the same.
815 int ll_readpage(struct file *filp, struct page *page)
817 struct ll_file_data *fd = filp->private_data;
818 struct inode *inode = page->mapping->host;
819 struct obd_export *exp;
820 struct ll_async_page *llap;
821 struct obd_io_group *oig = NULL;
825 LASSERT(PageLocked(page));
826 LASSERT(!PageUptodate(page));
827 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),offset="LPX64"\n",
828 inode->i_ino, inode->i_generation, inode,
829 (((obd_off)page->index) << PAGE_SHIFT));
830 LASSERT(atomic_read(&filp->f_dentry->d_inode->i_count) > 0);
836 exp = ll_i2obdexp(inode);
838 GOTO(out, rc = -EINVAL);
840 llap = llap_from_page(page);
842 GOTO(out, rc = PTR_ERR(llap));
844 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
845 ras_update(&fd->fd_ras, page->index,
846 ll_i2sbi(inode)->ll_max_read_ahead_pages);
848 if (llap->llap_defer_uptodate) {
849 rc = ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
852 obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd,
854 LL_CDEBUG_PAGE(D_PAGE, page, "marking uptodate from defer\n");
855 SetPageUptodate(page);
857 GOTO(out_oig, rc = 0);
860 rc = ll_page_matches(page, fd->fd_flags);
862 LL_CDEBUG_PAGE(D_ERROR, page, "lock match failed: rc %d\n", rc);
867 static unsigned long next_print;
868 CDEBUG(D_INODE, "ino %lu page %lu (%llu) didn't match a lock\n",
869 inode->i_ino, page->index,
870 (long long)page->index << PAGE_CACHE_SHIFT);
871 if (time_after(jiffies, next_print)) {
872 CWARN("ino %lu page %lu (%llu) not covered by "
873 "a lock (mmap?). check debug logs.\n",
874 inode->i_ino, page->index,
875 (long long)page->index << PAGE_CACHE_SHIFT);
876 next_print = jiffies + 30 * HZ;
880 rc = ll_issue_page_read(exp, llap, oig, 0);
884 LL_CDEBUG_PAGE(D_PAGE, page, "queued readpage\n");
885 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
886 ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
889 rc = obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd, NULL, oig);