original development tree for Linux kernel GTP module; now long in mainline.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
4.2 KiB

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
12 years ago
  1. /*
  2. * linux/fs/isofs/namei.c
  3. *
  4. * (C) 1992 Eric Youngdale Modified for ISO 9660 filesystem.
  5. *
  6. * (C) 1991 Linus Torvalds - minix filesystem
  7. */
  8. #include <linux/gfp.h>
  9. #include "isofs.h"
  10. /*
  11. * ok, we cannot use strncmp, as the name is not in our data space.
  12. * Thus we'll have to use isofs_match. No big problem. Match also makes
  13. * some sanity tests.
  14. */
  15. static int
  16. isofs_cmp(struct dentry *dentry, const char *compare, int dlen)
  17. {
  18. struct qstr qstr;
  19. if (!compare)
  20. return 1;
  21. /* check special "." and ".." files */
  22. if (dlen == 1) {
  23. /* "." */
  24. if (compare[0] == 0) {
  25. if (!dentry->d_name.len)
  26. return 0;
  27. compare = ".";
  28. } else if (compare[0] == 1) {
  29. compare = "..";
  30. dlen = 2;
  31. }
  32. }
  33. qstr.name = compare;
  34. qstr.len = dlen;
  35. return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr);
  36. }
  37. /*
  38. * isofs_find_entry()
  39. *
  40. * finds an entry in the specified directory with the wanted name. It
  41. * returns the inode number of the found entry, or 0 on error.
  42. */
  43. static unsigned long
  44. isofs_find_entry(struct inode *dir, struct dentry *dentry,
  45. unsigned long *block_rv, unsigned long *offset_rv,
  46. char *tmpname, struct iso_directory_record *tmpde)
  47. {
  48. unsigned long bufsize = ISOFS_BUFFER_SIZE(dir);
  49. unsigned char bufbits = ISOFS_BUFFER_BITS(dir);
  50. unsigned long block, f_pos, offset, block_saved, offset_saved;
  51. struct buffer_head *bh = NULL;
  52. struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb);
  53. if (!ISOFS_I(dir)->i_first_extent)
  54. return 0;
  55. f_pos = 0;
  56. offset = 0;
  57. block = 0;
  58. while (f_pos < dir->i_size) {
  59. struct iso_directory_record *de;
  60. int de_len, match, i, dlen;
  61. char *dpnt;
  62. if (!bh) {
  63. bh = isofs_bread(dir, block);
  64. if (!bh)
  65. return 0;
  66. }
  67. de = (struct iso_directory_record *) (bh->b_data + offset);
  68. de_len = *(unsigned char *) de;
  69. if (!de_len) {
  70. brelse(bh);
  71. bh = NULL;
  72. f_pos = (f_pos + ISOFS_BLOCK_SIZE) & ~(ISOFS_BLOCK_SIZE - 1);
  73. block = f_pos >> bufbits;
  74. offset = 0;
  75. continue;
  76. }
  77. block_saved = bh->b_blocknr;
  78. offset_saved = offset;
  79. offset += de_len;
  80. f_pos += de_len;
  81. /* Make sure we have a full directory entry */
  82. if (offset >= bufsize) {
  83. int slop = bufsize - offset + de_len;
  84. memcpy(tmpde, de, slop);
  85. offset &= bufsize - 1;
  86. block++;
  87. brelse(bh);
  88. bh = NULL;
  89. if (offset) {
  90. bh = isofs_bread(dir, block);
  91. if (!bh)
  92. return 0;
  93. memcpy((void *) tmpde + slop, bh->b_data, offset);
  94. }
  95. de = tmpde;
  96. }
  97. dlen = de->name_len[0];
  98. dpnt = de->name;
  99. /* Basic sanity check, whether name doesn't exceed dir entry */
  100. if (de_len < dlen + sizeof(struct iso_directory_record)) {
  101. printk(KERN_NOTICE "iso9660: Corrupted directory entry"
  102. " in block %lu of inode %lu\n", block,
  103. dir->i_ino);
  104. return 0;
  105. }
  106. if (sbi->s_rock &&
  107. ((i = get_rock_ridge_filename(de, tmpname, dir)))) {
  108. dlen = i; /* possibly -1 */
  109. dpnt = tmpname;
  110. #ifdef CONFIG_JOLIET
  111. } else if (sbi->s_joliet_level) {
  112. dlen = get_joliet_filename(de, tmpname, dir);
  113. dpnt = tmpname;
  114. #endif
  115. } else if (sbi->s_mapping == 'a') {
  116. dlen = get_acorn_filename(de, tmpname, dir);
  117. dpnt = tmpname;
  118. } else if (sbi->s_mapping == 'n') {
  119. dlen = isofs_name_translate(de, tmpname, dir);
  120. dpnt = tmpname;
  121. }
  122. /*
  123. * Skip hidden or associated files unless hide or showassoc,
  124. * respectively, is set
  125. */
  126. match = 0;
  127. if (dlen > 0 &&
  128. (!sbi->s_hide ||
  129. (!(de->flags[-sbi->s_high_sierra] & 1))) &&
  130. (sbi->s_showassoc ||
  131. (!(de->flags[-sbi->s_high_sierra] & 4)))) {
  132. match = (isofs_cmp(dentry, dpnt, dlen) == 0);
  133. }
  134. if (match) {
  135. isofs_normalize_block_and_offset(de,
  136. &block_saved,
  137. &offset_saved);
  138. *block_rv = block_saved;
  139. *offset_rv = offset_saved;
  140. brelse(bh);
  141. return 1;
  142. }
  143. }
  144. brelse(bh);
  145. return 0;
  146. }
  147. struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
  148. {
  149. int found;
  150. unsigned long uninitialized_var(block);
  151. unsigned long uninitialized_var(offset);
  152. struct inode *inode;
  153. struct page *page;
  154. page = alloc_page(GFP_USER);
  155. if (!page)
  156. return ERR_PTR(-ENOMEM);
  157. found = isofs_find_entry(dir, dentry,
  158. &block, &offset,
  159. page_address(page),
  160. 1024 + page_address(page));
  161. __free_page(page);
  162. inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL;
  163. return d_splice_alias(inode, dentry);
  164. }