Skip to content

Commit 13ba024

Browse files
committed
gufi_du
implements du with --apparent-size --block-size SIZE --total --summarize only includes file/link blocks/size directory blocks/size are not included requires the treesummary table to be present if no rows are returned from gufi_query, will print warning works with rollups changed -a to an enum AND -> RUN_ON_ROW (0) (default) OR -> RUN_SE (1) new: RUN_TSE (2) added totblocks to summary and treesummary tables gufi_rollup now copies treesummary data upwards
1 parent 644e42e commit 13ba024

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1206
-202
lines changed

docs/latex/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ set(gufi_administrator_inputs
138138
set(gufi_user_inputs
139139
sections/introduction.tex
140140
sections/user_env.tex
141+
sections/gufi_du.tex
141142
sections/gufi_find.tex
142143
sections/gufi_ls.tex
143144
sections/gufi_stats.tex

docs/latex/GUFIText.sty

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
\newcommand{\processdir}{\texttt{processdir}\xspace}
105105
\newcommand{\querydb}{\texttt{querydb}\xspace}
106106
\newcommand{\querydbs}{\texttt{querydbs}\xspace}
107+
\newcommand{\gufidu}{\texttt{gufi\_du}\xspace}
107108
\newcommand{\gufifind}{\texttt{gufi\_find}\xspace}
108109
\newcommand{\gufils}{\texttt{gufi\_ls}\xspace}
109110
\newcommand{\gufisqlite}{\texttt{gufi\_sqlite3}\xspace}

docs/latex/gufi_user.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
% Useful packages
6666
\usepackage{graphicx}
6767
\usepackage{hyperref}
68+
\usepackage{tabularx}
6869
\usepackage{textcomp}
6970
\usepackage{verbatim}
7071
\usepackage{GUFIText}
@@ -91,6 +92,7 @@
9192
\include{sections/license}
9293
\include{sections/introduction}
9394
\include{sections/user_env}
95+
\include{sections/gufi_du}
9496
\include{sections/gufi_find}
9597
\include{sections/gufi_ls}
9698
\include{sections/gufi_stat}

docs/latex/sections/gufi_du.tex

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
% This file is part of GUFI, which is part of MarFS, which is released
2+
% under the BSD license.
3+
%
4+
%
5+
% Copyright (c) 2017, Los Alamos National Security (LANS), LLC
6+
% All rights reserved.
7+
%
8+
% Redistribution and use in source and binary forms, with or without modification,
9+
% are permitted provided that the following conditions are met:
10+
%
11+
% 1. Redistributions of source code must retain the above copyright notice, this
12+
% list of conditions and the following disclaimer.
13+
%
14+
% 2. Redistributions in binary form must reproduce the above copyright notice,
15+
% this list of conditions and the following disclaimer in the documentation and/or
16+
% other materials provided with the distribution.
17+
%
18+
% 3. Neither the name of the copyright holder nor the names of its contributors
19+
% may be used to endorse or promote products derived from this software without
20+
% specific prior written permission.
21+
%
22+
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
% ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25+
% IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26+
% INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
% BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28+
% DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30+
% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31+
% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
%
33+
%
34+
% From Los Alamos National Security, LLC:
35+
% LA-CC-15-039
36+
%
37+
% Copyright (c) 2017, Los Alamos National Security, LLC All rights reserved.
38+
% Copyright 2017. Los Alamos National Security, LLC. This software was produced
39+
% under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
40+
% Laboratory (LANL), which is operated by Los Alamos National Security, LLC for
41+
% the U.S. Department of Energy. The U.S. Government has rights to use,
42+
% reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
43+
% ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
44+
% ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is
45+
% modified to produce derivative works, such modified software should be
46+
% clearly marked, so as not to confuse it with the version available from
47+
% LANL.
48+
%
49+
% THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND CONTRIBUTORS
50+
% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
51+
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52+
% ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS NATIONAL SECURITY, LLC OR
53+
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
54+
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
55+
% OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
56+
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
57+
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
58+
% IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
59+
% OF SUCH DAMAGE.
60+
61+
62+
63+
\section{\gufidu}
64+
\gufidu replicates a subset of the functionality provided by the POSIX
65+
command du.
66+
67+
\subsection{Notes}
68+
\begin{itemize}
69+
\item \gufidu requires the index to have treesummary data in at least
70+
the directory that is passed in. If only some directories have
71+
treesummary data, \gufidu without arguments will only report sizes
72+
from those directories.
73+
\begin{itemize}
74+
\item Run \gufitreesummary, \gufitreesummaryall, or \gufirollup
75+
before calling \gufidu.
76+
\end{itemize}
77+
\item \gufidu output does not include the block count or size of
78+
directories.
79+
\end{itemize}
80+
81+
\subsection{Flags}
82+
\begin{table} [h!]
83+
\centering
84+
\begin{tabularx}{\textwidth}{| l | X |}
85+
\hline
86+
Flags & Functionality \\
87+
\hline
88+
-{}-help & displays help menu \\
89+
\hline
90+
-v, -{}-version & show program's version number and exit \\
91+
\hline
92+
-{}-apparent-size & print apparent sizes, rather than disk usage;
93+
although the apparent size is usually smaller, it may be larger
94+
due to holes in ('sparse') files, internal fragmentation, indirect
95+
blocks, and the like \\
96+
\hline
97+
-B, -{}-block-size & scale sizes by SIZE before printing them \\
98+
\hline
99+
-c, -{}-total & produce a grand total \\
100+
\hline
101+
-s, -{}-summarize & display only a total for each argument \\
102+
\hline
103+
\end{tabularx}
104+
\caption{\label{fig:gufi_du flags}{gufi\_du Flags and Functionality}}
105+
\end{table}

docs/latex/sections/gufi_ls.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ \section{\gufils}
6868
\subsection{Flags}
6969
\begin{table} [h!]
7070
\centering
71-
\begin{tabular}{| l | r |}
71+
\begin{tabular}{| l | l |}
7272
\hline
7373
Flags & Functionality \\
7474
\hline

examples/gengidsummaryavoidentriesscan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ THREADS="${2:-1}"
7373
# if not, fall back to pulling from entries
7474

7575
echo "create gid summary records in summary tables in ${INDEX}"
76-
"${BFQ}" -n "${THREADS}" -a -w \
76+
"${BFQ}" -n "${THREADS}" -a 1 -w \
7777
-S "DELETE FROM summary WHERE rectype == 2; INSERT INTO summary (gid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, rectype) SELECT gid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, 2 FROM summary WHERE rectype == 0 AND mingid == maxgid" \
7878
-E "INSERT INTO summary (gid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, rectype) SELECT gid, SUM(CASE WHEN type == 'f' THEN 1 ELSE 0 END), SUM(CASE WHEN type == 'l' THEN 1 ELSE 0 END), MIN(uid), MAX(uid), MIN(gid), MAX(gid), MIN(size), MAX(size), SUM(CASE WHEN size <= 1024 then 1 ELSE 0 END), SUM(CASE WHEN size > 1024 then 1 ELSE 0 END), SUM(CASE WHEN size <= 1048576 then 1 ELSE 0 END), SUM(CASE WHEN size > 1048576 then 1 ELSE 0 END), SUM(CASE WHEN size > 1073741824 then 1 ELSE 0 END), SUM(CASE WHEN size > 1099511627776 then 1 ELSE 0 END), SUM(size), MIN(ctime), MAX(ctime), MIN(mtime), MAX(mtime), MIN(atime), MAX(atime), MIN(blocks), MAX(blocks), SUM(LENGTH(xattr_names) - LENGTH(REPLACE(xattr_names, char(31), ''))), MIN(crtime), MAX(crtime), MIN(ossint1), MAX(ossint1), SUM(ossint1), MIN(ossint2), MAX(ossint2), SUM(ossint2), MIN(ossint3), MAX(ossint3), SUM(ossint3), MIN(ossint4), MAX(ossint4), SUM(ossint4), 2 FROM entries WHERE NOT EXISTS (SELECT 1 FROM summary WHERE rectype == 2) GROUP BY gid;" \
7979
"${INDEX}"

examples/genuidsummaryavoidentriesscan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ THREADS="${2:-1}"
7373
# if not, fall back to pulling from entries
7474

7575
echo "create uid summary records in summary tables in ${INDEX}"
76-
"${BFQ}" -n "${THREADS}" -a -w \
76+
"${BFQ}" -n "${THREADS}" -a 1 -w \
7777
-S "DELETE FROM summary WHERE rectype == 1; INSERT INTO summary (uid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, rectype) SELECT uid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, 1 FROM summary WHERE rectype == 0 AND minuid == maxuid;" \
7878
-E "INSERT INTO summary (uid, totfiles, totlinks, minuid, maxuid, mingid, maxgid, minsize, maxsize, totltk, totmtk, totltm, totmtm, totmtg, totmtt, totsize, minctime, maxctime, minmtime, maxmtime, minatime, maxatime, minblocks, maxblocks, totxattr, mincrtime, maxcrtime, minossint1, maxossint1, totossint1, minossint2, maxossint2, totossint2, minossint3, maxossint3, totossint3, minossint4, maxossint4, totossint4, rectype) SELECT uid, SUM(CASE WHEN type == 'f' THEN 1 ELSE 0 END), SUM(CASE WHEN type == 'l' THEN 1 ELSE 0 END), MIN(uid), MAX(uid), MIN(gid), MAX(gid), MIN(size), MAX(size), SUM(CASE when size <= 1024 then 1 ELSE 0 END), SUM(CASE when size > 1024 then 1 ELSE 0 END), SUM(CASE when size <= 1048576 then 1 ELSE 0 END), SUM(CASE when size > 1048576 then 1 ELSE 0 END), SUM(CASE when size > 1073741824 then 1 ELSE 0 END), SUM(CASE when size > 1099511627776 then 1 ELSE 0 END), SUM(size), MIN(ctime), MAX(ctime), MIN(mtime), MAX(mtime), MIN(atime), MAX(atime), MIN(blocks), MAX(blocks), SUM(LENGTH(xattr_names) - LENGTH(REPLACE(xattr_names, char(31), ''))), MIN(crtime), MAX(crtime), MIN(ossint1), MAX(ossint1), SUM(ossint1), MIN(ossint2), MAX(ossint2), SUM(ossint2), MIN(ossint3), MAX(ossint3), SUM(ossint3), MIN(ossint4), MAX(ossint4), SUM(ossint4), 1 FROM entries WHERE NOT EXISTS (SELECT 1 FROM summary WHERE rectype == 1) GROUP BY uid;" \
7979
"${INDEX}"

include/bf.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct sum {
111111
long long int maxatime;
112112
long long int minblocks;
113113
long long int maxblocks;
114+
long long int totblocks; /* files only - does not include directory/self */
114115
long long int totxattr;
115116
long long int totsubdirs;
116117
long long int maxsubdirfiles;
@@ -133,10 +134,11 @@ struct sum {
133134
long long int totextdbs; /* only tracked in treesummary, not summary */
134135
};
135136

136-
typedef enum AndOr {
137-
AND,
138-
OR,
139-
} AndOr_t;
137+
typedef enum AFlag {
138+
RUN_ON_ROW = 0, /* if returned row, run next SQL, else stop (continue descent) (default) */
139+
RUN_SE = 1, /* skip T, run S and E whether or not a row was returned (old -a) */
140+
RUN_TSE = 2, /* run T, S, and E whether or not a row was returned */
141+
} AFlag_t;
140142

141143
typedef enum OutputMethod {
142144
STDOUT, /* default */
@@ -212,7 +214,7 @@ struct input {
212214
char delim;
213215
int buildindex;
214216
size_t maxthreads;
215-
AndOr_t andor;
217+
AFlag_t process_sql; /* what to do if an SQL statement returns/doesn't return 1 row */
216218
int insertdir; // added for bfwreaddirplus2db
217219
int insertfl; // added for bfwreaddirplus2db
218220
int suspectd; // added for bfwreaddirplus2db for how to default suspect directories 0 - not supsect 1 - suspect

include/dbutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ extern const char ENTRIES_INSERT[];
109109
/* directory metadata + aggregate data */
110110
#define SUMMARY "summary"
111111
#define SUMMARY_SCHEMA(name, extra_cols) \
112-
"CREATE TABLE " name "(" extra_cols "name TEXT, type TEXT, inode TEXT, mode INT64, nlink INT64, uid INT64, gid INT64, size INT64, blksize INT64, blocks INT64, atime INT64, mtime INT64, ctime INT64, linkname TEXT, xattr_names BLOB, totfiles INT64, totlinks INT64, minuid INT64, maxuid INT64, mingid INT64, maxgid INT64, minsize INT64, maxsize INT64, totzero INT64, totltk INT64, totmtk INT64, totltm INT64, totmtm INT64, totmtg INT64, totmtt INT64, totsize INT64, minctime INT64, maxctime INT64, minmtime INT64, maxmtime INT64, minatime INT64, maxatime INT64, minblocks INT64, maxblocks INT64, totxattr INT64, depth INT64, mincrtime INT64, maxcrtime INT64, minossint1 INT64, maxossint1 INT64, totossint1 INT64, minossint2 INT64, maxossint2 INT64, totossint2 INT64, minossint3 INT64, maxossint3 INT64, totossint3 INT64, minossint4 INT64, maxossint4 INT64, totossint4 INT64, rectype INT64, pinode TEXT, isroot INT64, rollupscore INT64);"
112+
"CREATE TABLE " name "(" extra_cols "name TEXT, type TEXT, inode TEXT, mode INT64, nlink INT64, uid INT64, gid INT64, size INT64, blksize INT64, blocks INT64, atime INT64, mtime INT64, ctime INT64, linkname TEXT, xattr_names BLOB, totfiles INT64, totlinks INT64, minuid INT64, maxuid INT64, mingid INT64, maxgid INT64, minsize INT64, maxsize INT64, totzero INT64, totltk INT64, totmtk INT64, totltm INT64, totmtm INT64, totmtg INT64, totmtt INT64, totsize INT64, minctime INT64, maxctime INT64, minmtime INT64, maxmtime INT64, minatime INT64, maxatime INT64, minblocks INT64, maxblocks INT64, totblocks INT16, totxattr INT64, depth INT64, mincrtime INT64, maxcrtime INT64, minossint1 INT64, maxossint1 INT64, totossint1 INT64, minossint2 INT64, maxossint2 INT64, totossint2 INT64, minossint3 INT64, maxossint3 INT64, totossint3 INT64, minossint4 INT64, maxossint4 INT64, totossint4 INT64, rectype INT64, pinode TEXT, isroot INT64, rollupscore INT64);"
113113
extern const char SUMMARY_CREATE[];
114114

115115
/* view of summary table with rollups */
@@ -136,7 +136,7 @@ extern const char VRPENTRIES_CREATE[];
136136
/* aggregate data of tree starting at current directory */
137137
#define TREESUMMARY "treesummary"
138138
#define TREESUMMARY_SCHEMA(name, extra_cols) \
139-
"CREATE TABLE " name "(" extra_cols "inode TEXT, pinode TEXT, totsubdirs INT64, maxsubdirfiles INT64, maxsubdirlinks INT64, maxsubdirsize INT64, totfiles INT64, totlinks INT64, minuid INT64, maxuid INT64, mingid INT64, maxgid INT64, minsize INT64, maxsize INT64, totzero INT64, totltk INT64, totmtk INT64, totltm INT64, totmtm INT64, totmtg INT64, totmtt INT64, totsize INT64, minctime INT64, maxctime INT64, minmtime INT64, maxmtime INT64, minatime INT64, maxatime INT64, minblocks INT64, maxblocks INT64, totxattr INT64, depth INT64, mincrtime INT64, maxcrtime INT64, minossint1 INT64, maxossint1 INT64, totossint1 INT64, minossint2 INT64, maxossint2 INT64, totossint2 INT64, minossint3 INT64, maxossint3 INT64, totossint3 INT64, minossint4 INT64, maxossint4 INT64, totossint4 INT64, totextdbs INT64, rectype INT64, uid INT64, gid INT64);"
139+
"CREATE TABLE " name "(" extra_cols "inode TEXT, pinode TEXT, totsubdirs INT64, maxsubdirfiles INT64, maxsubdirlinks INT64, maxsubdirsize INT64, totfiles INT64, totlinks INT64, minuid INT64, maxuid INT64, mingid INT64, maxgid INT64, minsize INT64, maxsize INT64, totzero INT64, totltk INT64, totmtk INT64, totltm INT64, totmtm INT64, totmtg INT64, totmtt INT64, totsize INT64, minctime INT64, maxctime INT64, minmtime INT64, maxmtime INT64, minatime INT64, maxatime INT64, minblocks INT64, maxblocks INT64, totblocks INT64, totxattr INT64, depth INT64, mincrtime INT64, maxcrtime INT64, minossint1 INT64, maxossint1 INT64, totossint1 INT64, minossint2 INT64, maxossint2 INT64, totossint2 INT64, minossint3 INT64, maxossint3 INT64, totossint3 INT64, minossint4 INT64, maxossint4 INT64, totossint4 INT64, totextdbs INT64, rectype INT64, uid INT64, gid INT64);"
140140
#define TREESUMMARY_CREATE \
141141
DROP_TABLE(TREESUMMARY) \
142142
TREESUMMARY_SCHEMA(TREESUMMARY, "")

scripts/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
# gufi_* scripts
6464
set(TOOLS
65+
du
6566
find
6667
getfattr
6768
ls

0 commit comments

Comments
 (0)