1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2011, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
39 #ifndef LUSTRE_PATCHLESS_COMPAT_H
40 #define LUSTRE_PATCHLESS_COMPAT_H
42 #include <linux/lustre_version.h>
45 #ifndef HAVE_TRUNCATE_COMPLETE_PAGE
46 #include <linux/list.h>
48 #include <linux/hash.h>
50 #ifndef HAVE_CANCEL_DIRTY_PAGE /* 2.6.20 */
51 #define cancel_dirty_page(page, size) clear_page_dirty(page)
54 #ifndef HAVE_DELETE_FROM_PAGE_CACHE /* 2.6.39 */
55 #ifndef HAVE_REMOVE_FROM_PAGE_CACHE /* 2.6.35 - 2.6.38 */
56 #ifdef HAVE_NR_PAGECACHE /* 2.6.18 */
57 #define __dec_zone_page_state(page, flag) atomic_add(-1, &nr_pagecache);
58 #endif /* HAVE_NR_PAGECACHE */
60 /* XXX copy & paste from 2.6.15 kernel */
61 static inline void ll_remove_from_page_cache(struct page *page)
63 struct address_space *mapping = page->mapping;
65 BUG_ON(!PageLocked(page));
67 #ifdef HAVE_RW_TREE_LOCK
68 write_lock_irq(&mapping->tree_lock);
70 cfs_spin_lock_irq(&mapping->tree_lock);
72 radix_tree_delete(&mapping->page_tree, page->index);
75 __dec_zone_page_state(page, NR_FILE_PAGES);
77 #ifdef HAVE_RW_TREE_LOCK
78 write_unlock_irq(&mapping->tree_lock);
80 cfs_spin_unlock_irq(&mapping->tree_lock);
83 #else /* HAVE_REMOVE_FROM_PAGE_CACHE */
84 #define ll_remove_from_page_cache(page) remove_from_page_cache(page)
85 #endif /* !HAVE_REMOVE_FROM_PAGE_CACHE */
87 static inline void ll_delete_from_page_cache(struct page *page)
89 ll_remove_from_page_cache(page);
90 page_cache_release(page);
92 #else /* HAVE_DELETE_FROM_PAGE_CACHE */
93 #define ll_delete_from_page_cache(page) delete_from_page_cache(page)
94 #endif /* !HAVE_DELETE_FROM_PAGE_CACHE */
97 truncate_complete_page(struct address_space *mapping, struct page *page)
99 if (page->mapping != mapping)
102 if (PagePrivate(page))
103 page->mapping->a_ops->invalidatepage(page, 0);
105 cancel_dirty_page(page, PAGE_SIZE);
106 ClearPageMappedToDisk(page);
107 ll_delete_from_page_cache(page);
109 #endif /* !HAVE_TRUNCATE_COMPLETE_PAGE */
111 #if !defined(HAVE_D_REHASH_COND) && !defined(HAVE___D_REHASH)
113 static inline void d_rehash_cond(struct dentry * entry, int lock)
116 spin_unlock(&dcache_lock);
121 spin_lock(&dcache_lock);
124 #define __d_rehash(dentry, lock) d_rehash_cond(dentry, lock)
125 #endif /* !HAVE_D_REHASH_COND && !HAVE___D_REHASH*/
128 # define ATTR_FROM_OPEN ATTR_OPEN
130 # ifndef ATTR_FROM_OPEN
131 # define ATTR_FROM_OPEN 0
133 #endif /* ATTR_OPEN */
139 #ifndef ATTR_CTIME_SET
141 * set ATTR_CTIME_SET to a high value to avoid any risk of collision with other
142 * ATTR_* attributes (see bug 13828)
144 #define ATTR_CTIME_SET (1 << 28)
147 #endif /* LUSTRE_PATCHLESS_COMPAT_H */