Skip to contentSkip to conversation

xfsdump: prune inventory sessions by session id

PATCH In review Bill Kendall 2 participants 3 messages Feb 24, 2011 – Feb 25, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsdump: prune inventory sessions by session id

Allow xfsinvutil to prune inventory sessions by their ID instead of only by filesystem and cutoff date.

---
 invutil/getopt.h      |    3 +-
 invutil/invutil.c     |   99 ++++++++++++++++++++++++++++++++++++++----------
 invutil/invutil.h     |    7 ++-
 man/man8/xfsinvutil.8 |    7 +++
 4 files changed, 91 insertions(+), 25 deletions(-)
invutil/getopt.h +2 -1
index 14c9ec5..7170ac6 100644
@@ -18,7 +18,7 @@
 #ifndef GETOPT_H
 #define GETOPT_H
 
-#define GETOPT_CMDSTRING	"dilnu:wCFM:m:"
+#define GETOPT_CMDSTRING	"dilnu:wCFM:m:s:"
 
 #define GETOPT_DEBUG		'd'	/* debug */
 #define GETOPT_INTERACTIVE	'i'	/* interactive mode */
@@ -29,5 +29,6 @@
 #define GETOPT_FORCE		'F'	/* force - do not ask for confirmation */
 #define GETOPT_PRUNEMNT		'M'	/* prune mount point */
 #define GETOPT_PRUNEMEDIALABEL	'm'	/* prune media label */
+#define GETOPT_PRUNESESSION	's'	/* prune session id */
 
 #endif /* GETOPT_H */
invutil/invutil.c +78 -21

224 lines not on this page · raw message

invutil/invutil.h +4 -3
index dc42108..f1b1681 100644
@@ -44,9 +44,10 @@ extern bool_t	wait_for_locks;
 char *	GetFstabFullPath(char *);
 char *	GetNameOfInvIndex (char *, uuid_t);
 char *	GetNameOfStobj (char *inv_path, char *filename);
-void	CheckAndPruneFstab(char *, bool_t, char *, uuid_t *, time32_t, char *);
-int	CheckAndPruneInvIndexFile( bool_t, char *, time32_t, char *);
-int	CheckAndPruneStObjFile( bool_t, char *, time32_t, char *);
+void	CheckAndPruneFstab(
+		char *, bool_t, char *, uuid_t *, uuid_t *, time32_t, char *);
+int	CheckAndPruneInvIndexFile( bool_t, char *, uuid_t *, time32_t, char *);
+int	CheckAndPruneStObjFile( bool_t, char *, uuid_t *, time32_t, char *);
 int	uses_specified_mf_label(
 		invt_seshdr_t *, invt_session_t *, char	*, char *);
 time32_t ParseDate(char *);
man/man8/xfsinvutil.8 +7 -0
index 27db5dc..cb878be 100644
@@ -5,6 +5,7 @@ xfsinvutil \- \&xfsdump inventory database checking and pruning utility
 .nf
 \f3xfsinvutil\f1 [\-F|\-i] [\-m \f2media_label\f1] \-M \f2mount_point\f1 \f2mm/dd/yyyy\f1
 \f3xfsinvutil\f1 [\-F|\-i] [\-m \f2media_label\f1] \-u \f2UUID\f1 \f2mm/dd/yyyy\f1
+\f3xfsinvutil\f1 [\-F] \-s \f2SESSION_ID\f1
 \f3xfsinvutil\f1 \-i
 \f3xfsinvutil\f1 \-C
 .fi
@@ -64,6 +65,12 @@ in addition to those imposed by the date and the \f3\-M\f1 or
 references to media which may have been overwritten or lost. Note that
 this option does not apply to sessions with no media files.
 .TP 5
+\f3\-s\f1 \f2SESSION_ID\f1
+Prunes the dump session identified by the given session id.
+.I xfsinvutil
+will prompt the operator prior to pruning a dump session unless
+the \f3\-F\f1 option is given.
+.TP 5
 .B \-C
 With this option, 
 .I xfsinvutil 
Signature · 6 lines
1.7.0.4

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Bill Kendall

Allow xfsinvutil to prune inventory sessions by their ID instead of only by filesystem and cutoff date.

This would have been a bit nicer with a little more explanation. I.e.:
- You specify the session id using the new "-s <sessid>" command line option.
- The "-s" option is mutually exclusive with "-u <UUID>" and "-M <mount_point> <mm/dd/yy>". It also cannot be used together with the "-i" (interactive) or "-C" (consistency check) options.
- The change is implemented by adding a session id argument to CheckAndPruneFstab(), CheckAndPruneInvIndexFile(), and CheckAndPruneStObjFile(). That session becomes a third way of identifying entries to be pruned (in addition to mount point and UUID).

Anyway, this looks good to me. I have one question below, but regardless of your answer...

Quoted 3 lines

---

. . .

invutil/invutil.c

Quoted 4 lines
invutil/invutil.c +0 -0
index af6836b..37489c0 100644

. . .

invutil/invutil.c CheckAndPruneInvIndexFile( bool_t checkonly, · line 602

Quoted 10 lines
invutil/invutil.c +0 -6
@@ -594,14 +648,8 @@ CheckAndPruneInvIndexFile( bool_t checkonly,
 	    removeflag = BOOL_TRUE;
 	}    
 
-	if (( !removeflag ) && (checkonly == BOOL_FALSE) && 
-		( invIndexEntry[i].ie_timeperiod.tp_start < prunetime))
-	{
-	    IdxCheckOnly = BOOL_FALSE;
-	    printf("          Mount point match\n");
-	}

Why do you no longer print this in this case?

invutil/invutil.c CheckAndPruneInvIndexFile( bool_t checkonly, · line 655

Quoted 7 lines
invutil/invutil.c +2 -2
-	if (CheckAndPruneStObjFile(IdxCheckOnly, invIndexEntry[i].ie_filename,
-		    prunetime, r_mf_label) == -1) {
+	if (CheckAndPruneStObjFile(checkonly, invIndexEntry[i].ie_filename,
+		    sessionp, prunetime, r_mf_label) == -1) {
 	    removeflag = BOOL_TRUE; /* The StObj is gone */
 	}
 

. . .

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 4 lines · Alex Elder
Quoted 2 lines · Bill Kendall

Allow xfsinvutil to prune inventory sessions by their ID instead of only by filesystem and cutoff date.

Quoted 13 lines

This would have been a bit nicer with a little more explanation. I.e.:
- You specify the session id using the new "-s<sessid>" command line option.
- The "-s" option is mutually exclusive with "-u<UUID>" and "-M<mount_point> <mm/dd/yy>". It also cannot be used together with the "-i" (interactive) or "-C" (consistency check) options.
- The change is implemented by adding a session id argument to CheckAndPruneFstab(), CheckAndPruneInvIndexFile(), and CheckAndPruneStObjFile(). That session becomes a third way of identifying entries to be pruned (in addition to mount point and UUID).

Feel free to amend the commit message when you check this in. I agree that at least it should have mentioned that this adds a new xfsinvutil -s option.

Quoted 22 lines

Anyway, this looks good to me. I have one question below, but regardless of your answer...

Quoted 3 lines

---

. . .

invutil/invutil.c

Quoted 4 lines
invutil/invutil.c +0 -0
index af6836b..37489c0 100644

. . .

Quoted 4 lines
invutil/invutil.c +0 -0
@@ -594,14 +648,8 @@ CheckAndPruneInvIndexFile( bool_t checkonly,
  	    removeflag = BOOL_TRUE;
  	}
 
Quoted 8 lines

invutil/invutil.c CheckAndPruneInvIndexFile( bool_t checkonly, · line 602

Quoted 6 lines
invutil/invutil.c +0 -6
-	if (( !removeflag )&&  (checkonly == BOOL_FALSE)&&
-		( invIndexEntry[i].ie_timeperiod.tp_start<  prunetime))
-	{
-	    IdxCheckOnly = BOOL_FALSE;
-	    printf("          Mount point match\n");
-	}

Why do you no longer print this in this case?

The message did not seem to serve a purpose. To reach the print we already had to match on the mount point, and a message is already issued for that.

As you probably noticed, the 'if' statement did not serve a functional purpose since the prune time has to be checked for each session anyway, and further the 'if' statement would have to be reworked to consider whether this is a prune-by-session run.

As a side note, it's too bad that the consistency checking and pruning is coupled together. It would be much cleaner to implement the various pruning filters as separate functions.

Bill

Quoted 10 lines

invutil/invutil.c CheckAndPruneInvIndexFile( bool_t checkonly, · line 655

Quoted 8 lines
invutil/invutil.c +2 -2
-	if (CheckAndPruneStObjFile(IdxCheckOnly, invIndexEntry[i].ie_filename,
-		    prunetime, r_mf_label) == -1) {
+	if (CheckAndPruneStObjFile(checkonly, invIndexEntry[i].ie_filename,
+		    sessionp, prunetime, r_mf_label) == -1) {
  	    removeflag = BOOL_TRUE; /* The StObj is gone */
  	}
 

. . .

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs