All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/6] btrfs-progs: inspect: add support for LOGICAL_INO_V2 ioctl
Date: Tue, 26 Nov 2019 22:55:07 -0500	[thread overview]
Message-ID: <20191127035509.15011-5-ce3g8jdj@umail.furryterror.org> (raw)
In-Reply-To: <20191127035509.15011-1-ce3g8jdj@umail.furryterror.org>

Increase the maximum buffer size to SZ_16M.

Add an option (-o) to set the ..._IGNORE_OFFSET flag.

If the buffer size is greater than 64K or the IGNORE_OFFSET option
is used, call ioctl V2; otherwise, use ioctl V1 to be compatible with
older kernels.

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
---
 cmds/inspect.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/cmds/inspect.c b/cmds/inspect.c
index 758b6e60..81eb8125 100644
--- a/cmds/inspect.c
+++ b/cmds/inspect.c
@@ -126,14 +126,17 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd,
 static DEFINE_SIMPLE_COMMAND(inspect_inode_resolve, "inode-resolve");
 
 static const char * const cmd_inspect_logical_resolve_usage[] = {
-	"btrfs inspect-internal logical-resolve [-Pv] [-s bufsize] <logical> <path>",
+	"btrfs inspect-internal logical-resolve [-Pvo] [-s bufsize] <logical> <path>",
 	"Get file system paths for the given logical address",
 	"",
 	"-P          skip the path resolving and print the inodes instead",
 	"-v          verbose mode",
+	"-o          ignore offsets when matching references (requires v2 ioctl",
+	"            support in the kernel)",
 	"-s bufsize  set inode container's size. This is used to increase inode",
 	"            container's size in case it is not enough to read all the ",
-	"            resolved results. The max value one can set is 64k",
+	"            resolved results. The max value one can set is 64k with the",
+	"            v1 ioctl. Sizes over 64k will use the v2 ioctl.",
 	NULL
 };
 
@@ -152,10 +155,12 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
 	char full_path[PATH_MAX];
 	char *path_ptr;
 	DIR *dirstream = NULL;
+	u64 flags = 0;
+	unsigned long request = BTRFS_IOC_LOGICAL_INO;
 
 	optind = 0;
 	while (1) {
-		int c = getopt(argc, argv, "Pvs:");
+		int c = getopt(argc, argv, "Pvos:");
 		if (c < 0)
 			break;
 
@@ -166,6 +171,9 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
 		case 'v':
 			verbose = 1;
 			break;
+		case 'o':
+			flags |= BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET;
+			break;
 		case 's':
 			size = arg_strtou64(optarg);
 			break;
@@ -177,14 +185,18 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
 	if (check_argc_exact(argc - optind, 2))
 		return 1;
 
-	size = min(size, (u64)SZ_64K);
+	size = min(size, (u64)SZ_16M);
 	inodes = malloc(size);
 	if (!inodes)
 		return 1;
 
+	if (size > SZ_64K || flags != 0)
+		request = BTRFS_IOC_LOGICAL_INO_V2;
+
 	memset(inodes, 0, sizeof(*inodes));
 	loi.logical = arg_strtou64(argv[optind]);
 	loi.size = size;
+	loi.flags = flags;
 	loi.inodes = ptr_to_u64(inodes);
 
 	fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1);
@@ -193,7 +205,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
 		goto out;
 	}
 
-	ret = ioctl(fd, BTRFS_IOC_LOGICAL_INO, &loi);
+	ret = ioctl(fd, request, &loi);
 	if (ret < 0) {
 		error("logical ino ioctl: %m");
 		goto out;
-- 
2.20.1


  parent reply	other threads:[~2019-11-27  4:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  3:55 [PATCH 0/6] btrfs-progs: add support for LOGICAL_INO_V2 features in logical-resolve Zygo Blaxell
2019-11-27  3:55 ` [PATCH 1/6] btrfs-progs: ioctl-test: add LOGICAL_INO_V2 Zygo Blaxell
2019-11-27  3:55 ` [PATCH 2/6] btrfs-progs: libbtrfsutil: " Zygo Blaxell
2019-11-27  3:55 ` [PATCH 3/6] btrfs-progs: add LOGICAL_INO_V2 to ioctl.h Zygo Blaxell
2019-11-27  3:55 ` Zygo Blaxell [this message]
2019-11-27  3:55 ` [PATCH 5/6] btrfs-progs: inspect: increase logical-resolve default buffer size to 64K Zygo Blaxell
2019-11-27  3:55 ` [PATCH 6/6] btrfs-progs: inspect-internal: document new logical-resolve options and kernel requirements Zygo Blaxell
2019-12-02 11:02 ` [PATCH 0/6] btrfs-progs: add support for LOGICAL_INO_V2 features in logical-resolve Anand Jain
2019-12-02 18:42   ` Zygo Blaxell
2019-12-03  1:08     ` Anand Jain
2020-01-02 19:00 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191127035509.15011-5-ce3g8jdj@umail.furryterror.org \
    --to=ce3g8jdj@umail.furryterror.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.