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 &&
71 (pg.off + 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,
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,
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_gr = lsm->lsm_object_gr;
123 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
124 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE|OBD_MD_FLMODE|OBD_MD_FLATIME|
125 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
127 CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n",
128 oa.o_id, inode->i_size);
130 /* truncate == punch from new size to absolute end of file */
131 /* NB: obd_punch must be called with i_sem held! It updates the kms! */
132 rc = obd_punch(ll_i2obdexp(inode), &oa, lsm, inode->i_size,
133 OBD_OBJECT_EOF, NULL);
135 CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino);
137 obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
138 OBD_MD_FLATIME | OBD_MD_FLMTIME |
145 __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms);
146 int ll_prepare_write(struct file *file, struct page *page, unsigned from,
149 struct inode *inode = page->mapping->host;
150 struct ll_inode_info *lli = ll_i2info(inode);
151 struct lov_stripe_md *lsm = lli->lli_smd;
152 obd_off offset = ((obd_off)page->index) << PAGE_SHIFT;
159 LASSERT(PageLocked(page));
160 (void)llap_cast_private(page); /* assertion */
162 /* Check to see if we should return -EIO right away */
165 pga.count = PAGE_SIZE;
168 oa.o_id = lsm->lsm_object_id;
169 oa.o_gr = lsm->lsm_object_gr;
170 oa.o_mode = inode->i_mode;
171 oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE
172 | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
174 rc = obd_brw(OBD_BRW_CHECK, ll_i2obdexp(inode), &oa, lsm, 1, &pga,
179 if (PageUptodate(page))
182 /* We're completely overwriting an existing page, so _don't_ set it up
183 * to date until commit_write */
184 if (from == 0 && to == PAGE_SIZE) {
185 POISON_PAGE(page, 0x11);
189 /* If are writing to a new page, no need to read old data. The extent
190 * locking will have updated the KMS, and for our purposes here we can
191 * treat it like i_size. */
192 kms = lov_merge_size(lsm, 1);
194 memset(kmap(page), 0, PAGE_SIZE);
196 GOTO(prepare_done, rc = 0);
199 /* XXX could be an async ocp read.. read-ahead? */
200 rc = ll_brw(OBD_BRW_READ, inode, &oa, page, 0);
202 /* bug 1598: don't clobber blksize */
203 oa.o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ);
204 obdo_refresh_inode(inode, &oa, oa.o_valid);
210 SetPageUptodate(page);
215 struct ll_async_page *llap_from_cookie(void *cookie)
217 struct ll_async_page *llap = cookie;
218 if (llap->llap_magic != LLAP_MAGIC)
219 return ERR_PTR(-EINVAL);
223 static int ll_ap_make_ready(void *data, int cmd)
225 struct ll_async_page *llap;
229 llap = llap_from_cookie(data);
233 page = llap->llap_page;
235 LASSERT(cmd != OBD_BRW_READ);
237 /* we're trying to write, but the page is locked.. come back later */
238 if (TryLockPage(page))
241 LL_CDEBUG_PAGE(D_PAGE, page, "made ready\n");
242 page_cache_get(page);
244 /* if we left PageDirty we might get another writepage call
245 * in the future. list walkers are bright enough
246 * to check page dirty so we can leave it on whatever list
247 * its on. XXX also, we're called with the cli list so if
248 * we got the page cache list we'd create a lock inversion
249 * with the removepage path which gets the page lock then the
251 clear_page_dirty(page);
255 /* We have two reasons for giving llite the opportunity to change the
256 * write length of a given queued page as it builds the RPC containing
259 * 1) Further extending writes may have landed in the page cache
260 * since a partial write first queued this page requiring us
261 * to write more from the page cache.
262 * 2) We might have raced with truncate and want to avoid performing
263 * write RPCs that are just going to be thrown away by the
264 * truncate's punch on the storage targets.
266 * The kms serves these purposes as it is set at both truncate and extending
269 static int ll_ap_refresh_count(void *data, int cmd)
271 struct ll_async_page *llap;
272 struct lov_stripe_md *lsm;
277 /* readpage queues with _COUNT_STABLE, shouldn't get here. */
278 LASSERT(cmd != OBD_BRW_READ);
280 llap = llap_from_cookie(data);
282 RETURN(PTR_ERR(llap));
284 page = llap->llap_page;
285 lsm = ll_i2info(page->mapping->host)->lli_smd;
286 kms = lov_merge_size(lsm, 1);
288 /* catch race with truncate */
289 if (((__u64)page->index << PAGE_SHIFT) >= kms)
292 /* catch sub-page write at end of file */
293 if (((__u64)page->index << PAGE_SHIFT) + PAGE_SIZE > kms)
294 return kms % PAGE_SIZE;
299 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
301 struct lov_stripe_md *lsm;
302 obd_flag valid_flags;
304 lsm = ll_i2info(inode)->lli_smd;
306 oa->o_id = lsm->lsm_object_id;
307 oa->o_gr = lsm->lsm_object_gr;
308 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
309 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
310 if (cmd == OBD_BRW_WRITE) {
311 oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH;
312 mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode);
313 obdo_fid(oa)->mds = ll_i2info(inode)->lli_mds;
314 oa->o_easize = ll_i2info(inode)->lli_io_epoch;
316 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
319 obdo_from_inode(oa, inode, valid_flags);
322 static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
324 struct ll_async_page *llap;
327 llap = llap_from_cookie(data);
333 ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
337 static struct obd_async_page_ops ll_async_page_ops = {
338 .ap_make_ready = ll_ap_make_ready,
339 .ap_refresh_count = ll_ap_refresh_count,
340 .ap_fill_obdo = ll_ap_fill_obdo,
341 .ap_completion = ll_ap_completion,
344 struct ll_async_page *llap_cast_private(struct page *page)
346 struct ll_async_page *llap = (struct ll_async_page *)page->private;
348 LASSERTF(llap == NULL || llap->llap_magic == LLAP_MAGIC,
349 "page %p private %lu gave magic %d which != %d\n",
350 page, page->private, llap->llap_magic, LLAP_MAGIC);
355 /* XXX have the exp be an argument? */
356 struct ll_async_page *llap_from_page(struct page *page)
358 struct ll_async_page *llap;
359 struct obd_export *exp;
360 struct inode *inode = page->mapping->host;
361 struct ll_sb_info *sbi = ll_i2sbi(inode);
365 llap = llap_cast_private(page);
369 exp = ll_i2obdexp(page->mapping->host);
371 RETURN(ERR_PTR(-EINVAL));
373 OBD_ALLOC(llap, sizeof(*llap));
375 RETURN(ERR_PTR(-ENOMEM));
376 llap->llap_magic = LLAP_MAGIC;
377 rc = obd_prep_async_page(exp, ll_i2info(inode)->lli_smd, NULL, page,
378 (obd_off)page->index << PAGE_SHIFT,
379 &ll_async_page_ops, llap, &llap->llap_cookie);
381 OBD_FREE(llap, sizeof(*llap));
385 CDEBUG(D_CACHE, "llap %p page %p cookie %p obj off "LPU64"\n", llap,
386 page, llap->llap_cookie, (obd_off)page->index << PAGE_SHIFT);
387 /* also zeroing the PRIVBITS low order bitflags */
388 page->private = (unsigned long)llap;
389 llap->llap_page = page;
391 spin_lock(&sbi->ll_lock);
392 sbi->ll_pglist_gen++;
393 list_add_tail(&llap->llap_proc_item, &sbi->ll_pglist);
394 spin_unlock(&sbi->ll_lock);
399 void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
401 /* update our write count to account for i_size increases that may have
402 * happened since we've queued the page for io. */
404 /* be careful not to return success without setting the page Uptodate or
405 * the next pass through prepare_write will read in stale data from disk. */
406 int ll_commit_write(struct file *file, struct page *page, unsigned from,
409 struct inode *inode = page->mapping->host;
410 struct ll_inode_info *lli = ll_i2info(inode);
411 struct lov_stripe_md *lsm = lli->lli_smd;
412 struct obd_export *exp = NULL;
413 struct ll_async_page *llap;
418 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
419 LASSERT(inode == file->f_dentry->d_inode);
420 LASSERT(PageLocked(page));
422 CDEBUG(D_INODE, "inode %p is writing page %p from %d to %d at %lu\n",
423 inode, page, from, to, page->index);
425 llap = llap_from_page(page);
427 RETURN(PTR_ERR(llap));
429 /* queue a write for some time in the future the first time we
431 if (!PageDirty(page)) {
432 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
433 LPROC_LL_DIRTY_MISSES);
435 exp = ll_i2obdexp(inode);
439 /* _make_ready only sees llap once we've unlocked the page */
440 llap->llap_write_queued = 1;
441 rc = obd_queue_async_io(exp, lsm, NULL, llap->llap_cookie,
442 OBD_BRW_WRITE, 0, 0, 0, 0);
443 if (rc != 0) { /* async failed, try sync.. */
444 struct obd_io_group *oig;
449 llap->llap_write_queued = 0;
450 rc = obd_queue_group_io(exp, lsm, NULL, oig,
452 OBD_BRW_WRITE, 0, to, 0,
453 ASYNC_READY | ASYNC_URGENT |
460 rc = obd_trigger_group_io(exp, lsm, NULL, oig);
469 LL_CDEBUG_PAGE(D_PAGE, page, "write queued\n");
470 //llap_write_pending(inode, llap);
472 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats,
473 LPROC_LL_DIRTY_HITS);
476 /* put the page in the page cache, from now on ll_removepage is
477 * responsible for cleaning up the llap */
478 set_page_dirty(page);
482 size = (((obd_off)page->index) << PAGE_SHIFT) + to;
483 lov_increase_kms(exp, lsm, size);
484 if (size > inode->i_size)
485 inode->i_size = size;
486 SetPageUptodate(page);
491 static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, unsigned long len)
496 spin_lock(&sbi->ll_lock);
497 ret = min(sbi->ll_max_read_ahead_pages - sbi->ll_read_ahead_pages,
499 sbi->ll_read_ahead_pages += ret;
500 spin_unlock(&sbi->ll_lock);
505 static void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
507 spin_lock(&sbi->ll_lock);
508 LASSERTF(sbi->ll_read_ahead_pages >= len, "r_a_p %lu len %lu\n",
509 sbi->ll_read_ahead_pages, len);
510 sbi->ll_read_ahead_pages -= len;
511 spin_unlock(&sbi->ll_lock);
514 /* called for each page in a completed rpc.*/
515 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
517 struct ll_async_page *llap;
521 llap = llap_from_cookie(data);
527 page = llap->llap_page;
528 LASSERT(PageLocked(page));
530 LL_CDEBUG_PAGE(D_PAGE, page, "completing cmd %d with %d\n", cmd, rc);
532 if (cmd == OBD_BRW_READ && llap->llap_defer_uptodate)
533 ll_ra_count_put(ll_i2sbi(page->mapping->host), 1);
536 if (cmd == OBD_BRW_READ) {
537 if (!llap->llap_defer_uptodate)
538 SetPageUptodate(page);
540 llap->llap_write_queued = 0;
542 ClearPageError(page);
544 if (cmd == OBD_BRW_READ)
545 llap->llap_defer_uptodate = 0;
551 if (0 && cmd == OBD_BRW_WRITE) {
552 llap_write_complete(page->mapping->host, llap);
553 ll_try_done_writing(page->mapping->host);
556 page_cache_release(page);
560 /* the kernel calls us here when a page is unhashed from the page cache.
561 * the page will be locked and the kernel is holding a spinlock, so
562 * we need to be careful. we're just tearing down our book-keeping
564 void ll_removepage(struct page *page)
566 struct inode *inode = page->mapping->host;
567 struct obd_export *exp;
568 struct ll_async_page *llap;
569 struct ll_sb_info *sbi = ll_i2sbi(inode);
573 LASSERT(!in_interrupt());
575 /* sync pages or failed read pages can leave pages in the page
576 * cache that don't have our data associated with them anymore */
577 if (page->private == 0) {
582 LL_CDEBUG_PAGE(D_PAGE, page, "being evicted\n");
584 exp = ll_i2obdexp(inode);
586 CERROR("page %p ind %lu gave null export\n", page, page->index);
591 llap = llap_from_page(page);
593 CERROR("page %p ind %lu couldn't find llap: %ld\n", page,
594 page->index, PTR_ERR(llap));
599 //llap_write_complete(inode, llap);
600 rc = obd_teardown_async_page(exp, ll_i2info(inode)->lli_smd, NULL,
603 CERROR("page %p ind %lu failed: %d\n", page, page->index, rc);
605 /* this unconditional free is only safe because the page lock
606 * is providing exclusivity to memory pressure/truncate/writeback..*/
609 spin_lock(&sbi->ll_lock);
610 if (!list_empty(&llap->llap_proc_item))
611 list_del_init(&llap->llap_proc_item);
612 sbi->ll_pglist_gen++;
613 spin_unlock(&sbi->ll_lock);
614 OBD_FREE(llap, sizeof(*llap));
618 static int ll_page_matches(struct page *page, int fd_flags)
620 struct lustre_handle match_lockh = {0};
621 struct inode *inode = page->mapping->host;
622 ldlm_policy_data_t page_extent;
626 if (fd_flags & LL_FILE_GROUP_LOCKED)
629 page_extent.l_extent.start = (__u64)page->index << PAGE_CACHE_SHIFT;
630 page_extent.l_extent.end =
631 page_extent.l_extent.start + PAGE_CACHE_SIZE - 1;
632 flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
633 matches = obd_match(ll_i2sbi(inode)->ll_osc_exp,
634 ll_i2info(inode)->lli_smd, LDLM_EXTENT,
635 &page_extent, LCK_PR | LCK_PW, &flags, inode,
640 static int ll_issue_page_read(struct obd_export *exp,
641 struct ll_async_page *llap,
642 struct obd_io_group *oig, int defer)
644 struct page *page = llap->llap_page;
647 page_cache_get(page);
648 llap->llap_defer_uptodate = defer;
649 rc = obd_queue_group_io(exp, ll_i2info(page->mapping->host)->lli_smd,
650 NULL, oig, llap->llap_cookie, OBD_BRW_READ, 0,
651 PAGE_SIZE, 0, ASYNC_COUNT_STABLE | ASYNC_READY
654 LL_CDEBUG_PAGE(D_ERROR, page, "read queue failed: rc %d\n", rc);
655 page_cache_release(page);
660 #define RAS_CDEBUG(ras) \
661 CDEBUG(D_READA, "lrp %lu c %lu ws %lu wl %lu nra %lu\n", \
662 ras->ras_last_readpage, ras->ras_consecutive, \
663 ras->ras_window_start, ras->ras_window_len, \
664 ras->ras_next_readahead);
666 static int ll_readahead(struct ll_readahead_state *ras,
667 struct obd_export *exp, struct address_space *mapping,
668 struct obd_io_group *oig, int flags)
670 unsigned long i, start = 0, end = 0, reserved;
671 struct ll_async_page *llap;
677 kms = lov_merge_size(ll_i2info(mapping->host)->lli_smd, 1);
681 spin_lock(&ras->ras_lock);
683 if (ras->ras_window_len) {
684 start = ras->ras_next_readahead;
685 end = ras->ras_window_start + ras->ras_window_len - 1;
686 end = min(end, (unsigned long)(kms >> PAGE_CACHE_SHIFT));
687 ras->ras_next_readahead = max(end, end + 1);
692 spin_unlock(&ras->ras_lock);
697 reserved = ll_ra_count_get(ll_i2sbi(mapping->host), end - start + 1);
699 for (i = start; reserved > 0 && i <= end; i++) {
700 /* skip locked pages from previous readpage calls */
701 page = grab_cache_page_nowait(mapping, i);
703 CDEBUG(D_READA, "g_c_p_n failed\n");
707 /* we do this first so that we can see the page in the /proc
709 llap = llap_from_page(page);
710 if (IS_ERR(llap) || llap->llap_defer_uptodate)
713 /* skip completed pages */
714 if (Page_Uptodate(page))
717 /* bail when we hit the end of the lock. */
718 if ((rc = ll_page_matches(page, flags)) <= 0) {
719 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
720 "lock match failed: rc %d\n", rc);
725 rc = ll_issue_page_read(exp, llap, oig, 1);
729 LL_CDEBUG_PAGE(D_READA| D_PAGE, page,
730 "started read-ahead\n");
734 LL_CDEBUG_PAGE(D_READA | D_PAGE, page,
735 "skipping read-ahead\n");
739 page_cache_release(page);
742 LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
744 ll_ra_count_put(ll_i2sbi(mapping->host), reserved);
748 static void ras_set_start(struct ll_readahead_state *ras,
751 ras->ras_window_start = index & (~(PTLRPC_MAX_BRW_PAGES - 1));
752 ras->ras_next_readahead = max(ras->ras_window_start,
753 ras->ras_next_readahead);
756 /* called with the ras_lock held or from places where it doesn't matter */
757 static void ras_reset(struct ll_readahead_state *ras,
760 ras->ras_last_readpage = index;
761 ras->ras_consecutive = 1;
762 ras->ras_window_len = 0;
763 ras_set_start(ras, index);
764 ras->ras_next_readahead = ras->ras_window_start;
769 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras)
771 spin_lock_init(&ras->ras_lock);
775 static void ras_update(struct ll_readahead_state *ras,
776 unsigned long index, unsigned long max)
780 spin_lock(&ras->ras_lock);
782 if (index != ras->ras_last_readpage + 1) {
783 ras_reset(ras, index);
787 ras->ras_last_readpage = index;
788 ras->ras_consecutive++;
789 ras_set_start(ras, index);
791 if (ras->ras_consecutive == 2) {
792 ras->ras_window_len = PTLRPC_MAX_BRW_PAGES;
796 /* we need to increase the window sometimes. we'll arbitrarily
797 * do it half-way through the pages in an rpc */
798 if ((index & (PTLRPC_MAX_BRW_PAGES - 1)) ==
799 (PTLRPC_MAX_BRW_PAGES >> 1)) {
800 ras->ras_window_len += PTLRPC_MAX_BRW_PAGES;
801 ras->ras_window_len = min(ras->ras_window_len, max);
807 spin_unlock(&ras->ras_lock);
812 * for now we do our readpage the same on both 2.4 and 2.5. The kernel's
813 * read-ahead assumes it is valid to issue readpage all the way up to
814 * i_size, but our dlm locks make that not the case. We disable the
815 * kernel's read-ahead and do our own by walking ahead in the page cache
816 * checking for dlm lock coverage. the main difference between 2.4 and
817 * 2.6 is how read-ahead gets batched and issued, but we're using our own,
818 * so they look the same.
820 int ll_readpage(struct file *filp, struct page *page)
822 struct ll_file_data *fd = filp->private_data;
823 struct inode *inode = page->mapping->host;
824 struct obd_export *exp;
825 struct ll_async_page *llap;
826 struct obd_io_group *oig = NULL;
830 LASSERT(PageLocked(page));
831 LASSERT(!PageUptodate(page));
832 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),offset="LPX64"\n",
833 inode->i_ino, inode->i_generation, inode,
834 (((obd_off)page->index) << PAGE_SHIFT));
835 LASSERT(atomic_read(&filp->f_dentry->d_inode->i_count) > 0);
841 exp = ll_i2obdexp(inode);
843 GOTO(out, rc = -EINVAL);
845 llap = llap_from_page(page);
847 GOTO(out, rc = PTR_ERR(llap));
849 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
850 ras_update(&fd->fd_ras, page->index,
851 ll_i2sbi(inode)->ll_max_read_ahead_pages);
853 if (llap->llap_defer_uptodate) {
854 rc = ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
857 obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd,
859 LL_CDEBUG_PAGE(D_PAGE, page, "marking uptodate from defer\n");
860 SetPageUptodate(page);
862 GOTO(out_oig, rc = 0);
865 rc = ll_page_matches(page, fd->fd_flags);
867 LL_CDEBUG_PAGE(D_ERROR, page, "lock match failed: rc %d\n", rc);
872 static unsigned long next_print;
873 CDEBUG(D_INODE, "ino %lu page %lu (%llu) didn't match a lock\n",
874 inode->i_ino, page->index,
875 (long long)page->index << PAGE_CACHE_SHIFT);
876 if (time_after(jiffies, next_print)) {
877 CWARN("ino %lu page %lu (%llu) not covered by "
878 "a lock (mmap?). check debug logs.\n",
879 inode->i_ino, page->index,
880 (long long)page->index << PAGE_CACHE_SHIFT);
881 next_print = jiffies + 30 * HZ;
885 rc = ll_issue_page_read(exp, llap, oig, 0);
889 LL_CDEBUG_PAGE(D_PAGE, page, "queued readpage\n");
890 if (ll_i2sbi(inode)->ll_flags & LL_SBI_READAHEAD)
891 ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
894 rc = obd_trigger_group_io(exp, ll_i2info(inode)->lli_smd, NULL, oig);