blob: 569263b23c0c49c26299f066354d7907c32df8b5 [file] [log] [blame]
Ryusuke Konishiae980432018-09-04 15:46:30 -07001/* SPDX-License-Identifier: GPL-2.0+ */
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -07002/*
Ryusuke Konishi94ee1d92021-11-08 18:35:01 -08003 * Buffer/page management specific to NILFS
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -07004 *
5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
6 *
Ryusuke Konishi4b420ab2016-05-23 16:23:09 -07007 * Written by Ryusuke Konishi and Seiji Kihara.
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -07008 */
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,
Ryusuke Konishi4e13e662010-07-18 10:42:25 +090023 BH_NILFS_Checked,
Ryusuke Konishib1f6a4f2010-08-31 11:40:34 +090024 BH_NILFS_Redirected,
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070025};
26
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070027BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
28BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
Ryusuke Konishi4e13e662010-07-18 10:42:25 +090029BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
Ryusuke Konishib1f6a4f2010-08-31 11:40:34 +090030BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070031
32
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070033int __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 *);
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070041
42int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
43void nilfs_copy_back_pages(struct address_space *, struct address_space *);
Vyacheslav Dubeyko8c26c4e2013-04-30 15:27:48 -070044void nilfs_clear_dirty_page(struct page *, bool);
45void nilfs_clear_dirty_pages(struct address_space *, bool);
Christoph Hellwigb83ae6d2015-01-14 10:42:37 +010046void nilfs_mapping_init(struct address_space *mapping, struct inode *inode);
Ryusuke Konishi0c6c44c2016-05-23 16:23:39 -070047unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
48 unsigned int);
Ryusuke Konishi622daaff2010-12-26 16:38:43 +090049unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
50 sector_t start_blk,
51 sector_t *blkoff);
Ryusuke Konishi0bd49f92009-04-06 19:01:27 -070052
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 */