blob: f3687c958fa848c20a3d17cab71b5a0da77de5d1 [file] [log] [blame]
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -07001/*
2 * page.h - buffer/page management specific to NILFS
3 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
Ryusuke Konishi4b420ab2016-05-23 16:23:09 -070016 * Written by Ryusuke Konishi and Seiji Kihara.
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070017 */
18
19#ifndef _NILFS_PAGE_H
20#define _NILFS_PAGE_H
21
22#include <linux/buffer_head.h>
23#include "nilfs.h"
24
25/*
26 * Extended buffer state bits
27 */
28enum {
29 BH_NILFS_Allocated = BH_PrivateStart,
30 BH_NILFS_Node,
31 BH_NILFS_Volatile,
Ryusuke Konishi4e13e662010-07-18 10:42:25 +090032 BH_NILFS_Checked,
Ryusuke Konishib1f6a4f2010-08-31 11:40:34 +090033 BH_NILFS_Redirected,
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070034};
35
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070036BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
37BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
Ryusuke Konishi4e13e662010-07-18 10:42:25 +090038BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
Ryusuke Konishib1f6a4f2010-08-31 11:40:34 +090039BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070040
41
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070042int __nilfs_clear_page_dirty(struct page *);
43
44struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
45 unsigned long, unsigned long);
46void nilfs_forget_buffer(struct buffer_head *);
47void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
48int nilfs_page_buffers_clean(struct page *);
49void nilfs_page_bug(struct page *);
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070050
51int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
52void nilfs_copy_back_pages(struct address_space *, struct address_space *);
Vyacheslav Dubeyko8c26c4e2013-04-30 15:27:48 -070053void nilfs_clear_dirty_page(struct page *, bool);
54void nilfs_clear_dirty_pages(struct address_space *, bool);
Christoph Hellwigb83ae6d2015-01-14 10:42:37 +010055void nilfs_mapping_init(struct address_space *mapping, struct inode *inode);
Ryusuke Konishi0c6c44c2016-05-23 16:23:39 -070056unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
57 unsigned int);
Ryusuke Konishi622daaff2010-12-26 16:38:43 +090058unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
59 sector_t start_blk,
60 sector_t *blkoff);
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070061
62#define NILFS_PAGE_BUG(page, m, a...) \
63 do { nilfs_page_bug(page); BUG(); } while (0)
64
65static inline struct buffer_head *
66nilfs_page_get_nth_block(struct page *page, unsigned int count)
67{
68 struct buffer_head *bh = page_buffers(page);
69
70 while (count-- > 0)
71 bh = bh->b_this_page;
72 get_bh(bh);
73 return bh;
74}
75
76#endif /* _NILFS_PAGE_H */