Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 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 | */ |
| 33 | enum { |
| 34 | BH_NILFS_Allocated = BH_PrivateStart, |
| 35 | BH_NILFS_Node, |
| 36 | BH_NILFS_Volatile, |
Ryusuke Konishi | 4e13e66 | 2010-07-18 10:42:25 +0900 | [diff] [blame] | 37 | BH_NILFS_Checked, |
Ryusuke Konishi | b1f6a4f | 2010-08-31 11:40:34 +0900 | [diff] [blame] | 38 | BH_NILFS_Redirected, |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | BUFFER_FNS(NILFS_Allocated, nilfs_allocated) /* nilfs private buffers */ |
| 42 | BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */ |
| 43 | BUFFER_FNS(NILFS_Volatile, nilfs_volatile) |
Ryusuke Konishi | 4e13e66 | 2010-07-18 10:42:25 +0900 | [diff] [blame] | 44 | BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */ |
Ryusuke Konishi | b1f6a4f | 2010-08-31 11:40:34 +0900 | [diff] [blame] | 45 | BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */ |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 46 | |
| 47 | |
| 48 | void nilfs_mark_buffer_dirty(struct buffer_head *bh); |
| 49 | int __nilfs_clear_page_dirty(struct page *); |
| 50 | |
| 51 | struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, |
| 52 | unsigned long, unsigned long); |
| 53 | void nilfs_forget_buffer(struct buffer_head *); |
| 54 | void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *); |
| 55 | int nilfs_page_buffers_clean(struct page *); |
| 56 | void nilfs_page_bug(struct page *); |
| 57 | struct page *nilfs_alloc_private_page(struct block_device *, int, |
| 58 | unsigned long); |
| 59 | void nilfs_free_private_page(struct page *); |
| 60 | |
| 61 | int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); |
| 62 | void nilfs_copy_back_pages(struct address_space *, struct address_space *); |
| 63 | void nilfs_clear_dirty_pages(struct address_space *); |
Ryusuke Konishi | ebdfed4 | 2010-09-06 12:05:43 +0900 | [diff] [blame] | 64 | void nilfs_mapping_init_once(struct address_space *mapping); |
| 65 | void nilfs_mapping_init(struct address_space *mapping, |
| 66 | struct backing_dev_info *bdi, |
| 67 | const struct address_space_operations *aops); |
Ryusuke Konishi | 0bd49f9 | 2009-04-06 19:01:27 -0700 | [diff] [blame] | 68 | unsigned nilfs_page_count_clean_buffers(struct page *, unsigned, unsigned); |
| 69 | |
| 70 | #define NILFS_PAGE_BUG(page, m, a...) \ |
| 71 | do { nilfs_page_bug(page); BUG(); } while (0) |
| 72 | |
| 73 | static inline struct buffer_head * |
| 74 | nilfs_page_get_nth_block(struct page *page, unsigned int count) |
| 75 | { |
| 76 | struct buffer_head *bh = page_buffers(page); |
| 77 | |
| 78 | while (count-- > 0) |
| 79 | bh = bh->b_this_page; |
| 80 | get_bh(bh); |
| 81 | return bh; |
| 82 | } |
| 83 | |
| 84 | #endif /* _NILFS_PAGE_H */ |