All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Kendall <wkendall@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH] xfsdump: exempt quota files from filesize checks
Date: Thu, 1 Apr 2010 15:39:56 -0500	[thread overview]
Message-ID: <20100401203956.GA28295@sgi.com> (raw)

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>

diff --git a/common/content.h b/common/content.h
index e21f38e..03b72f0 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 7637fee..c6840e5 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 3a5cda0..fcb5792 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,

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2010-04-01 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 20:39 Bill Kendall [this message]
2010-04-03  9:22 ` [PATCH] xfsdump: exempt quota files from filesize checks Christoph Hellwig
2010-04-05 12:29   ` Bill Kendall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100401203956.GA28295@sgi.com \
    --to=wkendall@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.