exofs.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com)
  4. * Copyright (C) 2005, 2006
  5. * International Business Machines
  6. * Copyright (C) 2008, 2009
  7. * Boaz Harrosh <bharrosh@panasas.com>
  8. *
  9. * Copyrights for code taken from ext2:
  10. * Copyright (C) 1992, 1993, 1994, 1995
  11. * Remy Card (card@masi.ibp.fr)
  12. * Laboratoire MASI - Institut Blaise Pascal
  13. * Universite Pierre et Marie Curie (Paris VI)
  14. * from
  15. * linux/fs/minix/inode.c
  16. * Copyright (C) 1991, 1992 Linus Torvalds
  17. *
  18. * This file is part of exofs.
  19. *
  20. * exofs is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation. Since it is based on ext2, and the only
  23. * valid version of GPL for the Linux kernel is version 2, the only valid
  24. * version of GPL for exofs is version 2.
  25. *
  26. * exofs is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU General Public License
  32. * along with exofs; if not, write to the Free Software
  33. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  34. */
  35. #include <linux/fs.h>
  36. #include <linux/time.h>
  37. #include "common.h"
  38. #ifndef __EXOFS_H__
  39. #define __EXOFS_H__
  40. #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a)
  41. #ifdef CONFIG_EXOFS_DEBUG
  42. #define EXOFS_DBGMSG(fmt, a...) \
  43. printk(KERN_NOTICE "exofs @%s:%d: " fmt, __func__, __LINE__, ##a)
  44. #else
  45. #define EXOFS_DBGMSG(fmt, a...) \
  46. do { if (0) printk(fmt, ##a); } while (0)
  47. #endif
  48. /* u64 has problems with printk this will cast it to unsigned long long */
  49. #define _LLU(x) (unsigned long long)(x)
  50. /*
  51. * our extension to the in-memory superblock
  52. */
  53. struct exofs_sb_info {
  54. struct osd_dev *s_dev; /* returned by get_osd_dev */
  55. osd_id s_pid; /* partition ID of file system*/
  56. int s_timeout; /* timeout for OSD operations */
  57. uint64_t s_nextid; /* highest object ID used */
  58. uint32_t s_numfiles; /* number of files on fs */
  59. spinlock_t s_next_gen_lock; /* spinlock for gen # update */
  60. u32 s_next_generation; /* next gen # to use */
  61. atomic_t s_curr_pending; /* number of pending commands */
  62. uint8_t s_cred[OSD_CAP_LEN]; /* all-powerful credential */
  63. };
  64. /*
  65. * our extension to the in-memory inode
  66. */
  67. struct exofs_i_info {
  68. unsigned long i_flags; /* various atomic flags */
  69. uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/
  70. uint32_t i_dir_start_lookup; /* which page to start lookup */
  71. wait_queue_head_t i_wq; /* wait queue for inode */
  72. uint64_t i_commit_size; /* the object's written length */
  73. uint8_t i_cred[OSD_CAP_LEN];/* all-powerful credential */
  74. struct inode vfs_inode; /* normal in-memory inode */
  75. };
  76. /*
  77. * our inode flags
  78. */
  79. #define OBJ_2BCREATED 0 /* object will be created soon*/
  80. #define OBJ_CREATED 1 /* object has been created on the osd*/
  81. static inline int obj_2bcreated(struct exofs_i_info *oi)
  82. {
  83. return test_bit(OBJ_2BCREATED, &oi->i_flags);
  84. }
  85. static inline void set_obj_2bcreated(struct exofs_i_info *oi)
  86. {
  87. set_bit(OBJ_2BCREATED, &oi->i_flags);
  88. }
  89. static inline int obj_created(struct exofs_i_info *oi)
  90. {
  91. return test_bit(OBJ_CREATED, &oi->i_flags);
  92. }
  93. static inline void set_obj_created(struct exofs_i_info *oi)
  94. {
  95. set_bit(OBJ_CREATED, &oi->i_flags);
  96. }
  97. int __exofs_wait_obj_created(struct exofs_i_info *oi);
  98. static inline int wait_obj_created(struct exofs_i_info *oi)
  99. {
  100. if (likely(obj_created(oi)))
  101. return 0;
  102. return __exofs_wait_obj_created(oi);
  103. }
  104. /*
  105. * get to our inode from the vfs inode
  106. */
  107. static inline struct exofs_i_info *exofs_i(struct inode *inode)
  108. {
  109. return container_of(inode, struct exofs_i_info, vfs_inode);
  110. }
  111. /*
  112. * Maximum count of links to a file
  113. */
  114. #define EXOFS_LINK_MAX 32000
  115. /*************************
  116. * function declarations *
  117. *************************/
  118. /* inode.c */
  119. void exofs_truncate(struct inode *inode);
  120. int exofs_setattr(struct dentry *, struct iattr *);
  121. int exofs_write_begin(struct file *file, struct address_space *mapping,
  122. loff_t pos, unsigned len, unsigned flags,
  123. struct page **pagep, void **fsdata);
  124. extern struct inode *exofs_iget(struct super_block *, unsigned long);
  125. struct inode *exofs_new_inode(struct inode *, int);
  126. extern int exofs_write_inode(struct inode *, int);
  127. extern void exofs_delete_inode(struct inode *);
  128. /* dir.c: */
  129. int exofs_add_link(struct dentry *, struct inode *);
  130. ino_t exofs_inode_by_name(struct inode *, struct dentry *);
  131. int exofs_delete_entry(struct exofs_dir_entry *, struct page *);
  132. int exofs_make_empty(struct inode *, struct inode *);
  133. struct exofs_dir_entry *exofs_find_entry(struct inode *, struct dentry *,
  134. struct page **);
  135. int exofs_empty_dir(struct inode *);
  136. struct exofs_dir_entry *exofs_dotdot(struct inode *, struct page **);
  137. ino_t exofs_parent_ino(struct dentry *child);
  138. int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *,
  139. struct inode *);
  140. /*********************
  141. * operation vectors *
  142. *********************/
  143. /* dir.c: */
  144. extern const struct file_operations exofs_dir_operations;
  145. /* file.c */
  146. extern const struct inode_operations exofs_file_inode_operations;
  147. extern const struct file_operations exofs_file_operations;
  148. /* inode.c */
  149. extern const struct address_space_operations exofs_aops;
  150. /* namei.c */
  151. extern const struct inode_operations exofs_dir_inode_operations;
  152. extern const struct inode_operations exofs_special_inode_operations;
  153. /* symlink.c */
  154. extern const struct inode_operations exofs_symlink_inode_operations;
  155. extern const struct inode_operations exofs_fast_symlink_inode_operations;
  156. #endif