diff options
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r-- | include/linux/pagemap.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 5da31c12101c..709742be02f0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -32,6 +32,34 @@ static inline void mapping_set_error(struct address_space *mapping, int error) | |||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
36 | #define AS_UNEVICTABLE (__GFP_BITS_SHIFT + 2) /* e.g., ramdisk, SHM_LOCK */ | ||
37 | |||
38 | static inline void mapping_set_unevictable(struct address_space *mapping) | ||
39 | { | ||
40 | set_bit(AS_UNEVICTABLE, &mapping->flags); | ||
41 | } | ||
42 | |||
43 | static inline void mapping_clear_unevictable(struct address_space *mapping) | ||
44 | { | ||
45 | clear_bit(AS_UNEVICTABLE, &mapping->flags); | ||
46 | } | ||
47 | |||
48 | static inline int mapping_unevictable(struct address_space *mapping) | ||
49 | { | ||
50 | if (likely(mapping)) | ||
51 | return test_bit(AS_UNEVICTABLE, &mapping->flags); | ||
52 | return !!mapping; | ||
53 | } | ||
54 | #else | ||
55 | static inline void mapping_set_unevictable(struct address_space *mapping) { } | ||
56 | static inline void mapping_clear_unevictable(struct address_space *mapping) { } | ||
57 | static inline int mapping_unevictable(struct address_space *mapping) | ||
58 | { | ||
59 | return 0; | ||
60 | } | ||
61 | #endif | ||
62 | |||
35 | static inline gfp_t mapping_gfp_mask(struct address_space * mapping) | 63 | static inline gfp_t mapping_gfp_mask(struct address_space * mapping) |
36 | { | 64 | { |
37 | return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; | 65 | return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; |
@@ -271,19 +299,19 @@ extern int __lock_page_killable(struct page *page); | |||
271 | extern void __lock_page_nosync(struct page *page); | 299 | extern void __lock_page_nosync(struct page *page); |
272 | extern void unlock_page(struct page *page); | 300 | extern void unlock_page(struct page *page); |
273 | 301 | ||
274 | static inline void set_page_locked(struct page *page) | 302 | static inline void __set_page_locked(struct page *page) |
275 | { | 303 | { |
276 | set_bit(PG_locked, &page->flags); | 304 | __set_bit(PG_locked, &page->flags); |
277 | } | 305 | } |
278 | 306 | ||
279 | static inline void clear_page_locked(struct page *page) | 307 | static inline void __clear_page_locked(struct page *page) |
280 | { | 308 | { |
281 | clear_bit(PG_locked, &page->flags); | 309 | __clear_bit(PG_locked, &page->flags); |
282 | } | 310 | } |
283 | 311 | ||
284 | static inline int trylock_page(struct page *page) | 312 | static inline int trylock_page(struct page *page) |
285 | { | 313 | { |
286 | return !test_and_set_bit(PG_locked, &page->flags); | 314 | return (likely(!test_and_set_bit_lock(PG_locked, &page->flags))); |
287 | } | 315 | } |
288 | 316 | ||
289 | /* | 317 | /* |
@@ -410,17 +438,17 @@ extern void __remove_from_page_cache(struct page *page); | |||
410 | 438 | ||
411 | /* | 439 | /* |
412 | * Like add_to_page_cache_locked, but used to add newly allocated pages: | 440 | * Like add_to_page_cache_locked, but used to add newly allocated pages: |
413 | * the page is new, so we can just run set_page_locked() against it. | 441 | * the page is new, so we can just run __set_page_locked() against it. |
414 | */ | 442 | */ |
415 | static inline int add_to_page_cache(struct page *page, | 443 | static inline int add_to_page_cache(struct page *page, |
416 | struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask) | 444 | struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask) |
417 | { | 445 | { |
418 | int error; | 446 | int error; |
419 | 447 | ||
420 | set_page_locked(page); | 448 | __set_page_locked(page); |
421 | error = add_to_page_cache_locked(page, mapping, offset, gfp_mask); | 449 | error = add_to_page_cache_locked(page, mapping, offset, gfp_mask); |
422 | if (unlikely(error)) | 450 | if (unlikely(error)) |
423 | clear_page_locked(page); | 451 | __clear_page_locked(page); |
424 | return error; | 452 | return error; |
425 | } | 453 | } |
426 | 454 | ||