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 for the 2.5/2.6 kernel version
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/buffer_head.h>
38 #include <linux/mpage.h>
39 #include <linux/writeback.h>
40 #include <linux/stat.h>
41 #include <asm/uaccess.h>
42 #include <asm/segment.h>
44 #include <linux/pagemap.h>
45 #include <linux/smp_lock.h>
47 #define DEBUG_SUBSYSTEM S_LLITE
49 #include <linux/lustre_mds.h>
50 #include <linux/lustre_lite.h>
51 #include "llite_internal.h"
52 #include <linux/lustre_compat25.h>
54 /* called as the osc engine completes an rpc that included our ocp.
55 * the ocp itself holds a reference to the page and will drop it when
56 * the page is removed from the page cache. our job is simply to
57 * transfer rc into the page and unlock it */
58 void ll_complete_writepage_26(struct obd_client_page *ocp, int rc)
60 struct page *page = ocp->ocp_page;
62 LASSERT(page->private == (unsigned long)ocp);
63 LASSERT(PageLocked(page));
66 CERROR("writeback error on page %p index %ld: %d\n", page,
70 ocp->ocp_flags &= ~OCP_IO_READY;
72 /* let everyone get at this page again.. I wonder if this ordering
75 end_page_writeback(page);
77 page_cache_release(page);
80 static int ll_writepage_26(struct page *page, struct writeback_control *wbc)
82 struct obd_client_page *ocp;
85 LASSERT(!PageDirty(page));
86 LASSERT(PageLocked(page));
87 LASSERT(page->private != 0);
89 ocp = (struct obd_client_page *)page->private;
90 ocp->ocp_flags |= OCP_IO_READY;
94 /* filemap_fdatawait() makes me think we need to set PageWriteback
95 * on pages that are in flight. But our ocp mechanics doesn't
96 * really expect a page to be on both the osc lru and in flight.
97 * so for now, we don't unlock the page.. dirtiers whill wait
98 * for io to complete */
99 SetPageWriteback(page);
101 /* sadly, not all callers who writepage eventually call sync_page
102 * (ahem, kswapd) so we need to raise this page's priority
104 RETURN(ll_sync_page(page));
107 struct address_space_operations ll_aops = {
108 readpage: ll_readpage,
109 // readpages: ll_readpages,
110 // direct_IO: ll_direct_IO_26,
111 writepage: ll_writepage_26,
112 writepages: generic_writepages,
113 set_page_dirty: __set_page_dirty_nobuffers,
114 sync_page: block_sync_page,
115 prepare_write: ll_prepare_write,
116 commit_write: ll_commit_write,