pagemap.h 17.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11
#ifndef _LINUX_PAGEMAP_H
#define _LINUX_PAGEMAP_H

/*
 * Copyright 1995 Linus Torvalds
 */
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/highmem.h>
#include <linux/compiler.h>
12
#include <linux/uaccess.h>
L
Linus Torvalds 已提交
13
#include <linux/gfp.h>
14
#include <linux/bitops.h>
N
Nick Piggin 已提交
15
#include <linux/hardirq.h> /* for in_interrupt() */
16
#include <linux/hugetlb_inline.h>
L
Linus Torvalds 已提交
17 18

/*
19
 * Bits in mapping->flags.
L
Linus Torvalds 已提交
20
 */
21
enum mapping_flags {
22 23 24 25 26
	AS_EIO		= 0,	/* IO error on async write */
	AS_ENOSPC	= 1,	/* ENOSPC on async write */
	AS_MM_ALL_LOCKS	= 2,	/* under mm_take_all_locks() */
	AS_UNEVICTABLE	= 3,	/* e.g., ramdisk, SHM_LOCK */
	AS_EXITING	= 4, 	/* final truncate in progress */
27
	/* writeback related tags are not used */
28
	AS_NO_WRITEBACK_TAGS = 5,
29
};
L
Linus Torvalds 已提交
30

31 32
static inline void mapping_set_error(struct address_space *mapping, int error)
{
33
	if (unlikely(error)) {
34 35 36 37 38 39 40
		if (error == -ENOSPC)
			set_bit(AS_ENOSPC, &mapping->flags);
		else
			set_bit(AS_EIO, &mapping->flags);
	}
}

41 42 43 44 45
static inline void mapping_set_unevictable(struct address_space *mapping)
{
	set_bit(AS_UNEVICTABLE, &mapping->flags);
}

46 47 48 49 50
static inline void mapping_clear_unevictable(struct address_space *mapping)
{
	clear_bit(AS_UNEVICTABLE, &mapping->flags);
}

51 52
static inline int mapping_unevictable(struct address_space *mapping)
{
53
	if (mapping)
54 55
		return test_bit(AS_UNEVICTABLE, &mapping->flags);
	return !!mapping;
56 57
}

58 59 60 61 62 63 64 65 66 67
static inline void mapping_set_exiting(struct address_space *mapping)
{
	set_bit(AS_EXITING, &mapping->flags);
}

static inline int mapping_exiting(struct address_space *mapping)
{
	return test_bit(AS_EXITING, &mapping->flags);
}

68 69 70 71 72 73 74 75 76 77
static inline void mapping_set_no_writeback_tags(struct address_space *mapping)
{
	set_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
}

static inline int mapping_use_writeback_tags(struct address_space *mapping)
{
	return !test_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
}

A
Al Viro 已提交
78
static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
L
Linus Torvalds 已提交
79
{
80
	return mapping->gfp_mask;
L
Linus Torvalds 已提交
81 82
}

83 84 85 86 87 88 89
/* Restricts the given gfp_mask to what the mapping allows. */
static inline gfp_t mapping_gfp_constraint(struct address_space *mapping,
		gfp_t gfp_mask)
{
	return mapping_gfp_mask(mapping) & gfp_mask;
}

L
Linus Torvalds 已提交
90 91 92 93
/*
 * This is non-atomic.  Only to be used before the mapping is activated.
 * Probably needs a barrier...
 */
A
Al Viro 已提交
94
static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
L
Linus Torvalds 已提交
95
{
96
	m->gfp_mask = mask;
L
Linus Torvalds 已提交
97 98
}

99
void release_pages(struct page **pages, int nr, bool cold);
L
Linus Torvalds 已提交
100

N
Nick Piggin 已提交
101 102
/*
 * speculatively take a reference to a page.
103 104
 * If the page is free (_refcount == 0), then _refcount is untouched, and 0
 * is returned. Otherwise, _refcount is incremented by 1 and 1 is returned.
N
Nick Piggin 已提交
105 106 107
 *
 * This function must be called inside the same rcu_read_lock() section as has
 * been used to lookup the page in the pagecache radix-tree (or page table):
108
 * this allows allocators to use a synchronize_rcu() to stabilize _refcount.
N
Nick Piggin 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
 *
 * Unless an RCU grace period has passed, the count of all pages coming out
 * of the allocator must be considered unstable. page_count may return higher
 * than expected, and put_page must be able to do the right thing when the
 * page has been finished with, no matter what it is subsequently allocated
 * for (because put_page is what is used here to drop an invalid speculative
 * reference).
 *
 * This is the interesting part of the lockless pagecache (and lockless
 * get_user_pages) locking protocol, where the lookup-side (eg. find_get_page)
 * has the following pattern:
 * 1. find page in radix tree
 * 2. conditionally increment refcount
 * 3. check the page is still in pagecache (if no, goto 1)
 *
124
 * Remove-side that cares about stability of _refcount (eg. reclaim) has the
N
Nick Piggin 已提交
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
 * following (with tree_lock held for write):
 * A. atomically check refcount is correct and set it to 0 (atomic_cmpxchg)
 * B. remove page from pagecache
 * C. free the page
 *
 * There are 2 critical interleavings that matter:
 * - 2 runs before A: in this case, A sees elevated refcount and bails out
 * - A runs before 2: in this case, 2 sees zero refcount and retries;
 *   subsequently, B will complete and 1 will find no page, causing the
 *   lookup to return NULL.
 *
 * It is possible that between 1 and 2, the page is removed then the exact same
 * page is inserted into the same position in pagecache. That's OK: the
 * old find_get_page using tree_lock could equally have run before or after
 * such a re-insertion, depending on order that locks are granted.
 *
 * Lookups racing against pagecache insertion isn't a big problem: either 1
 * will find the page or it will not. Likewise, the old find_get_page could run
 * either before the insertion or afterwards, depending on timing.
 */
static inline int page_cache_get_speculative(struct page *page)
{
	VM_BUG_ON(in_interrupt());

P
Paul E. McKenney 已提交
149
#ifdef CONFIG_TINY_RCU
150
# ifdef CONFIG_PREEMPT_COUNT
N
Nick Piggin 已提交
151 152 153 154 155 156 157 158 159 160 161
	VM_BUG_ON(!in_atomic());
# endif
	/*
	 * Preempt must be disabled here - we rely on rcu_read_lock doing
	 * this for us.
	 *
	 * Pagecache won't be truncated from interrupt context, so if we have
	 * found a page in the radix tree here, we have pinned its refcount by
	 * disabling preempt, and hence no need for the "speculative get" that
	 * SMP requires.
	 */
162
	VM_BUG_ON_PAGE(page_count(page) == 0, page);
163
	page_ref_inc(page);
N
Nick Piggin 已提交
164 165 166 167 168 169 170 171 172 173 174

#else
	if (unlikely(!get_page_unless_zero(page))) {
		/*
		 * Either the page has been freed, or will be freed.
		 * In either case, retry here and the caller should
		 * do the right thing (see comments above).
		 */
		return 0;
	}
#endif
175
	VM_BUG_ON_PAGE(PageTail(page), page);
N
Nick Piggin 已提交
176 177 178 179

	return 1;
}

180 181 182 183 184 185 186
/*
 * Same as above, but add instead of inc (could just be merged)
 */
static inline int page_cache_add_speculative(struct page *page, int count)
{
	VM_BUG_ON(in_interrupt());

187
#if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
188
# ifdef CONFIG_PREEMPT_COUNT
189 190
	VM_BUG_ON(!in_atomic());
# endif
191
	VM_BUG_ON_PAGE(page_count(page) == 0, page);
192
	page_ref_add(page, count);
193 194

#else
195
	if (unlikely(!page_ref_add_unless(page, count, 0)))
196 197
		return 0;
#endif
198
	VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page);
199 200 201 202

	return 1;
}

203
#ifdef CONFIG_NUMA
204
extern struct page *__page_cache_alloc(gfp_t gfp);
205
#else
206 207 208 209 210 211
static inline struct page *__page_cache_alloc(gfp_t gfp)
{
	return alloc_pages(gfp, 0);
}
#endif

L
Linus Torvalds 已提交
212 213
static inline struct page *page_cache_alloc(struct address_space *x)
{
214
	return __page_cache_alloc(mapping_gfp_mask(x));
L
Linus Torvalds 已提交
215 216 217 218
}

static inline struct page *page_cache_alloc_cold(struct address_space *x)
{
219
	return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
L
Linus Torvalds 已提交
220 221
}

222
static inline gfp_t readahead_gfp_mask(struct address_space *x)
223
{
224 225
	return mapping_gfp_mask(x) |
				  __GFP_COLD | __GFP_NORETRY | __GFP_NOWARN;
226 227
}

L
Linus Torvalds 已提交
228 229
typedef int filler_t(void *, struct page *);

230 231 232 233 234
pgoff_t page_cache_next_hole(struct address_space *mapping,
			     pgoff_t index, unsigned long max_scan);
pgoff_t page_cache_prev_hole(struct address_space *mapping,
			     pgoff_t index, unsigned long max_scan);

235 236 237 238 239 240 241 242
#define FGP_ACCESSED		0x00000001
#define FGP_LOCK		0x00000002
#define FGP_CREAT		0x00000004
#define FGP_WRITE		0x00000008
#define FGP_NOFS		0x00000010
#define FGP_NOWAIT		0x00000020

struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
243
		int fgp_flags, gfp_t cache_gfp_mask);
244 245 246 247 248 249 250 251 252 253 254 255 256 257

/**
 * find_get_page - find and get a page reference
 * @mapping: the address_space to search
 * @offset: the page index
 *
 * Looks up the page cache slot at @mapping & @offset.  If there is a
 * page cache page, it is returned with an increased refcount.
 *
 * Otherwise, %NULL is returned.
 */
static inline struct page *find_get_page(struct address_space *mapping,
					pgoff_t offset)
{
258
	return pagecache_get_page(mapping, offset, 0, 0);
259 260 261 262 263
}

static inline struct page *find_get_page_flags(struct address_space *mapping,
					pgoff_t offset, int fgp_flags)
{
264
	return pagecache_get_page(mapping, offset, fgp_flags, 0);
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
}

/**
 * find_lock_page - locate, pin and lock a pagecache page
 * pagecache_get_page - find and get a page reference
 * @mapping: the address_space to search
 * @offset: the page index
 *
 * Looks up the page cache slot at @mapping & @offset.  If there is a
 * page cache page, it is returned locked and with an increased
 * refcount.
 *
 * Otherwise, %NULL is returned.
 *
 * find_lock_page() may sleep.
 */
static inline struct page *find_lock_page(struct address_space *mapping,
					pgoff_t offset)
{
284
	return pagecache_get_page(mapping, offset, FGP_LOCK, 0);
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
}

/**
 * find_or_create_page - locate or add a pagecache page
 * @mapping: the page's address_space
 * @index: the page's index into the mapping
 * @gfp_mask: page allocation mode
 *
 * Looks up the page cache slot at @mapping & @offset.  If there is a
 * page cache page, it is returned locked and with an increased
 * refcount.
 *
 * If the page is not present, a new page is allocated using @gfp_mask
 * and added to the page cache and the VM's LRU list.  The page is
 * returned locked and with an increased refcount.
 *
 * On memory exhaustion, %NULL is returned.
 *
 * find_or_create_page() may sleep, even if @gfp_flags specifies an
 * atomic allocation!
 */
static inline struct page *find_or_create_page(struct address_space *mapping,
					pgoff_t offset, gfp_t gfp_mask)
{
	return pagecache_get_page(mapping, offset,
					FGP_LOCK|FGP_ACCESSED|FGP_CREAT,
311
					gfp_mask);
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
}

/**
 * grab_cache_page_nowait - returns locked page at given index in given cache
 * @mapping: target address_space
 * @index: the page index
 *
 * Same as grab_cache_page(), but do not wait if the page is unavailable.
 * This is intended for speculative data generators, where the data can
 * be regenerated if the page couldn't be grabbed.  This routine should
 * be safe to call while holding the lock for another page.
 *
 * Clear __GFP_FS when allocating the page to avoid recursion into the fs
 * and deadlock against the caller's locked page.
 */
static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
				pgoff_t index)
{
	return pagecache_get_page(mapping, index,
			FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
332
			mapping_gfp_mask(mapping));
333 334
}

335 336 337 338 339
struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset);
unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
			  unsigned int nr_entries, struct page **entries,
			  pgoff_t *indices);
L
Linus Torvalds 已提交
340 341
unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
			unsigned int nr_pages, struct page **pages);
342 343
unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
			       unsigned int nr_pages, struct page **pages);
L
Linus Torvalds 已提交
344 345
unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
			int tag, unsigned int nr_pages, struct page **pages);
R
Ross Zwisler 已提交
346 347 348
unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
			int tag, unsigned int nr_entries,
			struct page **entries, pgoff_t *indices);
L
Linus Torvalds 已提交
349

350 351
struct page *grab_cache_page_write_begin(struct address_space *mapping,
			pgoff_t index, unsigned flags);
352

L
Linus Torvalds 已提交
353 354 355
/*
 * Returns locked page at given index in given cache, creating it if needed.
 */
356 357
static inline struct page *grab_cache_page(struct address_space *mapping,
								pgoff_t index)
L
Linus Torvalds 已提交
358 359 360 361 362
{
	return find_or_create_page(mapping, index, mapping_gfp_mask(mapping));
}

extern struct page * read_cache_page(struct address_space *mapping,
363
				pgoff_t index, filler_t *filler, void *data);
364 365
extern struct page * read_cache_page_gfp(struct address_space *mapping,
				pgoff_t index, gfp_t gfp_mask);
L
Linus Torvalds 已提交
366 367 368
extern int read_cache_pages(struct address_space *mapping,
		struct list_head *pages, filler_t *filler, void *data);

369
static inline struct page *read_mapping_page(struct address_space *mapping,
370
				pgoff_t index, void *data)
371 372 373 374 375
{
	filler_t *filler = (filler_t *)mapping->a_ops->readpage;
	return read_cache_page(mapping, index, filler, data);
}

376
/*
377 378
 * Get index of the page with in radix-tree
 * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
379
 */
380
static inline pgoff_t page_to_index(struct page *page)
381
{
382 383 384
	pgoff_t pgoff;

	if (likely(!PageTransTail(page)))
385
		return page->index;
386 387 388 389 390

	/*
	 *  We don't initialize ->index for tail pages: calculate based on
	 *  head page
	 */
391
	pgoff = compound_head(page)->index;
392 393
	pgoff += page - compound_head(page);
	return pgoff;
394 395
}

396 397 398 399 400 401 402 403 404 405 406 407
/*
 * Get the offset in PAGE_SIZE.
 * (TODO: hugepage should have ->index in PAGE_SIZE)
 */
static inline pgoff_t page_to_pgoff(struct page *page)
{
	if (unlikely(PageHeadHuge(page)))
		return page->index << compound_order(page);

	return page_to_index(page);
}

L
Linus Torvalds 已提交
408 409 410 411 412
/*
 * Return byte-offset into filesystem object for page.
 */
static inline loff_t page_offset(struct page *page)
{
413
	return ((loff_t)page->index) << PAGE_SHIFT;
L
Linus Torvalds 已提交
414 415
}

416 417
static inline loff_t page_file_offset(struct page *page)
{
H
Huang Ying 已提交
418
	return ((loff_t)page_index(page)) << PAGE_SHIFT;
419 420
}

421 422 423
extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
				     unsigned long address);

L
Linus Torvalds 已提交
424 425 426
static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
					unsigned long address)
{
427 428 429 430
	pgoff_t pgoff;
	if (unlikely(is_vm_hugetlb_page(vma)))
		return linear_hugepage_index(vma, address);
	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
L
Linus Torvalds 已提交
431
	pgoff += vma->vm_pgoff;
432
	return pgoff;
L
Linus Torvalds 已提交
433 434
}

435 436
extern void __lock_page(struct page *page);
extern int __lock_page_killable(struct page *page);
437 438
extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
				unsigned int flags);
439
extern void unlock_page(struct page *page);
L
Linus Torvalds 已提交
440

N
Nick Piggin 已提交
441 442
static inline int trylock_page(struct page *page)
{
443
	page = compound_head(page);
N
Nick Piggin 已提交
444
	return (likely(!test_and_set_bit_lock(PG_locked, &page->flags)));
N
Nick Piggin 已提交
445 446
}

447 448 449
/*
 * lock_page may only be called if we have the page's inode pinned.
 */
L
Linus Torvalds 已提交
450 451 452
static inline void lock_page(struct page *page)
{
	might_sleep();
N
Nick Piggin 已提交
453
	if (!trylock_page(page))
L
Linus Torvalds 已提交
454 455
		__lock_page(page);
}
456

M
Matthew Wilcox 已提交
457 458 459 460 461 462 463 464
/*
 * lock_page_killable is like lock_page but can be interrupted by fatal
 * signals.  It returns 0 if it locked the page and -EINTR if it was
 * killed while waiting.
 */
static inline int lock_page_killable(struct page *page)
{
	might_sleep();
N
Nick Piggin 已提交
465
	if (!trylock_page(page))
M
Matthew Wilcox 已提交
466 467 468 469
		return __lock_page_killable(page);
	return 0;
}

470 471 472
/*
 * lock_page_or_retry - Lock the page, unless this would block and the
 * caller indicated that it can handle a retry.
473 474 475
 *
 * Return value and mmap_sem implications depend on flags; see
 * __lock_page_or_retry().
476 477 478 479 480 481 482 483
 */
static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm,
				     unsigned int flags)
{
	might_sleep();
	return trylock_page(page) || __lock_page_or_retry(page, mm, flags);
}

L
Linus Torvalds 已提交
484
/*
N
NeilBrown 已提交
485 486
 * This is exported only for wait_on_page_locked/wait_on_page_writeback,
 * and for filesystems which need to wait on PG_private.
L
Linus Torvalds 已提交
487
 */
488
extern void wait_on_page_bit(struct page *page, int bit_nr);
489
extern int wait_on_page_bit_killable(struct page *page, int bit_nr);
490
extern void wake_up_page_bit(struct page *page, int bit_nr);
491

N
NeilBrown 已提交
492 493
static inline void wake_up_page(struct page *page, int bit)
{
494 495 496
	if (!PageWaiters(page))
		return;
	wake_up_page_bit(page, bit);
N
NeilBrown 已提交
497 498
}

L
Linus Torvalds 已提交
499 500 501 502 503 504 505 506 507 508
/* 
 * Wait for a page to be unlocked.
 *
 * This must be called with the caller "holding" the page,
 * ie with increased "page->count" so that the page won't
 * go away during the wait..
 */
static inline void wait_on_page_locked(struct page *page)
{
	if (PageLocked(page))
509
		wait_on_page_bit(compound_head(page), PG_locked);
L
Linus Torvalds 已提交
510 511
}

512 513 514 515 516 517 518
static inline int wait_on_page_locked_killable(struct page *page)
{
	if (!PageLocked(page))
		return 0;
	return wait_on_page_bit_killable(compound_head(page), PG_locked);
}

L
Linus Torvalds 已提交
519 520 521 522 523 524 525 526 527 528
/* 
 * Wait for a page to complete writeback
 */
static inline void wait_on_page_writeback(struct page *page)
{
	if (PageWriteback(page))
		wait_on_page_bit(page, PG_writeback);
}

extern void end_page_writeback(struct page *page);
529
void wait_for_stable_page(struct page *page);
L
Linus Torvalds 已提交
530

531
void page_endio(struct page *page, bool is_write, int err);
532

533 534 535 536 537
/*
 * Add an arbitrary waiter to a page's wait queue
 */
extern void add_page_wait_queue(struct page *page, wait_queue_t *waiter);

L
Linus Torvalds 已提交
538
/*
539
 * Fault everything in given userspace address range in.
L
Linus Torvalds 已提交
540 541
 */
static inline int fault_in_pages_writeable(char __user *uaddr, int size)
542
{
543
	char __user *end = uaddr + size - 1;
544 545

	if (unlikely(size == 0))
546
		return 0;
547

548 549
	if (unlikely(uaddr > end))
		return -EFAULT;
550 551 552 553
	/*
	 * Writing zeroes into userspace here is OK, because we know that if
	 * the zero gets there, we'll be overwriting it.
	 */
554 555 556
	do {
		if (unlikely(__put_user(0, uaddr) != 0))
			return -EFAULT;
557
		uaddr += PAGE_SIZE;
558
	} while (uaddr <= end);
559 560 561 562

	/* Check whether the range spilled into the next page. */
	if (((unsigned long)uaddr & PAGE_MASK) ==
			((unsigned long)end & PAGE_MASK))
563
		return __put_user(0, end);
564

565
	return 0;
566 567
}

568
static inline int fault_in_pages_readable(const char __user *uaddr, int size)
569 570 571 572 573
{
	volatile char c;
	const char __user *end = uaddr + size - 1;

	if (unlikely(size == 0))
574
		return 0;
575

576 577 578 579 580 581
	if (unlikely(uaddr > end))
		return -EFAULT;

	do {
		if (unlikely(__get_user(c, uaddr) != 0))
			return -EFAULT;
582
		uaddr += PAGE_SIZE;
583
	} while (uaddr <= end);
584 585 586 587

	/* Check whether the range spilled into the next page. */
	if (((unsigned long)uaddr & PAGE_MASK) ==
			((unsigned long)end & PAGE_MASK)) {
588
		return __get_user(c, end);
589 590
	}

591
	(void)c;
592
	return 0;
593 594
}

N
Nick Piggin 已提交
595 596 597 598
int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
				pgoff_t index, gfp_t gfp_mask);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
				pgoff_t index, gfp_t gfp_mask);
599
extern void delete_from_page_cache(struct page *page);
J
Johannes Weiner 已提交
600
extern void __delete_from_page_cache(struct page *page, void *shadow);
601
int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
N
Nick Piggin 已提交
602 603 604

/*
 * Like add_to_page_cache_locked, but used to add newly allocated pages:
605
 * the page is new, so we can just run __SetPageLocked() against it.
N
Nick Piggin 已提交
606 607 608 609 610 611
 */
static inline int add_to_page_cache(struct page *page,
		struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask)
{
	int error;

612
	__SetPageLocked(page);
N
Nick Piggin 已提交
613 614
	error = add_to_page_cache_locked(page, mapping, offset, gfp_mask);
	if (unlikely(error))
615
		__ClearPageLocked(page);
N
Nick Piggin 已提交
616 617 618
	return error;
}

619 620
static inline unsigned long dir_pages(struct inode *inode)
{
621 622
	return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
			       PAGE_SHIFT;
623 624
}

L
Linus Torvalds 已提交
625
#endif /* _LINUX_PAGEMAP_H */