]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Add new freeze subdirectory
authorSteve Lord <lord@sgi.com>
Thu, 17 May 2001 02:58:46 +0000 (02:58 +0000)
committerSteve Lord <lord@sgi.com>
Thu, 17 May 2001 02:58:46 +0000 (02:58 +0000)
Makefile
VERSION
freeze/Makefile [new file with mode: 0644]
freeze/xfs_freeze.c [new file with mode: 0644]
include/xfs_fs.h
include/xfs_mount.h
man/man8/xfs_freeze.8 [new file with mode: 0644]

index 885c9157451f43abaf8ed650479401c3b11858ba..6bcec76b9f7d3ddf57fd4a5f835ab96de319a5bc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ LSRCFILES = configure configure.in Makepkgs install-sh README VERSION
 LDIRT = config.* conftest* Logs/* built install.* install-dev.* *.gz
 
 SUBDIRS = include libxfs libhandle \
-       bmap db fsck growfs logprint mkfile mkfs repair rtcp \
+       bmap db freeze fsck growfs logprint mkfile mkfs repair rtcp \
        man doc debian build
 
 default: $(CONFIGURE)
diff --git a/VERSION b/VERSION
index ec9832e1395c153b8a89ea06211c03777f614d3b..d3e2c1382525c6127ac4337191348cb675437412 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -3,5 +3,5 @@
 #
 PKG_MAJOR=1
 PKG_MINOR=2
-PKG_REVISION=6
+PKG_REVISION=7
 PKG_BUILD=0
diff --git a/freeze/Makefile b/freeze/Makefile
new file mode 100644 (file)
index 0000000..b9820c1
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+# 
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+# 
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# 
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like.  Any license provided herein, whether implied or
+# otherwise, applies only to this software file.  Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston MA 02111-1307, USA.
+# 
+# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+# Mountain View, CA  94043, or:
+# 
+# http://www.sgi.com 
+# 
+# For further information regarding this notice, see: 
+# 
+# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+#
+
+TOPDIR = ..
+include $(TOPDIR)/include/builddefs
+
+CMDTARGET = xfs_freeze
+
+CFILES = xfs_freeze.c
+
+default: $(CMDTARGET)
+
+include $(BUILDRULES)
+
+install: default
+       $(INSTALL) -m 755 -d $(PKG_BIN_DIR)
+       $(INSTALL) -m 755 $(CMDTARGET) $(PKG_BIN_DIR)
+install-dev:
diff --git a/freeze/xfs_freeze.c b/freeze/xfs_freeze.c
new file mode 100644 (file)
index 0000000..9166a7b
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2001 Silicon Graphics, Inc.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+
+#include <libxfs.h>
+#include <sys/ioctl.h>
+#include <sys/vfs.h>
+
+char   *progname;
+
+static void
+usage(void)
+{
+       fprintf(stderr,
+"Usage: %s [options] mountpoint\n\n\
+Options:\n\
+        -f          freeze filesystem access\n\
+        -u          unfreeze filesystem access\n",
+               progname);
+       exit(2);
+}
+
+int
+main(int argc, char **argv)
+{
+       int                     c;      /* current option character */
+       int                     ffd;    /* mount point file descriptor */
+       int                     fflag, uflag;
+       int                     level;
+       struct statfs           buf;
+
+       fflag = uflag = 0;
+       progname = basename(argv[0]);
+       while ((c = getopt(argc, argv, "fu")) != EOF) {
+               switch (c) {
+               case 'f':
+                       fflag = 1;
+                       break;
+               case 'u':
+                       uflag = 1;
+                       break;
+               case '?':
+               default:
+                       usage();
+               }
+       }
+       if (argc - optind != 1)
+               usage();
+       if ((fflag + uflag) != 1)
+               usage();
+
+       ffd = open(argv[optind], O_RDONLY);
+       if (ffd < 0) {
+               perror(argv[optind]);
+               return 1;
+       }
+       fstatfs(ffd, &buf);
+       if (buf.f_type != XFS_SUPER_MAGIC) {
+               fprintf(stderr,
+                       "%s: specified file is not on an XFS filesystem\n",
+                       progname);
+               exit(1);
+       }
+
+       if (fflag) {
+               level = 1;
+               if (ioctl(ffd, XFS_IOC_FREEZE, &level) < 0) {
+                       fprintf(stderr, "%s: cannot freeze filesystem"
+                               " mounted at %s: %s\n",
+                               progname, argv[optind], strerror(errno));
+                       exit(1);
+               }
+       }
+
+       if (uflag) {
+               if (ioctl(ffd, XFS_IOC_THAW, &level) < 0) {
+                       fprintf(stderr, "%s: cannot unfreeze filesystem"
+                               " mounted at %s: %s\n",
+                               progname, argv[optind], strerror(errno));
+                       exit(1);
+               }
+       }
+
+       close(ffd);
+}
index 2f4a3dd45a5bcb825139b0d348bc9e325cc152a3..45ba66f31747620f8269ab011aec4f79773fc16a 100644 (file)
@@ -453,6 +453,8 @@ typedef struct xfs_handle {
 #define XFS_IOC_ERROR_CLEARALL       _IOW('X', 117, struct xfs_error_injection)
 #endif /* DEBUG || INDUCE_IO_ERROR */
 #define        XFS_IOC_ATTRCTL_BY_HANDLE    _IOWR('X', 118, struct xfs_fsop_attr_handlereq)
+#define XFS_IOC_FREEZE              _IOWR('X', 119, int)
+#define XFS_IOC_THAW                _IOWR('X', 120, int)
 /*
  * ioctl command to export information not in standard interfaces
  *     140: IRIX statvfs.f_fstr field - UUID from the superblock
index f76fdcad2ed164f5b7f42a0e4c920b5dc1827cbc..042f0395a6908aca0c6ab36230115a112cb48dfc 100644 (file)
@@ -308,6 +308,10 @@ typedef struct xfs_mount {
                                                /* which bits matter in rpc
                                                   log item pin masks */
        uint                    m_cxfstype;     /* mounted shared, etc. */
+       lock_t                  m_freeze_lock;
+       uint                    m_frozen;
+       sv_t                    m_wait_unfreeze;
+       atomic_t                m_active_trans;
 } xfs_mount_t;
 
 /*
@@ -482,6 +486,14 @@ void            xfs_freesb(xfs_mount_t *);
 void           _xfs_force_shutdown(struct xfs_mount *, int, char *, int);
 int            xfs_syncsub(xfs_mount_t *, int, int, int *);
 void           xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t, __int64_t);
+
+#define XFS_FREEZE_WRITE       1
+#define XFS_FREEZE_TRANS       2
+
+void           xfs_start_freeze(xfs_mount_t *, int);
+void           xfs_finish_freeze(xfs_mount_t *);
+void           xfs_check_frozen(xfs_mount_t *, int);
+
 extern struct vfsops xfs_vfsops;
 
 #endif /* __KERNEL__ */
diff --git a/man/man8/xfs_freeze.8 b/man/man8/xfs_freeze.8
new file mode 100644 (file)
index 0000000..b4105cd
--- /dev/null
@@ -0,0 +1,55 @@
+.TH xfs_freeze 8
+.SH NAME
+xfs_freeze \- suspend access to an XFS filesystem
+.SH SYNOPSIS
+.nf
+\f3xfs_freeze\f1 [ \f3\-fu\f1 ] [ \f3-t\f1 mtab ] mount-point
+.fi
+.SH DESCRIPTION
+.I xfs_freeze
+Suspend and resume access to an XFS filesystem (see
+.IR xfs (5)).
+The
+.I mount-point
+argument is the pathname of the directory where the filesystem
+is mounted.
+The filesystem must be mounted to be frozen (see
+.IR mount (8)).
+.I xfs_freeze
+is intended to be used with volume managers and hardware raid devices which
+support snapshotting,
+.I xfs_freeze
+will halt new access to the filesystem and create a stable image on disk 
+suitable for using as a snapshot.
+.PP
+Using the \f3\-f\f1 option, the filesystem is locked out from new
+modifications, write system calls are halted on entry, other calls
+which modify the filesystem are halted at the start of a transaction,
+all ongoing transactions in the filesystem are allowed to complete.
+.PP
+All dirty data is written out to disk, the log is flushed to disk and
+all dirty metadata is written out. The \f3\-u\f1 option is then used
+to unfreeze the filesystem and allow operations to continue.
+.PP
+The options to
+.I xfs_freeze
+are:
+.TP
+\f3\-f\f1
+Specifies that the filesystem should be frozen.
+.TP
+.B \-u
+Specifies that the filesystem should be unfrozen and new modifications
+allowed.
+.TP
+.B \-t
+Specifies an alternate mount table file (default is
+.IR /etc/mtab ).
+This is used when working with filesystems mounted without writing to
+.I /etc/mtab
+file - refer to
+.BR mount (8)
+for further details.
+.SH SEE ALSO
+lvm(8),
+mount(8).