xfsdump: exempt quota files from filesize checks
PATCH 1/1 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.
common/content.h +6 -0
@@ -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,
dump/content.c +29 -4
@@ -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);
dump/inomap.c +4 -2
@@ -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,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 13 lines · Bill Kendall
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 <[email protected]>common/content.h +0
-0
common/content.h typedef struct content_hdr content_hdr_t; · line 68
Quoted 4 lines
common/content.h +1
-0@@ -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
How is this related to the rest of the patch?
common/content.h typedef struct content_hdr content_hdr_t;
Quoted 10 lines
common/content.h +3
-3/* 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 } };
trailing fields in static structures are implicitly filled with zeroes.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 17 lines · Christoph Hellwig
Quoted 16 lines · Bill Kendall
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 <[email protected]>common/content.h +0
-0@@ -65,6 +65,8 @@ typedef struct content_hdr content_hdr_t;#define CONTENT_PQUOTAFILE "xfsdump_quotas_proj"#define CONTENT_GQUOTAFILE "xfsdump_quotas_group"
Quoted 3 lines
common/content.h typedef struct content_hdr content_hdr_t; · line 68
Quoted 1 line
common/content.h +1
-0+#ifdef DUMP How is this related to the rest of the patch?
is_quota_file() is not defined for xfsrestore. I then noticed that quota_info_t is not used in xfsrestore, so I expanded the ifdef to exclude it as well.
Quoted 13 lines
common/content.h typedef struct content_hdr content_hdr_t;
Quoted 11 lines
common/content.h +3
-3/* 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 } };trailing fields in static structures are implicitly filled with zeroes.
I guess I'm accustomed to seeing missing-initializer warnings. Guess they're not turned on for xfsdump. Better to be explicit anyway, IMHO.
Thanks for the review.
Bill
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs