Red Hat Bugzilla – Bug 364741
GFS2: gfs2_quota doesn't work unless lock table specified
Last modified: 2010-01-11 22:40:26 EST
Description of problem:
I was doing some poking around looking at how the gfs2 tools were
using sysfs, and I discovered that gfs2_quota was using it improperly.
The problem is that gfs2_quota tries to look in /sys/fs/gfs2/<lock table>
for information, but in a stand-alone gfs2 file system, the lock table
may be NULL. In this case, the kernel uses the vfs s_id instead of the
lock table to name this sysfs directory. The gfs2_tool overcomes this
by using functions in util.c. Really, all the userland tools that use
sysfs need to be doing the same thing.
We should take the functions from gfs2_tool's util.c and put them
into libgfs2 so that they can be linked in by gfs2_tool and gfs2_quota
and any other tools that need to access the sysfs files.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. mkfs.gfs2 /dev/sdb1
2. mount -tgfs2 /dev/sdb1 /mnt/hell
3. gfs2_quota check -f /mnt/hell
gfs2_quota: can't open file /sys/fs/gfs2//quota_sync: No such file or directory
Should not error out. It should use /sys/fs/gfs2/sdb1/*, but it should
do so by using the standard functions from gfs2_tool's util.c.
Like gfs2_tool, we can't assume anything about the device name.
For example, the user can do: mknod /dev/xxx_yyy b 8 17 then mkfs and
mount /dev/xxx_yyy, and the sysfs file will still be in /sys/fs/gfs2/sdb1.
I've got other changes to gfs2_tool that affect this. They need to be
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release. Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products. This request is not yet committed for inclusion in an Update
Created attachment 251611 [details]
Proposed patch to fix the problem
This is my first attempt at a patch. Although the patch file is more
than 1000 lines, it's really not that much of a code change. Basically,
the following is changed (in the order they appear in the patch):
1. Most of the gfs2 utils defined their own versions of IO functions.
Functions die, do_lseek, do_read, and do_write were standardized and
moved to a central place, libgfs2.h. I made an exception for the
lseek function in gfs2_fsck, which needs to not die on illegal seeks,
since the file system might be corrupt. The fsck version of that
function was renamed.
2. All user space tools were standardized to use these common functions.
3. The same common IO functions referenced the sbd structure in libgfs2's
buf.c, rather than the file handle, so I changed buf.c to use the
4. All the functions from gfs2_tool's util.c were moved to libgfs2's
misc.c which already contained similar functions (e.g. debugfs vs
sysfs). So gfs2_tool's util.c is no longer needed.
5. The functions inside gfs2_quota that were referencing the files in
gfs2's sysfs directory were changed to use the simpler common
functions that were moved from gfs2_tool to libgfs2. These are the
functions that figure out the proper directory within sysfs, even
if the device does not match the vfs s_id and the lock table is NULL.
So this is the most important part.
Created attachment 253041 [details]
Patch to fix the problem (try #2)
Found and fixed a problem. The previous version wasn't using the "user"
variable like it should have, in check.c's function set_list().
I tested all the affected tools on roth-01. Patch reviewed by Abhi.
I checked it in to the HEAD and RHEL5 branches of CVS for inclusion
in RHEL5.2. Changing status to Modified.
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.