* [PATCH RFC] xfs_spaceman: updated preallocation support (eofblocks v6)
@ 2012-11-06 14:55 Brian Foster
2012-11-06 22:43 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Brian Foster @ 2012-11-06 14:55 UTC (permalink / raw)
To: xfs; +Cc: dchinner
This is an update to Dave's patch to xfs_spaceman to support
preallocation trimming. The original patch is here:
http://oss.sgi.com/archives/xfs/2012-10/msg00418.html
The code is updated as follows:
- Update to latest struct xfs_eofblocks (supports v6 of the
speculative preallocation inode tracking set).
- Support multiple id scan.
- Fix the minimum argument count (no args means a trylock scan).
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
Dave,
I can also squash this into the original and post a new version if that is
preferred.
Brian
spaceman/prealloc.c | 68 +++++++++++++++++++++++++++-----------------------
1 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/spaceman/prealloc.c b/spaceman/prealloc.c
index 8af30a6..ba6095d 100644
--- a/spaceman/prealloc.c
+++ b/spaceman/prealloc.c
@@ -31,23 +31,28 @@
struct xfs_eofblocks {
__u32 eof_version;
__u32 eof_flags;
- __u32 eof_q_id;
- __u32 eof_q_type;
- __u32 eof_min_file_size;
- unsigned char pad[12];
+ uid_t eof_uid;
+ gid_t eof_gid;
+ __u32 eof_prid;
+ __u64 eof_min_file_size;
+ __u32 pad[25];
};
/* eof_flags values */
-#define XFS_EOF_FLAGS_SYNC 0x01 /* sync/wait mode scan */
-#define XFS_EOF_FLAGS_QUOTA 0x02 /* filter by quota id */
-#define XFS_EOF_FLAGS_MINFILESIZE 0x04 /* filter by min file size */
+#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
int gflag;
int uflag;
int pflag;
int sflag;
-int qid;
+int uid;
+int gid;
+int prid;
int minlen;
static cmdinfo_t prealloc_cmd;
@@ -68,27 +73,23 @@ prealloc_f(
pflag = 0;
sflag = 0;
minlen = 0;
- qid = 0;
+ uid = 0;
+ gid = 0;
+ prid = 0;
while ((c = getopt(argc, argv, "g:m:p:su:")) != EOF) {
switch (c) {
case 'g':
- if (uflag || pflag)
- return command_usage(&prealloc_cmd);
gflag = 1;
- qid = atoi(optarg);
+ gid = atoi(optarg);
break;
case 'u':
- if (gflag || pflag)
- return command_usage(&prealloc_cmd);
uflag = 1;
- qid = atoi(optarg);
+ uid = atoi(optarg);
break;
case 'p':
- if (uflag || gflag)
- return command_usage(&prealloc_cmd);
pflag = 1;
- qid = atoi(optarg);
+ prid = atoi(optarg);
break;
case 's':
sflag = 1;
@@ -111,15 +112,20 @@ prealloc_f(
eofb.eof_flags |= XFS_EOF_FLAGS_MINFILESIZE;
eofb.eof_min_file_size = minlen;
}
- if (uflag || gflag || pflag) {
- eofb.eof_flags |= XFS_EOF_FLAGS_QUOTA;
- eofb.eof_q_id = qid;
- if (uflag)
- eofb.eof_q_type = XQM_USRQUOTA;
- else if (gflag)
- eofb.eof_q_type = XQM_GRPQUOTA;
- else if (pflag)
- eofb.eof_q_type = XQM_PRJQUOTA;
+
+ if (uflag) {
+ eofb.eof_flags |= XFS_EOF_FLAGS_UID;
+ eofb.eof_uid = uid;
+ }
+
+ if (gflag) {
+ eofb.eof_flags |= XFS_EOF_FLAGS_GID;
+ eofb.eof_gid = gid;
+ }
+
+ if (pflag) {
+ eofb.eof_flags |= XFS_EOF_FLAGS_PRID;
+ eofb.eof_prid = prid;
}
if (xfsctl(file->name, file->fd, XFS_IOC_FREE_EOFBLOCKS, &eofb) < 0) {
@@ -136,7 +142,7 @@ prealloc_help(void)
"\n"
"Control speculative preallocation\n"
"\n"
-"Options: [-s] [-ugp id] [-m minlen]\n"
+"Options: [-s] [-u id] [-g id] [-p id] [-m minlen]\n"
"\n"
" -s -- synchronous flush - wait for flush to complete\n"
" -u id -- remove prealloc on files matching user quota id <id>\n"
@@ -153,11 +159,11 @@ prealloc_init(void)
prealloc_cmd.name = "prealloc";
prealloc_cmd.altname = "prealloc";
prealloc_cmd.cfunc = prealloc_f;
- prealloc_cmd.argmin = 1;
+ prealloc_cmd.argmin = 0;
prealloc_cmd.argmax = -1;
- prealloc_cmd.args = "[-s] [-ugp id] [-m minlen]\n";
+ prealloc_cmd.args = "[-s] [-u id] [-g id] [-p id] [-m minlen]\n";
prealloc_cmd.flags = CMD_FLAG_GLOBAL;
- prealloc_cmd.oneline = _("Control specualtive preallocation");
+ prealloc_cmd.oneline = _("Control speculative preallocation");
prealloc_cmd.help = prealloc_help;
add_command(&prealloc_cmd);
--
1.7.7.6
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RFC] xfs_spaceman: updated preallocation support (eofblocks v6)
2012-11-06 14:55 [PATCH RFC] xfs_spaceman: updated preallocation support (eofblocks v6) Brian Foster
@ 2012-11-06 22:43 ` Dave Chinner
2012-11-06 22:58 ` Brian Foster
0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2012-11-06 22:43 UTC (permalink / raw)
To: Brian Foster; +Cc: dchinner, xfs
On Tue, Nov 06, 2012 at 09:55:04AM -0500, Brian Foster wrote:
> This is an update to Dave's patch to xfs_spaceman to support
> preallocation trimming. The original patch is here:
>
> http://oss.sgi.com/archives/xfs/2012-10/msg00418.html
>
> The code is updated as follows:
>
> - Update to latest struct xfs_eofblocks (supports v6 of the
> speculative preallocation inode tracking set).
> - Support multiple id scan.
> - Fix the minimum argument count (no args means a trylock scan).
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>
> Dave,
>
> I can also squash this into the original and post a new version if that is
> preferred.
I'll probably do that myself - the current code I have is a little
different so the patch probably won't apply, anyway. I'll need to
munge it to suit the eventual struct xfs_eofblocks format, anyway.
....
> @@ -136,7 +142,7 @@ prealloc_help(void)
> "\n"
> "Control speculative preallocation\n"
> "\n"
> -"Options: [-s] [-ugp id] [-m minlen]\n"
> +"Options: [-s] [-u id] [-g id] [-p id] [-m minlen]\n"
> "\n"
> " -s -- synchronous flush - wait for flush to complete\n"
> " -u id -- remove prealloc on files matching user quota id <id>\n"
> @@ -153,11 +159,11 @@ prealloc_init(void)
> prealloc_cmd.name = "prealloc";
> prealloc_cmd.altname = "prealloc";
> prealloc_cmd.cfunc = prealloc_f;
> - prealloc_cmd.argmin = 1;
> + prealloc_cmd.argmin = 0;
While technically correct, it's not the desired behaviour. I wanted
it to issue the usage if you just type the comment. I think I need
to add a "-a" flag for "flush all" here.
> - prealloc_cmd.oneline = _("Control specualtive preallocation");
> + prealloc_cmd.oneline = _("Control speculative preallocation");
Good catch, Brain! :)
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH RFC] xfs_spaceman: updated preallocation support (eofblocks v6)
2012-11-06 22:43 ` Dave Chinner
@ 2012-11-06 22:58 ` Brian Foster
0 siblings, 0 replies; 3+ messages in thread
From: Brian Foster @ 2012-11-06 22:58 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On 11/06/2012 05:43 PM, Dave Chinner wrote:
> On Tue, Nov 06, 2012 at 09:55:04AM -0500, Brian Foster wrote:
>...
>> I can also squash this into the original and post a new version if that is
>> preferred.
>
> I'll probably do that myself - the current code I have is a little
> different so the patch probably won't apply, anyway. I'll need to
> munge it to suit the eventual struct xfs_eofblocks format, anyway.
>
Ok, I'll have a v2 replacement of this once the alignment thing is fixed
up...
>
>> @@ -136,7 +142,7 @@ prealloc_help(void)
>> "\n"
...
>> - prealloc_cmd.argmin = 1;
>> + prealloc_cmd.argmin = 0;
>
> While technically correct, it's not the desired behaviour. I wanted
> it to issue the usage if you just type the comment. I think I need
> to add a "-a" flag for "flush all" here.
>
Ok.
>> - prealloc_cmd.oneline = _("Control specualtive preallocation");
>> + prealloc_cmd.oneline = _("Control speculative preallocation");
>
> Good catch, Brain! :)
>
Today a typo, tomorrow the world! ;)
Brain
> Cheers,
>
> Dave.
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-06 22:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-06 14:55 [PATCH RFC] xfs_spaceman: updated preallocation support (eofblocks v6) Brian Foster
2012-11-06 22:43 ` Dave Chinner
2012-11-06 22:58 ` Brian Foster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox