1. 05 3月, 2010 11 次提交
    • 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 19 11月, 2009 1 次提交
  7. 12 11月, 2009 1 次提交
  8. 22 9月, 2009 2 次提交
  9. 30 7月, 2009 1 次提交
  10. 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
  11. 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
  12. 26 3月, 2009 8 次提交
  13. 06 2月, 2009 1 次提交
    • P
      netlink: change return-value logic of netlink_broadcast() · ff491a73
      Pablo Neira Ayuso 提交于
      Currently, netlink_broadcast() reports errors to the caller if no
      messages at all were delivered:
      
      1) If, at least, one message has been delivered correctly, returns 0.
      2) Otherwise, if no messages at all were delivered due to skb_clone()
         failure, return -ENOBUFS.
      3) Otherwise, if there are no listeners, return -ESRCH.
      
      With this patch, the caller knows if the delivery of any of the
      messages to the listeners have failed:
      
      1) If it fails to deliver any message (for whatever reason), return
         -ENOBUFS.
      2) Otherwise, if all messages were delivered OK, returns 0.
      3) Otherwise, if no listeners, return -ESRCH.
      
      In the current ctnetlink code and in Netfilter in general, we can add
      reliable logging and connection tracking event delivery by dropping the
      packets whose events were not successfully delivered over Netlink. Of
      course, this option would be settable via /proc as this approach reduces
      performance (in terms of filtered connections per seconds by a stateful
      firewall) but providing reliable logging and event delivery (for
      conntrackd) in return.
      
      This patch also changes some clients of netlink_broadcast() that
      may report ENOBUFS errors via printk. This error handling is not
      of any help. Instead, the userspace daemons that are listening to
      those netlink messages should resync themselves with the kernel-side
      if they hit ENOBUFS.
      
      BTW, netlink_broadcast() clients include those that call
      cn_netlink_send(), nlmsg_multicast() and genlmsg_multicast() since they
      internally call netlink_broadcast() and return its error value.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ff491a73
  14. 17 1月, 2009 1 次提交
    • J
      quota: Improve locking · cc33412f
      Jan Kara 提交于
      We implement dqget() and dqput() that need neither dqonoff_mutex nor dqptr_sem.
      Then move dqget() and dqput() calls so that they are not called from under
      dqptr_sem. This is important because filesystem callbacks aren't called from
      under dqptr_sem which used to cause *lots* of problems with lock ranking
      (and with OCFS2 they became close to unsolvable).
      
      The patch also removes two functions which were introduced solely because OCFS2
      needed them to cope with the old locking scheme. As time showed, they were not
      enough for OCFS2 anyway and it would be unnecessary work to adapt them to the
      new locking scheme in which they aren't needed.  As a result OCFS2 needs the
      following patch to compile properly with quotas.  Sorry to any bisecters which
      hit this in advance.
      Signed-off-by: NJan Kara <jack@suse.cz>
      cc33412f
  15. 09 1月, 2009 1 次提交
  16. 06 1月, 2009 6 次提交