gfs2-utils: master - gfs2-utils: Remove obsolete tools
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=46388807...
Commit: 46388807a62c24e4156584481f7df5eb7c8620cd
Parent: 954ccb986b9a18204e7d3137f4fae97bbcb2be8a
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 29 14:54:47 2012 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Jun 29 14:54:47 2012 +0100
gfs2-utils: Remove obsolete tools
gfs2_tool and gfs2_quota have been destined for removal for some time
and now that Fedora 15 has EOL'd the time has come to do so.
Users of gfs2_quota should now use the generic quota utilities
Users of gfs2_tool should now use tunegfs2, mount options and the
generic dmsetup and chattr/lsattr tools.
This also removes the mount.gfs2 manpage as mount.gfs2 was removed some
time ago. Mount options can be found in the gfs2(5) manpage.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 2 -
gfs2/Makefile.am | 2 +-
gfs2/man/Makefile.am | 3 -
gfs2/man/gfs2_quota.8 | 105 ------
gfs2/man/gfs2_tool.8 | 117 ------
gfs2/man/mount.gfs2.8 | 233 ------------
gfs2/quota/Makefile.am | 14 -
gfs2/quota/check.c | 601 -------------------------------
gfs2/quota/gfs2_quota.h | 95 -----
gfs2/quota/main.c | 911 -----------------------------------------------
gfs2/quota/names.c | 83 -----
gfs2/quota/target.mk | 3 -
gfs2/tool/Makefile.am | 13 -
gfs2/tool/gfs2_tool.h | 64 ----
gfs2/tool/iflags.h | 40 --
gfs2/tool/main.c | 198 ----------
gfs2/tool/misc.c | 343 ------------------
gfs2/tool/ondisk.c | 13 -
gfs2/tool/sb.c | 229 ------------
gfs2/tool/target.mk | 3 -
gfs2/tool/tune.c | 146 --------
21 files changed, 1 insertions(+), 3217 deletions(-)
diff --git a/configure.ac b/configure.ac
index e58aac9..570f826 100644
--- a/configure.ac
+++ b/configure.ac
@@ -280,8 +280,6 @@ AC_CONFIG_FILES([Makefile
gfs2/edit/Makefile
gfs2/fsck/Makefile
gfs2/mkfs/Makefile
- gfs2/quota/Makefile
- gfs2/tool/Makefile
gfs2/tune/Makefile
gfs2/man/Makefile
gfs2/lockgather/Makefile
diff --git a/gfs2/Makefile.am b/gfs2/Makefile.am
index 1011739..710ba8b 100644
--- a/gfs2/Makefile.am
+++ b/gfs2/Makefile.am
@@ -1,4 +1,4 @@
MAINTAINERCLEANFILES = Makefile.in
-SUBDIRS = libgfs2 convert edit fsck mkfs quota tool man \
+SUBDIRS = libgfs2 convert edit fsck mkfs man \
tune include lockgather #init.d
diff --git a/gfs2/man/Makefile.am b/gfs2/man/Makefile.am
index 648ed84..caf4658 100644
--- a/gfs2/man/Makefile.am
+++ b/gfs2/man/Makefile.am
@@ -6,9 +6,6 @@ dist_man_MANS = fsck.gfs2.8 \
gfs2_edit.8 \
gfs2_grow.8 \
gfs2_jadd.8 \
- gfs2_quota.8 \
- gfs2_tool.8 \
mkfs.gfs2.8 \
gfs2_lockgather.8 \
- mount.gfs2.8 \
tunegfs2.8
diff --git a/gfs2/man/gfs2_quota.8 b/gfs2/man/gfs2_quota.8
deleted file mode 100644
index 04e09e8..0000000
--- a/gfs2/man/gfs2_quota.8
+++ /dev/null
@@ -1,105 +0,0 @@
-.TH gfs2_quota 8
-
-.SH NAME
-gfs2_quota - Manipulate GFS2 disk quotas
-
-.SH SYNOPSIS
-.B gfs2_quota
-<list|sync|get|limit|warn|check|init|reset> [\fIOPTION\fR]...
-
-.SH DESCRIPTION
-gfs2_quota is used to examine and change quota values in a GFS2 filesystem.
-This command has a number of different actions.
-
-GFS2 introduced a new linked list format for the quotas in the quota file.
-This list format allows for faster \fBlist\fP, \fBcheck\fP and \fBinit\fP
-operations. Older GFS2 quota files may be migrated to this newer format using
-the \fBgfs2_quota reset\fP command.
-
-.SH ACTIONS
-.TP
-\fBlist\fP
-List the contents of the quota file. Only IDs that have a non-zero hard limit,
-warn limit, or value are printed.
-.TP
-\fBsync\fP
-Sync any local quota changes to the quota file.
-.TP
-\fBget\fP
-Get the current data for the ID specified by the -u or -g argument.
-.TP
-\fBlimit\fP
-Set the current hard limit for the ID specified by the -u or -g argument to
-the value specified by the -l argument on the specified filesystem.
-The filesystem won't let the user or group use more than this much space.
-A value of zero here means that no limit is enforced.
-.TP
-\fBwarn\fP
-Set the current warn limit for the ID specified by the -u or -g argument to
-the value specified by the -l argument on the specified filesystem.
-The filesystem will start complaining to the user or group when more
-than this much space is used. A value of zero here means that the
-user won't ever be warned.
-.TP
-\fBcheck\fP
-Scan a filesystem and make sure that what's out there on the disk matches
-what's in the quota file. This is only accurate if the filesystem is
-idle when this is running. If there is a mismatch, it is printed to
-stdout. Note: GFS2 quotas are transactional and a quota check is \fBnot\fP
-needed every time there is a system crash.
-.TP
-\fBinit\fP
-Scan a filesystem and initialize the quota file with the values obtained
-from the scan. The filesystem should be idle when this is run. You should
-only need to do this if you upgrade a pre-quota GFS2 filesystem (pre-GFS2 5.1).
-.TP
-\fBreset\fP
-The \fBreset\fP operation will truncate the quota file and all quota
-information (values, limits, warnings) will be lost. All quota limits and
-warnings will have to be reassigned after this operation.
-
-.SH OPTIONS
-\fB-b\fP
-The units for disk space are filesystem blocks.
-.TP
-\fB-f\fP \fIDirectory\fR
-Specifies which filesystem to perform the action on.
-.TP
-\fB-g\fP \fIGID\fR
-Specifies the group ID for get, limit, or warn. It can be either
-the group name from the group file, or the GID number.
-.TP
-\fB-h\fP
-Print out a help message describing available
-options, then exit.
-.TP
-\fB-k\fP
-The units for disk space are kilobytes.
-.TP
-\fB-l\fP \fISize\fR
-Specifies the new value for the limit or warn actions.
-The value is assumed to be in the units specified by the
--m, -k, -s, -b arguments. The default is megabytes.
-.TP
-\fB-m\fP
-The units for disk space are megabytes. This is the default.
-.TP
-\fB-n\fP
-Don't try to resolve UIDs and GIDs into user and group names.
-.TP
-\fB-s\fP
-The units for disk space are sectors (512-byte blocks).
-.TP
-\fB-u\fP \fIUID\fR
-Specifies the user ID for get, limit, or warn. It can be either
-the username from the password file, or the UID number.
-.TP
-\fB-V\fP
-Print program version information, then exit.
-
-.SH EXAMPLE
-To set the hard limit for user "nobody" to
-1048576 kilobytes on filesystem /gfs20
-
-gfs2_quota limit -l 1048576 -k -u nobody -f /gfs20
-
diff --git a/gfs2/man/gfs2_tool.8 b/gfs2/man/gfs2_tool.8
deleted file mode 100644
index dccd631..0000000
--- a/gfs2/man/gfs2_tool.8
+++ /dev/null
@@ -1,117 +0,0 @@
-.TH gfs2_tool 8
-
-.SH NAME
-gfs2_tool - interface to gfs2 ioctl/sysfs calls
-
-.SH SYNOPSIS
-.B gfs2_tool
-\fICOMMAND\fR [\fIOPTION\fR]...
-
-.SH DESCRIPTION
-gfs2_tool is an interface to a variety of the GFS2 ioctl/sysfs calls. Some
-of the functions of gfs_tool have been replaced by standard system tools
-such as mount and chattr, so gfs2_tool doesn't have as many options
-as gfs_tool used to.
-
-.SH COMMANDS
-.TP
-\fBclearflag\fP \fIFlag\fR \fIFile1\fR \fIFile2\fR \fI...\fR
-Clear an attribute flag on a file. This is now obsolete and kept
-only for backward compatibility, chattr is the preferred way to
-clear attribute flags. See \fBsetflag\fP for available flags. This
-option will probably be removed at a future date.
-.TP
-\fBfreeze\fP \fIMountPoint\fR
-Freeze (quiesce) a GFS2 cluster.
-.TP
-\fBgettune\fP \fIMountPoint\fR
-Print out the current values of the tuning parameters in a running
-filesystem. A better source of similar (more comprehensive) information
-is that in the /proc/mounts file. Running the mount command with no
-arguments will also provide the same information. This option is
-considered obsolete and will probably be removed at some future
-date.
-.TP
-\fBjournals\fP \fIMountPoint\fR
-Print out information about the journals in a mounted filesystem.
-.TP
-\fBlockdump\fP \fIMountPoint\fR
-Print out information about the locks this machine holds for a given
-filesystem. This information is also available via the debugfs
-glock dump file, and accessing that file is the preferred method
-of obtaining a dump of the glock state.
-.\".TP
-.\"\fBrindex\fP \fIMountPoint\fR
-.\"Print out the resource group index of a mounted filesystem.
-.TP
-\fBsb\fP \fIdevice\fR \fBproto\fP \fI[newvalue]\fR
-View (and possibly replace) the name of the locking protocol in the
-file system superblock. The file system shouldn't be mounted by any
-client when you do this.
-.TP
-\fBsb\fP \fIdevice\fR \fBtable\fP \fI[newvalue]\fR
-View (and possibly replace) the name of the locking table in the
-file system superblock. The file system shouldn't be mounted by any
-client when you do this.
-.TP
-\fBsb\fP \fIdevice\fR \fBondisk\fP \fI[newvalue]\fR
-View (and possibly replace) the ondisk format number in the
-file system superblock. The file system shouldn't be mounted by any
-client when you do this. No one should have to use this.
-.TP
-\fBsb\fP \fIdevice\fR \fBmultihost\fP \fI[newvalue]\fR
-View (and possibly replace) the multihost format number in the
-file system superblock. The file system shouldn't be mounted by any
-client when you do this. No one should have to use this.
-.TP
-\fBsb\fP \fIdevice\fR \fBuuid\fP \fI[newvalue]\fR
-View (and possibly replace) the uuid in the file system superblock.
-The file system shouldn't be mounted by any client when you do this.
-The new uuid value should be in the standard uuid format. For
-example: 1AEA8269-15C5-72BD-6D83-8720B17AA4EE
-.TP
-\fBsb\fP \fIdevice\fR \fBall\fP
-Print out the superblock.
-.TP
-\fBsetflag\fP \fIFlag\fR \fIFile1\fR \fIFile2\fR \fI...\fR
-Set an attribute flag on a file. The currently supported flags are
-jdata, immutable, appendonly, noatime, and sync. The
-chattr command is the preferred way to set attributes on
-files. This option will probably be removed at a future date.
-
-The \fIjdata\fR flag causes all the data written to a file
-to be journaled. If the \fIjdata\fR flag is set for a directory,
-all files and directories subsequently created within that directory
-are also journaled. This behavior replaces the old \fIinherit_jdata\fR
-flag from gfs. Same as chattr +j.
-
-The \fIimmutable\fR flag marks the file immutable. The behavior is
-similar to the immutable flag in the ext2/3 filesystems. All write
-access is denied. Same as chattr +i.
-
-The \fIappendonly\fR flag causes all data to be written at the end of
-the file. Same as chattr +a.
-
-The \fInoatime\fR flag disables updates to the file's access time.
-Same as chattr +A.
-
-The \fIsync\fR flag causes data written to the file to be sync'ed to
-stable storage immediately. Same as chattr +S.
-.TP
-\fBsettune\fP \fIMountPoint\fR \fIparameter\fR \fInewvalue\fR
-Set the value of tuning parameter. Use \fBgettune\fP for a listing of
-tunable parameters. The mount -oremount command is the preferred way
-to set the values of tunable parameters. At some future stage, when
-all parameters can be set via mount, this option will be removed.
-.TP
-\fBunfreeze\fP \fIMountPoint\fR
-Unfreeze a GFS2 cluster.
-.TP
-\fBversion\fP
-Print out the version of GFS2 that this program goes with.
-.TP
-\fBwithdraw\fP \fIMountPoint\fR
-Cause GFS2 to abnormally shutdown a given filesystem on this node.
-This feature is only useful for testing and should not be used
-during normal filesystem operation.
-
diff --git a/gfs2/man/mount.gfs2.8 b/gfs2/man/mount.gfs2.8
deleted file mode 100644
index 4f0f7b3..0000000
--- a/gfs2/man/mount.gfs2.8
+++ /dev/null
@@ -1,233 +0,0 @@
-.TH mount.gfs2 8
-
-.SH NAME
-mount.gfs2 - GFS2 mount options
-
-.SH SYNOPSIS
-.BI "mount \-a [\-fnrsvw] \-t " gfs2 " [\-O " options "]
-.br
-.BI "mount [\-fnrsvw] \-t " gfs2 " [\-o " options " ] " "device dir"
-
-.SH DESCRIPTION
-For details on the common mount options, please see the
-\fBmount\fP(8) command man page.
-The \fIdevice\fR may be any block device on which you
-have created a GFS2 filesystem. Examples include a
-single disk partition (e.g. /dev/sdb3), a loopback device, a device exported
-from another node (e.g. an iSCSI device), or a
-logical volume (typically comprised of a number of individual disks).
-
-\fIdevice\fR does not necessarily need to match the device name as seen on
-another node in the cluster, nor does it need to be a logical volume. However,
-the use of a cluster-aware volume manager such as CLVM2 (see \fBlvm\fP(8))
-will guarantee that the managed devices are named identically on each node in a
-cluster (for much easier management), and will allow you to configure a very
-large volume from multiple storage units (e.g. disk drives).
-
-\fIdevice\fR must make the entire filesystem storage area visible to the
-computer. That is, you cannot mount different parts of a single filesystem on
-different computers. Each computer must see an entire filesystem. You
-may, however, mount several GFS2 filesystems if you want to distribute your
-data storage in a controllable way.
-
-This man page describes GFS2-specific options that can be passed to the GFS2
-file system at mount time, using the \fB-o\fP flag. There are many other
-\fB-o\fP options handled by the generic mount command \fBmount\fP(8).
-However, the options described below are specifically for GFS2, and are not
-interpreted by the mount command nor by the kernel's Virtual File System. GFS2
-and non-GFS2 options may be intermingled after the \fB-o\fP, separated by
-commas (but no spaces).
-
-The options commit, discard, errors, quota_quantum, statfs_quantum, statfs_percent, barrier, acl, quota, suiddir, and data can be
-changed after mount using the "mount -o remount,option /mountpoint" command.
-The options quota, discard, barrier, acl, and suiddir support the "no"
-prefix. For example, "noacl" turns off what "acl" turns on.
-
-If you have trouble mounting GFS2, check the syslog (e.g. /var/log/messages)
-for specific error messages.
-
-.SH OPTIONS
-.TP
-\fBlockproto=\fP\fILockProtoName\fR
-This specifies which inter-node lock protocol is used by the GFS2 filesystem
-for this mount, overriding the default lock protocol name stored in the
-filesystem's on-disk superblock.
-
-The \fILockProtoName\fR must be one of the supported locking protocols,
-currently these are \fIlock_nolock\fR and \fIlock_dlm\fR.
-
-The default lock protocol name is written to disk initially when creating the
-filesystem with \fBmkfs.gfs2\fP(8), -p option. It can be changed on-disk by
-using the \fBgfs2_tool\fP(8) utility's \fBsb proto\fP command.
-
-The \fBlockproto\fP mount option should be used only under special
-circumstances in which you want to temporarily use a different lock protocol
-without changing the on-disk default. Using the incorrect lock protocol
-on a cluster filesystem mounted from more than one node will almost
-certainly result in filesystem corruption.
-.TP
-\fBlocktable=\fP\fILockTableName\fR
-This specifies the identity of the cluster and of the filesystem for this
-mount, overriding the default cluster/filesystem identify stored in the
-filesystem's on-disk superblock. The cluster/filesystem name is recognized
-globally throughout the cluster, and establishes a unique namespace for
-the inter-node locking system, enabling the mounting of multiple GFS2
-filesystems.
-
-The format of \fILockTableName\fR is lock-module-specific. For
-\fIlock_dlm\fR, the format is \fIclustername:fsname\fR. For
-\fIlock_nolock\fR, the field is ignored.
-
-The default cluster/filesystem name is written to disk initially when creating
-the filesystem with \fBmkfs.gfs2\fP(8), -t option. It can be changed on-disk
-by using the \fBgfs2_tool\fP(8) utility's \fBsb table\fP command.
-
-The \fBlocktable\fP mount option should be used only under special
-circumstances in which you want to mount the filesystem in a different cluster,
-or mount it as a different filesystem name, without changing the on-disk
-default.
-.TP
-\fBlocalcaching\fP
-This flag tells GFS2 that it is running as a local (not clustered) filesystem,
-so it can turn on some block caching optimizations that can't be used when
-running in cluster mode.
-
-This is turned on automatically by the lock_nolock module,
-but can be overridden by using the \fBignore_local_fs\fP option.
-.TP
-\fBlocalflocks\fP
-This flag tells GFS2 that it is running as a local (not clustered) filesystem,
-so it can allow the kernel VFS layer to do all flock and fcntl file locking.
-When running in cluster mode, these file locks require inter-node locks,
-and require the support of GFS2. When running locally, better performance
-is achieved by letting VFS handle the whole job.
-
-This is turned on automatically by the lock_nolock module,
-but can be overridden by using the \fBignore_local_fs\fP option.
-.TP
-\fBerrors=\fP\fI[panic|withdraw]\fR
-Setting errors=panic causes GFS2 to oops when encountering an error that
-would otherwise cause the
-mount to withdraw or print an assertion warning. The default setting
-is errors=withdraw. This option should not be used in a production system.
-It replaces the earlier \fBdebug\fP option on kernel versions 2.6.31 and
-above.
-.TP
-\fBignore_local_fs\fP
-By default, using the nolock lock module automatically turns on the
-\fBlocalcaching\fP and \fBlocalflocks\fP optimizations. \fBignore_local_fs\fP
-forces GFS2 to treat the filesystem as if it were a multihost (clustered)
-filesystem, with \fBlocalcaching\fP and \fBlocalflocks\fP optimizations
-turned off.
-.TP
-\fBupgrade\fP
-This flag tells GFS2 to upgrade the filesystem's on-disk format to the version
-supported by the current GFS2 software installation on this computer.
-If you try to mount an old-version disk image, GFS2 will notify you via a syslog
-message that you need to upgrade. Try mounting again, using the
-\fB-o upgrade\fP option. When upgrading, only one node may mount the GFS2
-filesystem.
-.TP
-\fBacl\fP
-Enables POSIX Access Control List \fBacl\fP(5) support within GFS2.
-.TP
-\fBspectator\fP
-Mount this filesystem using a special form of read-only mount. The mount
-does not use one of the filesystem's journals. The node is unable to
-recover journals for other nodes.
-.TP
-\fBsuiddir\fP
-Sets owner of any newly created file or directory to be that of parent
-directory, if parent directory has S_ISUID permission attribute bit set.
-Sets S_ISUID in any new directory, if its parent directory's S_ISUID is set.
-Strips all execution bits on a new file, if parent directory owner is different
-from owner of process creating the file. Set this option only if you know
-why you are setting it.
-.TP
-\fBquota=\fP\fI[off/account/on]\fR
-Turns quotas on or off for a filesystem. Setting the quotas to be in
-the "account" state causes the per UID/GID usage statistics to be
-correctly maintained by the filesystem, limit and warn values are
-ignored. The default value is "off".
-.TP
-\fBdiscard\fP
-Causes GFS2 to generate "discard" I/O requests for blocks which have
-been freed. These can be used by suitable hardware to implement
-thin-provisioning and similar schemes. This feature is supported
-in kernel version 2.6.30 and above.
-.TP
-\fBbarrier\fP
-This option, which defaults to on, causes GFS2 to send I/O barriers
-when flushing the journal. The option is automatically turned off
-if the underlying device does not support I/O barriers. We highly
-recommend the use of I/O barriers with GFS2 at all times unless
-the block device is designed so that it cannot lose its write cache
-content (e.g. its on a UPS, or it doesn't have a write cache)
-.TP
-\fBcommit=\fP\fIsecs\fR
-This is similar to the ext3 \fBcommit=\fP option in that it sets
-the maximum number of seconds between journal commits if there is
-dirty data in the journal. The default is 60 seconds. This option
-is only provided in kernel versions 2.6.31 and above.
-.TP
-\fBdata=\fP\fI[ordered|writeback]\fR
-When data=ordered is set, the user data modified by a transaction is
-flushed to the disk before the transaction is committed to disk. This
-should prevent the user from seeing uninitialized blocks in a file
-after a crash. Data=writeback mode writes the user data to the disk
-at any time after it's dirtied. This doesn't provide the same
-consistency guarantee as ordered mode, but it should be slightly
-faster for some workloads. The default is ordered mode.
-.TP
-\fBmeta\fP
-This option results in selecting the meta filesystem root rather than
-the normal filesystem root. This option is normally only used by
-the GFS2 utility functions. Altering any file on the GFS2 meta filesystem
-may render the filesystem unusable, so only experts in the GFS2
-on-disk layout should use this option.
-.TP
-\fBquota_quantum=\fP\fIsecs\fR
-This sets the number of seconds for which a change in the quota
-information may sit on one node before being written to the quota
-file. This is the preferred way to set this parameter. The value
-is an integer number of seconds greater than zero. The default is
-60 seconds. Shorter settings result in faster updates of the lazy
-quota information and less likelihood of someone exceeding their
-quota. Longer settings make filesystem operations involving quotas
-faster and more efficient.
-.TP
-\fBstatfs_quantum=\fP\fIsecs\fR
-Setting statfs_quantum to 0 is the preferred way to set the slow version
-of statfs. The default value is 30 secs which sets the maximum time
-period before statfs changes will be syned to the master statfs file.
-This can be adjusted to allow for faster, less accurate statfs values
-or slower more accurate values. When set to 0, statfs will always
-report the true values.
-.TP
-\fBstatfs_percent=\fP\fIvalue\fR
-This setting provides a bound on the maximum percentage change in
-the statfs information on a local basis before it is synced back
-to the master statfs file, even if the time period has not
-expired. If the setting of statfs_quantum is 0, then this setting
-is ignored.
-
-.SH BUGS
-
-GFS2 doesn't support \fBerrors=\fP\fIremount-ro\fR or \fBdata=\fP\fIjournal\fR.
-It is not possible to switch support for user and group quotas on and
-off independently of each other. Some of the error messages are rather
-cryptic, if you encounter one of these messages check firstly that gfs_controld
-is running and secondly that you have enough journals on the filesystem
-for the number of nodes in use.
-
-.SH SEE ALSO
-
-\fBgfs2\fP(5),
-\fBmount\fP(8) for general mount options,
-\fBchmod\fP(1) and \fBchmod\fP(2) for access permission flags,
-\fBacl\fP(5) for access control lists,
-\fBlvm\fP(8) for volume management,
-\fBccs\fP(7) for cluster management,
-\fBumount\fP(8),
-\fBinitrd\fP(4).
-
diff --git a/gfs2/quota/Makefile.am b/gfs2/quota/Makefile.am
deleted file mode 100644
index 9d75d20..0000000
--- a/gfs2/quota/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-sbin_PROGRAMS = gfs2_quota
-
-noinst_HEADERS = gfs2_quota.h
-
-gfs2_quota_SOURCES = check.c main.c names.c
-
-gfs2_quota_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
- -DHELPER_PROGRAM \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/gfs2/libgfs2
-
-gfs2_quota_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/quota/check.c b/gfs2/quota/check.c
deleted file mode 100644
index 9afb0ad..0000000
--- a/gfs2/quota/check.c
+++ /dev/null
@@ -1,601 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <dirent.h>
-#include <limits.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <linux/types.h>
-#include <linux/fiemap.h>
-
-#define __user
-#include "osi_list.h"
-
-#include "gfs2_quota.h"
-
-#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
-
-struct values {
- osi_list_t v_list;
-
- uint32_t v_id;
- int64_t v_blocks;
-};
-typedef struct values values_t;
-
-struct hardlinks {
- osi_list_t hl_list;
-
- ino_t hl_ino;
-};
-typedef struct hardlinks hardlinks_t;
-
-/**
- * add_value - add a ID / Allocated Blocks pair to the list
- * @list: the list
- * @id: the ID number
- * @blocks: the number of blocks to add
- *
- */
-
-static void
-add_value(osi_list_t *list, uint32_t id, int64_t blocks)
-{
- osi_list_t *tmp;
- values_t *v;
-
- for (tmp = list->next; tmp != list; tmp = tmp->next) {
- v = osi_list_entry(tmp, values_t, v_list);
- if (v->v_id != id)
- continue;
-
- v->v_blocks += blocks;
-
- osi_list_del(&v->v_list);
- osi_list_add(&v->v_list, list);
-
- return;
- }
-
- type_zalloc(v, values_t, 1);
-
- v->v_id = id;
- v->v_blocks = blocks;
-
- osi_list_add(&v->v_list, list);
-}
-
-/**
- * test_and_add_hard_link - Add a inode that has hard links to the list
- * @list: the list of inodes with hard links
- * @ino: the number of the inode to add
- *
- * Returns: Returns TRUE if the inode was already on the list, FALSE if it wasn't
- */
-
-static int
-test_and_add_hard_link(osi_list_t *list, ino_t ino)
-{
- osi_list_t *tmp;
- hardlinks_t *hl;
-
- for (tmp = list->next; tmp != list; tmp = tmp->next) {
- hl = osi_list_entry(tmp, hardlinks_t, hl_list);
- if (hl->hl_ino != ino)
- continue;
-
- return TRUE;
- }
-
- type_zalloc(hl, hardlinks_t, 1);
-
- hl->hl_ino = ino;
-
- osi_list_add(&hl->hl_list, list);
-
- return FALSE;
-}
-
-/**
- * scan_fs - recursively scan a filesystem and figure out what IDs have what
- * @device: the device the filesystem is on
- * @dirname: the name of the directory to read
- * @uid: returned list of UIDs for this FS
- * @gid: returned list of GIDs for this FS
- * @hl: returned list of hard links for this FS
- *
- */
-
-static void
-scan_fs(dev_t device, char *dirname,
- osi_list_t *uid, osi_list_t *gid, osi_list_t *hl)
-{
- DIR *dir;
- struct dirent *de;
- struct stat st;
- char *name;
- int error;
-
- dir = opendir(dirname);
- if (!dir)
- die("can't open directory %s: %s\n", dirname, strerror(errno));
-
- while ((de = readdir(dir))) {
- if (strcmp(de->d_name, "..") == 0)
- continue;
-
- type_alloc(name, char,
- strlen(dirname) + strlen(de->d_name) + 2);
- if (dirname[strlen(dirname) - 1] == '/')
- sprintf(name, "%s%s", dirname, de->d_name);
- else
- sprintf(name, "%s/%s", dirname, de->d_name);
-
- error = lstat(name, &st);
- if (error)
- die("can't stat file %s: %s\n", name, strerror(errno));
-
- if (st.st_dev != device)
- die("umount %s and try again\n", name);
-
- if (S_ISDIR(st.st_mode)) {
- if (strcmp(de->d_name, ".") == 0) {
- add_value(uid, st.st_uid, st.st_blocks);
- add_value(gid, st.st_gid, st.st_blocks);
- } else
- scan_fs(device, name, uid, gid, hl);
- } else if (st.st_nlink == 1 ||
- !test_and_add_hard_link(hl, st.st_ino)) {
- add_value(uid, st.st_uid, st.st_blocks);
- add_value(gid, st.st_gid, st.st_blocks);
- }
-
- free(name);
- }
-
- closedir(dir);
-}
-
-/**
- * read_quota_file - read the quota file and return list of its contents
- * @comline: the command line arguments
- * @uid: returned list of UIDs for the filesystem
- * @gid: returned list of GIDs for the filesystem
- *
- */
-static void
-read_quota_file(struct gfs2_sbd *sdp, commandline_t *comline,
- osi_list_t *uid, osi_list_t *gid)
-{
- int fd;
- uint32_t id, startq;
- int error = 0;
- char quota_file[BUF_SIZE];
- uint64_t quota_file_size = 0;
- struct fiemap fmap = { 0, }, *fmap2;
- struct stat statbuf;
-
- strcpy(sdp->path_name, comline->filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_RDONLY);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", comline->filesystem,
- strerror(errno));
- }
- if (fstat(fd, &statbuf) < 0) {
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't stat file %s: %s\n", quota_file,
- strerror(errno));
- }
- quota_file_size = statbuf.st_size;
- /* First find the number of extents in the quota file */
- fmap.fm_flags = 0;
- fmap.fm_start = 0;
- fmap.fm_length = (~0ULL);
- error = ioctl(fd, FS_IOC_FIEMAP, &fmap);
- if (error == -1) {
- fprintf(stderr, "fiemap error (%d): %s\n", errno, strerror(errno));
- goto out;
- }
- fmap2 = malloc(sizeof(struct fiemap) +
- fmap.fm_mapped_extents * sizeof(struct fiemap_extent));
- if (fmap2 == NULL) {
- fprintf(stderr, "malloc error (%d): %s\n", errno, strerror(errno));
- goto out;
- }
- fmap2->fm_flags = 0;
- fmap2->fm_start = 0;
- fmap2->fm_length = (~0ULL);
- fmap2->fm_extent_count = fmap.fm_mapped_extents;
- error = ioctl(fd, FS_IOC_FIEMAP, fmap2);
- if (error == -1) {
- fprintf(stderr, "fiemap error (%d): %s\n", errno, strerror(errno));
- goto fmap2_free;
- }
- if (fmap2->fm_mapped_extents) {
- int i;
- for (i=0; i<fmap2->fm_mapped_extents; i++) {
- struct fiemap_extent *fe = &fmap2->fm_extents[i];
- uint64_t end = fe->fe_logical + fe->fe_length, val_off;
- unsigned int v_off;
-
- end = end > quota_file_size ? quota_file_size : end;
- /* we only need to get the value fields, not the whole quota
- * This also works when struct gfs2_quota straddle page
- * boundaries. Getting only the value field avoids the
- * complexity of fetching two parts of the struct gfs2_quota
- * from two successive pages
- */
- /* offset of the value field within struct gfs2_quota */
- v_off = (unsigned long)(&((struct gfs2_quota *)NULL)->qu_value);
- /* startq could be at the end of previous extent... */
- startq = fe->fe_logical / sizeof(struct gfs2_quota);
- /* but the value field could be in this extent */
- if ((startq * sizeof(struct gfs2_quota) + v_off) >= fe->fe_logical)
- val_off = startq * sizeof(struct gfs2_quota) + v_off;
- else /* if the start of the extent doesn't have a split quota */
- val_off = ++startq * sizeof(struct gfs2_quota) + v_off;
-
- while ((val_off + sizeof(uint64_t)) <= end)
- {
- uint64_t value;
- /* read hidden quota file here */
- lseek(fd, val_off, SEEK_SET);
- error = read(fd, (unsigned char*)&value, sizeof(uint64_t));
- if (error < 0) {
- fprintf(stderr, "read error (%d): %s\n",
- errno, strerror(errno));
- goto fmap2_free;
- }
- value = be64_to_cpu(value);
- id = startq >> 1;
- /* We want value in 512 byte blocks (1 << 9 = 512) */
- value <<= sdp->sd_sb.sb_bsize_shift - 9;
- if (value) {
- /* if startq is even, it's a uid, else gid */
- if (startq % 2)
- add_value(gid, id, value);
- else
- add_value(uid, id, value);
- }
- startq++;
- val_off += sizeof(struct gfs2_quota);
- }
- }
- }
-fmap2_free:
- free(fmap2);
-out:
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * do_compare - compare to ID lists and see if they match
- * @type: the type of list (UID or GID)
- * @fs_list: the list derived from scaning the FS
- * @qf_list: the list derived from reading the quota file
- *
- * Returns: TRUE if there was a mismatch
- */
-
-static int
-do_compare(const char *type, osi_list_t *fs_list, osi_list_t *qf_list)
-{
- osi_list_t *tmp1, *tmp2;
- values_t *v1, *v2;
- int found;
- int mismatch = FALSE;
-
- for (tmp1 = fs_list->next; tmp1 != fs_list; tmp1 = tmp1->next) {
- v1 = osi_list_entry(tmp1, values_t, v_list);
-
- found = FALSE;
-
- for (tmp2 = qf_list->next; tmp2 != qf_list; tmp2 = tmp2->next) {
- v2 = osi_list_entry(tmp2, values_t, v_list);
- if (v1->v_id != v2->v_id)
- continue;
-
- if (v1->v_blocks != v2->v_blocks) {
- printf("mismatch: %s %u: scan = %lld, quotafile = %lld\n",
- type, v1->v_id,
- (long long)v1->v_blocks, (long long)v2->v_blocks);
- mismatch = TRUE;
- }
-
- osi_list_del(&v2->v_list);
- free(v2);
-
- found = TRUE;
- break;
- }
-
- if (!found) {
- printf("mismatch: %s %u: scan = %lld, quotafile = %lld\n",
- type, v1->v_id,
- (long long)v1->v_blocks, 0LL);
- mismatch = TRUE;
- }
- }
-
- for (tmp2 = qf_list->next; tmp2 != qf_list; tmp2 = tmp2->next) {
- v2 = osi_list_entry(tmp2, values_t, v_list);
-
- printf("mismatch: %s %u: scan = %lld, quotafile = %lld\n",
- type, v2->v_id,
- 0LL, (long long)v2->v_blocks);
- mismatch = TRUE;
- }
-
- return mismatch;
-}
-
-/**
- * verify_pathname - make sure the path on the command line is a mount point
- * @comline: the command line arguments
- *
- * Returns: the device the filesystem is on
- */
-
-static dev_t
-verify_pathname(commandline_t *comline)
-{
- struct stat st1, st2;
- dev_t device;
- char *name;
- int error;
-
- if (!*comline->filesystem)
- die("need a filesystem to work on\n");
-
- error = lstat(comline->filesystem, &st1);
- if (error)
- die("can't stat %s: %s\n", comline->filesystem,
- strerror(errno));
-
- if (!S_ISDIR(st1.st_mode))
- die("%s must be a directory\n", comline->filesystem);
-
- device = st1.st_dev;
-
- for (;;) {
- type_alloc(name, char, strlen(comline->filesystem) + 4);
- sprintf(name, "%s/..", comline->filesystem);
-
- error = lstat(name, &st2);
- if (error)
- die("can't stat %s: %s\n", name, strerror(errno));
-
- if (st2.st_dev != device || st2.st_ino == st1.st_ino) {
- free(name);
- break;
- }
-
- if (!realpath(name, comline->filesystem))
- die("error resolving filesystem pathname: %s\n",
- strerror(errno));
-
- free(name);
-
- st1 = st2;
- }
-
- return device;
-}
-
-/**
- * do_check - Check what's in the quota file
- * @comline: the struct containing the parsed command line arguments
- *
- */
-
-void
-do_check(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- dev_t device;
- osi_list_t fs_uid, fs_gid, qf_uid, qf_gid;
- osi_list_t hl;
- int mismatch;
-
- osi_list_init(&fs_uid);
- osi_list_init(&fs_gid);
- osi_list_init(&qf_uid);
- osi_list_init(&qf_gid);
- osi_list_init(&hl);
-
- device = verify_pathname(comline);
-
- scan_fs(device, comline->filesystem, &fs_uid, &fs_gid, &hl);
- read_quota_file(sdp, comline, &qf_uid, &qf_gid);
-
- mismatch = do_compare("user", &fs_uid, &qf_uid);
- mismatch |= do_compare("group", &fs_gid, &qf_gid);
-
- if (mismatch)
- exit(EXIT_FAILURE);
-}
-
-/**
- * set_list - write a list of IDs into the quota file
- * @comline: the command line arguments
- * @user: TRUE if this is a list of UIDs, FALSE if it is a list of GIDs
- * @list: the list of IDs and block counts
- * @multiplier: multiply block counts by this
- *
- */
-
-static void
-set_list(struct gfs2_sbd *sdp, commandline_t *comline, int user,
- osi_list_t *list, int64_t multiplier)
-{
- int fd;
- osi_list_t *tmp;
- values_t *v;
- uint64_t offset, max_off = 0;
- int64_t value;
- int error;
- char quota_file[BUF_SIZE];
- char id_str[16];
- char *fs;
- struct stat st;
-
- strcpy(sdp->path_name, comline->filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_WRONLY);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", comline->filesystem,
- strerror(errno));
- }
-
- for (tmp = list->next; tmp != list; tmp = tmp->next) {
- v = osi_list_entry(tmp, values_t, v_list);
-
- offset = (2 * (uint64_t)v->v_id + ((user) ? 0 : 1)) *
- sizeof(struct gfs2_quota);
- if (offset > max_off)
- max_off = offset;
- offset += (unsigned long)(&((struct gfs2_quota *)NULL)->qu_value);
-
- value = v->v_blocks * multiplier;
- value >>= sdp->sd_sb.sb_bsize_shift - 9;
- value = cpu_to_be64(value);
-
- lseek(fd, offset, SEEK_SET);
- error = write(fd, (char*)&value, sizeof(uint64_t));
- if (error != sizeof(uint64_t)) {
- fprintf(stderr, "can't write quota file (%d): %s\n",
- error, strerror(errno));
- goto out;
- }
-
- fs = mp2fsname(comline->filesystem);
- if (!fs) {
- fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n",
- comline->filesystem);
- exit(-1);
- }
-
- /* Write the id to sysfs quota refresh file to refresh gfs quotas */
- sprintf(id_str, "%d", comline->id);
- if (set_sysfs(fs, (user) ? "quota_refresh_user" : "quota_refresh_group",
- id_str)) {
- fprintf(stderr, "Error writing id to sysfs quota refresh file: %s\n",
- strerror(errno));
- exit(-1);
- }
- }
- /* If we wrote a value that extended the quota file size,
- * round the size off to the nearest quota boundary
- */
- error = fstat(fd, &st);
- if (error) {
- fprintf(stderr, "can't stat quota file (%d): %s\n",
- error, strerror(errno));
- goto out;
- }
- if (st.st_size < (max_off + sizeof(struct gfs2_quota))) {
- error = ftruncate(fd, (max_off + sizeof(struct gfs2_quota)));
- if (error)
- fprintf(stderr, "can't truncate quota file(%d): %s\n",
- error, strerror(errno));
- }
-out:
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * do_quota_init - initialize the quota file
- * @comline: the command line arguments
- *
- */
-
-void
-do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- dev_t device;
- osi_list_t fs_uid, fs_gid, qf_uid, qf_gid;
- osi_list_t hl;
- values_t *v;
-
- osi_list_init(&fs_uid);
- osi_list_init(&fs_gid);
- osi_list_init(&qf_uid);
- osi_list_init(&qf_gid);
- osi_list_init(&hl);
-
- device = verify_pathname(comline);
-
- scan_fs(device, comline->filesystem, &fs_uid, &fs_gid, &hl);
- read_quota_file(sdp, comline, &qf_uid, &qf_gid);
-
- type_zalloc(v, values_t, 1);
- v->v_id = 0;
- v->v_blocks = 0;
- osi_list_add(&v->v_list, &qf_uid);
-
- type_zalloc(v, values_t, 1);
- v->v_id = 0;
- v->v_blocks = 0;
- osi_list_add(&v->v_list, &qf_gid);
-
- set_list(sdp, comline, TRUE, &qf_uid, 0);
- set_list(sdp, comline, FALSE, &qf_gid, 0);
- set_list(sdp, comline, TRUE, &fs_uid, 1);
- set_list(sdp, comline, FALSE, &fs_gid, 1);
-
- do_sync(sdp, comline);
- do_check(sdp, comline);
-}
diff --git a/gfs2/quota/gfs2_quota.h b/gfs2/quota/gfs2_quota.h
deleted file mode 100644
index 744f02b..0000000
--- a/gfs2/quota/gfs2_quota.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __GFS2_QUOTA_DOT_H__
-#define __GFS2_QUOTA_DOT_H__
-
-#include <stdarg.h>
-#include "libgfs2.h"
-#include <linux/gfs2_ondisk.h>
-
-#define DIV_RU(x, y) (((x) + (y) - 1) / (y))
-
-#define type_zalloc(ptr, type, count) \
-do { \
- (ptr) = (type *)malloc(sizeof(type) * (count)); \
- if ((ptr)) \
- memset((char *)(ptr), 0, sizeof(type) * (count)); \
- else \
- die("unable to allocate memory on line %d of file %s\n", \
- __LINE__, __FILE__); \
-} while (0)
-
-#define type_alloc(ptr, type, count) \
-do { \
- (ptr) = (type *)malloc(sizeof(type) * (count)); \
- if (!(ptr)) \
- die("unable to allocate memory on line %d of file %s\n", \
- __LINE__, __FILE__); \
-} while (0)
-
-#define GQ_OP_LIST (12)
-#define GQ_OP_SYNC (13)
-#define GQ_OP_GET (14)
-#define GQ_OP_LIMIT (15)
-#define GQ_OP_WARN (16)
-#define GQ_OP_CHECK (17)
-#define GQ_OP_INIT (18)
-#define GQ_OP_RESET (19)
-
-#define GQ_ID_USER (23)
-#define GQ_ID_GROUP (24)
-
-#define GQ_UNITS_MEGABYTE (0)
-#define GQ_UNITS_KILOBYTE (34)
-#define GQ_UNITS_FSBLOCK (35)
-#define GQ_UNITS_BASICBLOCK (36)
-
-#define BUF_SIZE 4096
-
-struct commandline {
- unsigned int operation;
-
- uint64_t new_value;
- int new_value_set;
-
- unsigned int id_type;
- uint32_t id;
-
- unsigned int units;
-
- int numbers;
-
- char filesystem[PATH_MAX];
-};
-typedef struct commandline commandline_t;
-
-/* main.c */
-
-void do_get_super(int fd, struct gfs2_sb *sb);
-void do_sync(struct gfs2_sbd *sdp, commandline_t *comline);
-void cleanup(void);
-void read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp);
-void read_quota_internal(int fd, unsigned int id, int id_type,
- struct gfs2_quota *q);
-
-/* check.c */
-
-void do_check(struct gfs2_sbd *sdp, commandline_t *comline);
-void do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline);
-
-/* names.c */
-
-uint32_t name_to_id(int user, char *name, int numbers);
-char *id_to_name(int user, uint32_t id, int numbers);
-
-/* die() used to be in libgfs2.h */
-static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
-void die(const char *fmt, ...)
-{
- va_list ap;
- fprintf(stderr, "%s: ", __FILE__);
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(-1);
-}
-
-#endif /* __GFS2_QUOTA_DOT_H__ */
diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c
deleted file mode 100644
index 733f69d..0000000
--- a/gfs2/quota/main.c
+++ /dev/null
@@ -1,911 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <limits.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-#include <linux/types.h>
-#include <linux/fiemap.h>
-#include "gfs2_quota.h"
-
-#define __user
-
-#include "copyright.cf"
-
-
-/* Constants */
-
-#define OPTION_STRING ("bdf:g:hkl:mnsu:V")
-#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
-
-/**
- * This function is for libgfs2's sake.
- */
-void print_it(const char *label, const char *fmt, const char *fmt2, ...)
-{
- va_list args;
-
- va_start(args, fmt2);
- printf("%s: ", label);
- vprintf(fmt, args);
- va_end(args);
-}
-
-/**
- * print_usage - print usage info to the user
- * @prog_name: The name of this program
- */
-
-static void
-print_usage(const char *prog_name)
-{
- printf("Usage:\n");
- printf("\n");
- printf("%s <list|sync|get|limit|warn|check|init> [options]\n",
- prog_name);
- printf("\n");
- printf("Actions:\n");
- printf(" list list the whole quota file\n");
- printf(" sync sync out unsynced quotas\n");
- printf(" get get quota values for an ID\n");
- printf(" limit set a quota limit value for an ID\n");
- printf(" warn set a quota warning value for an ID\n");
- printf(" check check the quota file\n");
- printf(" init initialize the quota file\n");
- printf(" reset reset the quota file\n");
- printf("\n");
- printf("Options:\n");
- printf(" -b sizes are in FS blocks\n");
- printf(" -f <directory> the filesystem to work on\n");
- printf(" -g <gid> get/set a group ID\n");
- printf(" -h Print this help, then exit\n");
- printf(" -k sizes are in KB\n");
- printf(" -l <size> the new limit or warn value\n");
- printf(" -m sizes are in MB\n");
- printf(" -n print out UID/GID numbers instead of names\n");
- printf(" -s sizes are in 512-byte blocks\n");
- printf(" -u <uid> get/set a user ID\n");
- printf(" -V Print program version information, then exit\n");
-}
-
-/**
- * decode_arguments - parse command line arguments
- * @argc: well, it's argc...
- * @argv: well, it's argv...
- * @comline: the structure filled in with the parsed arguments
- *
- * Function description
- *
- * Returns: what is returned
- */
-
-static void
-decode_arguments(int argc, char *argv[], commandline_t *comline)
-{
- int cont = TRUE;
- int optchar;
-
- while (cont) {
- optchar = getopt(argc, argv, OPTION_STRING);
-
- switch (optchar) {
- case 'u':
- comline->id_type = GQ_ID_USER;
- comline->id = name_to_id(TRUE, optarg, comline->numbers);
- break;
-
- case 'g':
- comline->id_type = GQ_ID_GROUP;
- comline->id = name_to_id(FALSE, optarg, comline->numbers);
- break;
-
- case 'l':
- if (!isdigit(*optarg))
- die("argument to -l must be a number\n");
- sscanf(optarg, "%"SCNu64, &comline->new_value);
- comline->new_value_set = TRUE;
- break;
-
- case 'f':
- if (!realpath(optarg, comline->filesystem))
- die("can't find %s: %s\n", optarg,
- strerror(errno));
- break;
-
- case 'm':
- comline->units = GQ_UNITS_MEGABYTE;
- break;
-
- case 'k':
- comline->units = GQ_UNITS_KILOBYTE;
- break;
-
- case 'b':
- comline->units = GQ_UNITS_FSBLOCK;
- break;
-
- case 's':
- comline->units = GQ_UNITS_BASICBLOCK;
- break;
-
- case 'n':
- comline->numbers = TRUE;
- break;
-
- case 'V':
- printf("gfs2_quota %s (built %s %s)\n", VERSION,
- __DATE__, __TIME__);
- printf("%s\n", REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
- break;
-
- case 'h':
- print_usage(argv[0]);
- exit(EXIT_SUCCESS);
- break;
-
- case ':':
- case '?':
- fprintf(stderr, "Please use '-h' for usage.\n");
- exit(EXIT_FAILURE);
- break;
-
- case EOF:
- cont = FALSE;
- break;
-
- default:
- die("unknown option: %c\n", optchar);
- break;
- };
- }
-
- while (optind < argc) {
- if (strcmp(argv[optind], "list") == 0 ||
- strcmp(argv[optind], "dump") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_LIST;
- } else if (strcmp(argv[optind], "sync") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_SYNC;
- } else if (strcmp(argv[optind], "get") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_GET;
- } else if (strcmp(argv[optind], "limit") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_LIMIT;
- } else if (strcmp(argv[optind], "warn") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_WARN;
- } else if (strcmp(argv[optind], "check") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_CHECK;
- } else if (strcmp(argv[optind], "init") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_INIT;
- } else if (strcmp(argv[optind], "reset") == 0) {
- if (comline->operation)
- die("can't specify two operations\n");
- comline->operation = GQ_OP_RESET;
- } else
- die("unknown option %s\n", argv[optind]);
-
- optind++;
- }
-}
-
-/**
- * print_quota - Print out a quota entry
- * @comline: the struct containing the parsed command line arguments
- * @user: TRUE if this is a user quota, FALSE if it's a group quota
- * @id: the ID
- * @q: the quota value
- * @sb: the superblock of the filesystem this quota belongs to
- *
- */
-
-static void
-print_quota(commandline_t *comline,
- int user, uint32_t id,
- struct gfs2_quota *q,
- struct gfs2_sb *sb)
-{
- printf("%-5s %10s: ", (user) ? "user" : "group",
- id_to_name(user, id, comline->numbers));
-
- switch (comline->units) {
- case GQ_UNITS_MEGABYTE:
- printf("limit: %-10.1f warn: %-10.1f value: %-10.1f\n",
- (double) q->qu_limit * sb->sb_bsize / 1048576,
- (double) q->qu_warn * sb->sb_bsize / 1048576,
- (double) q->qu_value * sb->sb_bsize / 1048576);
- break;
-
- case GQ_UNITS_KILOBYTE:
- if (sb->sb_bsize == 512)
- printf("limit: %-10llu warn: %-10lluvalue: %-10llu\n",
- (unsigned long long)q->qu_limit / 2,
- (unsigned long long)q->qu_warn / 2,
- (unsigned long long)q->qu_value / 2);
- else
- printf("limit: %-10llu warn: %-10lluvalue: %-10llu\n",
- (unsigned long long)
- q->qu_limit << (sb->sb_bsize_shift - 10),
- (unsigned long long)
- q->qu_warn << (sb->sb_bsize_shift - 10),
- (unsigned long long)
- q->qu_value << (sb->sb_bsize_shift - 10));
- break;
-
- case GQ_UNITS_FSBLOCK:
- printf("limit: %-10llu warn: %-10llu value: %-10llu\n",
- (unsigned long long)q->qu_limit,
- (unsigned long long)q->qu_warn,
- (unsigned long long)q->qu_value);
- break;
-
- case GQ_UNITS_BASICBLOCK:
- printf("limit: %-10llu warn: %-10llu value: %-10llu\n",
- (unsigned long long)
- q->qu_limit << (sb->sb_bsize_shift - 9),
- (unsigned long long)
- q->qu_warn << (sb->sb_bsize_shift - 9),
- (unsigned long long)
- q->qu_value << (sb->sb_bsize_shift - 9));
- break;
-
- default:
- die("bad units\n");
- break;
- }
-}
-
-void
-read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp)
-{
- int fd;
- char buf[PATH_MAX];
- struct gfs2_buffer_head dummy_bh;
-
- dummy_bh.b_data = buf;
- fd = open(sdp->device_name, O_RDONLY);
- if (fd < 0) {
- die("Could not open the block device %s: %s\n",
- sdp->device_name, strerror(errno));
- }
- if (lseek(fd, 0x10 * 4096, SEEK_SET) != 0x10 * 4096) {
- fprintf(stderr, "bad seek: %s from %s:%d: "
- "superblock\n",
- strerror(errno), __FUNCTION__, __LINE__);
-
- exit(-1);
- }
- if (read(fd, buf, PATH_MAX) != PATH_MAX) {
- fprintf(stderr, "bad read: %s from %s:%d: superblock\n",
- strerror(errno), __FUNCTION__, __LINE__);
- exit(-1);
- }
- gfs2_sb_in(sb, &dummy_bh);
-
- close(fd);
-}
-
-void
-read_quota_internal(int fd, uint32_t id, int id_type, struct gfs2_quota *q)
-{
- /* seek to the appropriate offset in the quota file and read the
- quota info */
- uint64_t offset;
- char buf[256];
- int error;
- if (id_type == GQ_ID_USER)
- offset = (2 * (uint64_t)id) * sizeof(struct gfs2_quota);
- else
- offset = (2 * (uint64_t)id + 1) * sizeof(struct gfs2_quota);
- lseek(fd, offset, SEEK_SET);
- error = read(fd, buf, sizeof(struct gfs2_quota));
- if (error < 0)
- die("failed to read from quota file: %s\n", strerror(errno));
- if (error != sizeof(struct gfs2_quota))
- die("Couldn't read %lu bytes from quota file at offset %llu\n",
- (unsigned long)sizeof(struct gfs2_quota),
- (unsigned long long)offset);
- gfs2_quota_in(q, buf);
-}
-
-static inline void
-write_quota_internal(int fd, uint32_t id, int id_type, struct gfs2_quota *q)
-{
- /* seek to the appropriate offset in the quota file and write the
- quota info */
- uint64_t offset;
- char buf[256];
- int error;
- if (id_type == GQ_ID_USER)
- offset = (2 * (uint64_t)id) * sizeof(struct gfs2_quota);
- else
- offset = (2 * (uint64_t)id + 1) * sizeof(struct gfs2_quota);
- lseek(fd, offset, SEEK_SET);
- gfs2_quota_out(q, buf);
- error = write(fd, buf, sizeof(struct gfs2_quota));
- if (error != sizeof(struct gfs2_quota))
- die("failed to write to quota file: %s\n", strerror(errno));
-}
-
-/**
- * do_reset - Reset all the quota data for a filesystem
- * @comline: the struct containing the parsed command line arguments
- */
-
-static void
-do_reset(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- int fd;
- char quota_file[BUF_SIZE], c;
- struct gfs2_quota q;
-
- if (!*comline->filesystem)
- die("need a filesystem to work on\n");
-
- printf("This operation will permanently erase all quota information.\n"
- "You will have to re-assign all quota limit/warn values.\n"
- "Proceed [y/N]? ");
- c = getchar();
- if (c != 'y' && c != 'Y')
- return;
-
- strcpy(sdp->path_name, comline->filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_RDWR);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", quota_file,
- strerror(errno));
- }
-
- read_quota_internal(fd, 0, GQ_ID_USER, &q);
- write_quota_internal(fd, 0, GQ_ID_USER, &q);
-
- read_quota_internal(fd, 0, GQ_ID_GROUP, &q);
- write_quota_internal(fd, 0, GQ_ID_GROUP, &q);
-
- /* truncate the quota file such that only the first
- * two quotas(uid=0 and gid=0) remain.
- */
- if (ftruncate(fd, (sizeof(struct gfs2_quota)) * 2))
- die("couldn't truncate quota file %s\n", strerror(errno));
-
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * do_list - List all the quota data for a filesystem
- * @comline: the struct containing the parsed command line arguments
- *
- */
-
-static void
-do_list(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- int fd;
- struct gfs2_quota q;
- char buf[sizeof(struct gfs2_quota)];
- uint64_t offset;
- uint32_t id, startid;
- int pass = 0;
- int error = 0;
- char quota_file[BUF_SIZE];
- uint64_t quota_file_size = 0;
- struct fiemap fmap = { 0, }, *fmap2;
- struct stat statbuf;
-
- if (!*comline->filesystem)
- die("need a filesystem to work on\n");
-
- strcpy(sdp->path_name, comline->filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_RDONLY);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", quota_file,
- strerror(errno));
- }
- if (fstat(fd, &statbuf) < 0) {
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't stat file %s: %s\n", quota_file,
- strerror(errno));
- }
- quota_file_size = statbuf.st_size;
- /* First find the number of extents in the quota file */
- fmap.fm_flags = 0;
- fmap.fm_start = 0;
- fmap.fm_length = (~0ULL);
- error = ioctl(fd, FS_IOC_FIEMAP, &fmap);
- if (error == -1) {
- fprintf(stderr, "fiemap error (%d): %s\n", errno, strerror(errno));
- goto out;
- }
- fmap2 = malloc(sizeof(struct fiemap) +
- fmap.fm_mapped_extents * sizeof(struct fiemap_extent));
- if (fmap2 == NULL) {
- fprintf(stderr, "malloc error (%d): %s\n", errno, strerror(errno));
- goto out;
- }
- fmap2->fm_flags = 0;
- fmap2->fm_start = 0;
- fmap2->fm_length = (~0ULL);
- fmap2->fm_extent_count = fmap.fm_mapped_extents;
-
- error = ioctl(fd, FS_IOC_FIEMAP, fmap2);
- if (error == -1) {
- fprintf(stderr, "fiemap error (%d): %s\n", errno, strerror(errno));
- goto fmap2_free;
- }
- if (fmap2->fm_mapped_extents) {
- int i;
- again:
- for (i=0; i<fmap2->fm_mapped_extents; i++) {
- struct fiemap_extent *fe = &fmap2->fm_extents[i];
- uint64_t end = fe->fe_logical + fe->fe_length;
-
- end = end > quota_file_size ? quota_file_size : end;
- startid = DIV_RU(fe->fe_logical, sizeof(struct gfs2_quota));
- if (startid % 2 != pass)
- startid++;
- offset = startid * sizeof(struct gfs2_quota);
- do {
- memset(buf, 0, sizeof(struct gfs2_quota));
- /* read hidden quota file here */
- lseek(fd, offset, SEEK_SET);
- error = read(fd, buf, sizeof(struct gfs2_quota));
- if (error < 0) {
- fprintf(stderr, "read error (%d): %s\n",
- errno, strerror(errno));
- goto fmap2_free;
- }
- gfs2_quota_in(&q, buf);
- id = (offset / sizeof(struct gfs2_quota)) >> 1;
- if (q.qu_limit || q.qu_warn || q.qu_value)
- print_quota(comline, (pass) ? FALSE : TRUE, id,
- &q, &sdp->sd_sb);
- offset += 2 * sizeof(struct gfs2_quota);
- } while (offset < end);
- }
- if (!pass) {
- pass = 1;
- goto again;
- }
- }
-
-fmap2_free:
- free(fmap2);
-out:
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * do_get_one - Get a quota value from one FS
- * @comline: the struct containing the parsed command line arguments
- * @filesystem: the filesystem to get from
- *
- */
-
-static void
-do_get_one(struct gfs2_sbd *sdp, commandline_t *comline, char *filesystem)
-{
- int fd;
- char buf[256];
- struct gfs2_quota q;
- uint64_t offset;
- int error;
- char quota_file[BUF_SIZE];
-
- strcpy(sdp->path_name, filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_RDONLY);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", quota_file,
- strerror(errno));
- }
-
- if (comline->id_type == GQ_ID_USER)
- offset = (2 * (uint64_t)comline->id) * sizeof(struct gfs2_quota);
- else
- offset = (2 * (uint64_t)comline->id + 1) * sizeof(struct gfs2_quota);
-
- memset(&q, 0, sizeof(struct gfs2_quota));
-
- lseek(fd, offset, SEEK_SET);
- error = read(fd, buf, sizeof(struct gfs2_quota));
- if (error < 0) {
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't get quota info (%d): %s\n",
- error, strerror(errno));
- }
-
- gfs2_quota_in(&q, buf);
- print_quota(comline,
- (comline->id_type == GQ_ID_USER), comline->id,
- &q, &sdp->sd_sb);
-
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * do_get - Get a quota value
- * @comline: the struct containing the parsed command line arguments
- *
- */
-
-static void
-do_get(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- int first = TRUE;
-
- if (*comline->filesystem)
- do_get_one(sdp, comline, comline->filesystem);
- else {
- char buf[256], device[256], path[256], type[256];
- FILE *file;
-
- file = fopen("/proc/mounts", "r");
- if (!file)
- die("can't open /proc/mounts: %s\n", strerror(errno));
-
- while (fgets(buf, 256, file)) {
- if (sscanf(buf, "%s %s %s", device, path, type) != 3)
- continue;
- if (strcmp(type, "gfs2") != 0)
- continue;
-
- if (first)
- first = FALSE;
- else
- printf("\n");
-
- printf("%s\n", path);
- do_get_one(sdp, comline, path);
- }
-
- fclose(file);
- }
-}
-
-/**
- * do_sync_one - sync the quotas on one GFS2 filesystem
- * @path: a file/directory in the filesystem
- *
- */
-static void
-do_sync_one(struct gfs2_sbd *sdp, char *filesystem)
-{
- char *fsname;
-
- fsname = mp2fsname(filesystem);
- if (!fsname) {
- fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n",
- filesystem);
- exit(-1);
- }
- if (set_sysfs(fsname, "quota_sync", "1")) {
- fprintf(stderr, "Error writing to sysfs quota sync file: %s\n",
- strerror(errno));
- exit(-1);
- }
-}
-
-/**
- * do_sync - sync out unsyned quotas
- * @comline: the struct containing the parsed command line arguments
- *
- */
-
-void
-do_sync(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- sync();
-
- if (*comline->filesystem)
- do_sync_one(sdp, comline->filesystem);
- else {
- char buf[256], device[256], path[256], type[256];
- FILE *file;
-
- file = fopen("/proc/mounts", "r");
- if (!file)
- die("can't open /proc/mounts: %s\n", strerror(errno));
-
- while (fgets(buf, 256, file)) {
- if (sscanf(buf, "%s %s %s", device, path, type) != 3)
- continue;
- if (strcmp(type, "gfs2") != 0)
- continue;
-
- do_sync_one(sdp, path);
- }
-
- fclose(file);
- }
-}
-
-/**
- * do_set - Set a quota value
- * @comline: the struct containing the parsed command line arguments
- *
- */
-
-static void
-do_set(struct gfs2_sbd *sdp, commandline_t *comline)
-{
- int fd;
- uint64_t offset;
- uint64_t new_value;
- char quota_file[BUF_SIZE];
- char id_str[16];
- struct stat stat_buf;
- struct gfs2_quota q;
- char *fs;
-
- if (!*comline->filesystem)
- die("need a filesystem to work on\n");
- if (!comline->new_value_set)
- die("need a new value\n");
-
- strcpy(sdp->path_name, comline->filesystem);
- if (check_for_gfs2(sdp)) {
- if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s\n",
- sdp->path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- read_superblock(&sdp->sd_sb, sdp);
- if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s\n",
- strerror(errno));
- exit(-1);
- }
-
- strcpy(quota_file, sdp->metafs_path);
- strcat(quota_file, "/quota");
-
- fd = open(quota_file, O_RDWR);
- if (fd < 0) {
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
- die("can't open file %s: %s\n", quota_file,
- strerror(errno));
- }
-
- switch (comline->id_type) {
- case GQ_ID_USER:
- offset = (2 * (uint64_t)comline->id) * sizeof(struct gfs2_quota);
- break;
-
- case GQ_ID_GROUP:
- offset = (2 * (uint64_t)comline->id + 1) * sizeof(struct gfs2_quota);
- break;
-
- default:
- fprintf(stderr, "invalid user/group ID\n");
- goto out;
- }
-
- switch (comline->units) {
- case GQ_UNITS_MEGABYTE:
- new_value =
- comline->new_value << (20 - sdp->sd_sb.sb_bsize_shift);
- break;
-
- case GQ_UNITS_KILOBYTE:
- if (sdp->sd_sb.sb_bsize == 512)
- new_value = comline->new_value * 2;
- else
- new_value = comline->new_value >>
- (sdp->sd_sb.sb_bsize_shift - 10);
- break;
-
- case GQ_UNITS_FSBLOCK:
- new_value = comline->new_value;
- break;
-
- case GQ_UNITS_BASICBLOCK:
- new_value = comline->new_value >>
- (sdp->sd_sb.sb_bsize_shift - 9);
- break;
-
- default:
- fprintf(stderr, "bad units\n");
- goto out;
- }
-
- memset(&q, 0, sizeof(struct gfs2_quota));
- if (fstat(fd, &stat_buf)) {
- fprintf(stderr, "stat failed: %s\n", strerror(errno));
- goto out;
- }
- if (stat_buf.st_size >= (offset + sizeof(struct gfs2_quota)))
- read_quota_internal(fd, comline->id, comline->id_type, &q);
-
- switch (comline->operation) {
- case GQ_OP_LIMIT:
- q.qu_limit = new_value; break;
- case GQ_OP_WARN:
- q.qu_warn = new_value; break;
- }
-
- write_quota_internal(fd, comline->id, comline->id_type, &q);
- fs = mp2fsname(comline->filesystem);
- if (!fs) {
- fprintf(stderr, "Couldn't find GFS2 filesystem mounted at %s\n",
- comline->filesystem);
- exit(-1);
- }
- sprintf(id_str, "%d", comline->id);
- if (set_sysfs(fs, comline->id_type == GQ_ID_USER ?
- "quota_refresh_user" : "quota_refresh_group", id_str)) {
- fprintf(stderr, "Error writing to sysfs quota refresh file: %s\n",
- strerror(errno));
- exit(-1);
- }
-
-out:
- close(fd);
- close(sdp->metafs_fd);
- cleanup_metafs(sdp);
-}
-
-/**
- * main - Do everything
- * @argc: well, it's argc...
- * @argv: well, it's argv...
- *
- * Returns: exit status
- */
-
-int
-main(int argc, char *argv[])
-{
- struct gfs2_sbd sbd, *sdp = &sbd;
- commandline_t comline;
-
- memset(sdp, 0, sizeof(struct gfs2_sbd));
- memset(&comline, 0, sizeof(commandline_t));
-
- decode_arguments(argc, argv, &comline);
- sdp->path_name = (char*) malloc(512);
- if (!sdp->path_name)
- die("Can't malloc! %s\n", strerror(errno));
-
- switch (comline.operation) {
- case GQ_OP_LIST:
- do_list(sdp, &comline);
- break;
-
- case GQ_OP_GET:
- do_get(sdp, &comline);
- break;
-
- case GQ_OP_LIMIT:
- case GQ_OP_WARN:
- do_set(sdp, &comline);
- break;
-
- case GQ_OP_SYNC:
- do_sync(sdp, &comline);
- break;
-
- case GQ_OP_CHECK:
- do_sync(sdp, &comline);
- do_check(sdp, &comline);
- break;
-
- case GQ_OP_INIT:
- do_sync(sdp, &comline);
- do_quota_init(sdp, &comline);
- break;
-
- case GQ_OP_RESET:
- do_reset(sdp, &comline);
- break;
- default:
- if (!comline.id_type) {
- comline.id_type = GQ_ID_USER;
- comline.id = geteuid();
- }
- do_get(sdp, &comline);
- break;
- }
-
- free(sdp->path_name);
-
- exit(EXIT_SUCCESS);
-}
diff --git a/gfs2/quota/names.c b/gfs2/quota/names.c
deleted file mode 100644
index 22474e0..0000000
--- a/gfs2/quota/names.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <dirent.h>
-#include <limits.h>
-#include <pwd.h>
-#include <grp.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include "gfs2_quota.h"
-
-uint32_t
-name_to_id(int user, char *name, int numbers)
-{
- struct passwd *u;
- struct group *g;
- uint32_t id;
- int ok = FALSE;
-
- if (numbers) {
- } else if (user) {
- u = getpwnam(name);
- if (u) {
- id = u->pw_uid;
- ok = TRUE;
- }
- } else {
- g = getgrnam(name);
- if (g) {
- id = g->gr_gid;
- ok = TRUE;
- }
- }
-
- if (!ok) {
- if (!isdigit(name[0]))
- die("can't find %s %s\n",
- (user) ? "user" : "group",
- name);
- sscanf(name, "%u", &id);
- }
-
- return id;
-}
-
-char *
-id_to_name(int user, uint32_t id, int numbers)
-{
- struct passwd *u;
- struct group *g;
- static char name[256];
- int ok = FALSE;
-
- if (numbers) {
- } else if (user) {
- u = getpwuid(id);
- if (u) {
- strcpy(name, u->pw_name);
- ok = TRUE;
- }
- } else {
- g = getgrgid(id);
- if (g) {
- strcpy(name, g->gr_name);
- ok = TRUE;
- }
- }
-
- if (!ok)
- sprintf(name, "%u", id);
-
- return name;
-}
diff --git a/gfs2/quota/target.mk b/gfs2/quota/target.mk
deleted file mode 100644
index fc01f6f..0000000
--- a/gfs2/quota/target.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-
-$(eval $(call make-binary,/usr/sbin/gfs2_quota,gfs2/libgfs2/libgfs2.a))
-
diff --git a/gfs2/tool/Makefile.am b/gfs2/tool/Makefile.am
deleted file mode 100644
index a659eea..0000000
--- a/gfs2/tool/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-sbin_PROGRAMS = gfs2_tool
-
-noinst_HEADERS = gfs2_tool.h iflags.h
-
-gfs2_tool_SOURCES = main.c misc.c ondisk.c sb.c tune.c
-
-gfs2_tool_CPPFLAGS = -D_FILE_OFFSET_BITS=64 \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/gfs2/libgfs2
-
-gfs2_tool_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/tool/gfs2_tool.h b/gfs2/tool/gfs2_tool.h
deleted file mode 100644
index 3a181ff..0000000
--- a/gfs2/tool/gfs2_tool.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef __GFS2_TOOL_DOT_H__
-#define __GFS2_TOOL_DOT_H__
-
-#include <stdarg.h>
-
-#define OUTPUT_BLOCKS 0
-#define OUTPUT_K 1
-#define OUTPUT_HUMAN 2
-
-extern char *action;
-extern int override;
-extern int expert;
-extern int debug;
-extern int continuous;
-extern int interval;
-extern int output_type;
-
-/* From counters.c */
-
-void print_counters(int argc, char **argv);
-
-
-/* From main.c */
-
-void print_usage(void);
-
-
-/* From misc.c */
-
-void do_freeze(int argc, char **argv);
-void print_lockdump(int argc, char **argv);
-void set_flag(int argc, char **argv);
-void print_stat(int argc, char **argv);
-void print_sb(int argc, char **argv);
-void print_jindex(int argc, char **argv);
-void print_journals(int argc, char **argv);
-void print_rindex(int argc, char **argv);
-void print_quota(int argc, char **argv);
-void do_withdraw(int argc, char **argv);
-
-
-/* From sb.c */
-
-void do_sb(int argc, char **argv);
-
-
-/* From tune.c */
-
-void get_tune(int argc, char **argv);
-void set_tune(int argc, char **argv);
-
-/* die() used to be in libgfs2.h */
-static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
-void die(const char *fmt, ...)
-{
- va_list ap;
- fprintf(stderr, "%s: ", __FILE__);
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(-1);
-}
-
-#endif /* __GFS2_TOOL_DOT_H__ */
diff --git a/gfs2/tool/iflags.h b/gfs2/tool/iflags.h
deleted file mode 100644
index 2d6cf18..0000000
--- a/gfs2/tool/iflags.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __IFLAGS_DOT_H__
-#define __IFLAGS_DOT_H__
-
-#define FS_IOC_GETFLAGS _IOR('f', 1, long)
-#define FS_IOC_SETFLAGS _IOW('f', 2, long)
-#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
-#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
-
-/*
- * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
- */
-#define FS_SECRM_FL 0x00000001 /* Secure deletion */
-#define FS_UNRM_FL 0x00000002 /* Undelete */
-#define FS_COMPR_FL 0x00000004 /* Compress file */
-#define FS_SYNC_FL 0x00000008 /* Synchronous updates */
-#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
-#define FS_APPEND_FL 0x00000020 /* writes to file may only append */
-#define FS_NODUMP_FL 0x00000040 /* do not dump file */
-#define FS_NOATIME_FL 0x00000080 /* do not update atime */
-/* Reserved for compression usage... */
-#define FS_DIRTY_FL 0x00000100
-#define FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
-#define FS_NOCOMP_FL 0x00000400 /* Don't compress */
-#define FS_ECOMPR_FL 0x00000800 /* Compression error */
-/* End compression flags --- maybe not all used */
-#define FS_BTREE_FL 0x00001000 /* btree format dir */
-#define FS_INDEX_FL 0x00001000 /* hash-indexed directory */
-#define FS_IMAGIC_FL 0x00002000 /* AFS directory */
-#define FS_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
-#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
-#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
-#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
-#define FS_EXTENT_FL 0x00080000 /* Extents */
-#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
-#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
-
-#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
-#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
-
-#endif /* __IFLAGS_DOT_H__ */
diff --git a/gfs2/tool/main.c b/gfs2/tool/main.c
deleted file mode 100644
index 829dc76..0000000
--- a/gfs2/tool/main.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <errno.h>
-#include <linux/types.h>
-#include <libintl.h>
-#include <locale.h>
-#define _(String) gettext(String)
-
-#include "copyright.cf"
-
-#include "gfs2_tool.h"
-#include "libgfs2.h"
-
-char *action = NULL;
-int override = FALSE;
-int expert = FALSE;
-int debug = FALSE;
-int continuous = FALSE;
-int interval = 1;
-int output_type = OUTPUT_BLOCKS;
-
-static const char *usage = {
- "Clear a flag on a inode\n"
- " gfs2_tool clearflag flag <filenames>\n"
- "Freeze a GFS2 cluster:\n"
- " gfs2_tool freeze <mountpoint>\n"
- "Get tuneable parameters for a filesystem\n"
- " gfs2_tool gettune <mountpoint>\n"
- "List the file system's journals:\n"
- " gfs2_tool journals <mountpoint>\n"
- "Have GFS2 dump its lock state:\n"
- " gfs2_tool lockdump <mountpoint> [buffersize]\n"
- "Tune a GFS2 superblock\n"
- " gfs2_tool sb <device> proto [newval]\n"
- " gfs2_tool sb <device> table [newval]\n"
- " gfs2_tool sb <device> ondisk [newval]\n"
- " gfs2_tool sb <device> multihost [newval]\n"
- " gfs2_tool sb <device> all\n"
- "Set a flag on a inode\n"
- " gfs2_tool setflag flag <filenames>\n"
- "Tune a running filesystem\n"
- " gfs2_tool settune <mountpoint> <parameter> <value>\n"
- "Unfreeze a GFS2 cluster:\n"
- " gfs2_tool unfreeze <mountpoint>\n"
- "Print tool version information\n"
- " gfs2_tool version\n"
- "Withdraw this machine from participating in a filesystem:\n"
- " gfs2_tool withdraw <mountpoint>\n"
-};
-
-/**
- * print_usage - print out usage information
- *
- */
-
-void print_usage(void)
-{
- puts( _(usage) );
-}
-
-/**
- * print_version -
- *
- */
-
-static void print_version(void)
-{
- printf( _("gfs2_tool " VERSION " (built " __DATE__ " " __TIME__ ")\n"));
- puts( _(REDHAT_COPYRIGHT "\n") );
-}
-
-/**
- * decode_arguments -
- * @argc:
- * @argv:
- *
- */
-
-static void decode_arguments(int argc, char *argv[])
-{
- int cont = TRUE;
- int optchar;
-
- output_type = OUTPUT_BLOCKS;
- while (cont) {
- optchar = getopt(argc, argv, "cDhHki:OVX");
-
- switch (optchar) {
- case 'c':
- continuous = TRUE;
- break;
-
- case 'D':
- debug = TRUE;
- break;
-
- case 'h':
- print_usage();
- exit(0);
-
- case 'H':
- output_type = OUTPUT_HUMAN;
- break;
-
- case 'i':
- sscanf(optarg, "%u", &interval);
- break;
-
- case 'k':
- output_type = OUTPUT_K;
- break;
-
- case 'O':
- override = TRUE;
- break;
-
- case 'V':
- print_version();
- exit(0);
-
- case 'X':
- expert = TRUE;
- break;
-
- case EOF:
- cont = FALSE;
- break;
-
- default:
- die( _("unknown option: %c\n"), optchar);
- };
- }
-
- if (optind < argc) {
- action = argv[optind];
- optind++;
- } else {
- die( _("no action specified\n"));
- }
-}
-
-/**
- * main - Do everything
- * @argc:
- * @argv:
- *
- */
-
-int main(int argc, char *argv[])
-{
- setlocale(LC_ALL, "");
- textdomain("gfs2-utils");
-
- if (argc < 2) {
- print_usage();
- return 0;
- }
-
- decode_arguments(argc, argv);
-
- if (strcmp(action, "clearflag") == 0)
- set_flag(argc, argv);
- else if (strcmp(action, "freeze") == 0)
- do_freeze(argc, argv);
- else if (strcmp(action, "gettune") == 0)
- get_tune(argc, argv);
- else if (strcmp(action, "journals") == 0)
- print_journals(argc, argv);
- else if (strcmp(action, "lockdump") == 0)
- print_lockdump(argc, argv);
- else if (strcmp(action, "sb") == 0)
- do_sb(argc, argv);
- else if (strcmp(action, "setflag") == 0)
- set_flag(argc, argv);
- else if (strcmp(action, "settune") == 0)
- set_tune(argc, argv);
- else if (strcmp(action, "unfreeze") == 0)
- do_freeze(argc, argv);
- else if (strcmp(action, "version") == 0)
- print_version();
- else if (strcmp(action, "withdraw") == 0)
- do_withdraw(argc, argv);
- else
- die( _("unknown action: %s\n"), action);
-
- return 0;
-}
diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
deleted file mode 100644
index 216e4ed..0000000
--- a/gfs2/tool/misc.c
+++ /dev/null
@@ -1,343 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <linux/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <errno.h>
-#include <dirent.h>
-#include <libintl.h>
-#define _(String) gettext(String)
-
-#define __user
-#include <linux/gfs2_ondisk.h>
-#include <sys/mount.h>
-
-#include "libgfs2.h"
-#include "gfs2_tool.h"
-#include "iflags.h"
-
-#ifndef FIFREZE
-#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
-#define FITHAW _IOWR('X', 120, int) /* Thaw */
-#endif
-
-/**
- * do_freeze - freeze a GFS2 filesystem
- * @argc:
- * @argv:
- *
- */
-
-void do_freeze(int argc, char **argv)
-{
- char *command = argv[optind - 1];
- int fd;
-
- if (optind == argc)
- die("Usage: gfs2_tool %s <mountpoint>\n", command);
-
- fd = open(argv[optind], O_NOCTTY|O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, _("Couldn't find a GFS2 filesystem mounted at %s\n"),
- argv[optind]);
- exit(-1);
- }
-
- if (strcmp(command, "freeze") == 0) {
- if (ioctl(fd, FIFREEZE, 0)) {
- fprintf(stderr, _("Error freezing fs: %s\n"),
- strerror(errno));
- exit(-1);
- }
- } else if (strcmp(command, "unfreeze") == 0) {
- if (ioctl(fd, FITHAW, 0)) {
- fprintf(stderr, _("Error thawing fs: %s\n"),
- strerror(errno));
- exit(-1);
- }
- }
- close(fd);
-}
-
-/**
- * print_lockdump -
- * @argc:
- * @argv:
- *
- */
-
-void print_lockdump(int argc, char **argv)
-{
- char path[PATH_MAX];
- char *name, line[PATH_MAX];
- char *debugfs;
- FILE *file;
- int rc = -1;
-
- /* See if debugfs is mounted, and if not, mount it. */
- debugfs = find_debugfs_mount();
- if (!debugfs) {
- debugfs = malloc(PATH_MAX);
- if (!debugfs)
- die("Can't allocate memory for debugfs.\n");
-
- memset(debugfs, 0, PATH_MAX);
- sprintf(debugfs, "/tmp/debugfs.XXXXXX");
-
- if (!mkdtemp(debugfs)) {
- fprintf(stderr,_("Can't create %s mount point.\n"),
- debugfs);
- free(debugfs);
- exit(-1);
- }
-
- rc = mount("none", debugfs, "debugfs", 0, NULL);
- if (rc) {
- fprintf(stderr,
- _("Can't mount debugfs. "
- "Maybe your kernel doesn't support it.\n"));
- free(debugfs);
- exit(-1);
- }
- }
- name = mp2fsname(argv[optind]);
- if (name) {
- sprintf(path, "%s/gfs2/%s/glocks", debugfs, name);
- free(name);
- file = fopen(path, "rt");
- if (file) {
- while (fgets(line, PATH_MAX, file)) {
- printf("%s", line);
- }
- fclose(file);
- } else {
- fprintf(stderr, _("Can't open %s: %s\n"), path,
- strerror(errno));
- }
- } else {
- fprintf(stderr, _("Unable to locate sysfs for mount point %s.\n"),
- argv[optind]);
- }
- /* Check if we mounted the debugfs and if so, unmount it. */
- if (!rc) {
- umount(debugfs);
- rmdir(debugfs);
- }
- free(debugfs);
-}
-
-/**
- * print_flags - print the flags in a dinode's di_flags field
- * @di: the dinode structure
- *
- */
-
-static void print_flags(struct gfs2_dinode *di)
-{
- if (di->di_flags) {
- printf( _("Flags:\n"));
- if (di->di_flags & GFS2_DIF_JDATA)
- printf(" jdata\n");
- if (di->di_flags & GFS2_DIF_EXHASH)
- printf(" exhash\n");
- if (di->di_flags & GFS2_DIF_EA_INDIRECT)
- printf(" ea_indirect\n");
- if (di->di_flags & GFS2_DIF_IMMUTABLE)
- printf(" immutable\n");
- if (di->di_flags & GFS2_DIF_APPENDONLY)
- printf(" appendonly\n");
- if (di->di_flags & GFS2_DIF_NOATIME)
- printf( _(" noatime\n"));
- if (di->di_flags & GFS2_DIF_SYNC)
- printf(" sync\n");
- if (di->di_flags & GFS2_DIF_TRUNC_IN_PROG)
- printf(" trunc_in_prog\n");
- }
-}
-
-/*
- * Use FS_XXX_FL flags defined in <linux/fs.h> which correspond to
- * GFS2_DIF_XXX
- */
-static unsigned int get_flag_from_name(char *name)
-{
- if (strncmp(name, "jdata", 5) == 0)
- return FS_JOURNAL_DATA_FL;
- else if (strncmp(name, "exhash", 6) == 0)
- return FS_INDEX_FL;
- else if (strncmp(name, "immutable", 9) == 0)
- return FS_IMMUTABLE_FL;
- else if (strncmp(name, "appendonly", 10) == 0)
- return FS_APPEND_FL;
- else if (strncmp(name, "noatime", 7) == 0)
- return FS_NOATIME_FL;
- else if (strncmp(name, "sync", 4) == 0)
- return FS_SYNC_FL;
- else
- return 0;
-}
-
-/**
- * set_flag - set or clear flags in some dinodes
- * @argc:
- * @argv:
- *
- */
-void set_flag(int argc, char **argv)
-{
- struct gfs2_dinode di;
- char *flstr;
- int fd, error, set;
- unsigned int newflags = 0;
- unsigned int flag;
- if (optind == argc) {
- di.di_flags = 0xFFFFFFFF;
- print_flags(&di);
- return;
- }
-
- set = (strcmp(argv[optind -1], "setflag") == 0) ? 1 : 0;
- flstr = argv[optind++];
- if (!(flag = get_flag_from_name(flstr)))
- die( _("unrecognized flag %s\n"), argv[optind -1]);
-
- for (; optind < argc; optind++) {
- fd = open(argv[optind], O_RDONLY);
- if (fd < 0)
- die( _("can't open %s: %s\n"), argv[optind], strerror(errno));
- /* first get the existing flags on the file */
- error = ioctl(fd, FS_IOC_GETFLAGS, &newflags);
- if (error)
- die( _("can't get flags on %s: %s\n"),
- argv[optind], strerror(errno));
- newflags = set ? newflags | flag : newflags & ~flag;
- /* new flags */
- error = ioctl(fd, FS_IOC_SETFLAGS, &newflags);
- if (error)
- die( _("can't set flags on %s: %s\n"),
- argv[optind], strerror(errno));
- close(fd);
- }
-}
-
-/**
- * print_journals - print out the file system journal information
- * @argc:
- * @argv:
- *
- */
-
-void print_journals(int argc, char **argv)
-{
- struct gfs2_sbd sbd;
- DIR *jindex;
- struct dirent *journal;
- char jindex_name[PATH_MAX], jname[PATH_MAX];
- int jcount;
- struct stat statbuf;
-
- memset(&sbd, 0, sizeof(struct gfs2_sbd));
- sbd.bsize = GFS2_DEFAULT_BSIZE;
- sbd.rgsize = -1;
- sbd.jsize = GFS2_DEFAULT_JSIZE;
- sbd.qcsize = GFS2_DEFAULT_QCSIZE;
- sbd.md.journals = 1;
-
- sbd.path_name = argv[optind];
- sbd.path_fd = open(sbd.path_name, O_RDONLY);
- if (sbd.path_fd < 0)
- die("can't open root directory %s: %s\n",
- sbd.path_name, strerror(errno));
- if (check_for_gfs2(&sbd)) {
- if (errno == EINVAL)
- fprintf(stderr, _("Not a valid GFS2 mount point: %s\n"),
- sbd.path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- sbd.device_fd = open(sbd.device_name, O_RDONLY);
- if (sbd.device_fd < 0)
- die( _("can't open device %s: %s\n"),
- sbd.device_name, strerror(errno));
-
- if (mount_gfs2_meta(&sbd)) {
- fprintf(stderr, _("Error mounting GFS2 metafs: %s\n"),
- strerror(errno));
- exit(-1);
- }
-
- sprintf(jindex_name, "%s/jindex", sbd.metafs_path);
- jindex = opendir(jindex_name);
- if (!jindex) {
- die( _("Can't open %s\n"), jindex_name);
- } else {
- jcount = 0;
- while ((journal = readdir(jindex))) {
- if (journal->d_name[0] == '.')
- continue;
- sprintf(jname, "%s/%s", jindex_name, journal->d_name);
- if (stat(jname, &statbuf)) {
- statbuf.st_size = 0;
- perror(jname);
- }
- jcount++;
- printf("%s - %lluMB\n", journal->d_name,
- (unsigned long long)statbuf.st_size / 1048576);
- }
-
- printf( _("%d journal(s) found.\n"), jcount);
- closedir(jindex);
- }
- cleanup_metafs(&sbd);
- close(sbd.device_fd);
- close(sbd.path_fd);
-}
-
-/**
- * do_withdraw - withdraw a GFS2 filesystem
- * @argc:
- * @argv:
- *
- */
-
-void do_withdraw(int argc, char **argv)
-{
- char *name;
- struct gfs2_sbd sbd;
-
- if (optind == argc)
- die("Usage: gfs2_tool withdraw <mountpoint>\n");
-
- sbd.path_name = argv[optind];
- if (check_for_gfs2(&sbd)) {
- if (errno == EINVAL)
- fprintf(stderr, _("Not a valid GFS2 mount point: %s\n"),
- sbd.path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- name = mp2fsname(argv[optind]);
- if (!name) {
- fprintf(stderr, _("Couldn't find GFS2 filesystem mounted at %s\n"),
- argv[optind]);
- exit(-1);
- }
-
- if (set_sysfs(name, "withdraw", "1")) {
- fprintf(stderr, _("Error writing to sysfs withdraw file: %s\n"),
- strerror(errno));
- exit(-1);
- }
-}
-
diff --git a/gfs2/tool/ondisk.c b/gfs2/tool/ondisk.c
deleted file mode 100644
index d58c1ef..0000000
--- a/gfs2/tool/ondisk.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <linux/types.h>
-
-#define printk printf
-
-#define WANT_GFS2_CONVERSION_FUNCTIONS
-#include <linux/gfs2_ondisk.h>
diff --git a/gfs2/tool/sb.c b/gfs2/tool/sb.c
deleted file mode 100644
index 7865664..0000000
--- a/gfs2/tool/sb.c
+++ /dev/null
@@ -1,229 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <linux/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <libintl.h>
-#define _(String) gettext(String)
-
-#include <linux/gfs2_ondisk.h>
-
-#include "gfs2_tool.h"
-#include "libgfs2.h"
-
-void print_it(const char *label, const char *fmt, const char *fmt2, ...)
-{
- va_list args;
-
- va_start(args, fmt2);
- printf("%s = ", label);
- vprintf(fmt, args);
- printf("\n");
- va_end(args);
-}
-
-/**
- * str_to_hexchar - convert a string consisting of two isxdigits back to hex.
- * Returns: the hex character
- */
-static int str_to_hexchar(const char *estring)
-{
- int ch = 0;
-
- if (isdigit(*estring))
- ch = (*estring - '0') * 0x10;
- else if (*estring >= 'a' && *estring <= 'f')
- ch = (*estring - 'a' + 0x0a) * 0x10;
- else if (*estring >= 'A' && *estring <= 'F')
- ch = (*estring - 'A' + 0x0a) * 0x10;
-
- estring++;
- if (isdigit(*estring))
- ch += (*estring - '0');
- else if (*estring >= 'a' && *estring <= 'f')
- ch += (*estring - 'a' + 0x0a);
- else if (*estring >= 'A' && *estring <= 'F')
- ch += (*estring - 'A' + 0x0a);
- return ch;
-}
-
-/**
- * do_sb - examine/modify a unmounted FS' superblock
- * @argc:
- * @argv:
- *
- */
-
-void
-do_sb(int argc, char **argv)
-{
- char *device, *field, *newval = NULL;
- int fd;
- unsigned char buf[GFS2_BASIC_BLOCK], input[256];
- struct gfs2_sb sb;
- struct gfs2_buffer_head dummy_bh;
-
- dummy_bh.b_data = (char *)buf;
- if (optind == argc)
- die("Usage: gfs2_tool sb <device> <field> [newval]\n");
-
- device = argv[optind++];
-
- if (optind == argc)
- die("Usage: gfs2_tool sb <device> <field> [newval]\n");
-
- field = argv[optind++];
-
- if (optind < argc) {
- if (strcmp(field, "all") == 0)
- die("can't specify new value for \"all\"\n");
- newval = argv[optind++];
- }
-
-
- fd = open(device, (newval) ? O_RDWR : O_RDONLY);
- if (fd < 0)
- die("can't open %s: %s\n", device, strerror(errno));
-
- if (newval && !override) {
- printf( _("You shouldn't change any of these values if the filesystem is mounted.\n"));
- printf( _("\nAre you sure? [y/n] "));
- if(!fgets((char*)input, 255, stdin))
- die( _("unable to read from stdin\n"));
-
- if (input[0] != 'y')
- die( _("aborted\n"));
-
- printf("\n");
- }
-
- if (lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK, SEEK_SET) !=
- GFS2_SB_ADDR * GFS2_BASIC_BLOCK) {
- fprintf(stderr, _("bad seek: %s from %s:%d: superblock\n"),
- strerror(errno), __FUNCTION__, __LINE__);
- exit(-1);
- }
- if (read(fd, buf, GFS2_BASIC_BLOCK) != GFS2_BASIC_BLOCK) {
- fprintf(stderr, _("bad read: %s from %s:%d: superblock\n"),
- strerror(errno), __FUNCTION__, __LINE__);
- exit(-1);
- }
-
- gfs2_sb_in(&sb, &dummy_bh);
-
- if (sb.sb_header.mh_magic != GFS2_MAGIC ||
- sb.sb_header.mh_type != GFS2_METATYPE_SB)
- die( _("there isn't a GFS2 filesystem on %s\n"), device);
-
- if (strcmp(field, "proto") == 0) {
- printf( _("current lock protocol name = \"%s\"\n"),
- sb.sb_lockproto);
-
- if (newval) {
- if (strlen(newval) >= GFS2_LOCKNAME_LEN)
- die( _("new lockproto name is too long\n"));
- strcpy(sb.sb_lockproto, newval);
- printf( _("new lock protocol name = \"%s\"\n"),
- sb.sb_lockproto);
- }
- } else if (strcmp(field, "table") == 0) {
- printf( _("current lock table name = \"%s\"\n"),
- sb.sb_locktable);
-
- if (newval) {
- if (strlen(newval) >= GFS2_LOCKNAME_LEN)
- die( _("new locktable name is too long\n"));
- strcpy(sb.sb_locktable, newval);
- printf( _("new lock table name = \"%s\"\n"),
- sb.sb_locktable);
- }
- } else if (strcmp(field, "ondisk") == 0) {
- printf( _("current ondisk format = %u\n"),
- sb.sb_fs_format);
-
- if (newval) {
- sb.sb_fs_format = atoi(newval);
- printf( _("new ondisk format = %u\n"),
- sb.sb_fs_format);
- }
- } else if (strcmp(field, "multihost") == 0) {
- printf( _("current multihost format = %u\n"),
- sb.sb_multihost_format);
-
- if (newval) {
- sb.sb_multihost_format = atoi(newval);
- printf( _("new multihost format = %u\n"),
- sb.sb_multihost_format);
- }
-#ifdef GFS2_HAS_UUID
- } else if (strcmp(field, "uuid") == 0) {
- printf( _("current uuid = %s\n"), str_uuid(sb.sb_uuid));
-
- if (newval) {
- int i;
- unsigned char uuid[16], *cp;
-
- if (strlen(newval) != 36)
- die( _("uuid %s is the wrong length; must be 36 "
- "hex characters long.\n"), newval);
- cp = uuid;
- for (i = 0; i < 36; i++) {
- if ((i == 8) || (i == 13) ||
- (i == 18) || (i == 23)) {
- if (newval[i] == '-')
- continue;
- die( _("uuid %s has an invalid format."),
- newval);
- }
- if (!isxdigit(newval[i]))
- die( _("uuid %s has an invalid hex "
- "digit '%c' at offset %d.\n"),
- newval, newval[i], i + 1);
- *cp = str_to_hexchar(&newval[i++]);
- cp++;
- }
- memcpy(sb.sb_uuid, uuid, 16);
- printf( _("new uuid = %s\n"), str_uuid(sb.sb_uuid));
- }
-#endif
- } else if (strcmp(field, "all") == 0) {
- gfs2_sb_print(&sb);
- newval = FALSE;
- } else
- die( _("unknown field %s\n"), field);
-
- if (newval) {
- gfs2_sb_out(&sb, &dummy_bh);
-
- if (lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK, SEEK_SET) !=
- GFS2_SB_ADDR * GFS2_BASIC_BLOCK) {
- fprintf(stderr, _("bad seek: %s from %s:%d: superblock\n"),
- strerror(errno), __FUNCTION__, __LINE__);
- exit(-1);
- }
- if (write(fd, buf, GFS2_BASIC_BLOCK) != GFS2_BASIC_BLOCK) {
- fprintf(stderr, _("write error: %s from %s:%d: "
- "superblock\n"), strerror(errno),
- __FUNCTION__, __LINE__);
- exit(-1);
- }
-
- fsync(fd);
-
- printf( _("Done\n"));
- }
-
- close(fd);
-}
diff --git a/gfs2/tool/target.mk b/gfs2/tool/target.mk
deleted file mode 100644
index ba74727..0000000
--- a/gfs2/tool/target.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-
-$(eval $(call make-binary,/usr/sbin/gfs2_tool,gfs2/libgfs2/libgfs2.a))
-
diff --git a/gfs2/tool/tune.c b/gfs2/tool/tune.c
deleted file mode 100644
index 1bea4b2..0000000
--- a/gfs2/tool/tune.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <linux/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <errno.h>
-#include <dirent.h>
-#include <libintl.h>
-#define _(String) gettext(String)
-
-#define __user
-
-#include "gfs2_tool.h"
-#include "libgfs2.h"
-
-#define SIZE (65536)
-
-#define SYS_BASE "/sys/fs/gfs2" /* FIXME: Look in /proc/mounts for this */
-
-/**
- * get_tune - print out the current tuneable parameters for a filesystem
- * @argc:
- * @argv:
- *
- */
-
-void
-get_tune(int argc, char **argv)
-{
- char path[PATH_MAX];
- char *fs;
- DIR *d;
- struct dirent *de;
- double ratio;
- unsigned int num, den;
- struct gfs2_sbd sbd;
- char *value;
-
- if (optind == argc)
- die( _("Usage: gfs2_tool gettune <mountpoint>\n"));
-
- sbd.path_name = argv[optind];
- if (check_for_gfs2(&sbd)) {
- if (errno == EINVAL)
- fprintf(stderr, _("Not a valid GFS2 mount point: %s\n"),
- sbd.path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- fs = mp2fsname(argv[optind]);
- if (!fs) {
- fprintf(stderr, _("Couldn't find GFS2 filesystem mounted at %s\n"),
- argv[optind]);
- exit(-1);
- }
- memset(path, 0, PATH_MAX);
- snprintf(path, PATH_MAX - 1, "%s/%s/tune", SYS_BASE, fs);
-
- d = opendir(path);
- if (!d)
- die( _("can't open %s: %s\n"), path, strerror(errno));
-
- while((de = readdir(d))) {
- if (de->d_name[0] == '.')
- continue;
- snprintf(path, PATH_MAX - 1, "tune/%s", de->d_name);
- if (strcmp(de->d_name, "quota_scale") == 0) {
- value = get_sysfs(fs, "tune/quota_scale");
- if (!value) {
- printf( _("quota_scale = (Not found: %s)\n"),
- strerror(errno));
- continue;
- }
- sscanf(value, "%u %u", &num, &den);
- ratio = (double)num / den;
- printf( _("quota_scale = %.4f (%u, %u)\n"), ratio, num,
- den);
- } else
- printf("%s = %s\n", de->d_name, get_sysfs(fs, path));
- }
- closedir(d);
-}
-
-/**
- * set_tune - set a tuneable parameter
- * @argc:
- * @argv:
- *
- */
-
-void
-set_tune(int argc, char **argv)
-{
- char *param, *value;
- char tune_base[SIZE] = "tune/";
- char buf[256];
- char *fs;
- struct gfs2_sbd sbd;
-
- if (optind == argc)
- die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
- sbd.path_name = argv[optind++];
- if (optind == argc)
- die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
- param = argv[optind++];
- if (optind == argc)
- die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
- value = argv[optind++];
-
- if (check_for_gfs2(&sbd)) {
- if (errno == EINVAL)
- fprintf(stderr, _("Not a valid GFS2 mount point: %s\n"),
- sbd.path_name);
- else
- fprintf(stderr, "%s\n", strerror(errno));
- exit(-1);
- }
- fs = mp2fsname(sbd.path_name);
- if (!fs) {
- fprintf(stderr, _("Couldn't find GFS2 filesystem mounted at %s\n"),
- sbd.path_name);
- exit(-1);
- }
-
- if (strcmp(param, "quota_scale") == 0) {
- float s;
- sscanf(value, "%f", &s);
- sprintf(buf, "%u %u", (unsigned int)(s * 10000.0 + 0.5), 10000);
- value = buf;
- }
- if (set_sysfs(fs, strcat(tune_base, param), value)) {
- fprintf(stderr, _("Error writing to sysfs %s tune file: %s\n"),
- param, strerror(errno));
- exit(-1);
- }
-}
11 years, 9 months
cluster: STABLE32 - cman-preconfig: allow host aliases as valid cluster nodenames
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=8975bd6341b...
Commit: 8975bd6341b2d94c1f89279b1b00d4360da1f5ff
Parent: 955e85a37c34f2d04980585789c7fe5dbe7d1bf2
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Wed Jun 27 11:46:01 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Fri Jun 29 11:55:00 2012 +0200
cman-preconfig: allow host aliases as valid cluster nodenames
Resolves: rhbz#786118
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
cman/daemon/cman-preconfig.c | 91 +++++++++++++++++++++++++++++++++++-------
1 files changed, 76 insertions(+), 15 deletions(-)
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index d88ff3d..68fec22 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -451,7 +451,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
struct sockaddr *sa;
hdb_handle_t nodes_handle;
hdb_handle_t find_handle = 0;
- int error;
+ int found = 0;
/* nodename is either from commandline or from uname */
if (nodelist_byname(objdb, cluster_parent_handle, node))
@@ -497,12 +497,11 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
}
objdb->object_find_destroy(find_handle);
-
- /* The cluster.conf names may not be related to uname at all,
- they may match a hostname on some network interface.
- NOTE: This is IPv4 only */
- error = getifaddrs(&ifa_list);
- if (error)
+ /*
+ * The cluster.conf names may not be related to uname at all,
+ * they may match a hostname on some network interface.
+ */
+ if (getifaddrs(&ifa_list))
return -1;
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
@@ -521,12 +520,13 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
if (sa->sa_family == AF_INET6)
salen = sizeof(struct sockaddr_in6);
- error = getnameinfo(sa, salen, nodename2,
- sizeof(nodename2), NULL, 0, 0);
- if (!error) {
+ if (getnameinfo(sa, salen,
+ nodename2, sizeof(nodename2),
+ NULL, 0, 0) == 0) {
if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
strncpy(node, nodename2, sizeof(nodename) - 1);
+ found = 1;
goto out;
}
@@ -537,27 +537,88 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
strncpy(node, nodename2, sizeof(nodename) - 1);
+ found = 1;
goto out;
}
}
}
/* See if it's the IP address that's in cluster.conf */
- error = getnameinfo(sa, sizeof(*sa), nodename2,
- sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
- if (error)
+ if (getnameinfo(sa, sizeof(*sa),
+ nodename2, sizeof(nodename2),
+ NULL, 0, NI_NUMERICHOST))
continue;
if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
strncpy(node, nodename2, sizeof(nodename) - 1);
+ found = 1;
goto out;
}
}
- error = -1;
out:
+ if (found) {
+ freeifaddrs(ifa_list);
+ return 0;
+ }
+
+ /*
+ * This section covers the usecase where the nodename specified in cluster.conf
+ * is an alias specified in /etc/hosts. For example:
+ * <ipaddr> hostname alias1 alias2
+ * and <clusternode name="alias2">
+ * the above calls use uname and getnameinfo does not return aliases.
+ * here we take the name specified in cluster.conf, resolve it to an address
+ * and then compare against all known local ip addresses.
+ * if we have a match, we found our nodename. In theory this chunk of code
+ * could replace all the checks above, but let's avoid any possible regressions
+ * and use it as last.
+ */
+
+ nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
+ while (nodes_handle) {
+ char *dbnodename = NULL;
+ struct addrinfo hints;
+ struct addrinfo *result = NULL, *rp = NULL;
+
+ if (objdb_get_string(objdb, nodes_handle, "name", &dbnodename)) {
+ goto next;
+ }
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = 0;
+ hints.ai_protocol = IPPROTO_UDP;
+
+ if (getaddrinfo(dbnodename, NULL, &hints, &result))
+ goto next;
+
+ for (rp = result; rp != NULL; rp = rp->ai_next) {
+ for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
+ if (ipaddr_equal((struct sockaddr_storage *)rp->ai_addr,
+ (struct sockaddr_storage *)ifa->ifa_addr)) {
+ freeaddrinfo(result);
+ strncpy(node, dbnodename, sizeof(nodename) - 1);
+ found = 1;
+ goto out2;
+ }
+ }
+ }
+
+ freeaddrinfo(result);
+ next:
+ nodes_handle = nodeslist_next(objdb, find_handle);
+ }
+ out2:
+ objdb->object_find_destroy(find_handle);
freeifaddrs(ifa_list);
- return error;
+
+ if (found) {
+ return 0;
+ }
+
+ return -1;
}
/* Get any environment variable overrides */
11 years, 9 months
gfs2-utils: master - mkfs.gfs2: Check for symlinks before reporting device contents
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=954ccb98...
Commit: 954ccb986b9a18204e7d3137f4fae97bbcb2be8a
Parent: 9803f25df8f32c8eb4b99957097017df52bdd6fd
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 21 14:14:27 2012 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Jun 21 14:14:27 2012 +0100
mkfs.gfs2: Check for symlinks before reporting device contents
When using symlinks with mkfs.gfs2 it reports what the symlink points
to instead of the contents of the device, like so:
# ./mkfs.gfs2 -p lock_nolock /dev/vg/test
This will destroy any data on /dev/vg/test.
It appears to contain: symbolic link to `../dm-3'
This patch resolves symlinks before checking the device contents to make
the output more informative:
# ./mkfs.gfs2 -p lock_nolock /dev/vg/test
/dev/vg/test is a symlink to /dev/dm-3
This will destroy any data on /dev/dm-3.
It appears to contain: GFS2 Filesystem (blocksize 4096, lockproto lock_nolock)
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index e6b00a0..957b144 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -518,19 +518,46 @@ print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
printf("\n");
}
+
+/**
+ * If path is a symlink, return 1 with *abspath pointing to the absolute path,
+ * otherwise return 0. Exit on errors. The caller must free the memory pointed
+ * to by *abspath.
+ */
+static int is_symlink(char *path, char **abspath)
+{
+ struct stat lnkstat;
+
+ if (lstat(path, &lnkstat) == -1) {
+ perror("Failed to lstat the device");
+ exit(EXIT_FAILURE);
+ }
+ if (!S_ISLNK(lnkstat.st_mode)) {
+ return 0;
+ }
+ *abspath = canonicalize_file_name(path);
+ if (*abspath == NULL) {
+ perror(_("Could not find the absolute path of the device"));
+ exit(EXIT_FAILURE);
+ }
+ printf( _("%s is a symlink to %s\n"), path, *abspath);
+ return 1;
+}
+
/**
* main_mkfs - do everything
* @argc:
* @argv:
*
*/
-
void main_mkfs(int argc, char *argv[])
{
struct gfs2_sbd sbd, *sdp = &sbd;
int error;
int rgsize_specified = 0;
unsigned char uuid[16];
+ char *absname = NULL;
+ int islnk = 0;
memset(sdp, 0, sizeof(struct gfs2_sbd));
sdp->bsize = -1;
@@ -561,8 +588,10 @@ void main_mkfs(int argc, char *argv[])
}
if (!sdp->override) {
- printf( _("This will destroy any data on %s.\n"), sdp->device_name);
- check_dev_content(sdp->device_name);
+ islnk = is_symlink(sdp->device_name, &absname);
+ printf(_("This will destroy any data on %s.\n"), islnk ? absname : sdp->device_name);
+ check_dev_content(islnk ? absname : sdp->device_name);
+ free(absname);
are_you_sure();
}
11 years, 9 months
cluster: RHEL59 - GFS: Don't free superblock until last kobject user is done
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=4a3415a2056...
Commit: 4a3415a2056b8b09ab272edefc0de8950b84f393
Parent: 8ee021f46aca899b326c30859194707c94886530
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri May 18 09:47:52 2012 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Wed Jun 27 14:25:32 2012 -0500
GFS: Don't free superblock until last kobject user is done
This patch rearranges the sysfs interface to more closely match
GFS2, plus it adds an object release mechanism, as described in
kernel/Documentation/kobject.txt
rhbz#788694
---
gfs-kernel/src/gfs/ops_fstype.c | 27 +++++++++++++++++++--------
gfs-kernel/src/gfs/ops_fstype.h | 1 -
gfs-kernel/src/gfs/ops_super.c | 6 +-----
gfs-kernel/src/gfs/sys.c | 14 ++++++++++++++
4 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_fstype.c b/gfs-kernel/src/gfs/ops_fstype.c
index 34d9fa4..7104a2d 100644
--- a/gfs-kernel/src/gfs/ops_fstype.c
+++ b/gfs-kernel/src/gfs/ops_fstype.c
@@ -682,12 +682,24 @@ static int fill_super(struct super_block *sb, void *data, int silent)
goto fail;
}
error = init_names(sdp, silent);
- if (error)
- goto fail;
+ if (error) {
+ /* In this case, we haven't initialized sysfs, so we have to
+ manually free the sdp. */
+ vfree(sdp);
+ sb->s_fs_info = NULL;
+ return error;
+ }
error = gfs_sys_fs_add(sdp);
+ /*
+ * If we hit an error here, gfs2_sys_fs_add will have called function
+ * kobject_put which causes the sysfs usage count to go to zero, which
+ * causes sysfs to call function gfs2_sbd_release, which frees sdp.
+ * Subsequent error paths here will call gfs_sys_fs_del, which also
+ * kobject_put to free sdp.
+ */
if (error)
- goto fail;
+ return error;
/* Mount an inter-node lock module, check for local optimizations */
@@ -746,17 +758,16 @@ fail_locking:
fail_lm:
gfs_gl_hash_clear(sdp, TRUE);
gfs_lm_unmount(sdp);
+fail_sys:
gfs_clear_dirty_j(sdp);
while (invalidate_inodes(sb))
yield();
-fail_sys:
- gfs_sys_fs_del(sdp);
-
fail:
- vfree(sdp);
+ /* gfs_sys_fs_del must be the last thing we do, since it causes
+ * sysfs to call function gfs2_sbd_release, which frees sdp. */
+ gfs_sys_fs_del(sdp);
sb->s_fs_info = NULL;
-
return error;
}
diff --git a/gfs-kernel/src/gfs/ops_fstype.h b/gfs-kernel/src/gfs/ops_fstype.h
index 8f6f0f7..d31225e 100644
--- a/gfs-kernel/src/gfs/ops_fstype.h
+++ b/gfs-kernel/src/gfs/ops_fstype.h
@@ -16,7 +16,6 @@
int gfs_sys_init(void);
void gfs_sys_uninit(void);
-void gfs_sys_fs_del(struct gfs_sbd *sdp);
int gfs_test_bdev_super(struct super_block *sb, void *data);
int gfs_set_bdev_super(struct super_block *sb, void *data);
int init_names(struct gfs_sbd *sdp, int silent);
diff --git a/gfs-kernel/src/gfs/ops_super.c b/gfs-kernel/src/gfs/ops_super.c
index 1fa7faf..c111a2e 100644
--- a/gfs-kernel/src/gfs/ops_super.c
+++ b/gfs-kernel/src/gfs/ops_super.c
@@ -167,17 +167,13 @@ gfs_put_super(struct super_block *sb)
/* At this point, we're through participating in the lockspace */
- gfs_sys_fs_del(sdp);
-
gfs_clear_dirty_j(sdp);
/* Get rid of any extra inodes */
while (invalidate_inodes(sb))
yield();
- vfree(sdp);
-
- set_v2sdp(sb, NULL);
+ gfs_sys_fs_del(sdp);
}
/**
diff --git a/gfs-kernel/src/gfs/sys.c b/gfs-kernel/src/gfs/sys.c
index 81fe82b..3079cae 100644
--- a/gfs-kernel/src/gfs/sys.c
+++ b/gfs-kernel/src/gfs/sys.c
@@ -20,6 +20,7 @@
#include <linux/buffer_head.h>
#include <linux/proc_fs.h>
#include <linux/module.h>
+#include <linux/vmalloc.h>
#include <asm/uaccess.h>
#include "gfs.h"
@@ -75,12 +76,20 @@ static ssize_t gfs_attr_store(struct kobject *kobj, struct attribute *attr,
return a->store ? a->store(sdp, buf, len) : len;
}
+static void gfs_sbd_release(struct kobject *kobj)
+{
+ struct gfs_sbd *sdp = container_of(kobj, struct gfs_sbd, sd_kobj);
+
+ vfree(sdp);
+}
+
static struct sysfs_ops gfs_attr_ops = {
.show = gfs_attr_show,
.store = gfs_attr_store,
};
static struct kobj_type gfs_ktype = {
+ .release = gfs_sbd_release,
.default_attrs = gfs_attrs,
.sysfs_ops = &gfs_attr_ops,
};
@@ -93,6 +102,7 @@ static struct kset gfs_kset = {
int gfs_sys_fs_add(struct gfs_sbd *sdp)
{
+ struct super_block *sb;
int error;
sdp->sd_kobj.kset = &gfs_kset;
@@ -109,6 +119,10 @@ int gfs_sys_fs_add(struct gfs_sbd *sdp)
return 0;
fail:
+ printk("GFS: error %d adding sysfs files", error);
+ sb = sdp->sd_vfs;
+ vfree(sdp);
+ sb->s_fs_info = NULL;
return error;
}
11 years, 9 months
cluster: RHEL58 - rgmanager: fix nfsrestart option to be effective
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=790a470007b...
Commit: 790a470007b24c94089d2d97f18f5664c6ddaada
Parent: a7d4a8aee323162e42239fa80ea9a4b56dcace49
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Jun 21 10:02:05 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Jun 25 16:46:20 2012 +0200
rgmanager: fix nfsrestart option to be effective
The original patch a7d4a8aee32 was still racy in some conditions
as other rpc.* and nfs* processes were holding a lock on the filesystem.
stopping nfs in kernel is simply not enough in rhel5
this fixed version does stop nfs completely and re-instante nfs exports.
Resolves: rhbz#827390
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Acked-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 31 ++++++++++++++++++++-----------
rgmanager/src/resources/fs.sh | 31 ++++++++++++++++++++-----------
2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index 89b30a2..49eb724 100755
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -681,7 +681,10 @@ stopFilesystem() {
typeset -i max_tries=3 # how many times to try umount
typeset -i sleep_time=2 # time between each umount failure
typeset -i refs=0
- typeset nfsdthreads
+ typeset nfsexports=""
+ typeset nfsexp=""
+ typeset nfsopts=""
+ typeset nfsacl=""
typeset done=""
typeset umount_failed=""
typeset force_umount=""
@@ -804,16 +807,22 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ "$OCF_RESKEY_nfsrestart" = "yes" ] || \
[ "$OCF_RESKEY_nfsrestart" = "1" ]; then
- if [ -f /proc/fs/nfsd/threads ]; then
- ocf_log warning "Restarting nfsd/nfslock"
- nfsdthreads="$(cat /proc/fs/nfsd/threads)"
- service nfslock stop
- echo 0 > /proc/fs/nfsd/threads
- echo $nfsdthreads > /proc/fs/nfsd/threads
- service nfslock start
- else
- ocf_log err "Unable to determin nfsd information. nfsd restart aborted"
- fi
+ ocf_log warning "Restarting nfsd/nfslock"
+ nfsexports=$(cat /var/lib/nfs/etab)
+ service nfslock stop
+ service nfs stop
+ service nfs start
+ service nfslock start
+ echo "$nfsexports" | { while read line; do
+ nfsexp=$(echo $line | awk '{print $1}')
+ nfsopts=$(echo $line | sed -e 's#.*(##g' -e 's#).*##g')
+ nfsacl=$(echo $line | awk '{print $2}' | sed -e 's#(.*##g')
+ if [ -n "$nfsopts" ]; then
+ exportfs -i -o "$nfsopts" "$nfsacl":$nfsexp
+ else
+ exportfs -i "$nfsacl":$nfsexp
+ fi
+ done; }
fi
else
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 5724352..a98cddc 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -1019,7 +1019,10 @@ stopFilesystem() {
typeset -i max_tries=3 # how many times to try umount
typeset -i sleep_time=5 # time between each umount failure
typeset -i nfslock_reclaim=0
- typeset nfsdthreads
+ typeset nfsexports=""
+ typeset nfsexp=""
+ typeset nfsopts=""
+ typeset nfsacl=""
typeset done=""
typeset umount_failed=""
typeset force_umount=""
@@ -1126,16 +1129,22 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ "$OCF_RESKEY_nfsrestart" = "yes" ] || \
[ "$OCF_RESKEY_nfsrestart" = "1" ]; then
- if [ -f /proc/fs/nfsd/threads ]; then
- ocf_log warning "Restarting nfsd/nfslock"
- nfsdthreads="$(cat /proc/fs/nfsd/threads)"
- service nfslock stop
- echo 0 > /proc/fs/nfsd/threads
- echo $nfsdthreads > /proc/fs/nfsd/threads
- service nfslock start
- else
- ocf_log err "Unable to determin nfsd information. nfsd restart aborted"
- fi
+ ocf_log warning "Restarting nfsd/nfslock"
+ nfsexports=$(cat /var/lib/nfs/etab)
+ service nfslock stop
+ service nfs stop
+ service nfs start
+ service nfslock start
+ echo "$nfsexports" | { while read line; do
+ nfsexp=$(echo $line | awk '{print $1}')
+ nfsopts=$(echo $line | sed -e 's#.*(##g' -e 's#).*##g')
+ nfsacl=$(echo $line | awk '{print $2}' | sed -e 's#(.*##g')
+ if [ -n "$nfsopts" ]; then
+ exportfs -i -o "$nfsopts" "$nfsacl":$nfsexp
+ else
+ exportfs -i "$nfsacl":$nfsexp
+ fi
+ done; }
fi
else
fuser -kvm "$mp"
11 years, 10 months
cluster: RHEL59 - rgmanager: fix nfsrestart option to be effective
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=8ee021f46ac...
Commit: 8ee021f46aca899b326c30859194707c94886530
Parent: e512a9ce367da0bb251559452023ce11f4506f27
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Jun 21 10:02:05 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Jun 25 16:10:32 2012 +0200
rgmanager: fix nfsrestart option to be effective
The original patch e512a9ce367 was still racy in some conditions
as other rpc.* and nfs* processes were holding a lock on the filesystem.
stopping nfs in kernel is simply not enough in rhel5
this fixed version does stop nfs completely and re-instante nfs exports.
Resolves: rhbz#822066
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Acked-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 31 ++++++++++++++++++++-----------
rgmanager/src/resources/fs.sh | 31 ++++++++++++++++++++-----------
2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index 89b30a2..49eb724 100755
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -681,7 +681,10 @@ stopFilesystem() {
typeset -i max_tries=3 # how many times to try umount
typeset -i sleep_time=2 # time between each umount failure
typeset -i refs=0
- typeset nfsdthreads
+ typeset nfsexports=""
+ typeset nfsexp=""
+ typeset nfsopts=""
+ typeset nfsacl=""
typeset done=""
typeset umount_failed=""
typeset force_umount=""
@@ -804,16 +807,22 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ "$OCF_RESKEY_nfsrestart" = "yes" ] || \
[ "$OCF_RESKEY_nfsrestart" = "1" ]; then
- if [ -f /proc/fs/nfsd/threads ]; then
- ocf_log warning "Restarting nfsd/nfslock"
- nfsdthreads="$(cat /proc/fs/nfsd/threads)"
- service nfslock stop
- echo 0 > /proc/fs/nfsd/threads
- echo $nfsdthreads > /proc/fs/nfsd/threads
- service nfslock start
- else
- ocf_log err "Unable to determin nfsd information. nfsd restart aborted"
- fi
+ ocf_log warning "Restarting nfsd/nfslock"
+ nfsexports=$(cat /var/lib/nfs/etab)
+ service nfslock stop
+ service nfs stop
+ service nfs start
+ service nfslock start
+ echo "$nfsexports" | { while read line; do
+ nfsexp=$(echo $line | awk '{print $1}')
+ nfsopts=$(echo $line | sed -e 's#.*(##g' -e 's#).*##g')
+ nfsacl=$(echo $line | awk '{print $2}' | sed -e 's#(.*##g')
+ if [ -n "$nfsopts" ]; then
+ exportfs -i -o "$nfsopts" "$nfsacl":$nfsexp
+ else
+ exportfs -i "$nfsacl":$nfsexp
+ fi
+ done; }
fi
else
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 5724352..a98cddc 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -1019,7 +1019,10 @@ stopFilesystem() {
typeset -i max_tries=3 # how many times to try umount
typeset -i sleep_time=5 # time between each umount failure
typeset -i nfslock_reclaim=0
- typeset nfsdthreads
+ typeset nfsexports=""
+ typeset nfsexp=""
+ typeset nfsopts=""
+ typeset nfsacl=""
typeset done=""
typeset umount_failed=""
typeset force_umount=""
@@ -1126,16 +1129,22 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ "$OCF_RESKEY_nfsrestart" = "yes" ] || \
[ "$OCF_RESKEY_nfsrestart" = "1" ]; then
- if [ -f /proc/fs/nfsd/threads ]; then
- ocf_log warning "Restarting nfsd/nfslock"
- nfsdthreads="$(cat /proc/fs/nfsd/threads)"
- service nfslock stop
- echo 0 > /proc/fs/nfsd/threads
- echo $nfsdthreads > /proc/fs/nfsd/threads
- service nfslock start
- else
- ocf_log err "Unable to determin nfsd information. nfsd restart aborted"
- fi
+ ocf_log warning "Restarting nfsd/nfslock"
+ nfsexports=$(cat /var/lib/nfs/etab)
+ service nfslock stop
+ service nfs stop
+ service nfs start
+ service nfslock start
+ echo "$nfsexports" | { while read line; do
+ nfsexp=$(echo $line | awk '{print $1}')
+ nfsopts=$(echo $line | sed -e 's#.*(##g' -e 's#).*##g')
+ nfsacl=$(echo $line | awk '{print $2}' | sed -e 's#(.*##g')
+ if [ -n "$nfsopts" ]; then
+ exportfs -i -o "$nfsopts" "$nfsacl":$nfsexp
+ else
+ exportfs -i "$nfsacl":$nfsexp
+ fi
+ done; }
fi
else
fuser -kvm "$mp"
11 years, 10 months
dlm: the tag dlm-3.99.5 has been created
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=d38ab51fc27764a...
Commit: d38ab51fc27764ae34849229c7f447cc60de5de1
Parent: fcc60e8f89908cabd294bbd37537de3b566c4105
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 21 16:53:56 2012 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 21 16:53:56 2012 -0500
release 3.99.5
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
include/version.cf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/version.cf b/include/version.cf
index 3923440..e423c07 100644
--- a/include/version.cf
+++ b/include/version.cf
@@ -1,6 +1,6 @@
#ifndef _RELEASE_VERSION_CF_
#define _RELEASE_VERSION_CF_
-#define RELEASE_VERSION "3.99.4"
+#define RELEASE_VERSION "3.99.5"
#endif
11 years, 10 months
dlm: master - release 3.99.5
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=d38ab51fc27764a...
Commit: d38ab51fc27764ae34849229c7f447cc60de5de1
Parent: fcc60e8f89908cabd294bbd37537de3b566c4105
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 21 16:53:56 2012 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 21 16:53:56 2012 -0500
release 3.99.5
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
include/version.cf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/version.cf b/include/version.cf
index 3923440..e423c07 100644
--- a/include/version.cf
+++ b/include/version.cf
@@ -1,6 +1,6 @@
#ifndef _RELEASE_VERSION_CF_
#define _RELEASE_VERSION_CF_
-#define RELEASE_VERSION "3.99.4"
+#define RELEASE_VERSION "3.99.5"
#endif
11 years, 10 months
cluster: STABLE32 - qdisk: Report non-zero exit codes from heuristic
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=955e85a37c3...
Commit: 955e85a37c34f2d04980585789c7fe5dbe7d1bf2
Parent: 9d0ecbac1ff8ac1f045bd19bb73ca063a5351014
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Fri Jun 15 09:40:23 2012 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Fri Jun 15 09:42:26 2012 -0400
qdisk: Report non-zero exit codes from heuristic
If a heuristic failed, it was difficult to determine why.
This change allows debug logging of heuristic (or /bin/sh)
return codes so that administrators have an idea as to
what went wrong.
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/qdisk/score.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/cman/qdisk/score.c b/cman/qdisk/score.c
index 3ca531f..653fdf3 100644
--- a/cman/qdisk/score.c
+++ b/cman/qdisk/score.c
@@ -215,6 +215,8 @@ check_heuristic(struct h_data *h, int block, struct timespec *now)
goto miss;
}
if (WEXITSTATUS(status) != 0) {
+ logt_print(LOG_DEBUG, "Heuristic: sh returned %d for '%s'\n",
+ WEXITSTATUS(status), h->program);
ret = 0;
goto miss;
}
11 years, 10 months
dlm: master - dlm_tool: clear name buffer in output
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=fcc60e8f89908ca...
Commit: fcc60e8f89908cabd294bbd37537de3b566c4105
Parent: e7883bea402d425f176dc4176bf5123acc84e153
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 12 15:25:50 2012 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 15:25:50 2012 -0500
dlm_tool: clear name buffer in output
could end up printing some garbage after the name
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_tool/main.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 608ee49..7ce9395 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -875,7 +875,7 @@ static void do_waiters(char *name, struct summary *sum)
FILE *file;
char path[PATH_MAX];
char line[LOCK_LINE_MAX];
- char rname[65];
+ char rname[DLM_RESNAME_MAXLEN+1];
int header = 0;
int i, j, spaces;
int rv, nodeid, wait_type;
@@ -905,6 +905,7 @@ static void do_waiters(char *name, struct summary *sum)
/* parse the resource name from the remainder of the line */
j = 0;
spaces = 0;
+ memset(rname, 0, sizeof(rname));
for (i = 0; i < LOCK_LINE_MAX; i++) {
if (line[i] == '\n')
@@ -1043,7 +1044,7 @@ static void do_lockdump(char *name)
FILE *file;
char path[PATH_MAX];
char line[LOCK_LINE_MAX];
- char r_name[65];
+ char r_name[DLM_RESNAME_MAXLEN+1];
int r_nodeid;
int r_len;
int rv;
11 years, 10 months