4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2014, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #ifndef LUSTRE_PATCHLESS_COMPAT_H
34 #define LUSTRE_PATCHLESS_COMPAT_H
38 #ifndef HAVE_TRUNCATE_COMPLETE_PAGE
39 #include <linux/list.h>
40 #include <linux/hash.h>
42 #ifndef HAVE_DELETE_FROM_PAGE_CACHE /* 2.6.39 */
43 #ifndef HAVE_REMOVE_FROM_PAGE_CACHE /* 2.6.35 - 2.6.38 */
45 /* XXX copy & paste from 2.6.15 kernel */
46 static inline void ll_remove_from_page_cache(struct page *page)
48 struct address_space *mapping = page->mapping;
50 BUG_ON(!PageLocked(page));
52 spin_lock_irq(&mapping->tree_lock);
53 radix_tree_delete(&mapping->page_tree, page->index);
56 __dec_zone_page_state(page, NR_FILE_PAGES);
58 spin_unlock_irq(&mapping->tree_lock);
60 #else /* HAVE_REMOVE_FROM_PAGE_CACHE */
61 #define ll_remove_from_page_cache(page) remove_from_page_cache(page)
62 #endif /* !HAVE_REMOVE_FROM_PAGE_CACHE */
64 static inline void ll_delete_from_page_cache(struct page *page)
66 ll_remove_from_page_cache(page);
69 #else /* HAVE_DELETE_FROM_PAGE_CACHE */
70 #define ll_delete_from_page_cache(page) delete_from_page_cache(page)
71 #endif /* !HAVE_DELETE_FROM_PAGE_CACHE */
74 ll_cancel_dirty_page(struct address_space *mapping, struct page *page)
76 #ifdef HAVE_NEW_CANCEL_DIRTY_PAGE
77 cancel_dirty_page(page);
78 #elif defined(HAVE_CANCEL_DIRTY_PAGE)
79 cancel_dirty_page(page, PAGE_SIZE);
81 if (TestClearPageDirty(page))
82 account_page_cleaned(page, mapping);
83 #endif /* HAVE_NEW_CANCEL_DIRTY_PAGE */
87 truncate_complete_page(struct address_space *mapping, struct page *page)
89 if (page->mapping != mapping)
92 if (PagePrivate(page))
93 #ifdef HAVE_INVALIDATE_RANGE
94 page->mapping->a_ops->invalidatepage(page, 0, PAGE_SIZE);
96 page->mapping->a_ops->invalidatepage(page, 0);
99 ll_cancel_dirty_page(mapping, page);
100 ClearPageMappedToDisk(page);
101 ll_delete_from_page_cache(page);
103 #endif /* !HAVE_TRUNCATE_COMPLETE_PAGE */
105 #ifdef HAVE_DCACHE_LOCK
106 # define dget_dlock(d) dget_locked(d)
107 # define ll_d_count(d) atomic_read(&(d)->d_count)
108 #elif defined(HAVE_D_COUNT)
109 # define ll_d_count(d) d_count(d)
111 # define ll_d_count(d) ((d)->d_count)
112 #endif /* HAVE_DCACHE_LOCK */
114 #ifndef HAVE_IN_COMPAT_SYSCALL
115 #define in_compat_syscall is_compat_task
118 #endif /* LUSTRE_PATCHLESS_COMPAT_H */