page.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef _NILFS_PAGE_H
  24. #define _NILFS_PAGE_H
  25. #include <linux/buffer_head.h>
  26. #include "nilfs.h"
  27. /*
  28. * Extended buffer state bits
  29. */
  30. enum {
  31. BH_NILFS_Allocated = BH_PrivateStart,
  32. BH_NILFS_Node,
  33. BH_NILFS_Volatile,
  34. };
  35. BUFFER_FNS(NILFS_Allocated, nilfs_allocated) /* nilfs private buffers */
  36. BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */
  37. BUFFER_FNS(NILFS_Volatile, nilfs_volatile)
  38. void nilfs_mark_buffer_dirty(struct buffer_head *bh);
  39. int __nilfs_clear_page_dirty(struct page *);
  40. struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
  41. unsigned long, unsigned long);
  42. void nilfs_forget_buffer(struct buffer_head *);
  43. void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
  44. int nilfs_page_buffers_clean(struct page *);
  45. void nilfs_page_bug(struct page *);
  46. struct page *nilfs_alloc_private_page(struct block_device *, int,
  47. unsigned long);
  48. void nilfs_free_private_page(struct page *);
  49. int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
  50. void nilfs_copy_back_pages(struct address_space *, struct address_space *);
  51. void nilfs_clear_dirty_pages(struct address_space *);
  52. unsigned nilfs_page_count_clean_buffers(struct page *, unsigned, unsigned);
  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 */