linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jeff Layton <jlayton@poochiereds.net>,
	"J . Bruce Fields" <bfields@fieldses.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-unionfs@vger.kernel.org
Subject: Re: [PATCH 2/7] open_by_handle: test file handles of renamed files
Date: Wed, 8 Nov 2017 13:07:45 +0800	[thread overview]
Message-ID: <20171108050745.GM17339@eguan.usersys.redhat.com> (raw)
In-Reply-To: <20171108041008.GL17339@eguan.usersys.redhat.com>

On Wed, Nov 08, 2017 at 12:10:08PM +0800, Eryu Guan wrote:
> On Thu, Nov 02, 2017 at 12:15:34PM +0200, Amir Goldstein wrote:
> > usage: open_by_handle -m <test_dir> [N]
> > 
> > Get file handles for existing test set, rename all test files,
> > drop cache and try to open all files by handle.
> > 
> > This is needed for testing that overlayfs can find the upper
> > inode from lower file handle even when upper is not in the same
> > path as lower.
> > 
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > ---
> >  src/open_by_handle.c | 31 ++++++++++++++++++++++++++-----
> >  1 file changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/open_by_handle.c b/src/open_by_handle.c
> > index 52973c6..8b12df3 100644
> > --- a/src/open_by_handle.c
> > +++ b/src/open_by_handle.c
> > @@ -27,7 +27,7 @@
> >  
> >  /*
> >  
> > -usage: open_by_handle [-c|-l|-u|-d] <test_dir> [num_files]
> > +usage: open_by_handle [-cludm] <test_dir> [num_files]
> >  
> >  Examples:
> >  
> > @@ -48,7 +48,12 @@ Examples:
> >  
> >     open_by_handle -d <test_dir> [N]
> >  
> > -4. Get file handles for existing test set, hardlink all test files,
> > +4. Get file handles for existing test set, rename all test files,
> > +   drop caches, try to open all files by handle (should work):
> > +
> > +   open_by_handle -m <test_dir> [N]
> > +
> > +5. Get file handles for existing test set, hardlink all test files,
> >     then unlink the original files, drop caches and try to open all
> >     files by handle (should work):
> >  
> > @@ -84,13 +89,14 @@ struct handle {
> >  
> >  void usage(void)
> >  {
> > -	fprintf(stderr, "usage: open_by_handle [-c|-l|-u|-d] <test_dir> [num_files]\n");
> > +	fprintf(stderr, "usage: open_by_handle [-cludm] <test_dir> [num_files]\n");
> >  	fprintf(stderr, "\n");
> >  	fprintf(stderr, "open_by_handle -c <test_dir> [N] - create N test files under test_dir, try to get file handles and exit\n");
> >  	fprintf(stderr, "open_by_handle    <test_dir> [N] - get file handles of test files, drop caches and try to open by handle\n");
> >  	fprintf(stderr, "open_by_handle -l <test_dir> [N] - create hardlinks to test files, drop caches and try to open by handle\n");
> >  	fprintf(stderr, "open_by_handle -u <test_dir> [N] - unlink (hardlinked) test files, drop caches and try to open by handle\n");
> >  	fprintf(stderr, "open_by_handle -d <test_dir> [N] - unlink test files and hardlinks, drop caches and try to open by handle\n");
> > +	fprintf(stderr, "open_by_handle -m <test_dir> [N] - rename test files, drop caches and try to open by handle\n");
> >  	exit(EXIT_FAILURE);
> >  }
> >  
> > @@ -105,12 +111,12 @@ int main(int argc, char **argv)
> >  	char	*test_dir;
> >  	int	mount_fd, mount_id;
> >  	int	numfiles = 1;
> > -	int	create = 0, delete = 0, nlink = 1;
> > +	int	create = 0, delete = 0, nlink = 1, move = 0;
> >  
> >  	if (argc < 2 || argc > 4)
> >  		usage();
> >  
> > -	while ((c = getopt(argc, argv, "clud")) != -1) {
> > +	while ((c = getopt(argc, argv, "cludm")) != -1) {
> >  		switch (c) {
> >  		case 'c':
> >  			create = 1;
> > @@ -126,6 +132,9 @@ int main(int argc, char **argv)
> >  			delete = 1;
> >  			nlink = 0;
> >  			break;
> > +		case 'm':
> > +			move = 1;
> > +			break;
> >  		default:
> >  			fprintf(stderr, "illegal option '%s'\n", argv[optind]);
> >  		case 'h':
> > @@ -201,6 +210,18 @@ int main(int argc, char **argv)
> >  		}
> >  	}
> >  
> > +	/* rename the files */
> > +	for (i=0; move && i < numfiles; i++) {
> > +		sprintf(fname, "%s/file%06d", test_dir, i);
> > +		sprintf(fname2, "%s/link%06d", test_dir, i);
> 
> Should we choose another prefix for moved files? "link" is used for
> hardlink files already, use something like "move"? (I can fix it up if
> you agree to do so.)

Ah, seems this is not a trivial fixup as I thought, patch 4 depends on
the file name prefix of moved files to be "link" too.

Thanks,
Eryu

> 
> > +		ret = rename(fname, fname2);
> > +		if (ret < 0) {
> > +			strcat(fname2, ": rename");
> > +			perror(fname2);
> > +			return EXIT_FAILURE;
> > +		}
> > +	}
> > +
> >  	/* unlink the files */
> >  	for (i=0; delete && i < numfiles; i++) {
> >  		sprintf(fname, "%s/file%06d", test_dir, i);
> > -- 
> > 2.7.4
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-11-08  5:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 10:15 [PATCH 0/7] More NFS file handle unit tests Amir Goldstein
2017-11-02 10:15 ` [PATCH 1/7] open_by_handle: add filename to error reports Amir Goldstein
2017-11-02 10:15 ` [PATCH 2/7] open_by_handle: test file handles of renamed files Amir Goldstein
2017-11-08  4:10   ` Eryu Guan
2017-11-08  5:07     ` Eryu Guan [this message]
2017-11-08  6:11       ` Amir Goldstein
2017-11-02 10:15 ` [PATCH 3/7] open_by_handle: test content of open file handle Amir Goldstein
2017-11-02 10:15 ` [PATCH 4/7] open_by_handle: test directory " Amir Goldstein
2017-11-02 10:15 ` [PATCH 5/7] open_by_handle: test file handles of open files Amir Goldstein
2017-11-02 10:15 ` [PATCH 6/7] generic/426: factor out helper functions Amir Goldstein
2017-11-02 10:15 ` [PATCH 7/7] fstests: add test with more open by file handle use cases Amir Goldstein
2017-11-03 12:22 ` [PATCH 0/7] More NFS file handle unit tests Jeff Layton
2017-11-04 23:23   ` Jeff Layton
2017-11-07 19:54     ` J . Bruce Fields
2017-11-07 20:05 ` J . Bruce Fields

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=20171108050745.GM17339@eguan.usersys.redhat.com \
    --to=eguan@redhat.com \
    --cc=amir73il@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=fstests@vger.kernel.org \
    --cc=jlayton@poochiereds.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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;
as well as URLs for NNTP newsgroup(s).