Loading...
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * page.h - buffer/page management specific to NILFS
4 *
5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
6 *
7 * Written by Ryusuke Konishi and Seiji Kihara.
8 */
9
10#ifndef _NILFS_PAGE_H
11#define _NILFS_PAGE_H
12
13#include <linux/buffer_head.h>
14#include "nilfs.h"
15
16/*
17 * Extended buffer state bits
18 */
19enum {
20 BH_NILFS_Allocated = BH_PrivateStart,
21 BH_NILFS_Node,
22 BH_NILFS_Volatile,
23 BH_NILFS_Checked,
24 BH_NILFS_Redirected,
25};
26
27BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
28BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
29BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
30BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
31
32
33int __nilfs_clear_page_dirty(struct page *);
34
35struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
36 unsigned long, unsigned long);
37void nilfs_forget_buffer(struct buffer_head *);
38void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
39int nilfs_page_buffers_clean(struct page *);
40void nilfs_page_bug(struct page *);
41
42int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
43void nilfs_copy_back_pages(struct address_space *, struct address_space *);
44void nilfs_clear_dirty_page(struct page *, bool);
45void nilfs_clear_dirty_pages(struct address_space *, bool);
46void nilfs_mapping_init(struct address_space *mapping, struct inode *inode);
47unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
48 unsigned int);
49unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
50 sector_t start_blk,
51 sector_t *blkoff);
52
53#define NILFS_PAGE_BUG(page, m, a...) \
54 do { nilfs_page_bug(page); BUG(); } while (0)
55
56static inline struct buffer_head *
57nilfs_page_get_nth_block(struct page *page, unsigned int count)
58{
59 struct buffer_head *bh = page_buffers(page);
60
61 while (count-- > 0)
62 bh = bh->b_this_page;
63 get_bh(bh);
64 return bh;
65}
66
67#endif /* _NILFS_PAGE_H */
1/*
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 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Written by Ryusuke Konishi <ryusuke@osrg.net>,
21 * Seiji Kihara <kihara@osrg.net>.
22 */
23
24#ifndef _NILFS_PAGE_H
25#define _NILFS_PAGE_H
26
27#include <linux/buffer_head.h>
28#include "nilfs.h"
29
30/*
31 * Extended buffer state bits
32 */
33enum {
34 BH_NILFS_Allocated = BH_PrivateStart,
35 BH_NILFS_Node,
36 BH_NILFS_Volatile,
37 BH_NILFS_Checked,
38 BH_NILFS_Redirected,
39};
40
41BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
42BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
43BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
44BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
45
46
47int __nilfs_clear_page_dirty(struct page *);
48
49struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
50 unsigned long, unsigned long);
51void nilfs_forget_buffer(struct buffer_head *);
52void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
53int nilfs_page_buffers_clean(struct page *);
54void nilfs_page_bug(struct page *);
55
56int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
57void nilfs_copy_back_pages(struct address_space *, struct address_space *);
58void nilfs_clear_dirty_pages(struct address_space *);
59void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
60 struct backing_dev_info *bdi);
61unsigned nilfs_page_count_clean_buffers(struct page *, unsigned, unsigned);
62unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
63 sector_t start_blk,
64 sector_t *blkoff);
65
66#define NILFS_PAGE_BUG(page, m, a...) \
67 do { nilfs_page_bug(page); BUG(); } while (0)
68
69static inline struct buffer_head *
70nilfs_page_get_nth_block(struct page *page, unsigned int count)
71{
72 struct buffer_head *bh = page_buffers(page);
73
74 while (count-- > 0)
75 bh = bh->b_this_page;
76 get_bh(bh);
77 return bh;
78}
79
80#endif /* _NILFS_PAGE_H */