goto err;
inode_u->bi_ctime = now;
- bch2_inode_nlink_inc(inode_u);
+ ret = bch2_inode_nlink_inc(inode_u);
+ if (ret)
+ return ret;
ret = bch2_inode_peek(trans, &dir_iter, dir_u, dir, BTREE_ITER_INTENT);
if (ret)
struct bch_inode_unpacked *dir_u,
struct bch_inode_unpacked *inode_u,
const struct qstr *name,
- int deleting_snapshot)
+ bool deleting_snapshot)
{
struct bch_fs *c = trans->c;
struct btree_iter dir_iter = { NULL };
if (ret)
goto err;
- if (deleting_snapshot <= 0 && S_ISDIR(inode_u->bi_mode)) {
+ if (!deleting_snapshot && S_ISDIR(inode_u->bi_mode)) {
ret = bch2_empty_dir_trans(trans, inum);
if (ret)
goto err;
}
- if (deleting_snapshot < 0 &&
- inode_u->bi_subvol) {
- struct bch_subvolume s;
-
- ret = bch2_subvolume_get(trans, inode_u->bi_subvol, true,
- BTREE_ITER_CACHED|
- BTREE_ITER_WITH_UPDATES,
- &s);
- if (ret)
- goto err;
-
- if (BCH_SUBVOLUME_SNAP(&s))
- deleting_snapshot = 1;
+ if (deleting_snapshot && !inode_u->bi_subvol) {
+ ret = -ENOENT;
+ goto err;
}
- if (deleting_snapshot == 1) {
- if (!inode_u->bi_subvol) {
- ret = -ENOENT;
- goto err;
- }
-
- ret = bch2_subvolume_delete(trans, inode_u->bi_subvol,
- deleting_snapshot);
+ if (deleting_snapshot || inode_u->bi_subvol) {
+ ret = bch2_subvolume_unlink(trans, inode_u->bi_subvol);
if (ret)
goto err;
if (ret)
goto err;
} else {
- bch2_inode_nlink_dec(inode_u);
+ bch2_inode_nlink_dec(trans, inode_u);
}
if (inode_u->bi_dir == dirent_iter.pos.inode &&
bool ret = false;
for (id = 0; id < Inode_opt_nr; id++) {
+ /* Skip attributes that were explicitly set on this inode */
if (dst_u->bi_fields_set & (1 << id))
continue;
}
if (mode == BCH_RENAME_OVERWRITE)
- bch2_inode_nlink_dec(dst_inode_u);
+ bch2_inode_nlink_dec(trans, dst_inode_u);
src_dir_u->bi_mtime = now;
src_dir_u->bi_ctime = now;