05 Mar, 2010

22 commits

  • Just use 0 / -EDQUOT directly - that's what it translates to anyway.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Get rid of the initialize dquot operation - it is now always called from
    the filesystem and if a filesystem really needs it's own (which none
    currently does) it can just call into it's own routine directly.

    Rename the now static low-level dquot_initialize helper to __dquot_initialize
    and vfs_dq_init to dquot_initialize to have a consistent namespace.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Currently various places in the VFS call vfs_dq_init directly. This means
    we tie the quota code into the VFS. Get rid of that and make the
    filesystem responsible for the initialization. For most metadata operations
    this is a straight forward move into the methods, but for truncate and
    open it's a bit more complicated.

    For truncate we currently only call vfs_dq_init for the sys_truncate case
    because open already takes care of it for ftruncate and open(O_TRUNC) - the
    new code causes an additional vfs_dq_init for those which is harmless.

    For open the initialization is moved from do_filp_open into the open method,
    which means it happens slightly earlier now, and only for regular files.
    The latter is fine because we don't need to initialize it for operations
    on special files, and we already do it as part of the namespace operations
    for directories.

    Add a dquot_file_open helper that filesystems that support generic quotas
    can use to fill in ->open.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Get rid of the drop dquot operation - it is now always called from
    the filesystem and if a filesystem really needs it's own (which none
    currently does) it can just call into it's own routine directly.

    Rename the now static low-level dquot_drop helper to __dquot_drop
    and vfs_dq_drop to dquot_drop to have a consistent namespace.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Get rid of the transfer dquot operation - it is now always called from
    the filesystem and if a filesystem really needs it's own (which none
    currently does) it can just call into it's own routine directly.

    Rename the now static low-level dquot_transfer helper to __dquot_transfer
    and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
    and make the new dquot_transfer return a normal negative errno value
    which all callers expect.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Get rid of the alloc_inode and free_inode dquot operations - they are
    always called from the filesystem and if a filesystem really needs
    their own (which none currently does) it can just call into it's
    own routine directly.

    Also get rid of the vfs_dq_alloc/vfs_dq_free wrappers and always
    call the lowlevel dquot_alloc_inode / dqout_free_inode routines
    directly, which now lose the number argument which is always 1.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Get rid of the alloc_space, free_space, reserve_space, claim_space and
    release_rsv dquot operations - they are always called from the filesystem
    and if a filesystem really needs their own (which none currently does)
    it can just call into it's own routine directly.

    Move shared logic into the common __dquot_alloc_space,
    dquot_claim_space_nodirty and __dquot_free_space low-level methods,
    and rationalize the wrappers around it to move as much as possible
    code into the common block for CONFIG_QUOTA vs not. Also rename
    all these helpers to be named dquot_* instead of vfs_dq_*.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Sometimes invalidate_bdev() can fail to invalidate a part of block
    device cache because of dirty data. If the filesystem has blocksize
    smaller than page size, this can happen even for pages containing
    quota files and thus kernel would operate on stale data. Fix the
    issue by syncing the filesystem before invalidating the cache.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Current quota transfer interface support only uid/gid.
    This patch extend interface in order to support various quotas types
    The goal is accomplished without changes in most frequently used
    vfs_dq_transfer() func.

    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Dmitry Monakhov
     
  • - remove hardcoded USRQUOTA/GRPQUOTA flags
    - convert int to bool for appropriate functions

    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Dmitry Monakhov
     
  • Instead of adding ifdefs just split it into a new file.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Instead of adding ifdefs just split it into a new file.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Checking the "VFS" quota enabled and dirty bits from generic code means
    this code will never get called for other implementations, e.g. XFS and
    GFS2. Grabbing the reference on the superblock really isn't much overhead
    for a global Q_SYNC call, so just drop this optimization.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Currenly sync_quota_sb does a lot of sync and truncate action that only
    applies to "VFS" style quotas and is actively harmful for the sync
    performance in XFS. Move it into vfs_quota_sync and add a wait parameter
    to ->quota_sync to tell if we need it or not.

    My audit of the GFS2 code says it's also not needed given the way GFS2
    implements quotas, but I'd be happy if this can get a detailed review.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Currently Q_XQUOTASYNC calls into the quota_sync method, but XFS does something
    entirely different in it than the rest of the filesystems. xfs_quota which
    calls Q_XQUOTASYNC expects an asynchronous data writeout to flush delayed
    allocations, while the "VFS" quota support wants to flush changes to the quota
    file.

    So make Q_XQUOTASYNC call into the writeback code directly and make the
    quota_sync method optional as XFS doesn't need in the sense expected by the
    rest of the quota code.

    GFS2 was using limited XFS-style quota and has a quota_sync method fitting
    neither the style used by vfs_quota_sync nor xfs_fs_quota_sync. I left it
    in for now as per discussion with Steve it expects to be called from the
    sync path this way.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Stop having complicated different routines for checking permissions for
    XQM vs "VFS" quotas. Instead do the checks for having sb->s_qcop and
    a valid type directly in do_quotactl, and munge the *quotactl_valid functions
    into a check_quotactl_permission helper that only checks for permissions.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • The Q_SYNC command can be called without the path to a device, in which case
    it iterates over all superblocks. Special case this variant directly in
    sys_quotactl so that the other code always gets a superblock and doesn't
    need to deal with this case.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Move the checks for sb->s_qcop->foo next to the actual calls for them, same
    for sb_has_quota_active checks where applicable.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • Split out a helper for each non-trivial command from do_quotactl.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     
  • If a delayed-allocation write happens before quota is enabled, the
    kernel spits out a warning:
    WARNING: at fs/quota/dquot.c:988 dquot_claim_space+0x77/0x112()

    because the fact that user has some delayed allocation is not recorded
    in quota structure.

    Make dquot_initialize() update amount of reserved space for user if it sees
    inode has some space reserved. Also make sure that reserved quota space does
    not go negative and we warn about the filesystem bug just once.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Since we implemented generic reserved space management interface,
    then it is possible to account reserved space even when quota
    is not active (similar to i_blocks/i_bytes).

    Without this patch following testcase result in massive comlain from
    WARN_ON in dquot_claim_space()

    TEST_CASE:
    mount /dev/sdb /mnt -oquota
    dd if=/dev/zero of=/mnt/test bs=1M count=1
    quotaon /mnt
    # fs_reserved_spave == 1Mb
    # quota_reserved_space == 0, because quota was disabled
    dd if=/dev/zero of=/mnt/test seek=1 bs=1M count=1
    # fs_reserved_spave == 2Mb
    # quota_reserved_space == 1Mb
    sync # ->dquot_claim_space() -> WARN_ON

    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Dmitry Monakhov
     
  • Cleanup handling of S_NOQUOTA inode flag and document it a bit. The flag
    does not have to be set under dqptr_sem. Only functions modifying inode's
    dquot pointers have to check the flag under dqptr_sem before going forward
    with the modification. This way we are sure that we cannot add new dquot
    pointers to the inode which is just becoming a quota file.

    The good thing about this cleanup is that there are no more places in quota
    code which enforce i_mutex vs. dqptr_sem lock ordering (in particular that
    dqptr_sem -> i_mutex of quota file). This should silence some (false) lockdep
    warnings with ext4 + quota and generally make life of some filesystems easier.

    Signed-off-by: Jan Kara

    Jan Kara
     

11 Jan, 2010

1 commit

  • Commit fd8fbfc1 modified the way we find amount of reserved space
    belonging to an inode. The amount of reserved space is checked
    from dquot_transfer and thus inode_reserved_space gets called
    even for filesystems that don't provide get_reserved_space callback
    which results in a BUG.

    Fix the problem by checking get_reserved_space callback and return 0 if
    the filesystem does not provide it.

    CC: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Jan Kara
     

23 Dec, 2009

4 commits

  • When we are asked for vfsv0 quota format and the file is in vfsv1
    format (or vice versa), refuse to use the quota file. Also return
    with error when we don't like the header of quota file.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Fix warnings:
    fs/quota/quota_v2.c: In function ‘v2_read_file_info’:
    fs/quota/quota_v2.c:123: warning: integer constant is too large for ‘long’ type
    fs/quota/quota_v2.c:124: warning: integer constant is too large for ‘long’ type

    Reported-by: Jerry Leo
    Signed-off-by: Jan Kara

    Jan Kara
     
  • - for(..) { mark_dquot_dirty(); } -> mark_all_dquot_dirty()
    - for(..) { dput(); } -> dqput_all()

    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Dmitry Monakhov
     
  • Currently inode_reservation is managed by fs itself and this
    reservation is transfered on dquot_transfer(). This means what
    inode_reservation must always be in sync with
    dquot->dq_dqb.dqb_rsvspace. Otherwise dquot_transfer() will result
    in incorrect quota(WARN_ON in dquot_claim_reserved_space() will be
    triggered)
    This is not easy because of complex locking order issues
    for example http://bugzilla.kernel.org/show_bug.cgi?id=14739

    The patch introduce quota reservation field for each fs-inode
    (fs specific inode is used in order to prevent bloating generic
    vfs inode). This reservation is managed by quota code internally
    similar to i_blocks/i_bytes and may not be always in sync with
    internal fs reservation.

    Also perform some code rearrangement:
    - Unify dquot_reserve_space() and dquot_reserve_space()
    - Unify dquot_release_reserved_space() and dquot_free_space()
    - Also this patch add missing warning update to release_rsv()
    dquot_release_reserved_space() must call flush_warnings() as
    dquot_free_space() does.

    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Jan Kara

    Dmitry Monakhov
     

10 Dec, 2009

3 commits

  • So far the maximum quota space limit was 4TB. Apparently this isn't enough
    for Lustre guys anymore. So implement new quota format which raises block
    limits to 2^64 bytes. Also store number of inodes and inode limits in
    64-bit variables as 2^32 files isn't that insanely high anymore.

    The first version of the patch has been developed by Andrew Perepechko
    .

    CC: Andrew.Perepechko@Sun.COM
    Signed-off-by: Jan Kara

    Jan Kara
     
  • We should hold i_mutex when looking up quota files for journaled quotas,
    otherwise a WARN_ON in lookup_one_len triggers. The fact that we didn't
    hold i_mutex previously probably could not lead to a real bug since the
    filesystem is just being mounted / remounted read-write and thus the
    root directory cannot change anyway but it's definitely cleaner with
    i_mutex.

    Reported-by: Bastien ROUCARIES
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Signed-off-by: Alexey Dobriyan
    Signed-off-by: Jan Kara

    Alexey Dobriyan
     

08 Dec, 2009

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/sysctl-2.6: (43 commits)
    security/tomoyo: Remove now unnecessary handling of security_sysctl.
    security/tomoyo: Add a special case to handle accesses through the internal proc mount.
    sysctl: Drop & in front of every proc_handler.
    sysctl: Remove CTL_NONE and CTL_UNNUMBERED
    sysctl: kill dead ctl_handler definitions.
    sysctl: Remove the last of the generic binary sysctl support
    sysctl net: Remove unused binary sysctl code
    sysctl security/tomoyo: Don't look at ctl_name
    sysctl arm: Remove binary sysctl support
    sysctl x86: Remove dead binary sysctl support
    sysctl sh: Remove dead binary sysctl support
    sysctl powerpc: Remove dead binary sysctl support
    sysctl ia64: Remove dead binary sysctl support
    sysctl s390: Remove dead sysctl binary support
    sysctl frv: Remove dead binary sysctl support
    sysctl mips/lasat: Remove dead binary sysctl support
    sysctl drivers: Remove dead binary sysctl support
    sysctl crypto: Remove dead binary sysctl support
    sysctl security/keys: Remove dead binary sysctl support
    sysctl kernel: Remove binary sysctl logic
    ...

    Linus Torvalds
     

03 Dec, 2009

1 commit

  • Sending a message to userspace in a generic format to warn
    of events (e.g. quota exceeded) in the quota subsystem is
    a generically useful feature. This patch makes some minor
    changes to the send_message function from dquot.c renaming
    it quota_send_message, moving it to quota.c and exporting it
    for use by filesystems which do not use the dquot code.

    Signed-off-by: Steven Whitehouse

    Steven Whitehouse
     

19 Nov, 2009

1 commit


12 Nov, 2009

1 commit


22 Sep, 2009

2 commits


30 Jul, 2009

1 commit

  • Commit d01730d74d2b0155da50d44555001706294014f7 didn't completely fix
    the problem since we still take dqio_mutex and i_mutex in the wrong
    order. Move taking of i_mutex further down (luckily it's needed only
    for updating inode flags) below where dqio_mutex is taken.

    Tested-by: Valdis Kletnieks
    Signed-off-by: Jan Kara

    Jan Kara
     

08 Jul, 2009

1 commit

  • The following test script triggers a deadlock on ext2 filesystem:
    while true; do quotaon /dev/hda >&/dev/null; usleep $RANDOM; done &
    while true; do quotaoff /dev/hda >&/dev/null; usleep $RANDOM; done &

    I found there is a potential deadlock between quotaon and quotaoff (or
    quotasync). Basically, all of quotactl operations need to be protected by
    dqonoff_mutex. vfs_quota_off and vfs_quota_sync also call sb->s_op->quota_write
    that needs to grab the i_mutex of the quota file. But in vfs_quota_on_inode
    (called from quotaon operation), the current code tries to grab the i_mutex of
    the quota file first before getting quonoff_mutex.

    Reverse the order in which we take locks in vfs_quota_on_inode().

    Jan Kara: Changed changelog to be more readable, made lockdep happy with
    I_MUTEX_QUOTA.

    Signed-off-by: Jiaying Zhang
    Signed-off-by: Jan Kara

    Jiaying Zhang
     

12 Jun, 2009

1 commit

  • Currently the VFS calls vfs_dq_sync to sync out disk quotas for a given
    superblock. This is a small wrapper around sync_dquots which for the
    case of a non-NULL superblock is a small wrapper around quota_sync_sb.

    Just make quota_sync_sb global (rename it to sync_quota_sb) and call it
    directly. Also call it directly for those cases in quota.c that have a
    superblock and leave sync_dquots purely an iterator over sync_quota_sb and
    remove it's superblock argument.

    To make this nicer move the check for the lack of a quota_sync method
    from the callers into sync_quota_sb.

    [folded build fix from Alexander Beregalov ]

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara
    Signed-off-by: Al Viro

    Christoph Hellwig
     

27 Apr, 2009

1 commit