}
int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
- void *ctx, bool ignore_offset)
+ void *ctx, bool ignore_offset,
+ bool search_commit_root)
{
struct btrfs_backref_walk_ctx walk_ctx = { 0 };
int ret;
walk_ctx.extent_item_pos = logical - found_key.objectid;
walk_ctx.fs_info = fs_info;
- return iterate_extent_inodes(&walk_ctx, false, build_ino_list, ctx);
+ return iterate_extent_inodes(&walk_ctx, search_commit_root,
+ build_ino_list, ctx);
}
static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,
iterate_extent_inodes_t *iterate, void *user_ctx);
int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
- void *ctx, bool ignore_offset);
+ void *ctx, bool ignore_offset,
+ bool search_commit_root);
int paths_from_inode(u64 inum, struct inode_fs_paths *ipath);
struct btrfs_ioctl_logical_ino_args AUTO_KFREE(loi);
struct btrfs_data_container AUTO_KVFREE(inodes);
bool ignore_offset;
+ bool search_commit_root;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (version == 1) {
ignore_offset = false;
+ search_commit_root = false;
size = min_t(u32, loi->size, SZ_64K);
} else {
/* All reserved bits must be 0 for now */
return -EINVAL;
/* Only accept flags we have defined so far */
- if (loi->flags & ~(BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET))
+ if (loi->flags & ~(BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET |
+ BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT))
return -EINVAL;
ignore_offset = loi->flags & BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET;
+ search_commit_root = loi->flags & BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT;
size = min_t(u32, loi->size, SZ_16M);
}
if (IS_ERR(inodes))
return PTR_ERR(inodes);
- ret = iterate_inodes_from_logical(loi->logical, fs_info, inodes, ignore_offset);
+ ret = iterate_inodes_from_logical(loi->logical, fs_info, inodes,
+ ignore_offset, search_commit_root);
if (ret == -EINVAL)
return -ENOENT;
if (ret < 0)
*/
#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
+/*
+ * Resolve backrefs against the commit roots instead of the current trees.
+ *
+ * Resolving against the current trees is more expensive for the filesystem as
+ * a whole, not only for the caller. Callers that do not need to observe the
+ * currently running transaction should set this. The result can be up to one
+ * commit interval stale.
+ */
+#define BTRFS_LOGICAL_INO_ARGS_COMMIT_ROOT (1ULL << 1)
+
enum btrfs_dev_stat_values {
/* disk I/O failure stats */
BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */