1. 24 5月, 2010 3 次提交
  2. 22 5月, 2010 7 次提交
    • J
      quota: Refactor dquot_transfer code so that OCFS2 can pass in its references · bc8e5f07
      Jan Kara 提交于
      Currently, __dquot_transfer() acquires its own references of dquot structures
      that will be put into inode. But for OCFS2, this creates a lock inversion
      between dq_lock (waited on in dqget) and transaction start (started in
      ocfs2_setattr). Currently, deadlock is impossible because dq_lock is acquired
      only during dquot_acquire and dquot_release and we already hold a reference to
      dquot structures in ocfs2_setattr so neither of these functions can be called
      while we call dquot_transfer. But this is rather subtle and it is hard to teach
      lockdep about it. So provide __dquot_transfer function that can be passed dquot
      references directly. OCFS2 can then pass acquired dquot references directly to
      __dquot_transfer with proper locking.
      Signed-off-by: NJan Kara <jack@suse.cz>
      bc8e5f07
    • D
      quota: unify quota init condition in setattr · 12755627
      Dmitry Monakhov 提交于
      Quota must being initialized if size or uid/git changes requested.
      But initialization performed in two different places:
      in case of i_size file system is responsible for dquot init
      , but in case of uid/gid init will be called internally in
      dquot_transfer().
      This ambiguity makes code harder to understand.
      Let's move this logic to one common helper function.
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      12755627
    • C
      quota: unify ->set_dqblk · c472b432
      Christoph Hellwig 提交于
      Pass the larger struct fs_disk_quota to the ->set_dqblk operation so
      that the Q_SETQUOTA and Q_XSETQUOTA operations can be implemented
      with a single filesystem operation and we can retire the ->set_xquota
      operation.  The additional information (RT-subvolume accounting and
      warn counts) are left zero for the VFS quota implementation.
      
      Add new fieldmask values for setting the numer of blocks and inodes
      values which is required for the VFS quota, but wasn't for XFS.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      c472b432
    • C
      quota: unify ->get_dqblk · b9b2dd36
      Christoph Hellwig 提交于
      Pass the larger struct fs_disk_quota to the ->get_dqblk operation so
      that the Q_GETQUOTA and Q_XGETQUOTA operations can be implemented
      with a single filesystem operation and we can retire the ->get_xquota
      operation.  The additional information (RT-subvolume accounting and
      warn counts) are left zero for the VFS quota implementation.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      b9b2dd36
    • D
      quota: Make quota stat accounting lockless. · dde95888
      Dmitry Monakhov 提交于
      Quota stats is mostly writable data structure. Let's alloc percpu
      bucket for each value.
      
      NOTE: dqstats_read() function is racy against dqstats_{inc,dec}
      and may return inconsistent value. But this is ok since absolute
      accuracy is not required.
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      dde95888
    • S
      suppress warning: "quotatypes" defined but not used · da8d1ba2
      Sergey Senozhatsky 提交于
      Suppress compilation warning: "quotatypes" defined but not used.
      quotatypes is used only when CONFIG_QUOTA_DEBUG or CONFIG_PRINT_QUOTA_WARNING
      is/are defined.
      Signed-off-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      da8d1ba2
    • D
      quota: optimize mark_dirty logic · eabf290d
      Dmitry Monakhov 提交于
      - Skip locking if quota is dirty already.
      - Return old quota state to help fs-specciffic implementation to optimize
        case where quota was dirty already.
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      eabf290d
  3. 21 4月, 2010 1 次提交
    • J
      quota: Convert __DQUOT_PARANOIA symbol to standard config option · 62af9b52
      Jan Kara 提交于
      Make __DQUOT_PARANOIA define from the old days a standard config option
      and turn it off by default.
      
      This gets rid of a quota warning about writes before quota is turned on
      for systems with ext4 root filesystem. Currently there's no way to legally
      solve this because /etc/mtab has to be written before quota is turned on
      on most systems.
      Signed-off-by: NJan Kara <jack@suse.cz>
      62af9b52
  4. 13 4月, 2010 2 次提交
  5. 05 3月, 2010 14 次提交
    • C
      quota: stop using QUOTA_OK / NO_QUOTA · efd8f0e6
      Christoph Hellwig 提交于
      Just use 0 / -EDQUOT directly - that's what it translates to anyway.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      efd8f0e6
    • C
      dquot: cleanup dquot initialize routine · 871a2931
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      871a2931
    • C
      dquot: move dquot initialization responsibility into the filesystem · 907f4554
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      907f4554
    • C
      dquot: cleanup dquot drop routine · 9f754758
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      9f754758
    • C
      dquot: cleanup dquot transfer routine · b43fa828
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      b43fa828
    • C
      dquot: cleanup inode allocation / freeing routines · 63936dda
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      63936dda
    • C
      dquot: cleanup space allocation / freeing routines · 5dd4056d
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      5dd4056d
    • J
      quota: Properly invalidate caches even for filesystems with blocksize < pagesize · ab94c39b
      Jan Kara 提交于
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      ab94c39b
    • D
      quota: generalize quota transfer interface · 8ddd69d6
      Dmitry Monakhov 提交于
      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: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      8ddd69d6
    • D
      quota: sb_quota state flags cleanup · ad1e6e8d
      Dmitry Monakhov 提交于
      - remove hardcoded USRQUOTA/GRPQUOTA flags
      - convert int to bool for appropriate functions
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      ad1e6e8d
    • C
      quota: move code from sync_quota_sb into vfs_quota_sync · 5fb324ad
      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: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      5fb324ad
    • J
      quota: Fix warning when a delayed write happens before quota is enabled · 0a5a9c72
      Jan Kara 提交于
      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: NJan Kara <jack@suse.cz>
      0a5a9c72
    • D
      quota: manage reserved space when quota is not active [v2] · c469070a
      Dmitry Monakhov 提交于
      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: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      c469070a
    • J
      quota: Cleanup S_NOQUOTA handling · 26245c94
      Jan Kara 提交于
      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: NJan Kara <jack@suse.cz>
      26245c94
  6. 11 1月, 2010 1 次提交
    • J
      quota: Fix dquot_transfer for filesystems different from ext4 · 05b5d898
      Jan Kara 提交于
      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 <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      05b5d898
  7. 23 12月, 2009 2 次提交
    • D
      quota: Move duplicated code to separate functions · dc52dd3a
      Dmitry Monakhov 提交于
      - for(..) { mark_dquot_dirty(); } -> mark_all_dquot_dirty()
      - for(..) { dput(); }             -> dqput_all()
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      dc52dd3a
    • D
      quota: decouple fs reserved space from quota reservation · fd8fbfc1
      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: NDmitry Monakhov <dmonakhov@openvz.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      fd8fbfc1
  8. 10 12月, 2009 1 次提交
    • J
      quota: Fix WARN_ON in lookup_one_len · c56818d7
      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: NBastien ROUCARIES <roucaries.bastien@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      c56818d7
  9. 03 12月, 2009 1 次提交
    • S
      VFS: Export dquot_send_warning · 86e931a3
      Steven Whitehouse 提交于
      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: NSteven Whitehouse <swhiteho@redhat.com>
      86e931a3
  10. 19 11月, 2009 1 次提交
  11. 12 11月, 2009 1 次提交
  12. 22 9月, 2009 2 次提交
  13. 30 7月, 2009 1 次提交
  14. 08 7月, 2009 1 次提交
    • J
      quota: Fix possible deadlock during parallel quotaon and quotaoff · d01730d7
      Jiaying Zhang 提交于
      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: NJiaying Zhang <jiayingz@google.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      d01730d7
  15. 03 4月, 2009 1 次提交
    • W
      vfs: skip I_CLEAR state inodes · b6fac63c
      Wu Fengguang 提交于
      clear_inode() will switch inode state from I_FREEING to I_CLEAR, and do so
      _outside_ of inode_lock.  So any I_FREEING testing is incomplete without a
      coupled testing of I_CLEAR.
      
      So add I_CLEAR tests to drop_pagecache_sb(), generic_sync_sb_inodes() and
      add_dquot_ref().
      
      Masayoshi MIZUMA discovered the bug in drop_pagecache_sb() and Jan Kara
      reminds fixing the other two cases.
      
      Masayoshi MIZUMA has a nice panic flow:
      
      =====================================================================
                  [process A]               |        [process B]
       |                                    |
       |    prune_icache()                  | drop_pagecache()
       |      spin_lock(&inode_lock)        |   drop_pagecache_sb()
       |      inode->i_state |= I_FREEING;  |       |
       |      spin_unlock(&inode_lock)      |       V
       |          |                         |     spin_lock(&inode_lock)
       |          V                         |         |
       |      dispose_list()                |         |
       |        list_del()                  |         |
       |        clear_inode()               |         |
       |          inode->i_state = I_CLEAR  |         |
       |            |                       |         V
       |            |                       |      if (inode->i_state & (I_FREEING|I_WILL_FREE))
       |            |                       |              continue;           <==== NOT MATCH
       |            |                       |
       |            |                       | (DANGER from here on! Accessing disposing inode!)
       |            |                       |
       |            |                       |      __iget()
       |            |                       |        list_move() <===== PANIC on poisoned list !!
       V            V                       |
      (time)
      =====================================================================
      Reported-by: NMasayoshi MIZUMA <m.mizuma@jp.fujitsu.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NWu Fengguang <fengguang.wu@intel.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b6fac63c
  16. 26 3月, 2009 1 次提交