porting 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. Changes since 2.5.0:
  2. ---
  3. [recommended]
  4. New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
  5. sb_set_blocksize() and sb_min_blocksize().
  6. Use them.
  7. (sb_find_get_block() replaces 2.4's get_hash_table())
  8. ---
  9. [recommended]
  10. New methods: ->alloc_inode() and ->destroy_inode().
  11. Remove inode->u.foo_inode_i
  12. Declare
  13. struct foo_inode_info {
  14. /* fs-private stuff */
  15. struct inode vfs_inode;
  16. };
  17. static inline struct foo_inode_info *FOO_I(struct inode *inode)
  18. {
  19. return list_entry(inode, struct foo_inode_info, vfs_inode);
  20. }
  21. Use FOO_I(inode) instead of &inode->u.foo_inode_i;
  22. Add foo_alloc_inode() and foo_destory_inode() - the former should allocate
  23. foo_inode_info and return the address of ->vfs_inode, the latter should free
  24. FOO_I(inode) (see in-tree filesystems for examples).
  25. Make them ->alloc_inode and ->destroy_inode in your super_operations.
  26. Keep in mind that now you need explicit initialization of private data -
  27. typically in ->read_inode() and after getting an inode from new_inode().
  28. At some point that will become mandatory.
  29. ---
  30. [mandatory]
  31. Change of file_system_type method (->read_super to ->get_sb)
  32. ->read_super() is no more. Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
  33. Turn your foo_read_super() into a function that would return 0 in case of
  34. success and negative number in case of error (-EINVAL unless you have more
  35. informative error value to report). Call it foo_fill_super(). Now declare
  36. struct super_block foo_get_sb(struct file_system_type *fs_type,
  37. int flags, const char *dev_name, void *data)
  38. {
  39. return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
  40. }
  41. (or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
  42. filesystem).
  43. Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
  44. foo_get_sb.
  45. ---
  46. [mandatory]
  47. Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
  48. Most likely there is no need to change anything, but if you relied on
  49. global exclusion between renames for some internal purpose - you need to
  50. change your internal locking. Otherwise exclusion warranties remain the
  51. same (i.e. parents and victim are locked, etc.).
  52. ---
  53. [informational]
  54. Now we have the exclusion between ->lookup() and directory removal (by
  55. ->rmdir() and ->rename()). If you used to need that exclusion and do
  56. it by internal locking (most of filesystems couldn't care less) - you
  57. can relax your locking.
  58. ---
  59. [mandatory]
  60. ->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
  61. ->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
  62. and ->readdir() are called without BKL now. Grab it on entry, drop upon return
  63. - that will guarantee the same locking you used to have. If your method or its
  64. parts do not need BKL - better yet, now you can shift lock_kernel() and
  65. unlock_kernel() so that they would protect exactly what needs to be
  66. protected.
  67. ---
  68. [mandatory]
  69. BKL is also moved from around sb operations. ->write_super() Is now called
  70. without BKL held. BKL should have been shifted into individual fs sb_op
  71. functions. If you don't need it, remove it.
  72. ---
  73. [informational]
  74. check for ->link() target not being a directory is done by callers. Feel
  75. free to drop it...
  76. ---
  77. [informational]
  78. ->link() callers hold ->i_sem on the object we are linking to. Some of your
  79. problems might be over...
  80. ---
  81. [mandatory]
  82. new file_system_type method - kill_sb(superblock). If you are converting
  83. an existing filesystem, set it according to ->fs_flags:
  84. FS_REQUIRES_DEV - kill_block_super
  85. FS_LITTER - kill_litter_super
  86. neither - kill_anon_super
  87. FS_LITTER is gone - just remove it from fs_flags.
  88. ---
  89. [mandatory]
  90. FS_SINGLE is gone (actually, that had happened back when ->get_sb()
  91. went in - and hadn't been documented ;-/). Just remove it from fs_flags
  92. (and see ->get_sb() entry for other actions).
  93. ---
  94. [mandatory]
  95. ->setattr() is called without BKL now. Caller _always_ holds ->i_sem, so
  96. watch for ->i_sem-grabbing code that might be used by your ->setattr().
  97. Callers of notify_change() need ->i_sem now.
  98. ---
  99. [recommended]
  100. New super_block field "struct export_operations *s_export_op" for
  101. explicit support for exporting, e.g. via NFS. The structure is fully
  102. documented at its declaration in include/linux/fs.h, and in
  103. Documentation/filesystems/Exporting.
  104. Briefly it allows for the definition of decode_fh and encode_fh operations
  105. to encode and decode filehandles, and allows the filesystem to use
  106. a standard helper function for decode_fh, and provide file-system specific
  107. support for this helper, particularly get_parent.
  108. It is planned that this will be required for exporting once the code
  109. settles down a bit.
  110. [mandatory]
  111. s_export_op is now required for exporting a filesystem.
  112. isofs, ext2, ext3, resierfs, fat
  113. can be used as examples of very different filesystems.
  114. ---
  115. [mandatory]
  116. iget4() and the read_inode2 callback have been superseded by iget5_locked()
  117. which has the following prototype,
  118. struct inode *iget5_locked(struct super_block *sb, unsigned long ino,
  119. int (*test)(struct inode *, void *),
  120. int (*set)(struct inode *, void *),
  121. void *data);
  122. 'test' is an additional function that can be used when the inode
  123. number is not sufficient to identify the actual file object. 'set'
  124. should be a non-blocking function that initializes those parts of a
  125. newly created inode to allow the test function to succeed. 'data' is
  126. passed as an opaque value to both test and set functions.
  127. When the inode has been created by iget5_locked(), it will be returned with
  128. the I_NEW flag set and will still be locked. read_inode has not been
  129. called so the file system still has to finalize the initialization. Once
  130. the inode is initialized it must be unlocked by calling unlock_new_inode().
  131. The filesystem is responsible for setting (and possibly testing) i_ino
  132. when appropriate. There is also a simpler iget_locked function that
  133. just takes the superblock and inode number as arguments and does the
  134. test and set for you.
  135. e.g.
  136. inode = iget_locked(sb, ino);
  137. if (inode->i_state & I_NEW) {
  138. read_inode_from_disk(inode);
  139. unlock_new_inode(inode);
  140. }
  141. ---
  142. [recommended]
  143. ->getattr() finally getting used. See instances in nfs, minix, etc.
  144. ---
  145. [mandatory]
  146. ->revalidate() is gone. If your filesystem had it - provide ->getattr()
  147. and let it call whatever you had as ->revlidate() + (for symlinks that
  148. had ->revalidate()) add calls in ->follow_link()/->readlink().
  149. ---
  150. [mandatory]
  151. ->d_parent changes are not protected by BKL anymore. Read access is safe
  152. if at least one of the following is true:
  153. * filesystem has no cross-directory rename()
  154. * dcache_lock is held
  155. * we know that parent had been locked (e.g. we are looking at
  156. ->d_parent of ->lookup() argument).
  157. * we are called from ->rename().
  158. * the child's ->d_lock is held
  159. Audit your code and add locking if needed. Notice that any place that is
  160. not protected by the conditions above is risky even in the old tree - you
  161. had been relying on BKL and that's prone to screwups. Old tree had quite
  162. a few holes of that kind - unprotected access to ->d_parent leading to
  163. anything from oops to silent memory corruption.
  164. ---
  165. [mandatory]
  166. FS_NOMOUNT is gone. If you use it - just set MS_NOUSER in flags
  167. (see rootfs for one kind of solution and bdev/socket/pipe for another).
  168. ---
  169. [recommended]
  170. Use bdev_read_only(bdev) instead of is_read_only(kdev). The latter
  171. is still alive, but only because of the mess in drivers/s390/block/dasd.c.
  172. As soon as it gets fixed is_read_only() will die.
  173. ---
  174. [mandatory]
  175. ->permission() is called without BKL now. Grab it on entry, drop upon
  176. return - that will guarantee the same locking you used to have. If
  177. your method or its parts do not need BKL - better yet, now you can
  178. shift lock_kernel() and unlock_kernel() so that they would protect
  179. exactly what needs to be protected.
  180. ---
  181. [mandatory]
  182. ->statfs() is now called without BKL held. BKL should have been
  183. shifted into individual fs sb_op functions where it's not clear that
  184. it's safe to remove it. If you don't need it, remove it.
  185. ---
  186. [mandatory]
  187. is_read_only() is gone; use bdev_read_only() instead.
  188. ---
  189. [mandatory]
  190. destroy_buffers() is gone; use invalidate_bdev().
  191. ---
  192. [mandatory]
  193. fsync_dev() is gone; use fsync_bdev(). NOTE: lvm breakage is
  194. deliberate; as soon as struct block_device * is propagated in a reasonable
  195. way by that code fixing will become trivial; until then nothing can be
  196. done.