* [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth
@ 2009-01-28 13:56 Arkadiusz Miśkiewicz
2009-01-28 13:56 ` [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline Arkadiusz Miśkiewicz
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arkadiusz Miśkiewicz @ 2009-01-28 13:56 UTC (permalink / raw)
To: xfs
xfs_quota project directory depth processing can now be limited
to certain depth. For example: xfs_quota -x -c "project -d 2 -s 10"
limits recursion to level 2.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
---
quota/project.c | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/quota/project.c b/quota/project.c
index b4171e5..6635487 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -23,6 +23,7 @@
static cmdinfo_t project_cmd;
static prid_t prid;
+static int recurse_depth = -1;
enum {
CHECK_PROJECT = 0x1,
@@ -75,6 +76,10 @@ project_help(void)
" which do not have the project ID of the rest of the tree, or if the inode\n"
" flag is not set.\n"
"\n"
+" The -d <depth> option allows to descend at most <depth> levels of directories\n"
+" below the command line arguments. -d 0 means only apply the actions\n"
+" to the top level of the projects. -d -1 means no recursion limit (default).\n"
+"\n"
" The /etc/projid and /etc/projects file formats are simple, and described\n"
" on the xfs_quota man page.\n"
"\n"));
@@ -90,6 +95,9 @@ check_project(
struct fsxattr fsx;
int fd;
+ if (recurse_depth >= 0 && data->level > recurse_depth)
+ return -1;
+
if (flag == FTW_NS ){
exitcode = 1;
fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
@@ -132,6 +140,9 @@ clear_project(
struct fsxattr fsx;
int fd;
+ if (recurse_depth >= 0 && data->level > recurse_depth)
+ return -1;
+
if (flag == FTW_NS ){
exitcode = 1;
fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
@@ -176,6 +187,9 @@ setup_project(
struct fsxattr fsx;
int fd;
+ if (recurse_depth >= 0 && data->level > recurse_depth)
+ return -1;
+
if (flag == FTW_NS ){
exitcode = 1;
fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
@@ -219,15 +233,15 @@ project_operations(
switch (type) {
case CHECK_PROJECT:
printf(_("Checking project %s (path %s)...\n"), project, dir);
- nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
+ nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT);
break;
case SETUP_PROJECT:
printf(_("Setting up project %s (path %s)...\n"), project, dir);
- nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
+ nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT);
break;
case CLEAR_PROJECT:
printf(_("Clearing project %s (path %s)...\n"), project, dir);
- nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
+ nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT);
break;
}
}
@@ -249,8 +263,9 @@ project(
count++;
}
- printf(_("Processed %d %s paths for project %s\n"),
- count, projects_file, project);
+ printf(_("Processed %d %s paths for project %s with recursion depth %s (%d)\n"),
+ count, projects_file, project,
+ recurse_depth < 0 ? "infinite" : "limited", recurse_depth);
}
static int
@@ -260,11 +275,16 @@ project_f(
{
int c, type = 0;
- while ((c = getopt(argc, argv, "csC")) != EOF) {
+ while ((c = getopt(argc, argv, "cd:sC")) != EOF) {
switch (c) {
case 'c':
type = CHECK_PROJECT;
break;
+ case 'd':
+ recurse_depth = atoi(optarg);
+ if (recurse_depth < 0)
+ recurse_depth = -1;
+ break;
case 's':
type = SETUP_PROJECT;
break;
@@ -311,7 +331,7 @@ project_init(void)
project_cmd.name = _("project");
project_cmd.altname = _("tree");
project_cmd.cfunc = project_f;
- project_cmd.args = _("[-c|-s|-C] project ...");
+ project_cmd.args = _("[-c|-s|-C|-d <depth>] project ...");
project_cmd.argmin = 1;
project_cmd.argmax = -1;
project_cmd.oneline = _("check, setup or clear project quota trees");
--
1.6.1.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline
2009-01-28 13:56 [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Arkadiusz Miśkiewicz
@ 2009-01-28 13:56 ` Arkadiusz Miśkiewicz
2009-01-29 6:22 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Donald
2009-01-29 22:00 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Arkadiusz Miśkiewicz @ 2009-01-28 13:56 UTC (permalink / raw)
To: xfs
/etc/project is currently required for using project quota. This
patch adds ability to specify paths at command line.
fs_table_insert_project_path() introduced in libxcmd. Allows to insert
arbitrary path to fs_* iterating engine. We insert our paths with
-1 as project id (because we know no "original" id for this path
and generally this knowledge is not needed).
New option introduced for paths passing - project -p <path>.
Example:
$ sudo rm -f /etc/projects /etc/projid
$ sudo ./xfs_quota -x -c "project -p /tmp/xx -s 60"
Setting up project 60 (path /tmp/xx)...
Processed 1 (/etc/projects and cmdline) paths for project 60 with
recursion depth infinite (-1).
$ sudo ./xfs_quota -x -c "project -p /tmp/xx -c 60"
Checking project 60 (path /tmp/xx)...
Processed 1 (/etc/projects and cmdline) paths for project 60 with
recursion depth infinite (-1).
$ sudo ./xfs_quota -x -c "project -p /tmp/xx -c 70"
Checking project 70 (path /tmp/xx)...
/tmp/xx - project identifier is not set (inode=60, tree=70)
/tmp/xx/file1 - project identifier is not set (inode=60, tree=70)
/tmp/xx/file2 - project identifier is not set (inode=60, tree=70)
/tmp/xx/file3 - project identifier is not set (inode=60, tree=70)
/tmp/xx/dir1 - project identifier is not set (inode=60, tree=70)
/tmp/xx/dir2 - project identifier is not set (inode=60, tree=70)
Processed 1 (/etc/projects and cmdline) paths for project 70 with
recursion depth infinite (-1).
$ sudo ./xfs_quota -x -c "project -p /tmp/xx -s 70"
Setting up project 70 (path /tmp/xx)...
Processed 1 (/etc/projects and cmdline) paths for project 70 with
recursion depth infinite (-1).
$ sudo ./xfs_quota -x -c "project -p /tmp/xx -c 70"
Checking project 70 (path /tmp/xx)...
Processed 1 (/etc/projects and cmdline) paths for project 70 with
recursion depth infinite (-1).
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
---
include/path.h | 2 ++
libxcmd/paths.c | 28 ++++++++++++++++++++++++++++
quota/project.c | 28 ++++++++++++++++++++++------
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/include/path.h b/include/path.h
index 6bf7338..b8c8b31 100644
--- a/include/path.h
+++ b/include/path.h
@@ -52,6 +52,8 @@ extern void fs_table_destroy(void);
extern void fs_table_insert_mount(char *__mount);
extern void fs_table_insert_project(char *__project);
+extern void fs_table_insert_project_path(char *__dir, uint __projid);
+
extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
diff --git a/libxcmd/paths.c b/libxcmd/paths.c
index b84720a..facea06 100644
--- a/libxcmd/paths.c
+++ b/libxcmd/paths.c
@@ -402,6 +402,34 @@ fs_table_insert_project(
}
}
+void
+fs_table_insert_project_path(
+ char *udir,
+ prid_t prid)
+{
+ fs_path_t *fs;
+ char *dir = NULL, *fsname = NULL;
+ int error = 0;
+
+ if ((fs = fs_mount_point_from_path(udir)) != NULL) {
+ dir = strdup(udir);
+ fsname = strdup(fs->fs_name);
+ if (dir && fsname)
+ error = fs_table_insert(dir, prid,
+ FS_PROJECT_PATH, fsname, NULL, NULL);
+ else
+ error = ENOMEM;
+ } else
+ error = ENOENT;
+
+ if (error) {
+ if (dir) free(dir);
+ if (fsname) free(fsname);
+ fprintf(stderr, _("%s: cannot setup path for project dir %s: %s\n"),
+ progname, udir, strerror(error));
+ exit(1);
+ }
+}
/*
* Table iteration (cursor-based) interfaces
*/
diff --git a/quota/project.c b/quota/project.c
index 6635487..0f7a9e2 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -76,6 +76,11 @@ project_help(void)
" which do not have the project ID of the rest of the tree, or if the inode\n"
" flag is not set.\n"
"\n"
+" The -p <path> option can be used to manually specify project path without\n"
+" need to create /etc/projects file. This option can be used multiple times\n"
+" to specify multiple paths. When using this option only one projid/name can\n"
+" be specified at command line. Note that /etc/projects is also used if exists.\n"
+"\n"
" The -d <depth> option allows to descend at most <depth> levels of directories\n"
" below the command line arguments. -d 0 means only apply the actions\n"
" to the top level of the projects. -d -1 means no recursion limit (default).\n"
@@ -257,13 +262,13 @@ project(
fs_cursor_initialise(NULL, FS_PROJECT_PATH, &cursor);
while ((path = fs_cursor_next_entry(&cursor))) {
- if (prid != path->fs_prid)
+ if (prid != path->fs_prid && path->fs_prid != -1)
continue;
project_operations(project, path->fs_dir, type);
count++;
}
- printf(_("Processed %d %s paths for project %s with recursion depth %s (%d)\n"),
+ printf(_("Processed %d (%s and cmdline) paths for project %s with recursion depth %s (%d).\n"),
count, projects_file, project,
recurse_depth < 0 ? "infinite" : "limited", recurse_depth);
}
@@ -273,9 +278,9 @@ project_f(
int argc,
char **argv)
{
- int c, type = 0;
+ int c, type = 0, ispath = 0;
- while ((c = getopt(argc, argv, "cd:sC")) != EOF) {
+ while ((c = getopt(argc, argv, "cd:p:sC")) != EOF) {
switch (c) {
case 'c':
type = CHECK_PROJECT;
@@ -285,6 +290,10 @@ project_f(
if (recurse_depth < 0)
recurse_depth = -1;
break;
+ case 'p':
+ ispath = 1;
+ fs_table_insert_project_path(optarg, -1);
+ break;
case 's':
type = SETUP_PROJECT;
break;
@@ -304,13 +313,20 @@ project_f(
type = CHECK_PROJECT;
setprfiles();
- if (access(projects_file, F_OK) != 0) {
+ if (!ispath && access(projects_file, F_OK) != 0) {
exitcode = 1;
fprintf(stderr, _("projects file \"%s\" doesn't exist\n"),
projects_file);
return 0;
}
+ if (ispath && argc - optind > 1) {
+ exitcode = 1;
+ fprintf(stderr, _("%s: only one projid/name can be specified when using -p <path>, %d found.\n"),
+ progname, argc - optind);
+ return 0;
+ }
+
while (argc > optind) {
prid = prid_from_string(argv[optind]);
if (prid == -1) {
@@ -331,7 +347,7 @@ project_init(void)
project_cmd.name = _("project");
project_cmd.altname = _("tree");
project_cmd.cfunc = project_f;
- project_cmd.args = _("[-c|-s|-C|-d <depth>] project ...");
+ project_cmd.args = _("[-c|-s|-C|-d <depth>|-p <path>] project ...");
project_cmd.argmin = 1;
project_cmd.argmax = -1;
project_cmd.oneline = _("check, setup or clear project quota trees");
--
1.6.1.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth
2009-01-28 13:56 [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Arkadiusz Miśkiewicz
2009-01-28 13:56 ` [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline Arkadiusz Miśkiewicz
@ 2009-01-29 6:22 ` Donald
2009-01-29 7:51 ` [PATCH] [MAN]: Document new project quota options (-d and -p) Arkadiusz Miśkiewicz
2009-01-29 22:00 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Donald @ 2009-01-29 6:22 UTC (permalink / raw)
To: Arkadiusz Miśkiewicz; +Cc: xfs
Arkadiusz Miśkiewicz wrote:
> xfs_quota project directory depth processing can now be limited
> to certain depth. For example: xfs_quota -x -c "project -d 2 -s 10"
> limits recursion to level 2.
Nice improvements. Could you also update the man page for xfs_quota with for both changes?
Don
> Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
> ---
> quota/project.c | 34 +++++++++++++++++++++++++++-------
> 1 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/quota/project.c b/quota/project.c
> index b4171e5..6635487 100644
> --- a/quota/project.c
> +++ b/quota/project.c
> @@ -23,6 +23,7 @@
>
> static cmdinfo_t project_cmd;
> static prid_t prid;
> +static int recurse_depth = -1;
>
> enum {
> CHECK_PROJECT = 0x1,
> @@ -75,6 +76,10 @@ project_help(void)
> " which do not have the project ID of the rest of the tree, or if the inode\n"
> " flag is not set.\n"
> "\n"
> +" The -d <depth> option allows to descend at most <depth> levels of directories\n"
> +" below the command line arguments. -d 0 means only apply the actions\n"
> +" to the top level of the projects. -d -1 means no recursion limit (default).\n"
> +"\n"
> " The /etc/projid and /etc/projects file formats are simple, and described\n"
> " on the xfs_quota man page.\n"
> "\n"));
> @@ -90,6 +95,9 @@ check_project(
> struct fsxattr fsx;
> int fd;
>
> + if (recurse_depth >= 0 && data->level > recurse_depth)
> + return -1;
> +
> if (flag == FTW_NS ){
> exitcode = 1;
> fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -132,6 +140,9 @@ clear_project(
> struct fsxattr fsx;
> int fd;
>
> + if (recurse_depth >= 0 && data->level > recurse_depth)
> + return -1;
> +
> if (flag == FTW_NS ){
> exitcode = 1;
> fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -176,6 +187,9 @@ setup_project(
> struct fsxattr fsx;
> int fd;
>
> + if (recurse_depth >= 0 && data->level > recurse_depth)
> + return -1;
> +
> if (flag == FTW_NS ){
> exitcode = 1;
> fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -219,15 +233,15 @@ project_operations(
> switch (type) {
> case CHECK_PROJECT:
> printf(_("Checking project %s (path %s)...\n"), project, dir);
> - nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> + nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT);
> break;
> case SETUP_PROJECT:
> printf(_("Setting up project %s (path %s)...\n"), project, dir);
> - nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> + nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT);
> break;
> case CLEAR_PROJECT:
> printf(_("Clearing project %s (path %s)...\n"), project, dir);
> - nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> + nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT);
> break;
> }
> }
> @@ -249,8 +263,9 @@ project(
> count++;
> }
>
> - printf(_("Processed %d %s paths for project %s\n"),
> - count, projects_file, project);
> + printf(_("Processed %d %s paths for project %s with recursion depth %s (%d)\n"),
> + count, projects_file, project,
> + recurse_depth < 0 ? "infinite" : "limited", recurse_depth);
> }
>
> static int
> @@ -260,11 +275,16 @@ project_f(
> {
> int c, type = 0;
>
> - while ((c = getopt(argc, argv, "csC")) != EOF) {
> + while ((c = getopt(argc, argv, "cd:sC")) != EOF) {
> switch (c) {
> case 'c':
> type = CHECK_PROJECT;
> break;
> + case 'd':
> + recurse_depth = atoi(optarg);
> + if (recurse_depth < 0)
> + recurse_depth = -1;
> + break;
> case 's':
> type = SETUP_PROJECT;
> break;
> @@ -311,7 +331,7 @@ project_init(void)
> project_cmd.name = _("project");
> project_cmd.altname = _("tree");
> project_cmd.cfunc = project_f;
> - project_cmd.args = _("[-c|-s|-C] project ...");
> + project_cmd.args = _("[-c|-s|-C|-d <depth>] project ...");
> project_cmd.argmin = 1;
> project_cmd.argmax = -1;
> project_cmd.oneline = _("check, setup or clear project quota trees");
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH] [MAN]: Document new project quota options (-d and -p).
2009-01-29 6:22 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Donald
@ 2009-01-29 7:51 ` Arkadiusz Miśkiewicz
0 siblings, 0 replies; 5+ messages in thread
From: Arkadiusz Miśkiewicz @ 2009-01-29 7:51 UTC (permalink / raw)
To: xfs; +Cc: ddouwsma
Document -d <depth> and -p <path> project quota options.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
---
man/man8/xfs_quota.8 | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/man/man8/xfs_quota.8 b/man/man8/xfs_quota.8
index 6d1ea85..e9afa2e 100644
--- a/man/man8/xfs_quota.8
+++ b/man/man8/xfs_quota.8
@@ -547,6 +547,14 @@ instead of stdout.
.B project
[
.B \-cCs
+[
+.B \-d
+.I depth
+]
+[
+.B \-p
+.I path
+]
.I id
|
.I name
@@ -562,8 +570,14 @@ files). The
.BR \-C ,
and
.B \-s
-options allow the directory
-tree quota mechanism, discussed in detail below, to be maintained.
+options allow the directory tree quota mechanism to be maintained.
+.BR \-d
+allows to limit recursion level when processing project directories
+and
+.BR \-p
+allows to specify project paths at command line ( instead of
+.I /etc/projects
+). All options are discussed in detail below.
.SH DIRECTORY TREE QUOTA
The project quota mechanism in XFS can be used to implement a form of
directory tree quota, where a specified directory and all of the files
@@ -602,6 +616,18 @@ option can be used to check whether a
tree is setup, it reports nothing if the tree is correct, otherwise it
reports the paths of inodes which do not have the project ID of the rest
of the tree, or if the inode flag is not set.
+.PP
+Option
+.B \-d
+can be used to limit recursion level (-1 is infinite, 0 is top level only,
+1 is first level ... ).
+Option
+.B \-p
+adds posibility to specify project paths in command line without a need
+for
+.I /etc/projects
+to exist. Note that if projects file exists then it is also used.
+
.SH FILE FORMATS
There are two files involved with the tree quota mechanism, namely
.I /etc/projects
@@ -666,6 +692,17 @@ log file directories to only using 1 gigabyte of space).
# xfs_quota \-x \-c 'limit \-p bhard=1g logfiles' /var
.in -5
.fi
+.PP
+Same as above without a need for configuration files.
+.nf
+.sp
+.in +5
+# rm \-f /etc/projects /etc/projid
+# mount \-o prjquota /dev/xvm/var /var
+# xfs_quota \-x \-c 'project \-s \-p /var/log 42' /var
+# xfs_quota \-x \-c 'limit \-p bhard=1g 42' /var
+.in -5
+.fi
.SH CAVEATS
XFS implements delayed allocation (aka. allocate-on-flush) and this
has implications for the quota subsystem.
--
1.6.1.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth
2009-01-28 13:56 [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Arkadiusz Miśkiewicz
2009-01-28 13:56 ` [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline Arkadiusz Miśkiewicz
2009-01-29 6:22 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Donald
@ 2009-01-29 22:00 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2009-01-29 22:00 UTC (permalink / raw)
To: Arkadiusz Mi??kiewicz; +Cc: xfs
I've applied these three patches, and folded the missed translations
into the first patch.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-29 22:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 13:56 [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Arkadiusz Miśkiewicz
2009-01-28 13:56 ` [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline Arkadiusz Miśkiewicz
2009-01-29 6:22 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Donald
2009-01-29 7:51 ` [PATCH] [MAN]: Document new project quota options (-d and -p) Arkadiusz Miśkiewicz
2009-01-29 22:00 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox