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 static int ll_writepage_26(struct page *page, struct writeback_control *wbc)
56 struct inode *inode = page->mapping->host;
57 struct obd_export *exp;
58 struct ll_async_page *llap;
62 LASSERT(!PageDirty(page));
63 LASSERT(PageLocked(page));
65 exp = ll_i2obdexp(inode);
67 GOTO(out, rc = -EINVAL);
69 llap = llap_from_page(page);
71 GOTO(out, rc = PTR_ERR(llap));
74 if (llap->llap_write_queued) {
75 LL_CDEBUG_PAGE(D_PAGE, page, "marking urgent\n");
76 rc = obd_set_async_flags(exp, ll_i2info(inode)->lli_smd, NULL,
78 ASYNC_READY | ASYNC_URGENT);
80 llap->llap_write_queued = 1;
81 rc = obd_queue_async_io(exp, ll_i2info(inode)->lli_smd, NULL,
82 llap->llap_cookie, OBD_BRW_WRITE, 0, 0,
83 0, ASYNC_READY | ASYNC_URGENT);
85 LL_CDEBUG_PAGE(D_PAGE, page, "mmap write queued\n");
87 llap->llap_write_queued = 0;
90 page_cache_release(page);
97 struct address_space_operations ll_aops = {
98 .readpage = ll_readpage,
99 // .readpages = ll_readpages,
100 // .direct_IO = ll_direct_IO_26,
101 .writepage = ll_writepage_26,
102 .writepages = generic_writepages,
103 .set_page_dirty = __set_page_dirty_nobuffers,
105 .prepare_write = ll_prepare_write,
106 .commit_write = ll_commit_write,
107 .removepage = ll_removepage,