Commit 30c25be71fcbd87fd33518045cc014e69bff3d6f

Authored by Ryusuke Konishi
1 parent fb6e7113ae

nilfs2: return EBUSY against delete request on snapshot

This helps userland programs like the rmcp command to distinguish
error codes returned against a checkpoint removal request.

Previously -EPERM was returned, and not discriminable from real
permission errors.  This also allows removal of the latest checkpoint
because the deletion leads to create a new checkpoint, and thus it's
harmless for the filesystem.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>

Showing 1 changed file with 2 additions and 12 deletions Side-by-side Diff

... ... @@ -295,10 +295,6 @@
295 295 return -EINVAL;
296 296 }
297 297  
298   - /* cannot delete the latest checkpoint */
299   - if (start == nilfs_mdt_cno(cpfile) - 1)
300   - return -EPERM;
301   -
302 298 down_write(&NILFS_MDT(cpfile)->mi_sem);
303 299  
304 300 ret = nilfs_cpfile_get_header_block(cpfile, &header_bh);
305 301  
... ... @@ -542,20 +538,14 @@
542 538 struct nilfs_cpinfo ci;
543 539 __u64 tcno = cno;
544 540 ssize_t nci;
545   - int ret;
546 541  
547 542 nci = nilfs_cpfile_do_get_cpinfo(cpfile, &tcno, &ci, sizeof(ci), 1);
548 543 if (nci < 0)
549 544 return nci;
550 545 else if (nci == 0 || ci.ci_cno != cno)
551 546 return -ENOENT;
552   -
553   - /* cannot delete the latest checkpoint nor snapshots */
554   - ret = nilfs_cpinfo_snapshot(&ci);
555   - if (ret < 0)
556   - return ret;
557   - else if (ret > 0 || cno == nilfs_mdt_cno(cpfile) - 1)
558   - return -EPERM;
  547 + else if (nilfs_cpinfo_snapshot(&ci))
  548 + return -EBUSY;
559 549  
560 550 return nilfs_cpfile_delete_checkpoints(cpfile, cno, cno + 1);
561 551 }