linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org,
	Dave Chinner <dchinner@redhat.com>
Subject: Re: [PATCH 5/9] xfs_spaceman: add new speculative prealloc control
Date: Tue, 30 May 2017 11:34:00 -0700	[thread overview]
Message-ID: <20170530183400.GZ4519@birch.djwong.org> (raw)
In-Reply-To: <c47eb93e-a177-2c47-185e-3224b60ae11f@sandeen.net>

On Fri, May 26, 2017 at 08:45:58PM -0500, Eric Sandeen wrote:
> 
> 
> On 5/7/17 10:56 AM, Darrick J. Wong wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> > 
> > Add an control interface for purging speculative
> > preallocation via the new ioctls.
> > 
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > [darrick: change xfsctl to ioctl]
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  spaceman/Makefile   |    2 -
> >  spaceman/init.c     |    1 
> >  spaceman/prealloc.c |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  spaceman/space.h    |    1 
> >  4 files changed, 138 insertions(+), 1 deletion(-)
> >  create mode 100644 spaceman/prealloc.c
> > 
> > 
> > diff --git a/spaceman/Makefile b/spaceman/Makefile
> > index 9fb9142..b1f1136 100644
> > --- a/spaceman/Makefile
> > +++ b/spaceman/Makefile
> > @@ -8,7 +8,7 @@ include $(TOPDIR)/include/builddefs
> >  LTCOMMAND = xfs_spaceman
> >  HFILES = init.h space.h
> >  CFILES = init.c \
> > -	file.c trim.c
> > +	file.c prealloc.c trim.c
> >  
> >  LLDLIBS = $(LIBXCMD)
> >  LTDEPENDENCIES = $(LIBXCMD)
> > diff --git a/spaceman/init.c b/spaceman/init.c
> > index ae5cfb5..08b5a33 100644
> > --- a/spaceman/init.c
> > +++ b/spaceman/init.c
> > @@ -39,6 +39,7 @@ init_commands(void)
> >  {
> >  	file_init();
> >  	help_init();
> > +	prealloc_init();
> >  	quit_init();
> >  	trim_init();
> >  }
> > diff --git a/spaceman/prealloc.c b/spaceman/prealloc.c
> > new file mode 100644
> > index 0000000..b93f909
> > --- /dev/null
> > +++ b/spaceman/prealloc.c
> > @@ -0,0 +1,135 @@
> > +/*
> > + * Copyright (c) 2012 Red Hat, Inc.
> > + * All Rights Reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it would be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write the Free Software Foundation,
> > + * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> > + */
> > +
> > +#include "libxfs.h"
> > +#include "command.h"
> > +#include "input.h"
> > +#include "init.h"
> > +#include "space.h"
> > +
> > +#ifndef XFS_IOC_FREE_EOFBLOCKS
> > +#define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_eofblocks)
> > +
> > +#define XFS_EOFBLOCKS_VERSION           1
> > +struct xfs_fs_eofblocks {
> > +	__u32		eof_version;
> > +	__u32		eof_flags;
> > +	uid_t		eof_uid;
> > +	gid_t		eof_gid;
> > +	prid_t		eof_prid;
> > +	__u32		pad32;
> > +	__u64		eof_min_file_size;
> > +	__u64		pad64[12];
> > +};
> > +
> > +/* eof_flags values */
> > +#define XFS_EOF_FLAGS_SYNC		(1 << 0) /* sync/wait mode scan */
> > +#define XFS_EOF_FLAGS_UID		(1 << 1) /* filter by uid */
> > +#define XFS_EOF_FLAGS_GID		(1 << 2) /* filter by gid */
> > +#define XFS_EOF_FLAGS_PRID		(1 << 3) /* filter by project id */
> > +#define XFS_EOF_FLAGS_MINFILESIZE	(1 << 4) /* filter by min file size */
> > +
> > +#endif
> 
> I think including libxfs defines XFS_IOC_FREE_EOFBLOCKS, via xfs_fs.h
> and that whole hunk can go, no?

Yeah.

> > +
> > +static cmdinfo_t prealloc_cmd;
> > +
> > +/*
> > + * Control preallocation amounts.
> > + */
> > +static int
> > +prealloc_f(
> > +	int	argc,
> > +	char	**argv)
> > +{
> > +	struct xfs_fs_eofblocks eofb = {0};
> > +	int	c;
> > +
> > +	eofb.eof_version = XFS_EOFBLOCKS_VERSION;
> > +
> > +	while ((c = getopt(argc, argv, "g:m:p:su:")) != EOF) {
> > +		switch (c) {
> > +		case 'g':
> > +			eofb.eof_flags |= XFS_EOF_FLAGS_GID;
> > +			eofb.eof_gid = atoi(optarg);
> > +			break;
> > +		case 'u':
> > +			eofb.eof_flags |= XFS_EOF_FLAGS_UID;
> > +			eofb.eof_uid = atoi(optarg);
> > +			break;
> > +		case 'p':
> > +			eofb.eof_flags |= XFS_EOF_FLAGS_PRID;
> > +			eofb.eof_prid = atoi(optarg);
> > +			break;
> > +		case 's':
> > +			eofb.eof_flags |= XFS_EOF_FLAGS_SYNC;
> > +			break;
> > +		case 'm':
> > +			eofb.eof_flags |= XFS_EOF_FLAGS_MINFILESIZE;
> > +			eofb.eof_min_file_size = cvtnum(file->geom.blocksize,
> > +							file->geom.sectsize,
> > +							optarg);
> > +			break;
> > +		case '?':
> > +		default:
> > +			return command_usage(&prealloc_cmd);
> > +		}
> > +	}
> > +	if (optind != argc)
> > +		return command_usage(&prealloc_cmd);
> > +
> > +	if (ioctl(file->fd, XFS_IOC_FREE_EOFBLOCKS, &eofb) < 0) {
> > +		fprintf(stderr, _("%s: XFS_IOC_FREE_EOFBLOCKS on %s: %s\n"),
> > +			progname, file->name, strerror(errno));
> > +	}
> > +	return 0;
> > +}
> > +
> > +static void
> > +prealloc_help(void)
> > +{
> > +	printf(_(
> > +"\n"
> > +"Control speculative preallocation\n"
> > +"\n"
> > +"Options: [-s] [-ugp id] [-m minlen]\n"
> > +"\n"
> > +" -s -- synchronous flush - wait for flush to complete\n"
> 
> really flush?  (maybe removal? scan?)

"-s        -- wait for removal to complete\n"

> 
> > +" -u uid -- remove prealloc on files matching user <uid>\n"
> > +" -g gid -- remove prealloc on files matching group <gid>\n"
> > +" -p prid -- remove prealloc on files matching project <prid>\n"
> > +" -m minlen -- only consider files larger than <minlen>\n"
> > +"\n"));
> 
> +" -s        -- synchronous flush - wait for flush to complete\n"
> +" -u uid    -- remove prealloc on files matching user <uid>\n"
> +" -g gid    -- remove prealloc on files matching group <gid>\n"
> +" -p prid   -- remove prealloc on files matching project <prid>\n"
> +" -m minlen -- only consider files larger than <minlen>\n"
> 
> 
> > +
> > +}
> > +
> > +void
> > +prealloc_init(void)
> > +{
> > +	prealloc_cmd.name = "prealloc";
> > +	prealloc_cmd.altname = "prealloc";
> > +	prealloc_cmd.cfunc = prealloc_f;
> > +	prealloc_cmd.argmin = 1;
> > +	prealloc_cmd.argmax = -1;
> > +	prealloc_cmd.args = "[-s] [-ugp id] [-m minlen]\n";
> 
> no \n please:
> 
> xfs_spaceman> help
> ...
> 
> prealloc [-s] [-ugp id] [-m minlen]
>  -- Control speculative preallocation
> 
> should be on same line ala xfs_io IMHO

Ok.

--D

> 
> > +	prealloc_cmd.flags = CMD_FLAG_ONESHOT;
> > +	prealloc_cmd.oneline = _("Control speculative preallocation");
> > +	prealloc_cmd.help = prealloc_help;
> > +
> > +	add_command(&prealloc_cmd);
> > +}
> > +
> > diff --git a/spaceman/space.h b/spaceman/space.h
> > index 7b4f034..0ae3116 100644
> > --- a/spaceman/space.h
> > +++ b/spaceman/space.h
> > @@ -33,5 +33,6 @@ extern int	addfile(char *, int , xfs_fsop_geom_t *, int);
> >  
> >  extern void	file_init(void);
> >  extern void	help_init(void);
> > +extern void	prealloc_init(void);
> >  extern void	quit_init(void);
> >  extern void	trim_init(void);
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" 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-05-30 18:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 15:56 [PATCH v7 0/9] xfsprogs 4.12: GETFSMAP support Darrick J. Wong
2017-05-07 15:56 ` [PATCH 1/9] xfs_io: support the new getfsmap ioctl Darrick J. Wong
2017-05-08 21:01   ` Eric Sandeen
2017-05-15 19:18     ` Darrick J. Wong
2017-05-15 19:30       ` Eric Sandeen
2017-05-07 15:56 ` [PATCH 2/9] xfs_repair: replace rmap_compare with libxfs version Darrick J. Wong
2017-05-07 15:56 ` [PATCH 3/9] xfs_spaceman: space management tool Darrick J. Wong
2017-05-27  1:34   ` Eric Sandeen
2017-05-30 17:37     ` Darrick J. Wong
2017-05-30 18:17       ` Eric Sandeen
2017-05-30 18:47         ` Darrick J. Wong
2017-06-02 19:44           ` Darrick J. Wong
2017-05-07 15:56 ` [PATCH 4/9] xfs_spaceman: add FITRIM support Darrick J. Wong
2017-05-27  0:27   ` Eric Sandeen
2017-05-30 18:24     ` Darrick J. Wong
2017-05-07 15:56 ` [PATCH 5/9] xfs_spaceman: add new speculative prealloc control Darrick J. Wong
2017-05-27  1:45   ` Eric Sandeen
2017-05-30 18:34     ` Darrick J. Wong [this message]
2017-05-07 15:56 ` [PATCH 6/9] xfs_spaceman: AG state control Darrick J. Wong
2017-05-26 23:06   ` Eric Sandeen
2017-05-30 18:30     ` Darrick J. Wong
2017-05-07 15:57 ` [PATCH 7/9] xfs_spaceman: Free space mapping command Darrick J. Wong
2017-05-27  1:57   ` Eric Sandeen
2017-05-30 18:40     ` Darrick J. Wong
2017-05-30 18:56       ` Eric Sandeen
2017-05-30 19:19         ` Darrick J. Wong
2017-05-07 15:57 ` [PATCH 8/9] xfs_spaceman: add a man page Darrick J. Wong
2017-05-07 15:57 ` [PATCH 9/9] xfs_spaceman: add group summary mode Darrick J. Wong
2017-05-08 19:47 ` [PATCH 0.9/9] xfs: introduce the XFS_IOC_GETFSMAP ioctl Darrick J. Wong
2017-05-10 14:46   ` Eric Sandeen
2017-05-10 17:03     ` Darrick J. Wong
2017-05-12 22:29   ` Eric Sandeen
2017-05-12 23:05     ` Darrick J. Wong
2017-05-12 23:11       ` Eric Sandeen
2017-05-26 21:20   ` Eric Sandeen
2017-05-26 21:41     ` Darrick J. Wong
2017-05-26 22:12       ` Eric Sandeen
2017-05-30 18:44         ` Darrick J. Wong
2017-05-30 18:47           ` Eric Sandeen
2017-05-30 18:59             ` Eric Sandeen
  -- strict thread matches above, loose matches on Subject: below --
2017-03-08  1:14 [PATCH v6 0/9] xfsprogs 4.12: GETFSMAP support Darrick J. Wong
2017-03-08  1:15 ` [PATCH 5/9] xfs_spaceman: add new speculative prealloc control Darrick J. Wong

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=20170530183400.GZ4519@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /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).