[PATCH 17/23] Add ngnfs_dir_rename() and very basic debugfs command
Auke Kok
auke.kok at versity.com
Sat Apr 5 22:01:00 PDT 2025
There's something wrong with the new version of ngnfs_dir_rename.
Previously I was able to call it with e.g. (..., 'file', cwd_ig,
'newfile') and it would appropriately rename the file. This now no
longer works, so the problem is likely somewhere here:
On Fri, Apr 4, 2025 at 11:48 AM Valerie Aurora <val at versity.com> wrote:
> + do {
> + ret = ngnfs_inode_get(nfi, &op->txn, NBF_WRITE, src_dir_ig, &op->src_dir) ?:
> + check_ifmt(op->src_dir.ninode, S_IFDIR, -ENOTDIR) ?:
> + lookup_dirent(nfi, &op->txn, &op->src_dir, &op->src_da) ?:
> + ngnfs_inode_get(nfi, &op->txn, NBF_WRITE, dst_dir_ig, &op->dst_dir) ?:
> + check_ifmt(op->dst_dir.ninode, S_IFDIR, -ENOTDIR) ?:
> + lookup_dirent_enoent_ok(nfi, &op->txn, &op->dst_dir, &op->dst_da) ?:
> + check_rename(nfi, &op->txn, &op->src_dir, &op->src_da, &op->dst_dir,
> + &op->dst_da) ?:
> + remove_dirent(nfi, &op->txn, &op->src_dir, &op->src_da) ?:
> + update_dir(op->src_dir.tblk, op->src_dir.ninode, &op->src_da, -1) ?:
> + replace_dirent(nfi, &op->txn, &op->dst_dir, &op->src_da) ?:
> + update_dir(op->dst_dir.tblk, op->dst_dir.ninode, &op->src_da, 1);
I did notice from the git diff with the previous version of this code,
that there are several less calls to update dirent stuff:
@@ -864,19 +921,16 @@ int ngnfs_dir_rename(struct ngnfs_fs_info *nfi,
struct ngnfs_inode_ino_gen *src_
do {
ret = ngnfs_inode_get(nfi, &op->txn, NBF_WRITE,
src_dir_ig, &op->src_dir) ?:
check_ifmt(op->src_dir.ninode, S_IFDIR,
-ENOTDIR) ?:
- lookup_dirent(nfi, &op->txn, &op->src_dir,
&op->src_da, false) ?:
+ lookup_dirent(nfi, &op->txn, &op->src_dir,
&op->src_da) ?:
ngnfs_inode_get(nfi, &op->txn, NBF_WRITE,
dst_dir_ig, &op->dst_dir) ?:
check_ifmt(op->dst_dir.ninode, S_IFDIR,
-ENOTDIR) ?:
- lookup_dirent(nfi, &op->txn, &op->dst_dir,
&op->dst_da, true) ?:
+ lookup_dirent_enoent_ok(nfi, &op->txn,
&op->dst_dir, &op->dst_da) ?:
check_rename(nfi, &op->txn, &op->src_dir,
&op->src_da, &op->dst_dir,
&op->dst_da)
?:
- update_dirent_args_ig(&op->dst_da,
&op->src_da.ig) ?:
- remove_dirent(nfi, &op->txn, &op->src_dir,
&op->src_da, false) ?:
+ remove_dirent(nfi, &op->txn, &op->src_dir,
&op->src_da) ?:
update_dir(op->src_dir.tblk, op->src_dir.ninode,
&op->src_da, -1) ?:
- remove_dirent(nfi, &op->txn, &op->dst_dir,
&op->dst_da, true) ?:
- update_dirent_args_ig(&op->dst_da,
&op->src_da.ig) ?:
- insert_dirent(nfi, &op->txn, &op->dst_dir,
&op->dst_da) ?:
- update_dir(op->dst_dir.tblk, op->dst_dir.ninode,
&op->dst_da, 1);
+ replace_dirent(nfi, &op->txn, &op->dst_dir,
&op->src_da) ?:
+ update_dir(op->dst_dir.tblk, op->dst_dir.ninode,
&op->src_da, 1);
} while (ngnfs_txn_retry(nfi, &op->txn, &ret));
I can't put my finger on exactly what's not right though. Moving files
between directories work, but any dst_name passed is also just
ignored.
Auke
More information about the ngnfs-devel
mailing list