Ryusuke Konishi | ae98043 | 2018-09-04 15:46:30 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 2 | /* |
Ryusuke Konishi | 94ee1d9 | 2021-11-08 18:35:01 -0800 | [diff] [blame] | 3 | * Buffer/page management specific to NILFS |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. |
| 6 | * |
Ryusuke Konishi | 4b420ab | 2016-05-23 16:23:09 -0700 | [diff] [blame] | 7 | * Written by Ryusuke Konishi and Seiji Kihara. |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 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 | */ |
| 19 | enum { |
| 20 | BH_NILFS_Allocated = BH_PrivateStart, |
| 21 | BH_NILFS_Node, |
| 22 | BH_NILFS_Volatile, |
Ryusuke Konishi | 4e13e66 | 2010-07-18 10:42:25 +0900 | [diff] [blame] | 23 | BH_NILFS_Checked, |
Ryusuke Konishi | b1f6a4f | 2010-08-31 11:40:34 +0900 | [diff] [blame] | 24 | BH_NILFS_Redirected, |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 27 | BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */ |
| 28 | BUFFER_FNS(NILFS_Volatile, nilfs_volatile) |
Ryusuke Konishi | 4e13e66 | 2010-07-18 10:42:25 +0900 | [diff] [blame] | 29 | BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */ |
Ryusuke Konishi | b1f6a4f | 2010-08-31 11:40:34 +0900 | [diff] [blame] | 30 | BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */ |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 31 | |
| 32 | |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 33 | int __nilfs_clear_page_dirty(struct page *); |
| 34 | |
| 35 | struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, |
| 36 | unsigned long, unsigned long); |
| 37 | void nilfs_forget_buffer(struct buffer_head *); |
| 38 | void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *); |
| 39 | int nilfs_page_buffers_clean(struct page *); |
| 40 | void nilfs_page_bug(struct page *); |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 41 | |
| 42 | int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); |
| 43 | void nilfs_copy_back_pages(struct address_space *, struct address_space *); |
Vyacheslav Dubeyko | 8c26c4e | 2013-04-30 15:27:48 -0700 | [diff] [blame] | 44 | void nilfs_clear_dirty_page(struct page *, bool); |
| 45 | void nilfs_clear_dirty_pages(struct address_space *, bool); |
Christoph Hellwig | b83ae6d | 2015-01-14 10:42:37 +0100 | [diff] [blame] | 46 | void nilfs_mapping_init(struct address_space *mapping, struct inode *inode); |
Ryusuke Konishi | 0c6c44c | 2016-05-23 16:23:39 -0700 | [diff] [blame] | 47 | unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int, |
| 48 | unsigned int); |
Ryusuke Konishi | 622daaff | 2010-12-26 16:38:43 +0900 | [diff] [blame] | 49 | unsigned long nilfs_find_uncommitted_extent(struct inode *inode, |
| 50 | sector_t start_blk, |
| 51 | sector_t *blkoff); |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 52 | |
| 53 | #define NILFS_PAGE_BUG(page, m, a...) \ |
| 54 | do { nilfs_page_bug(page); BUG(); } while (0) |
| 55 | |
| 56 | static inline struct buffer_head * |
| 57 | nilfs_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 */ |