1. 04 3月, 2015 1 次提交
    • K
      quota: reorder flags in quota state · 78197024
      Konstantin Khlebnikov 提交于
      Flags in struct quota_state keep flags for each quota type and
      some common flags. This patch reorders typed flags:
      
      Before:
      
      0 USRQUOTA DQUOT_USAGE_ENABLED
      1 USRQUOTA DQUOT_LIMITS_ENABLED
      2 USRQUOTA DQUOT_SUSPENDED
      3 GRPQUOTA DQUOT_USAGE_ENABLED
      4 GRPQUOTA DQUOT_LIMITS_ENABLED
      5 GRPQUOTA DQUOT_SUSPENDED
      6          DQUOT_QUOTA_SYS_FILE
      7          DQUOT_NEGATIVE_USAGE
      
      After:
      
      0 USRQUOTA DQUOT_USAGE_ENABLED
      1 GRPQUOTA DQUOT_USAGE_ENABLED
      2 USRQUOTA DQUOT_LIMITS_ENABLED
      3 GRPQUOTA DQUOT_LIMITS_ENABLED
      4 USRQUOTA DQUOT_SUSPENDED
      5 GRPQUOTA DQUOT_SUSPENDED
      6          DQUOT_QUOTA_SYS_FILE
      7          DQUOT_NEGATIVE_USAGE
      
      Now we can get bitmap of all enabled/suspended quota types without loop.
      For example suspended: (flags / DQUOT_SUSPENDED) & ((1 << MAXQUOTAS) - 1).
      
      add/remove: 0/1 grow/shrink: 3/11 up/down: 56/-215 (-159)
      function                                     old     new   delta
      __dquot_initialize                           423     447     +24
      dquot_transfer                               181     197     +16
      dquot_alloc_inode                            286     302     +16
      dquot_reclaim_space_nodirty                  316     313      -3
      dquot_claim_space_nodirty                    314     311      -3
      dquot_resume                                 286     281      -5
      dquot_free_inode                             332     324      -8
      __dquot_alloc_space                          500     492      -8
      dquot_disable                               1944    1929     -15
      dquot_quota_enable                           252     236     -16
      __dquot_free_space                           750     734     -16
      dquot_writeback_dquots                       625     608     -17
      __dquot_transfer                            1186    1154     -32
      dquot_quota_sync                             299     261     -38
      dquot_active.isra                             54       -     -54
      Signed-off-by: NKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: NJan Kara <jack@suse.cz>
      78197024
  2. 30 1月, 2015 3 次提交
  3. 28 1月, 2015 1 次提交
    • J
      quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units · 14bf61ff
      Jan Kara 提交于
      Currently ->get_dqblk() and ->set_dqblk() use struct fs_disk_quota which
      tracks space limits and usage in 512-byte blocks. However VFS quotas
      track usage in bytes (as some filesystems require that) and we need to
      somehow pass this information. Upto now it wasn't a problem because we
      didn't do any unit conversion (thus VFS quota routines happily stuck
      number of bytes into d_bcount field of struct fd_disk_quota). Only if
      you tried to use Q_XGETQUOTA or Q_XSETQLIM for VFS quotas (or Q_GETQUOTA
      / Q_SETQUOTA for XFS quotas), you got bogus results. Hardly anyone
      tried this but reportedly some Samba users hit the problem in practice.
      So when we want interfaces compatible we need to fix this.
      
      We bite the bullet and define another quota structure used for passing
      information from/to ->get_dqblk()/->set_dqblk. It's somewhat sad we have
      to have more conversion routines in fs/quota/quota.c and another copying
      of quota structure slows down getting of quota information by about 2%
      but it seems cleaner than overloading e.g. units of d_bcount to bytes.
      
      CC: stable@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      14bf61ff
  4. 22 1月, 2015 1 次提交
  5. 10 11月, 2014 1 次提交
  6. 16 7月, 2014 1 次提交
  7. 05 5月, 2014 1 次提交
    • E
      xfs: fix Q_XQUOTARM ioctl · 9da93f9b
      Eric Sandeen 提交于
      The Q_XQUOTARM quotactl was not working properly, because
      we weren't passing around proper flags.  The xfs_fs_set_xstate()
      ioctl handler used the same flags for Q_XQUOTAON/OFF as
      well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
      XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
      i.e. quota type + state, while Q_XQUOTARM looks only for
      the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
      
      Unfortunately these flag spaces overlap a bit, so we
      got semi-random results for Q_XQUOTARM; i.e. the value
      for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc.  yeargh.
      
      Add a new quotactl op vector specifically for the QUOTARM
      operation, since it operates with a different flag space.
      
      This has been broken more or less forever, AFAICT.
      Signed-off-by: NEric Sandeen <sandeen@redhat.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      
      9da93f9b
  8. 21 8月, 2013 1 次提交
    • C
      quota: Add a new quotactl command Q_XGETQSTATV · af30cb44
      Chandra Seetharaman 提交于
      XFS now supports three types of quotas (user, group and project).
      
      Current version of Q_XGETSTAT has support for only two types of quotas.
      In order to support three types of quotas, the interface, specifically
      struct fs_quota_stat, need to be expanded. Current version of fs_quota_stat
      does not allow expansion without breaking backward compatibility.
      
      So, a quotactl command and new fs_quota_stat structure need to be added.
      
      This patch adds a new command Q_XGETQSTATV to quotactl() which takes
      a new data structure fs_quota_statv. This new data structure provides
      support for future expansion and backward compatibility.
      
      Callers of the new quotactl command have to set the version of the data
      structure being passed, and kernel will fill as much data as requested.
      If the kernel does not support the user-space provided version, EINVAL
      will be returned. User-space can reduce the version number and call the same
      quotactl again.
      Signed-off-by: NChandra Seetharaman <sekharan@us.ibm.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NRich Johnston <rjohnston@sgi.com>
      Signed-off-by: NBen Myers <bpm@sgi.com>
      
      [v2: Applied rjohnston's suggestions as per Chandra's request. -bpm]
      af30cb44
  9. 25 1月, 2013 1 次提交
  10. 13 10月, 2012 1 次提交
  11. 18 9月, 2012 4 次提交
    • E
      userns: Convert struct dquot dq_id to be a struct kqid · 4c376dca
      Eric W. Biederman 提交于
      Change struct dquot dq_id to a struct kqid and remove the now
      unecessary dq_type.
      
      Make minimal changes to dquot, quota_tree, quota_v1, quota_v2, ext3,
      ext4, and ocfs2 to deal with the change in quota structures and
      signatures.  The ocfs2 changes are larger than most because of the
      extensive tracing throughout the ocfs2 quota code that prints out
      dq_id.
      
      quota_tree.c:get_index is modified to take a struct kqid instead of a
      qid_t because all of it's callers pass in dquot->dq_id and it allows
      me to introduce only a single conversion.
      
      The rest of the changes are either just replacing dq_type with dq_id.type,
      adding conversions to deal with the change in type and occassionally
      adding qid_eq to allow quota id comparisons in a user namespace safe way.
      
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Theodore Tso <tytso@mit.edu>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      4c376dca
    • E
      userns: Convert quota netlink aka quota_send_warning · 431f1974
      Eric W. Biederman 提交于
      Modify quota_send_warning to take struct kqid instead a type and
      identifier pair.
      
      When sending netlink broadcasts always convert uids and quota
      identifiers into the intial user namespace.  There is as yet no way to
      send a netlink broadcast message with different contents to receivers
      in different namespaces, so for the time being just map all of the
      identifiers into the initial user namespace which preserves the
      current behavior.
      
      Change the callers of quota_send_warning in gfs2, xfs and dquot
      to generate a struct kqid to pass to quota send warning.  When
      all of the user namespaces convesions are complete a struct kqid
      values will be availbe without need for conversion, but a conversion
      is needed now to avoid needing to convert everything at once.
      
      Cc: Ben Myers <bpm@sgi.com>
      Cc: Alex Elder <elder@kernel.org>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Steven Whitehouse <swhiteho@redhat.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      431f1974
    • E
      userns: Convert qutoactl · 74a8a103
      Eric W. Biederman 提交于
      Update the quotactl user space interface to successfull compile with
      user namespaces support enabled and to hand off quota identifiers to
      lower layers of the kernel in struct kqid instead of type and qid
      pairs.
      
      The quota on function is not converted because while it takes a quota
      type and an id.  The id is the on disk quota format to use, which
      is something completely different.
      
      The signature of two struct quotactl_ops methods were changed to take
      struct kqid argumetns get_dqblk and set_dqblk.
      
      The dquot, xfs, and ocfs2 implementations of get_dqblk and set_dqblk
      are minimally changed so that the code continues to work with
      the change in parameter type.
      
      This is the first in a series of changes to always store quota
      identifiers in the kernel in struct kqid and only use raw type and qid
      values when interacting with on disk structures or userspace.  Always
      using struct kqid internally makes it hard to miss places that need
      conversion to or from the kernel internal values.
      
      Cc: Jan Kara <jack@suse.cz>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Ben Myers <bpm@sgi.com>
      Cc: Alex Elder <elder@kernel.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      74a8a103
    • E
      userns: Implement struct kqid · e8a3e471
      Eric W. Biederman 提交于
      Add the data type struct kqid which holds the kernel internal form of
      the owning identifier of a quota.  struct kqid is a replacement for
      the implicit union of uid, gid and project id stored in an unsigned
      int and the quota type field that is was used in the quota data
      structures.  Making the data type explicit allows the kuid_t and
      kgid_t type safety to propogate more thoroughly through the code,
      revealing more places where uid/gid conversions need be made.
      
      Along with the data type struct kqid comes the helper functions
      qid_eq, qid_lt, from_kqid, from_kqid_munged, qid_valid, make_kqid,
      make_kqid_invalid, make_kqid_uid, make_kqid_gid.
      
      Cc: Jan Kara <jack@suse.cz>
      Cc: Dave Chinner <david@fromorbit.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      e8a3e471
  12. 23 7月, 2012 1 次提交
  13. 12 1月, 2012 1 次提交
  14. 27 7月, 2011 1 次提交
  15. 20 7月, 2011 1 次提交
  16. 13 1月, 2011 1 次提交
    • J
      quota: Fix deadlock during path resolution · f00c9e44
      Jan Kara 提交于
      As Al Viro pointed out path resolution during Q_QUOTAON calls to quotactl
      is prone to deadlocks. We hold s_umount semaphore for reading during the
      path resolution and resolution itself may need to acquire the semaphore
      for writing when e. g. autofs mountpoint is passed.
      
      Solve the problem by performing the resolution before we get hold of the
      superblock (and thus s_umount semaphore). The whole thing is complicated
      by the fact that some filesystems (OCFS2) ignore the path argument. So to
      distinguish between filesystem which want the path and which do not we
      introduce new .quota_on_meta callback which does not get the path. OCFS2
      then uses this callback instead of old .quota_on.
      
      CC: Al Viro <viro@ZenIV.linux.org.uk>
      CC: Christoph Hellwig <hch@lst.de>
      CC: Ted Ts'o <tytso@mit.edu>
      CC: Joel Becker <joel.becker@oracle.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      f00c9e44
  17. 28 5月, 2010 1 次提交
  18. 24 5月, 2010 1 次提交
  19. 22 5月, 2010 3 次提交
    • 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
  20. 05 3月, 2010 9 次提交
  21. 23 12月, 2009 1 次提交
    • 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
  22. 10 12月, 2009 3 次提交
  23. 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