xref: /openbmc/linux/fs/nilfs2/page.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1ae98043fSRyusuke Konishi /* SPDX-License-Identifier: GPL-2.0+ */
20bd49f94SRyusuke Konishi /*
3*94ee1d91SRyusuke Konishi  * Buffer/page management specific to NILFS
40bd49f94SRyusuke Konishi  *
50bd49f94SRyusuke Konishi  * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
60bd49f94SRyusuke Konishi  *
74b420ab4SRyusuke Konishi  * Written by Ryusuke Konishi and Seiji Kihara.
80bd49f94SRyusuke Konishi  */
90bd49f94SRyusuke Konishi 
100bd49f94SRyusuke Konishi #ifndef _NILFS_PAGE_H
110bd49f94SRyusuke Konishi #define _NILFS_PAGE_H
120bd49f94SRyusuke Konishi 
130bd49f94SRyusuke Konishi #include <linux/buffer_head.h>
140bd49f94SRyusuke Konishi #include "nilfs.h"
150bd49f94SRyusuke Konishi 
160bd49f94SRyusuke Konishi /*
170bd49f94SRyusuke Konishi  * Extended buffer state bits
180bd49f94SRyusuke Konishi  */
190bd49f94SRyusuke Konishi enum {
200bd49f94SRyusuke Konishi 	BH_NILFS_Allocated = BH_PrivateStart,
210bd49f94SRyusuke Konishi 	BH_NILFS_Node,
220bd49f94SRyusuke Konishi 	BH_NILFS_Volatile,
234e13e66bSRyusuke Konishi 	BH_NILFS_Checked,
24b1f6a4f2SRyusuke Konishi 	BH_NILFS_Redirected,
250bd49f94SRyusuke Konishi };
260bd49f94SRyusuke Konishi 
270bd49f94SRyusuke Konishi BUFFER_FNS(NILFS_Node, nilfs_node)		/* nilfs node buffers */
280bd49f94SRyusuke Konishi BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
294e13e66bSRyusuke Konishi BUFFER_FNS(NILFS_Checked, nilfs_checked)	/* buffer is verified */
30b1f6a4f2SRyusuke Konishi BUFFER_FNS(NILFS_Redirected, nilfs_redirected)	/* redirected to a copy */
310bd49f94SRyusuke Konishi 
320bd49f94SRyusuke Konishi 
330bd49f94SRyusuke Konishi int __nilfs_clear_page_dirty(struct page *);
340bd49f94SRyusuke Konishi 
350bd49f94SRyusuke Konishi struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
360bd49f94SRyusuke Konishi 				      unsigned long, unsigned long);
370bd49f94SRyusuke Konishi void nilfs_forget_buffer(struct buffer_head *);
380bd49f94SRyusuke Konishi void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
390bd49f94SRyusuke Konishi int nilfs_page_buffers_clean(struct page *);
400bd49f94SRyusuke Konishi void nilfs_page_bug(struct page *);
410bd49f94SRyusuke Konishi 
420bd49f94SRyusuke Konishi int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
430bd49f94SRyusuke Konishi void nilfs_copy_back_pages(struct address_space *, struct address_space *);
448c26c4e2SVyacheslav Dubeyko void nilfs_clear_dirty_page(struct page *, bool);
458c26c4e2SVyacheslav Dubeyko void nilfs_clear_dirty_pages(struct address_space *, bool);
460c6c44cbSRyusuke Konishi unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
470c6c44cbSRyusuke Konishi 					    unsigned int);
48622daaffSRyusuke Konishi unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
49622daaffSRyusuke Konishi 					    sector_t start_blk,
50622daaffSRyusuke Konishi 					    sector_t *blkoff);
510bd49f94SRyusuke Konishi 
520bd49f94SRyusuke Konishi #define NILFS_PAGE_BUG(page, m, a...) \
530bd49f94SRyusuke Konishi 	do { nilfs_page_bug(page); BUG(); } while (0)
540bd49f94SRyusuke Konishi 
550bd49f94SRyusuke Konishi static inline struct buffer_head *
nilfs_page_get_nth_block(struct page * page,unsigned int count)560bd49f94SRyusuke Konishi nilfs_page_get_nth_block(struct page *page, unsigned int count)
570bd49f94SRyusuke Konishi {
580bd49f94SRyusuke Konishi 	struct buffer_head *bh = page_buffers(page);
590bd49f94SRyusuke Konishi 
600bd49f94SRyusuke Konishi 	while (count-- > 0)
610bd49f94SRyusuke Konishi 		bh = bh->b_this_page;
620bd49f94SRyusuke Konishi 	get_bh(bh);
630bd49f94SRyusuke Konishi 	return bh;
640bd49f94SRyusuke Konishi }
650bd49f94SRyusuke Konishi 
660bd49f94SRyusuke Konishi #endif /* _NILFS_PAGE_H */
67