Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / llite / rw26.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Lustre Lite I/O page cache routines for the 2.5/2.6 kernel version
5  *
6  *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
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.
13  *
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.
18  *
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.
22  */
23
24 #include <linux/config.h>
25 #include <linux/kernel.h>
26 #include <linux/mm.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>
35
36 #include <linux/fs.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>
43 #include <linux/mm.h>
44 #include <linux/pagemap.h>
45 #include <linux/smp_lock.h>
46
47 #define DEBUG_SUBSYSTEM S_LLITE
48
49 #include <linux/lustre_mds.h>
50 #include <linux/lustre_lite.h>
51 #include "llite_internal.h"
52 #include <linux/lustre_compat25.h>
53
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)
59 {
60         struct page *page = ocp->ocp_page;
61
62         LASSERT(page->private == (unsigned long)ocp);
63         LASSERT(PageLocked(page));
64
65         if (rc != 0) {
66                 CERROR("writeback error on page %p index %ld: %d\n", page,
67                        page->index, rc);
68                 SetPageError(page);
69         }
70         ocp->ocp_flags &= ~OCP_IO_READY;
71
72         /* let everyone get at this page again.. I wonder if this ordering
73          * is corect */
74         unlock_page(page);
75         end_page_writeback(page);
76
77         page_cache_release(page);
78 }
79
80 static int ll_writepage_26(struct page *page, struct writeback_control *wbc)
81 {
82         struct obd_client_page *ocp;
83         ENTRY;
84
85         LASSERT(!PageDirty(page));
86         LASSERT(PageLocked(page));
87         LASSERT(page->private != 0);
88
89         ocp = (struct obd_client_page *)page->private;
90         ocp->ocp_flags |= OCP_IO_READY;
91
92         page_cache_get(page);
93
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);
100
101         /* sadly, not all callers who writepage eventually call sync_page
102          * (ahem, kswapd) so we need to raise this page's priority 
103          * immediately */
104         RETURN(ll_sync_page(page));
105 }
106
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,
117         bmap: NULL
118 };