diff options
author | Krzysztof Błaszkowski <kb@sysmikro.com.pl> | 2016-06-01 02:56:04 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2016-06-01 03:01:52 -0400 |
commit | 8985f53ee2eaa503c22e2fc90e81b1fb8e547ab4 (patch) | |
tree | 348971934de496265ceb406cd6f7e87667d0a217 | |
parent | 0e481d3c0964ef00ff3dc9f25508980619e28752 (diff) |
freevxfs: move VFS inode allocation into vxfs_blkiget and vxfs_stiget
Signed-off-by: Krzysztof Błaszkowski <kb@sysmikro.com.pl>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | fs/freevxfs/vxfs_extern.h | 8 | ||||
-rw-r--r-- | fs/freevxfs/vxfs_fshead.c | 33 | ||||
-rw-r--r-- | fs/freevxfs/vxfs_inode.c | 27 |
3 files changed, 31 insertions, 37 deletions
diff --git a/fs/freevxfs/vxfs_extern.h b/fs/freevxfs/vxfs_extern.h index b59df797665f..2ec8c0f27865 100644 --- a/fs/freevxfs/vxfs_extern.h +++ b/fs/freevxfs/vxfs_extern.h | |||
@@ -54,11 +54,9 @@ extern int vxfs_read_fshead(struct super_block *); | |||
54 | extern const struct address_space_operations vxfs_immed_aops; | 54 | extern const struct address_space_operations vxfs_immed_aops; |
55 | extern struct kmem_cache *vxfs_inode_cachep; | 55 | extern struct kmem_cache *vxfs_inode_cachep; |
56 | extern void vxfs_dumpi(struct vxfs_inode_info *, ino_t); | 56 | extern void vxfs_dumpi(struct vxfs_inode_info *, ino_t); |
57 | extern struct inode * vxfs_get_fake_inode(struct super_block *, | 57 | extern struct inode *vxfs_blkiget(struct super_block *, u_long, ino_t); |
58 | struct vxfs_inode_info *); | 58 | extern struct inode *vxfs_stiget(struct super_block *, ino_t); |
59 | extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t); | 59 | extern struct inode *vxfs_iget(struct super_block *, ino_t); |
60 | extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t); | ||
61 | extern struct inode * vxfs_iget(struct super_block *, ino_t); | ||
62 | extern void vxfs_evict_inode(struct inode *); | 60 | extern void vxfs_evict_inode(struct inode *); |
63 | 61 | ||
64 | /* vxfs_lookup.c */ | 62 | /* vxfs_lookup.c */ |
diff --git a/fs/freevxfs/vxfs_fshead.c b/fs/freevxfs/vxfs_fshead.c index e7501cb85321..2651b4238eb2 100644 --- a/fs/freevxfs/vxfs_fshead.c +++ b/fs/freevxfs/vxfs_fshead.c | |||
@@ -108,31 +108,26 @@ vxfs_read_fshead(struct super_block *sbp) | |||
108 | { | 108 | { |
109 | struct vxfs_sb_info *infp = VXFS_SBI(sbp); | 109 | struct vxfs_sb_info *infp = VXFS_SBI(sbp); |
110 | struct vxfs_fsh *pfp, *sfp; | 110 | struct vxfs_fsh *pfp, *sfp; |
111 | struct vxfs_inode_info *vip, *tip; | 111 | struct vxfs_inode_info *vip; |
112 | 112 | ||
113 | vip = vxfs_blkiget(sbp, infp->vsi_iext, infp->vsi_fshino); | 113 | infp->vsi_fship = vxfs_blkiget(sbp, infp->vsi_iext, infp->vsi_fshino); |
114 | if (!vip) { | 114 | if (!infp->vsi_fship) { |
115 | printk(KERN_ERR "vxfs: unable to read fsh inode\n"); | 115 | printk(KERN_ERR "vxfs: unable to read fsh inode\n"); |
116 | return -EINVAL; | 116 | return -EINVAL; |
117 | } | 117 | } |
118 | |||
119 | vip = VXFS_INO(infp->vsi_fship); | ||
118 | if (!VXFS_ISFSH(vip)) { | 120 | if (!VXFS_ISFSH(vip)) { |
119 | printk(KERN_ERR "vxfs: fsh list inode is of wrong type (%x)\n", | 121 | printk(KERN_ERR "vxfs: fsh list inode is of wrong type (%x)\n", |
120 | vip->vii_mode & VXFS_TYPE_MASK); | 122 | vip->vii_mode & VXFS_TYPE_MASK); |
121 | goto out_free_fship; | 123 | goto out_iput_fship; |
122 | } | 124 | } |
123 | 125 | ||
124 | |||
125 | #ifdef DIAGNOSTIC | 126 | #ifdef DIAGNOSTIC |
126 | printk("vxfs: fsh inode dump:\n"); | 127 | printk("vxfs: fsh inode dump:\n"); |
127 | vxfs_dumpi(vip, infp->vsi_fshino); | 128 | vxfs_dumpi(vip, infp->vsi_fshino); |
128 | #endif | 129 | #endif |
129 | 130 | ||
130 | infp->vsi_fship = vxfs_get_fake_inode(sbp, vip); | ||
131 | if (!infp->vsi_fship) { | ||
132 | printk(KERN_ERR "vxfs: unable to get fsh inode\n"); | ||
133 | goto out_free_fship; | ||
134 | } | ||
135 | |||
136 | sfp = vxfs_getfsh(infp->vsi_fship, 0); | 131 | sfp = vxfs_getfsh(infp->vsi_fship, 0); |
137 | if (!sfp) { | 132 | if (!sfp) { |
138 | printk(KERN_ERR "vxfs: unable to get structural fsh\n"); | 133 | printk(KERN_ERR "vxfs: unable to get structural fsh\n"); |
@@ -153,15 +148,10 @@ vxfs_read_fshead(struct super_block *sbp) | |||
153 | vxfs_dumpfsh(pfp); | 148 | vxfs_dumpfsh(pfp); |
154 | #endif | 149 | #endif |
155 | 150 | ||
156 | tip = vxfs_blkiget(sbp, infp->vsi_iext, | 151 | infp->vsi_stilist = vxfs_blkiget(sbp, infp->vsi_iext, |
157 | fs32_to_cpu(infp, sfp->fsh_ilistino[0])); | 152 | fs32_to_cpu(infp, sfp->fsh_ilistino[0])); |
158 | if (!tip) | ||
159 | goto out_free_pfp; | ||
160 | |||
161 | infp->vsi_stilist = vxfs_get_fake_inode(sbp, tip); | ||
162 | if (!infp->vsi_stilist) { | 153 | if (!infp->vsi_stilist) { |
163 | printk(KERN_ERR "vxfs: unable to get structural list inode\n"); | 154 | printk(KERN_ERR "vxfs: unable to get structural list inode\n"); |
164 | kfree(tip); | ||
165 | goto out_free_pfp; | 155 | goto out_free_pfp; |
166 | } | 156 | } |
167 | if (!VXFS_ISILT(VXFS_INO(infp->vsi_stilist))) { | 157 | if (!VXFS_ISILT(VXFS_INO(infp->vsi_stilist))) { |
@@ -170,13 +160,9 @@ vxfs_read_fshead(struct super_block *sbp) | |||
170 | goto out_iput_stilist; | 160 | goto out_iput_stilist; |
171 | } | 161 | } |
172 | 162 | ||
173 | tip = vxfs_stiget(sbp, fs32_to_cpu(infp, pfp->fsh_ilistino[0])); | 163 | infp->vsi_ilist = vxfs_stiget(sbp, fs32_to_cpu(infp, pfp->fsh_ilistino[0])); |
174 | if (!tip) | ||
175 | goto out_iput_stilist; | ||
176 | infp->vsi_ilist = vxfs_get_fake_inode(sbp, tip); | ||
177 | if (!infp->vsi_ilist) { | 164 | if (!infp->vsi_ilist) { |
178 | printk(KERN_ERR "vxfs: unable to get inode list inode\n"); | 165 | printk(KERN_ERR "vxfs: unable to get inode list inode\n"); |
179 | kfree(tip); | ||
180 | goto out_iput_stilist; | 166 | goto out_iput_stilist; |
181 | } | 167 | } |
182 | if (!VXFS_ISILT(VXFS_INO(infp->vsi_ilist))) { | 168 | if (!VXFS_ISILT(VXFS_INO(infp->vsi_ilist))) { |
@@ -198,7 +184,4 @@ vxfs_read_fshead(struct super_block *sbp) | |||
198 | out_iput_fship: | 184 | out_iput_fship: |
199 | iput(infp->vsi_fship); | 185 | iput(infp->vsi_fship); |
200 | return -EINVAL; | 186 | return -EINVAL; |
201 | out_free_fship: | ||
202 | kfree(vip); | ||
203 | return -EINVAL; | ||
204 | } | 187 | } |
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index 6087ca703f12..7b5de83405f2 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c | |||
@@ -44,6 +44,8 @@ | |||
44 | 44 | ||
45 | struct kmem_cache *vxfs_inode_cachep; | 45 | struct kmem_cache *vxfs_inode_cachep; |
46 | 46 | ||
47 | static struct inode * vxfs_get_fake_inode(struct super_block *, | ||
48 | struct vxfs_inode_info *); | ||
47 | 49 | ||
48 | #ifdef DIAGNOSTIC | 50 | #ifdef DIAGNOSTIC |
49 | /* | 51 | /* |
@@ -112,10 +114,11 @@ static inline void dip2vip_cpy(struct vxfs_sb_info *sbi, | |||
112 | * buffercache. This function should not be used outside the | 114 | * buffercache. This function should not be used outside the |
113 | * read_super() method, otherwise the data may be incoherent. | 115 | * read_super() method, otherwise the data may be incoherent. |
114 | */ | 116 | */ |
115 | struct vxfs_inode_info * | 117 | struct inode * |
116 | vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino) | 118 | vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino) |
117 | { | 119 | { |
118 | struct buffer_head *bp; | 120 | struct buffer_head *bp; |
121 | struct inode *inode; | ||
119 | u_long block, offset; | 122 | u_long block, offset; |
120 | 123 | ||
121 | block = extent + ((ino * VXFS_ISIZE) / sbp->s_blocksize); | 124 | block = extent + ((ino * VXFS_ISIZE) / sbp->s_blocksize); |
@@ -134,7 +137,11 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino) | |||
134 | vxfs_dumpi(vip, ino); | 137 | vxfs_dumpi(vip, ino); |
135 | #endif | 138 | #endif |
136 | brelse(bp); | 139 | brelse(bp); |
137 | return (vip); | 140 | |
141 | inode = vxfs_get_fake_inode(sbp, vip); | ||
142 | if (!inode) | ||
143 | kmem_cache_free(vxfs_inode_cachep, vip); | ||
144 | return inode; | ||
138 | } | 145 | } |
139 | 146 | ||
140 | fail: | 147 | fail: |
@@ -152,7 +159,7 @@ fail: | |||
152 | * Description: | 159 | * Description: |
153 | * Search the for inode number @ino in the filesystem | 160 | * Search the for inode number @ino in the filesystem |
154 | * described by @sbp. Use the specified inode table (@ilistp). | 161 | * described by @sbp. Use the specified inode table (@ilistp). |
155 | * Returns the matching VxFS inode on success, else an error code. | 162 | * Returns the matching inode on success, else an error code. |
156 | */ | 163 | */ |
157 | static struct vxfs_inode_info * | 164 | static struct vxfs_inode_info * |
158 | __vxfs_iget(ino_t ino, struct inode *ilistp) | 165 | __vxfs_iget(ino_t ino, struct inode *ilistp) |
@@ -196,15 +203,21 @@ fail: | |||
196 | * Description: | 203 | * Description: |
197 | * Find inode @ino in the filesystem described by @sbp using | 204 | * Find inode @ino in the filesystem described by @sbp using |
198 | * the structural inode list. | 205 | * the structural inode list. |
199 | * Returns the matching VxFS inode on success, else a NULL pointer. | 206 | * Returns the matching inode on success, else a NULL pointer. |
200 | */ | 207 | */ |
201 | struct vxfs_inode_info * | 208 | struct inode * |
202 | vxfs_stiget(struct super_block *sbp, ino_t ino) | 209 | vxfs_stiget(struct super_block *sbp, ino_t ino) |
203 | { | 210 | { |
204 | struct vxfs_inode_info *vip; | 211 | struct vxfs_inode_info *vip; |
212 | struct inode *inode; | ||
205 | 213 | ||
206 | vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist); | 214 | vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist); |
207 | return IS_ERR(vip) ? NULL : vip; | 215 | if (IS_ERR(vip)) |
216 | return NULL; | ||
217 | inode = vxfs_get_fake_inode(sbp, vip); | ||
218 | if (!inode) | ||
219 | kmem_cache_free(vxfs_inode_cachep, vip); | ||
220 | return inode; | ||
208 | } | 221 | } |
209 | 222 | ||
210 | /** | 223 | /** |
@@ -282,7 +295,7 @@ vxfs_iinit(struct inode *ip, struct vxfs_inode_info *vip) | |||
282 | * superblock, vxfs_inode pair. | 295 | * superblock, vxfs_inode pair. |
283 | * Returns the filled VFS inode. | 296 | * Returns the filled VFS inode. |
284 | */ | 297 | */ |
285 | struct inode * | 298 | static struct inode * |
286 | vxfs_get_fake_inode(struct super_block *sbp, struct vxfs_inode_info *vip) | 299 | vxfs_get_fake_inode(struct super_block *sbp, struct vxfs_inode_info *vip) |
287 | { | 300 | { |
288 | struct inode *ip = NULL; | 301 | struct inode *ip = NULL; |