diff options
author | Bill Kendall <wkendall@sgi.com> | 2010-04-01 20:39:56 +0000 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-06 12:58:54 -0500 |
commit | e4387c2797c4fbf4b20b85901d8fd4ce13aee407 (patch) | |
tree | 1dc546b1def837379aedbe035ca671462a00e588 | |
parent | 576896edf7119010f0391376949e1425a26b6ed4 (diff) | |
download | xfsdump-dev-e4387c2797c4fbf4b20b85901d8fd4ce13aee407.tar.gz |
xfsdump: exempt quota files from filesize checks
xfsdump backs up quota information by generating quota dump files
("xfs_quota -c dump") in the root of the filesystem being dumped.
If the user filters files from the dump based on max file size (-z
option) the quota files may not be dumped. The following patch makes
the quota files exempt from the max filesize checks.
Signed-off-by: Bill Kendall <wkendall@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r-- | common/content.h | 6 | ||||
-rw-r--r-- | dump/content.c | 33 | ||||
-rw-r--r-- | dump/inomap.c | 6 |
3 files changed, 39 insertions, 6 deletions
diff --git a/common/content.h b/common/content.h index e21f38e5..03b72f03 100644 --- a/common/content.h +++ b/common/content.h @@ -65,6 +65,8 @@ typedef struct content_hdr content_hdr_t; #define CONTENT_PQUOTAFILE "xfsdump_quotas_proj" #define CONTENT_GQUOTAFILE "xfsdump_quotas_group" +#ifdef DUMP + struct quota_info { char * desc; /* Quotas type (user, project, etc) */ bool_t savequotas; /* Quotas saved OK */ @@ -72,10 +74,14 @@ struct quota_info { char quotapath[MAXPATHLEN]; /* Full path to quotafile */ char * repquotaargs; /* Args to repquota to create this quotafile */ int statflag; /* quota stats flag for this type */ + ino_t quotaino; /* ino of the quota file */ }; typedef struct quota_info quota_info_t; +extern bool_t is_quota_file(ino_t ino); + +#endif /* DUMP */ #ifdef DUMP extern bool_t content_init( intgen_t argc, diff --git a/dump/content.c b/dump/content.c index 7637fee0..c6840e59 100644 --- a/dump/content.c +++ b/dump/content.c @@ -498,9 +498,9 @@ static bool_t sc_savequotas = BOOL_TRUE; /* save quota information in dump */ static quota_info_t quotas[] = { - { "user quota", BOOL_TRUE, CONTENT_QUOTAFILE, "", "-uf", XFS_QUOTA_UDQ_ACCT }, - { "project quota", BOOL_TRUE, CONTENT_PQUOTAFILE, "", "-pf", XFS_QUOTA_PDQ_ACCT }, - { "group quota", BOOL_TRUE, CONTENT_GQUOTAFILE, "", "-gf", XFS_QUOTA_GDQ_ACCT } + { "user quota", BOOL_TRUE, CONTENT_QUOTAFILE, "", "-uf", XFS_QUOTA_UDQ_ACCT, 0 }, + { "project quota", BOOL_TRUE, CONTENT_PQUOTAFILE, "", "-pf", XFS_QUOTA_PDQ_ACCT, 0 }, + { "group quota", BOOL_TRUE, CONTENT_GQUOTAFILE, "", "-gf", XFS_QUOTA_GDQ_ACCT, 0 } }; /* definition of locally defined global functions ****************************/ @@ -3976,7 +3976,9 @@ dump_file( void *arg1, 1); } - if (estimated_size > maxdumpfilesize) { + /* quota files are exempt from max size check */ + if (estimated_size > maxdumpfilesize && + !is_quota_file(statp->bs_ino)) { mlog( MLOG_DEBUG | MLOG_NOTE, "ino %llu increased beyond maximum size: " "NOT dumping\n", @@ -6698,6 +6700,18 @@ check_complete_flags( void ) return completepr; } +extern bool_t +is_quota_file(ino_t ino) +{ + int i; + + for(i = 0; i < (sizeof(quotas) / sizeof(quotas[0])); i++) { + if (quotas[i].savequotas && ino == quotas[i].quotaino) + return BOOL_TRUE; + } + return BOOL_FALSE; +} + #define REPQUOTA "xfs_quota" static bool_t @@ -6707,6 +6721,7 @@ save_quotas( char *mntpnt, quota_info_t *quotainfo ) char buf[1024] = ""; int fd; char tmp; + struct stat statb; mlog( MLOG_VERBOSE, _( "saving %s information for: %s\n"), quotainfo->desc, mntpnt ); @@ -6747,6 +6762,16 @@ save_quotas( char *mntpnt, quota_info_t *quotainfo ) strerror( errno )); return BOOL_FALSE; } + if(fstat(fd, &statb) < 0) { + mlog( MLOG_ERROR, _( + "stat failed %s: %s\n"), + quotainfo->quotapath, + strerror( errno )); + close(fd); + return BOOL_FALSE; + } + quotainfo->quotaino = statb.st_ino; + /* open and read dump file to ensure it is in the dump */ read(fd, &tmp, 1); close(fd); diff --git a/dump/inomap.c b/dump/inomap.c index 3a5cda0a..fcb57926 100644 --- a/dump/inomap.c +++ b/dump/inomap.c @@ -558,10 +558,12 @@ cb_add( void *arg1, } else { estimated_size = estimate_dump_space( statp ); - /* skip if size is greater than prune size + /* skip if size is greater than prune size. quota + * files are exempt from the check. */ if ( maxdumpfilesize > 0 && - estimated_size > maxdumpfilesize ) { + estimated_size > maxdumpfilesize && + !is_quota_file(statp->bs_ino) ) { mlog( MLOG_DEBUG | MLOG_EXCLFILES, "pruned ino %llu, owner %u, estimated size %llu: maximum size exceeded\n", statp->bs_ino, |