page.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * Written by Ryusuke Konishi and Seiji Kihara.
  17. */
  18. #ifndef _NILFS_PAGE_H
  19. #define _NILFS_PAGE_H
  20. #include <linux/buffer_head.h>
  21. #include "nilfs.h"
  22. /*
  23. * Extended buffer state bits
  24. */
  25. enum {
  26. BH_NILFS_Allocated = BH_PrivateStart,
  27. BH_NILFS_Node,
  28. BH_NILFS_Volatile,
  29. BH_NILFS_Checked,
  30. BH_NILFS_Redirected,
  31. };
  32. BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
  33. BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
  34. BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
  35. BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
  36. int __nilfs_clear_page_dirty(struct page *);
  37. struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
  38. unsigned long, unsigned long);
  39. void nilfs_forget_buffer(struct buffer_head *);
  40. void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
  41. int nilfs_page_buffers_clean(struct page *);
  42. void nilfs_page_bug(struct page *);
  43. int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
  44. void nilfs_copy_back_pages(struct address_space *, struct address_space *);
  45. void nilfs_clear_dirty_page(struct page *, bool);
  46. void nilfs_clear_dirty_pages(struct address_space *, bool);
  47. void nilfs_mapping_init(struct address_space *mapping, struct inode *inode);
  48. unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
  49. unsigned int);
  50. unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
  51. sector_t start_blk,
  52. sector_t *blkoff);
  53. #define NILFS_PAGE_BUG(page, m, a...) \
  54. do { nilfs_page_bug(page); BUG(); } while (0)
  55. static inline struct buffer_head *
  56. nilfs_page_get_nth_block(struct page *page, unsigned int count)
  57. {
  58. struct buffer_head *bh = page_buffers(page);
  59. while (count-- > 0)
  60. bh = bh->b_this_page;
  61. get_bh(bh);
  62. return bh;
  63. }
  64. #endif /* _NILFS_PAGE_H */