Commit 8c6d21528406ec719aaea9d589876fd105c31646

Authored by Jan Harkes
Committed by Linus Torvalds
1 parent d728900cd5

coda: allow removal of busy directories

A directory without children may still be busy when it is the cwd for some
process.  We can safely remove such a directory because the VFS prevents
further operations.  Also we don't need to call d_delete as it is already
called in vfs_rmdir.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 9 additions and 14 deletions Side-by-side Diff

... ... @@ -391,28 +391,23 @@
391 391 {
392 392 const char *name = de->d_name.name;
393 393 int len = de->d_name.len;
394   - int error;
  394 + int error;
395 395  
396 396 lock_kernel();
397 397 coda_vfs_stat.rmdir++;
398 398  
399   - if (!d_unhashed(de)) {
400   - unlock_kernel();
401   - return -EBUSY;
402   - }
403 399 error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
  400 + if (!error) {
  401 + /* VFS may delete the child */
  402 + if (de->d_inode)
  403 + de->d_inode->i_nlink = 0;
404 404  
405   - if ( error ) {
406   - unlock_kernel();
407   - return error;
  405 + /* fix the link count of the parent */
  406 + coda_dir_drop_nlink(dir);
  407 + coda_dir_update_mtime(dir);
408 408 }
409   -
410   - coda_dir_drop_nlink(dir);
411   - coda_dir_update_mtime(dir);
412   - drop_nlink(de->d_inode);
413   - d_delete(de);
414 409 unlock_kernel();
415   - return 0;
  410 + return error;
416 411 }
417 412  
418 413 /* rename */