public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Alexander Monakov <amonakov@ispras.ru>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs_db rdump: remove sole_path logic
Date: Wed, 12 Nov 2025 10:53:08 -0800	[thread overview]
Message-ID: <20251112185308.GB196370@frogsfrogsfrogs> (raw)
In-Reply-To: <20251112151932.12141-2-amonakov@ispras.ru>

On Wed, Nov 12, 2025 at 06:19:31PM +0300, Alexander Monakov wrote:
> Eliminate special handling of the case where rdump'ing one directory
> does not create the corresponding directory in the destination, but
> instead modifies the destination's attributes and creates children
> alongside the pre-existing children.

It sounds like what happened is that you ran rdump with a non-empty
destdir, only to have rdump mutate the existing children in that
directory.  Is that correct?

If so, then I think what you really wanted was for rdump to check for
that and error out, unless explicit --overwrite permission had been
granted.  Because...

> This can be a trap for the unwary (the effect on attributes can be
> particularly surprising and non-trivial to undo), and, in general, fewer
> special cases in such a low-level tool should be desirable.

...I use this "special case" and don't understand why you decided that
removing functionality was the solution here.  This is a filesystem
debugger, there are weird functions and sharp edges everywhere.

--D

> Signed-off-by: Alexander Monakov <amonakov@ispras.ru>
> ---
>  db/rdump.c        | 19 ++-----------------
>  man/man8/xfs_db.8 |  8 +-------
>  2 files changed, 3 insertions(+), 24 deletions(-)
> 
> diff --git a/db/rdump.c b/db/rdump.c
> index 9ff83355..73295dbe 100644
> --- a/db/rdump.c
> +++ b/db/rdump.c
> @@ -852,7 +852,6 @@ rdump_file(
>  static int
>  rdump_path(
>  	struct xfs_mount	*mp,
> -	bool			sole_path,
>  	const char		*path,
>  	const struct destdir	*destdir)
>  {
> @@ -890,20 +889,6 @@ rdump_path(
>  			dbprintf(_("%s: %s\n"), path, strerror(ret));
>  			return 1;
>  		}
> -
> -		if (sole_path) {
> -			struct xfs_dinode	*dip = iocur_top->data;
> -
> -			/*
> -			 * If this is the only path to copy out and it's a dir,
> -			 * then we can copy the children directly into the
> -			 * target.
> -			 */
> -			if (S_ISDIR(be16_to_cpu(dip->di_mode))) {
> -				pbuf->len = 0;
> -				pbuf->path[0] = 0;
> -			}
> -		}
>  	} else {
>  		set_cur_inode(mp->m_sb.sb_rootino);
>  	}
> @@ -980,7 +965,7 @@ rdump_f(
>  	if (optind == argc - 1) {
>  		/* no dirs given, just do the whole fs */
>  		push_cur();
> -		ret = rdump_path(mp, false, "", &destdir);
> +		ret = rdump_path(mp, "", &destdir);
>  		pop_cur();
>  		if (ret)
>  			exitcode = 1;
> @@ -996,7 +981,7 @@ rdump_f(
>  		argv[i][len] = 0;
>  
>  		push_cur();
> -		ret = rdump_path(mp, argc == optind + 2, argv[i], &destdir);
> +		ret = rdump_path(mp, argv[i], &destdir);
>  		pop_cur();
>  
>  		if (ret) {
> diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8
> index 1e85aebb..920b2b3e 100644
> --- a/man/man8/xfs_db.8
> +++ b/man/man8/xfs_db.8
> @@ -1147,13 +1147,7 @@ the filesystem as possible.
>  If zero
>  .B paths
>  are specified, the entire filesystem is dumped.
> -If only one
> -.B path
> -is specified and it is a directory, the children of that directory will be
> -copied directly to the destination.
> -If multiple
> -.B paths
> -are specified, each file is copied into the directory as a new child.
> +Otherwise, each entry is copied into the destination as a new child.
>  
>  If possible, sparse holes, xfs file attributes, and extended attributes will be
>  preserved.
> -- 
> 2.51.0
> 
> 

  reply	other threads:[~2025-11-12 18:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 15:19 [PATCH 0/2] xfs_db rdump: papercut fixes Alexander Monakov
2025-11-12 15:19 ` [PATCH 1/2] xfs_db rdump: remove sole_path logic Alexander Monakov
2025-11-12 18:53   ` Darrick J. Wong [this message]
2025-11-12 19:45     ` Alexander Monakov
2025-11-20 23:46       ` Darrick J. Wong
2025-11-12 15:19 ` [PATCH 2/2] xfs_db: use push_cur_and_set_type more Alexander Monakov
2025-11-12 18:59   ` Darrick J. Wong
2025-11-12 19:18     ` Alexander Monakov

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=20251112185308.GB196370@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=amonakov@ispras.ru \
    --cc=linux-xfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox