Commit 23516dc709914845f18fbe379b3524b8156e5c85
Committed by
Ingo Molnar
1 parent
c325962b68
Exists in
master
and in
7 other branches
kmemtrace, squashfs: fix slab.h dependency problem in squasfs
Impact: cleanup fs/squashfs/export.c depends on slab.h without including it: CC fs/squashfs/export.o fs/squashfs/export.c: In function ‘squashfs_read_inode_lookup_table’: fs/squashfs/export.c:133: error: implicit declaration of function ‘kmalloc’ fs/squashfs/export.c:133: warning: assignment makes pointer from integer without a cast fs/squashfs/export.c:143: error: implicit declaration of function ‘kfree’ make[1]: *** [fs/squashfs/export.o] Error 1 make: *** [fs/squashfs/] Error 2 It gets included implicitly currently - but this will not be the case with upcoming kmemtrace changes. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> LKML-Reference: <1237884999.25315.41.camel@penberg-laptop> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 1 additions and 0 deletions Inline Diff
fs/squashfs/export.c
1 | /* | 1 | /* |
2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
3 | * | 3 | * |
4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version 2, | 9 | * as published by the Free Software Foundation; either version 2, |
10 | * or (at your option) any later version. | 10 | * or (at your option) any later version. |
11 | * | 11 | * |
12 | * This program is distributed in the hope that it will be useful, | 12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | * | 16 | * |
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | * | 20 | * |
21 | * export.c | 21 | * export.c |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * This file implements code to make Squashfs filesystems exportable (NFS etc.) | 25 | * This file implements code to make Squashfs filesystems exportable (NFS etc.) |
26 | * | 26 | * |
27 | * The export code uses an inode lookup table to map inode numbers passed in | 27 | * The export code uses an inode lookup table to map inode numbers passed in |
28 | * filehandles to an inode location on disk. This table is stored compressed | 28 | * filehandles to an inode location on disk. This table is stored compressed |
29 | * into metadata blocks. A second index table is used to locate these. This | 29 | * into metadata blocks. A second index table is used to locate these. This |
30 | * second index table for speed of access (and because it is small) is read at | 30 | * second index table for speed of access (and because it is small) is read at |
31 | * mount time and cached in memory. | 31 | * mount time and cached in memory. |
32 | * | 32 | * |
33 | * The inode lookup table is used only by the export code, inode disk | 33 | * The inode lookup table is used only by the export code, inode disk |
34 | * locations are directly encoded in directories, enabling direct access | 34 | * locations are directly encoded in directories, enabling direct access |
35 | * without an intermediate lookup for all operations except the export ops. | 35 | * without an intermediate lookup for all operations except the export ops. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
39 | #include <linux/vfs.h> | 39 | #include <linux/vfs.h> |
40 | #include <linux/dcache.h> | 40 | #include <linux/dcache.h> |
41 | #include <linux/exportfs.h> | 41 | #include <linux/exportfs.h> |
42 | #include <linux/zlib.h> | 42 | #include <linux/zlib.h> |
43 | #include <linux/slab.h> | ||
43 | 44 | ||
44 | #include "squashfs_fs.h" | 45 | #include "squashfs_fs.h" |
45 | #include "squashfs_fs_sb.h" | 46 | #include "squashfs_fs_sb.h" |
46 | #include "squashfs_fs_i.h" | 47 | #include "squashfs_fs_i.h" |
47 | #include "squashfs.h" | 48 | #include "squashfs.h" |
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Look-up inode number (ino) in table, returning the inode location. | 51 | * Look-up inode number (ino) in table, returning the inode location. |
51 | */ | 52 | */ |
52 | static long long squashfs_inode_lookup(struct super_block *sb, int ino_num) | 53 | static long long squashfs_inode_lookup(struct super_block *sb, int ino_num) |
53 | { | 54 | { |
54 | struct squashfs_sb_info *msblk = sb->s_fs_info; | 55 | struct squashfs_sb_info *msblk = sb->s_fs_info; |
55 | int blk = SQUASHFS_LOOKUP_BLOCK(ino_num - 1); | 56 | int blk = SQUASHFS_LOOKUP_BLOCK(ino_num - 1); |
56 | int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino_num - 1); | 57 | int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino_num - 1); |
57 | u64 start = le64_to_cpu(msblk->inode_lookup_table[blk]); | 58 | u64 start = le64_to_cpu(msblk->inode_lookup_table[blk]); |
58 | __le64 ino; | 59 | __le64 ino; |
59 | int err; | 60 | int err; |
60 | 61 | ||
61 | TRACE("Entered squashfs_inode_lookup, inode_number = %d\n", ino_num); | 62 | TRACE("Entered squashfs_inode_lookup, inode_number = %d\n", ino_num); |
62 | 63 | ||
63 | err = squashfs_read_metadata(sb, &ino, &start, &offset, sizeof(ino)); | 64 | err = squashfs_read_metadata(sb, &ino, &start, &offset, sizeof(ino)); |
64 | if (err < 0) | 65 | if (err < 0) |
65 | return err; | 66 | return err; |
66 | 67 | ||
67 | TRACE("squashfs_inode_lookup, inode = 0x%llx\n", | 68 | TRACE("squashfs_inode_lookup, inode = 0x%llx\n", |
68 | (u64) le64_to_cpu(ino)); | 69 | (u64) le64_to_cpu(ino)); |
69 | 70 | ||
70 | return le64_to_cpu(ino); | 71 | return le64_to_cpu(ino); |
71 | } | 72 | } |
72 | 73 | ||
73 | 74 | ||
74 | static struct dentry *squashfs_export_iget(struct super_block *sb, | 75 | static struct dentry *squashfs_export_iget(struct super_block *sb, |
75 | unsigned int ino_num) | 76 | unsigned int ino_num) |
76 | { | 77 | { |
77 | long long ino; | 78 | long long ino; |
78 | struct dentry *dentry = ERR_PTR(-ENOENT); | 79 | struct dentry *dentry = ERR_PTR(-ENOENT); |
79 | 80 | ||
80 | TRACE("Entered squashfs_export_iget\n"); | 81 | TRACE("Entered squashfs_export_iget\n"); |
81 | 82 | ||
82 | ino = squashfs_inode_lookup(sb, ino_num); | 83 | ino = squashfs_inode_lookup(sb, ino_num); |
83 | if (ino >= 0) | 84 | if (ino >= 0) |
84 | dentry = d_obtain_alias(squashfs_iget(sb, ino, ino_num)); | 85 | dentry = d_obtain_alias(squashfs_iget(sb, ino, ino_num)); |
85 | 86 | ||
86 | return dentry; | 87 | return dentry; |
87 | } | 88 | } |
88 | 89 | ||
89 | 90 | ||
90 | static struct dentry *squashfs_fh_to_dentry(struct super_block *sb, | 91 | static struct dentry *squashfs_fh_to_dentry(struct super_block *sb, |
91 | struct fid *fid, int fh_len, int fh_type) | 92 | struct fid *fid, int fh_len, int fh_type) |
92 | { | 93 | { |
93 | if ((fh_type != FILEID_INO32_GEN && fh_type != FILEID_INO32_GEN_PARENT) | 94 | if ((fh_type != FILEID_INO32_GEN && fh_type != FILEID_INO32_GEN_PARENT) |
94 | || fh_len < 2) | 95 | || fh_len < 2) |
95 | return NULL; | 96 | return NULL; |
96 | 97 | ||
97 | return squashfs_export_iget(sb, fid->i32.ino); | 98 | return squashfs_export_iget(sb, fid->i32.ino); |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
101 | static struct dentry *squashfs_fh_to_parent(struct super_block *sb, | 102 | static struct dentry *squashfs_fh_to_parent(struct super_block *sb, |
102 | struct fid *fid, int fh_len, int fh_type) | 103 | struct fid *fid, int fh_len, int fh_type) |
103 | { | 104 | { |
104 | if (fh_type != FILEID_INO32_GEN_PARENT || fh_len < 4) | 105 | if (fh_type != FILEID_INO32_GEN_PARENT || fh_len < 4) |
105 | return NULL; | 106 | return NULL; |
106 | 107 | ||
107 | return squashfs_export_iget(sb, fid->i32.parent_ino); | 108 | return squashfs_export_iget(sb, fid->i32.parent_ino); |
108 | } | 109 | } |
109 | 110 | ||
110 | 111 | ||
111 | static struct dentry *squashfs_get_parent(struct dentry *child) | 112 | static struct dentry *squashfs_get_parent(struct dentry *child) |
112 | { | 113 | { |
113 | struct inode *inode = child->d_inode; | 114 | struct inode *inode = child->d_inode; |
114 | unsigned int parent_ino = squashfs_i(inode)->parent; | 115 | unsigned int parent_ino = squashfs_i(inode)->parent; |
115 | 116 | ||
116 | return squashfs_export_iget(inode->i_sb, parent_ino); | 117 | return squashfs_export_iget(inode->i_sb, parent_ino); |
117 | } | 118 | } |
118 | 119 | ||
119 | 120 | ||
120 | /* | 121 | /* |
121 | * Read uncompressed inode lookup table indexes off disk into memory | 122 | * Read uncompressed inode lookup table indexes off disk into memory |
122 | */ | 123 | */ |
123 | __le64 *squashfs_read_inode_lookup_table(struct super_block *sb, | 124 | __le64 *squashfs_read_inode_lookup_table(struct super_block *sb, |
124 | u64 lookup_table_start, unsigned int inodes) | 125 | u64 lookup_table_start, unsigned int inodes) |
125 | { | 126 | { |
126 | unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(inodes); | 127 | unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(inodes); |
127 | __le64 *inode_lookup_table; | 128 | __le64 *inode_lookup_table; |
128 | int err; | 129 | int err; |
129 | 130 | ||
130 | TRACE("In read_inode_lookup_table, length %d\n", length); | 131 | TRACE("In read_inode_lookup_table, length %d\n", length); |
131 | 132 | ||
132 | /* Allocate inode lookup table indexes */ | 133 | /* Allocate inode lookup table indexes */ |
133 | inode_lookup_table = kmalloc(length, GFP_KERNEL); | 134 | inode_lookup_table = kmalloc(length, GFP_KERNEL); |
134 | if (inode_lookup_table == NULL) { | 135 | if (inode_lookup_table == NULL) { |
135 | ERROR("Failed to allocate inode lookup table\n"); | 136 | ERROR("Failed to allocate inode lookup table\n"); |
136 | return ERR_PTR(-ENOMEM); | 137 | return ERR_PTR(-ENOMEM); |
137 | } | 138 | } |
138 | 139 | ||
139 | err = squashfs_read_table(sb, inode_lookup_table, lookup_table_start, | 140 | err = squashfs_read_table(sb, inode_lookup_table, lookup_table_start, |
140 | length); | 141 | length); |
141 | if (err < 0) { | 142 | if (err < 0) { |
142 | ERROR("unable to read inode lookup table\n"); | 143 | ERROR("unable to read inode lookup table\n"); |
143 | kfree(inode_lookup_table); | 144 | kfree(inode_lookup_table); |
144 | return ERR_PTR(err); | 145 | return ERR_PTR(err); |
145 | } | 146 | } |
146 | 147 | ||
147 | return inode_lookup_table; | 148 | return inode_lookup_table; |
148 | } | 149 | } |
149 | 150 | ||
150 | 151 | ||
151 | const struct export_operations squashfs_export_ops = { | 152 | const struct export_operations squashfs_export_ops = { |
152 | .fh_to_dentry = squashfs_fh_to_dentry, | 153 | .fh_to_dentry = squashfs_fh_to_dentry, |
153 | .fh_to_parent = squashfs_fh_to_parent, | 154 | .fh_to_parent = squashfs_fh_to_parent, |
154 | .get_parent = squashfs_get_parent | 155 | .get_parent = squashfs_get_parent |
155 | }; | 156 | }; |
156 | 157 |