diff options
Diffstat (limited to 'fs/nilfs2/namei.c')
-rw-r--r-- | fs/nilfs2/namei.c | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 95d1b29bff3c..df70dadb336f 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c | |||
@@ -109,7 +109,7 @@ static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
109 | { | 109 | { |
110 | struct inode *inode; | 110 | struct inode *inode; |
111 | struct nilfs_transaction_info ti; | 111 | struct nilfs_transaction_info ti; |
112 | int err, err2; | 112 | int err; |
113 | 113 | ||
114 | err = nilfs_transaction_begin(dir->i_sb, &ti, 1); | 114 | err = nilfs_transaction_begin(dir->i_sb, &ti, 1); |
115 | if (err) | 115 | if (err) |
@@ -123,8 +123,12 @@ static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
123 | mark_inode_dirty(inode); | 123 | mark_inode_dirty(inode); |
124 | err = nilfs_add_nondir(dentry, inode); | 124 | err = nilfs_add_nondir(dentry, inode); |
125 | } | 125 | } |
126 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 126 | if (!err) |
127 | return err ? : err2; | 127 | err = nilfs_transaction_commit(dir->i_sb); |
128 | else | ||
129 | nilfs_transaction_abort(dir->i_sb); | ||
130 | |||
131 | return err; | ||
128 | } | 132 | } |
129 | 133 | ||
130 | static int | 134 | static int |
@@ -132,7 +136,7 @@ nilfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
132 | { | 136 | { |
133 | struct inode *inode; | 137 | struct inode *inode; |
134 | struct nilfs_transaction_info ti; | 138 | struct nilfs_transaction_info ti; |
135 | int err, err2; | 139 | int err; |
136 | 140 | ||
137 | if (!new_valid_dev(rdev)) | 141 | if (!new_valid_dev(rdev)) |
138 | return -EINVAL; | 142 | return -EINVAL; |
@@ -147,8 +151,12 @@ nilfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
147 | mark_inode_dirty(inode); | 151 | mark_inode_dirty(inode); |
148 | err = nilfs_add_nondir(dentry, inode); | 152 | err = nilfs_add_nondir(dentry, inode); |
149 | } | 153 | } |
150 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 154 | if (!err) |
151 | return err ? : err2; | 155 | err = nilfs_transaction_commit(dir->i_sb); |
156 | else | ||
157 | nilfs_transaction_abort(dir->i_sb); | ||
158 | |||
159 | return err; | ||
152 | } | 160 | } |
153 | 161 | ||
154 | static int nilfs_symlink(struct inode *dir, struct dentry *dentry, | 162 | static int nilfs_symlink(struct inode *dir, struct dentry *dentry, |
@@ -158,7 +166,7 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry, | |||
158 | struct super_block *sb = dir->i_sb; | 166 | struct super_block *sb = dir->i_sb; |
159 | unsigned l = strlen(symname)+1; | 167 | unsigned l = strlen(symname)+1; |
160 | struct inode *inode; | 168 | struct inode *inode; |
161 | int err, err2; | 169 | int err; |
162 | 170 | ||
163 | if (l > sb->s_blocksize) | 171 | if (l > sb->s_blocksize) |
164 | return -ENAMETOOLONG; | 172 | return -ENAMETOOLONG; |
@@ -184,8 +192,12 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry, | |||
184 | 192 | ||
185 | err = nilfs_add_nondir(dentry, inode); | 193 | err = nilfs_add_nondir(dentry, inode); |
186 | out: | 194 | out: |
187 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 195 | if (!err) |
188 | return err ? : err2; | 196 | err = nilfs_transaction_commit(dir->i_sb); |
197 | else | ||
198 | nilfs_transaction_abort(dir->i_sb); | ||
199 | |||
200 | return err; | ||
189 | 201 | ||
190 | out_fail: | 202 | out_fail: |
191 | inode_dec_link_count(inode); | 203 | inode_dec_link_count(inode); |
@@ -198,7 +210,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir, | |||
198 | { | 210 | { |
199 | struct inode *inode = old_dentry->d_inode; | 211 | struct inode *inode = old_dentry->d_inode; |
200 | struct nilfs_transaction_info ti; | 212 | struct nilfs_transaction_info ti; |
201 | int err, err2; | 213 | int err; |
202 | 214 | ||
203 | if (inode->i_nlink >= NILFS_LINK_MAX) | 215 | if (inode->i_nlink >= NILFS_LINK_MAX) |
204 | return -EMLINK; | 216 | return -EMLINK; |
@@ -212,15 +224,19 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir, | |||
212 | atomic_inc(&inode->i_count); | 224 | atomic_inc(&inode->i_count); |
213 | 225 | ||
214 | err = nilfs_add_nondir(dentry, inode); | 226 | err = nilfs_add_nondir(dentry, inode); |
215 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 227 | if (!err) |
216 | return err ? : err2; | 228 | err = nilfs_transaction_commit(dir->i_sb); |
229 | else | ||
230 | nilfs_transaction_abort(dir->i_sb); | ||
231 | |||
232 | return err; | ||
217 | } | 233 | } |
218 | 234 | ||
219 | static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | 235 | static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
220 | { | 236 | { |
221 | struct inode *inode; | 237 | struct inode *inode; |
222 | struct nilfs_transaction_info ti; | 238 | struct nilfs_transaction_info ti; |
223 | int err, err2; | 239 | int err; |
224 | 240 | ||
225 | if (dir->i_nlink >= NILFS_LINK_MAX) | 241 | if (dir->i_nlink >= NILFS_LINK_MAX) |
226 | return -EMLINK; | 242 | return -EMLINK; |
@@ -252,8 +268,12 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
252 | 268 | ||
253 | d_instantiate(dentry, inode); | 269 | d_instantiate(dentry, inode); |
254 | out: | 270 | out: |
255 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 271 | if (!err) |
256 | return err ? : err2; | 272 | err = nilfs_transaction_commit(dir->i_sb); |
273 | else | ||
274 | nilfs_transaction_abort(dir->i_sb); | ||
275 | |||
276 | return err; | ||
257 | 277 | ||
258 | out_fail: | 278 | out_fail: |
259 | inode_dec_link_count(inode); | 279 | inode_dec_link_count(inode); |
@@ -270,7 +290,7 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry) | |||
270 | struct nilfs_dir_entry *de; | 290 | struct nilfs_dir_entry *de; |
271 | struct page *page; | 291 | struct page *page; |
272 | struct nilfs_transaction_info ti; | 292 | struct nilfs_transaction_info ti; |
273 | int err, err2; | 293 | int err; |
274 | 294 | ||
275 | err = nilfs_transaction_begin(dir->i_sb, &ti, 0); | 295 | err = nilfs_transaction_begin(dir->i_sb, &ti, 0); |
276 | if (err) | 296 | if (err) |
@@ -300,15 +320,19 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry) | |||
300 | inode_dec_link_count(inode); | 320 | inode_dec_link_count(inode); |
301 | err = 0; | 321 | err = 0; |
302 | out: | 322 | out: |
303 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 323 | if (!err) |
304 | return err ? : err2; | 324 | err = nilfs_transaction_commit(dir->i_sb); |
325 | else | ||
326 | nilfs_transaction_abort(dir->i_sb); | ||
327 | |||
328 | return err; | ||
305 | } | 329 | } |
306 | 330 | ||
307 | static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) | 331 | static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) |
308 | { | 332 | { |
309 | struct inode *inode = dentry->d_inode; | 333 | struct inode *inode = dentry->d_inode; |
310 | struct nilfs_transaction_info ti; | 334 | struct nilfs_transaction_info ti; |
311 | int err, err2; | 335 | int err; |
312 | 336 | ||
313 | err = nilfs_transaction_begin(dir->i_sb, &ti, 0); | 337 | err = nilfs_transaction_begin(dir->i_sb, &ti, 0); |
314 | if (err) | 338 | if (err) |
@@ -323,8 +347,12 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
323 | inode_dec_link_count(dir); | 347 | inode_dec_link_count(dir); |
324 | } | 348 | } |
325 | } | 349 | } |
326 | err2 = nilfs_transaction_end(dir->i_sb, !err); | 350 | if (!err) |
327 | return err ? : err2; | 351 | err = nilfs_transaction_commit(dir->i_sb); |
352 | else | ||
353 | nilfs_transaction_abort(dir->i_sb); | ||
354 | |||
355 | return err; | ||
328 | } | 356 | } |
329 | 357 | ||
330 | static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry, | 358 | static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry, |
@@ -404,7 +432,7 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
404 | inode_dec_link_count(old_dir); | 432 | inode_dec_link_count(old_dir); |
405 | } | 433 | } |
406 | 434 | ||
407 | err = nilfs_transaction_end(old_dir->i_sb, 1); | 435 | err = nilfs_transaction_commit(old_dir->i_sb); |
408 | return err; | 436 | return err; |
409 | 437 | ||
410 | out_dir: | 438 | out_dir: |
@@ -416,7 +444,7 @@ out_old: | |||
416 | kunmap(old_page); | 444 | kunmap(old_page); |
417 | page_cache_release(old_page); | 445 | page_cache_release(old_page); |
418 | out: | 446 | out: |
419 | nilfs_transaction_end(old_dir->i_sb, 0); | 447 | nilfs_transaction_abort(old_dir->i_sb); |
420 | return err; | 448 | return err; |
421 | } | 449 | } |
422 | 450 | ||