Bug 364741 - GFS2: gfs2_quota doesn't work unless lock table specified
GFS2: gfs2_quota doesn't work unless lock table specified
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gfs2-utils (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Chris Feist
GFS Bugs
Depends On:
  Show dependency treegraph
Reported: 2007-11-02 17:35 EDT by Robert Peterson
Modified: 2010-01-11 22:40 EST (History)
1 user (show)

See Also:
Fixed In Version: RHBA-2008-0350
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-05-21 13:20:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Proposed patch to fix the problem (26.56 KB, patch)
2007-11-08 10:22 EST, Robert Peterson
no flags Details | Diff
Patch to fix the problem (try #2) (26.53 KB, patch)
2007-11-09 12:15 EST, Robert Peterson
no flags Details | Diff

  None (edit)
Description Robert Peterson 2007-11-02 17:35:54 EDT
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):

How reproducible:

Steps to Reproduce:
1. mkfs.gfs2 /dev/sdb1
2. mount -tgfs2 /dev/sdb1 /mnt/hell
3. gfs2_quota check -f /mnt/hell
Actual results:
gfs2_quota: can't open file /sys/fs/gfs2//quota_sync: No such file or directory

Expected results:
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.

Additional info:
I've got other changes to gfs2_tool that affect this.  They need to be
done first.
Comment 1 RHEL Product and Program Management 2007-11-05 12:14:56 EST
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
Comment 2 Robert Peterson 2007-11-08 10:22:38 EST
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
   standard functions.
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.
Comment 3 Robert Peterson 2007-11-09 12:15:48 EST
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().
Comment 4 Robert Peterson 2007-11-13 12:09:32 EST
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.
Comment 7 errata-xmlrpc 2008-05-21 13:20:26 EDT
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.


Note You need to log in before you can comment on or make changes to this bug.