|
@@ -82,7 +82,7 @@
|
|
|
|
|
|
/*
|
|
|
* There are three quota SMP locks. dq_list_lock protects all lists with quotas
|
|
|
- * and quota formats, dqstats structure containing statistics about the lists
|
|
|
+ * and quota formats.
|
|
|
* dq_data_lock protects data from dq_dqb and also mem_dqinfo structures and
|
|
|
* also guards consistency of dquot->dq_dqb with inode->i_blocks, i_bytes.
|
|
|
* i_blocks and i_bytes updates itself are guarded by i_lock acquired directly
|
|
@@ -132,7 +132,9 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_state_lock);
|
|
|
__cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock);
|
|
|
EXPORT_SYMBOL(dq_data_lock);
|
|
|
|
|
|
+#if defined(CONFIG_QUOTA_DEBUG) || defined(CONFIG_PRINT_QUOTA_WARNING)
|
|
|
static char *quotatypes[] = INITQFNAMES;
|
|
|
+#endif
|
|
|
static struct quota_format_type *quota_formats; /* List of registered formats */
|
|
|
static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
|
|
|
|
|
@@ -226,6 +228,10 @@ static struct hlist_head *dquot_hash;
|
|
|
|
|
|
struct dqstats dqstats;
|
|
|
EXPORT_SYMBOL(dqstats);
|
|
|
+#ifdef CONFIG_SMP
|
|
|
+struct dqstats *dqstats_pcpu;
|
|
|
+EXPORT_SYMBOL(dqstats_pcpu);
|
|
|
+#endif
|
|
|
|
|
|
static qsize_t inode_get_rsv_space(struct inode *inode);
|
|
|
static void __dquot_initialize(struct inode *inode, int type);
|
|
@@ -273,7 +279,7 @@ static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
|
|
|
static inline void put_dquot_last(struct dquot *dquot)
|
|
|
{
|
|
|
list_add_tail(&dquot->dq_free, &free_dquots);
|
|
|
- dqstats.free_dquots++;
|
|
|
+ dqstats_inc(DQST_FREE_DQUOTS);
|
|
|
}
|
|
|
|
|
|
static inline void remove_free_dquot(struct dquot *dquot)
|
|
@@ -281,7 +287,7 @@ static inline void remove_free_dquot(struct dquot *dquot)
|
|
|
if (list_empty(&dquot->dq_free))
|
|
|
return;
|
|
|
list_del_init(&dquot->dq_free);
|
|
|
- dqstats.free_dquots--;
|
|
|
+ dqstats_dec(DQST_FREE_DQUOTS);
|
|
|
}
|
|
|
|
|
|
static inline void put_inuse(struct dquot *dquot)
|
|
@@ -289,12 +295,12 @@ static inline void put_inuse(struct dquot *dquot)
|
|
|
/* We add to the back of inuse list so we don't have to restart
|
|
|
* when traversing this list and we block */
|
|
|
list_add_tail(&dquot->dq_inuse, &inuse_list);
|
|
|
- dqstats.allocated_dquots++;
|
|
|
+ dqstats_inc(DQST_ALLOC_DQUOTS);
|
|
|
}
|
|
|
|
|
|
static inline void remove_inuse(struct dquot *dquot)
|
|
|
{
|
|
|
- dqstats.allocated_dquots--;
|
|
|
+ dqstats_dec(DQST_ALLOC_DQUOTS);
|
|
|
list_del(&dquot->dq_inuse);
|
|
|
}
|
|
|
/*
|
|
@@ -317,14 +323,23 @@ static inline int mark_dquot_dirty(struct dquot *dquot)
|
|
|
return dquot->dq_sb->dq_op->mark_dirty(dquot);
|
|
|
}
|
|
|
|
|
|
+/* Mark dquot dirty in atomic manner, and return it's old dirty flag state */
|
|
|
int dquot_mark_dquot_dirty(struct dquot *dquot)
|
|
|
{
|
|
|
+ int ret = 1;
|
|
|
+
|
|
|
+ /* If quota is dirty already, we don't have to acquire dq_list_lock */
|
|
|
+ if (test_bit(DQ_MOD_B, &dquot->dq_flags))
|
|
|
+ return 1;
|
|
|
+
|
|
|
spin_lock(&dq_list_lock);
|
|
|
- if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags))
|
|
|
+ if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
|
|
|
list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
|
|
|
info[dquot->dq_type].dqi_dirty_list);
|
|
|
+ ret = 0;
|
|
|
+ }
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
- return 0;
|
|
|
+ return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL(dquot_mark_dquot_dirty);
|
|
|
|
|
@@ -550,8 +565,8 @@ int dquot_scan_active(struct super_block *sb,
|
|
|
continue;
|
|
|
/* Now we have active dquot so we can just increase use count */
|
|
|
atomic_inc(&dquot->dq_count);
|
|
|
- dqstats.lookups++;
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_LOOKUPS);
|
|
|
dqput(old_dquot);
|
|
|
old_dquot = dquot;
|
|
|
ret = fn(dquot, priv);
|
|
@@ -596,8 +611,8 @@ int vfs_quota_sync(struct super_block *sb, int type, int wait)
|
|
|
* holding reference so we can safely just increase
|
|
|
* use count */
|
|
|
atomic_inc(&dquot->dq_count);
|
|
|
- dqstats.lookups++;
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_LOOKUPS);
|
|
|
sb->dq_op->write_dquot(dquot);
|
|
|
dqput(dquot);
|
|
|
spin_lock(&dq_list_lock);
|
|
@@ -609,9 +624,7 @@ int vfs_quota_sync(struct super_block *sb, int type, int wait)
|
|
|
if ((cnt == type || type == -1) && sb_has_quota_active(sb, cnt)
|
|
|
&& info_dirty(&dqopt->info[cnt]))
|
|
|
sb->dq_op->write_info(sb, cnt);
|
|
|
- spin_lock(&dq_list_lock);
|
|
|
- dqstats.syncs++;
|
|
|
- spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_SYNCS);
|
|
|
mutex_unlock(&dqopt->dqonoff_mutex);
|
|
|
|
|
|
if (!wait || (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE))
|
|
@@ -663,6 +676,22 @@ static void prune_dqcache(int count)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static int dqstats_read(unsigned int type)
|
|
|
+{
|
|
|
+ int count = 0;
|
|
|
+#ifdef CONFIG_SMP
|
|
|
+ int cpu;
|
|
|
+ for_each_possible_cpu(cpu)
|
|
|
+ count += per_cpu_ptr(dqstats_pcpu, cpu)->stat[type];
|
|
|
+ /* Statistics reading is racy, but absolute accuracy isn't required */
|
|
|
+ if (count < 0)
|
|
|
+ count = 0;
|
|
|
+#else
|
|
|
+ count = dqstats.stat[type];
|
|
|
+#endif
|
|
|
+ return count;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* This is called from kswapd when we think we need some
|
|
|
* more memory
|
|
@@ -675,7 +704,7 @@ static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
|
|
|
prune_dqcache(nr);
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
}
|
|
|
- return (dqstats.free_dquots / 100) * sysctl_vfs_cache_pressure;
|
|
|
+ return (dqstats_read(DQST_FREE_DQUOTS)/100) * sysctl_vfs_cache_pressure;
|
|
|
}
|
|
|
|
|
|
static struct shrinker dqcache_shrinker = {
|
|
@@ -703,10 +732,7 @@ void dqput(struct dquot *dquot)
|
|
|
BUG();
|
|
|
}
|
|
|
#endif
|
|
|
-
|
|
|
- spin_lock(&dq_list_lock);
|
|
|
- dqstats.drops++;
|
|
|
- spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_DROPS);
|
|
|
we_slept:
|
|
|
spin_lock(&dq_list_lock);
|
|
|
if (atomic_read(&dquot->dq_count) > 1) {
|
|
@@ -823,15 +849,15 @@ we_slept:
|
|
|
put_inuse(dquot);
|
|
|
/* hash it first so it can be found */
|
|
|
insert_dquot_hash(dquot);
|
|
|
- dqstats.lookups++;
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_LOOKUPS);
|
|
|
} else {
|
|
|
if (!atomic_read(&dquot->dq_count))
|
|
|
remove_free_dquot(dquot);
|
|
|
atomic_inc(&dquot->dq_count);
|
|
|
- dqstats.cache_hits++;
|
|
|
- dqstats.lookups++;
|
|
|
spin_unlock(&dq_list_lock);
|
|
|
+ dqstats_inc(DQST_CACHE_HITS);
|
|
|
+ dqstats_inc(DQST_LOOKUPS);
|
|
|
}
|
|
|
/* Wait for dq_lock - after this we know that either dquot_release() is
|
|
|
* already finished or it will be canceled due to dq_count > 1 test */
|
|
@@ -1677,16 +1703,19 @@ EXPORT_SYMBOL(dquot_free_inode);
|
|
|
|
|
|
/*
|
|
|
* Transfer the number of inode and blocks from one diskquota to an other.
|
|
|
+ * On success, dquot references in transfer_to are consumed and references
|
|
|
+ * to original dquots that need to be released are placed there. On failure,
|
|
|
+ * references are kept untouched.
|
|
|
*
|
|
|
* This operation can block, but only after everything is updated
|
|
|
* A transaction must be started when entering this function.
|
|
|
+ *
|
|
|
*/
|
|
|
-static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
|
|
|
+int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
|
|
|
{
|
|
|
qsize_t space, cur_space;
|
|
|
qsize_t rsv_space = 0;
|
|
|
- struct dquot *transfer_from[MAXQUOTAS];
|
|
|
- struct dquot *transfer_to[MAXQUOTAS];
|
|
|
+ struct dquot *transfer_from[MAXQUOTAS] = {};
|
|
|
int cnt, ret = 0;
|
|
|
char warntype_to[MAXQUOTAS];
|
|
|
char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS];
|
|
@@ -1696,19 +1725,12 @@ static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask
|
|
|
if (IS_NOQUOTA(inode))
|
|
|
return 0;
|
|
|
/* Initialize the arrays */
|
|
|
- for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
|
|
|
- transfer_from[cnt] = NULL;
|
|
|
- transfer_to[cnt] = NULL;
|
|
|
+ for (cnt = 0; cnt < MAXQUOTAS; cnt++)
|
|
|
warntype_to[cnt] = QUOTA_NL_NOWARN;
|
|
|
- }
|
|
|
- for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
|
|
|
- if (mask & (1 << cnt))
|
|
|
- transfer_to[cnt] = dqget(inode->i_sb, chid[cnt], cnt);
|
|
|
- }
|
|
|
down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
|
|
|
if (IS_NOQUOTA(inode)) { /* File without quota accounting? */
|
|
|
up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
|
|
|
- goto put_all;
|
|
|
+ return 0;
|
|
|
}
|
|
|
spin_lock(&dq_data_lock);
|
|
|
cur_space = inode_get_bytes(inode);
|
|
@@ -1760,47 +1782,41 @@ static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask
|
|
|
|
|
|
mark_all_dquot_dirty(transfer_from);
|
|
|
mark_all_dquot_dirty(transfer_to);
|
|
|
- /* The reference we got is transferred to the inode */
|
|
|
+ /* Pass back references to put */
|
|
|
for (cnt = 0; cnt < MAXQUOTAS; cnt++)
|
|
|
- transfer_to[cnt] = NULL;
|
|
|
-warn_put_all:
|
|
|
+ transfer_to[cnt] = transfer_from[cnt];
|
|
|
+warn:
|
|
|
flush_warnings(transfer_to, warntype_to);
|
|
|
flush_warnings(transfer_from, warntype_from_inodes);
|
|
|
flush_warnings(transfer_from, warntype_from_space);
|
|
|
-put_all:
|
|
|
- dqput_all(transfer_from);
|
|
|
- dqput_all(transfer_to);
|
|
|
return ret;
|
|
|
over_quota:
|
|
|
spin_unlock(&dq_data_lock);
|
|
|
up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
|
|
|
- /* Clear dquot pointers we don't want to dqput() */
|
|
|
- for (cnt = 0; cnt < MAXQUOTAS; cnt++)
|
|
|
- transfer_from[cnt] = NULL;
|
|
|
- goto warn_put_all;
|
|
|
+ goto warn;
|
|
|
}
|
|
|
+EXPORT_SYMBOL(__dquot_transfer);
|
|
|
|
|
|
/* Wrapper for transferring ownership of an inode for uid/gid only
|
|
|
* Called from FSXXX_setattr()
|
|
|
*/
|
|
|
int dquot_transfer(struct inode *inode, struct iattr *iattr)
|
|
|
{
|
|
|
- qid_t chid[MAXQUOTAS];
|
|
|
- unsigned long mask = 0;
|
|
|
+ struct dquot *transfer_to[MAXQUOTAS] = {};
|
|
|
+ struct super_block *sb = inode->i_sb;
|
|
|
+ int ret;
|
|
|
|
|
|
- if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) {
|
|
|
- mask |= 1 << USRQUOTA;
|
|
|
- chid[USRQUOTA] = iattr->ia_uid;
|
|
|
- }
|
|
|
- if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) {
|
|
|
- mask |= 1 << GRPQUOTA;
|
|
|
- chid[GRPQUOTA] = iattr->ia_gid;
|
|
|
- }
|
|
|
- if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
|
|
|
- dquot_initialize(inode);
|
|
|
- return __dquot_transfer(inode, chid, mask);
|
|
|
- }
|
|
|
- return 0;
|
|
|
+ if (!sb_any_quota_active(sb) || IS_NOQUOTA(inode))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
|
|
|
+ transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA);
|
|
|
+ if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
|
|
|
+ transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_uid, GRPQUOTA);
|
|
|
+
|
|
|
+ ret = __dquot_transfer(inode, transfer_to);
|
|
|
+ dqput_all(transfer_to);
|
|
|
+ return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL(dquot_transfer);
|
|
|
|
|
@@ -2275,25 +2291,30 @@ static inline qsize_t stoqb(qsize_t space)
|
|
|
}
|
|
|
|
|
|
/* Generic routine for getting common part of quota structure */
|
|
|
-static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
|
|
|
+static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
|
|
|
{
|
|
|
struct mem_dqblk *dm = &dquot->dq_dqb;
|
|
|
|
|
|
+ memset(di, 0, sizeof(*di));
|
|
|
+ di->d_version = FS_DQUOT_VERSION;
|
|
|
+ di->d_flags = dquot->dq_type == USRQUOTA ?
|
|
|
+ XFS_USER_QUOTA : XFS_GROUP_QUOTA;
|
|
|
+ di->d_id = dquot->dq_id;
|
|
|
+
|
|
|
spin_lock(&dq_data_lock);
|
|
|
- di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit);
|
|
|
- di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit);
|
|
|
- di->dqb_curspace = dm->dqb_curspace + dm->dqb_rsvspace;
|
|
|
- di->dqb_ihardlimit = dm->dqb_ihardlimit;
|
|
|
- di->dqb_isoftlimit = dm->dqb_isoftlimit;
|
|
|
- di->dqb_curinodes = dm->dqb_curinodes;
|
|
|
- di->dqb_btime = dm->dqb_btime;
|
|
|
- di->dqb_itime = dm->dqb_itime;
|
|
|
- di->dqb_valid = QIF_ALL;
|
|
|
+ di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit);
|
|
|
+ di->d_blk_softlimit = stoqb(dm->dqb_bsoftlimit);
|
|
|
+ di->d_ino_hardlimit = dm->dqb_ihardlimit;
|
|
|
+ di->d_ino_softlimit = dm->dqb_isoftlimit;
|
|
|
+ di->d_bcount = dm->dqb_curspace + dm->dqb_rsvspace;
|
|
|
+ di->d_icount = dm->dqb_curinodes;
|
|
|
+ di->d_btimer = dm->dqb_btime;
|
|
|
+ di->d_itimer = dm->dqb_itime;
|
|
|
spin_unlock(&dq_data_lock);
|
|
|
}
|
|
|
|
|
|
int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
|
|
|
- struct if_dqblk *di)
|
|
|
+ struct fs_disk_quota *di)
|
|
|
{
|
|
|
struct dquot *dquot;
|
|
|
|
|
@@ -2307,51 +2328,70 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
|
|
|
}
|
|
|
EXPORT_SYMBOL(vfs_get_dqblk);
|
|
|
|
|
|
+#define VFS_FS_DQ_MASK \
|
|
|
+ (FS_DQ_BCOUNT | FS_DQ_BSOFT | FS_DQ_BHARD | \
|
|
|
+ FS_DQ_ICOUNT | FS_DQ_ISOFT | FS_DQ_IHARD | \
|
|
|
+ FS_DQ_BTIMER | FS_DQ_ITIMER)
|
|
|
+
|
|
|
/* Generic routine for setting common part of quota structure */
|
|
|
-static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
|
|
|
+static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
|
|
|
{
|
|
|
struct mem_dqblk *dm = &dquot->dq_dqb;
|
|
|
int check_blim = 0, check_ilim = 0;
|
|
|
struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type];
|
|
|
|
|
|
- if ((di->dqb_valid & QIF_BLIMITS &&
|
|
|
- (di->dqb_bhardlimit > dqi->dqi_maxblimit ||
|
|
|
- di->dqb_bsoftlimit > dqi->dqi_maxblimit)) ||
|
|
|
- (di->dqb_valid & QIF_ILIMITS &&
|
|
|
- (di->dqb_ihardlimit > dqi->dqi_maxilimit ||
|
|
|
- di->dqb_isoftlimit > dqi->dqi_maxilimit)))
|
|
|
+ if (di->d_fieldmask & ~VFS_FS_DQ_MASK)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (((di->d_fieldmask & FS_DQ_BSOFT) &&
|
|
|
+ (di->d_blk_softlimit > dqi->dqi_maxblimit)) ||
|
|
|
+ ((di->d_fieldmask & FS_DQ_BHARD) &&
|
|
|
+ (di->d_blk_hardlimit > dqi->dqi_maxblimit)) ||
|
|
|
+ ((di->d_fieldmask & FS_DQ_ISOFT) &&
|
|
|
+ (di->d_ino_softlimit > dqi->dqi_maxilimit)) ||
|
|
|
+ ((di->d_fieldmask & FS_DQ_IHARD) &&
|
|
|
+ (di->d_ino_hardlimit > dqi->dqi_maxilimit)))
|
|
|
return -ERANGE;
|
|
|
|
|
|
spin_lock(&dq_data_lock);
|
|
|
- if (di->dqb_valid & QIF_SPACE) {
|
|
|
- dm->dqb_curspace = di->dqb_curspace - dm->dqb_rsvspace;
|
|
|
+ if (di->d_fieldmask & FS_DQ_BCOUNT) {
|
|
|
+ dm->dqb_curspace = di->d_bcount - dm->dqb_rsvspace;
|
|
|
check_blim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
|
|
|
}
|
|
|
- if (di->dqb_valid & QIF_BLIMITS) {
|
|
|
- dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
|
|
|
- dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
|
|
|
+
|
|
|
+ if (di->d_fieldmask & FS_DQ_BSOFT)
|
|
|
+ dm->dqb_bsoftlimit = qbtos(di->d_blk_softlimit);
|
|
|
+ if (di->d_fieldmask & FS_DQ_BHARD)
|
|
|
+ dm->dqb_bhardlimit = qbtos(di->d_blk_hardlimit);
|
|
|
+ if (di->d_fieldmask & (FS_DQ_BSOFT | FS_DQ_BHARD)) {
|
|
|
check_blim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
|
|
|
}
|
|
|
- if (di->dqb_valid & QIF_INODES) {
|
|
|
- dm->dqb_curinodes = di->dqb_curinodes;
|
|
|
+
|
|
|
+ if (di->d_fieldmask & FS_DQ_ICOUNT) {
|
|
|
+ dm->dqb_curinodes = di->d_icount;
|
|
|
check_ilim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
|
|
|
}
|
|
|
- if (di->dqb_valid & QIF_ILIMITS) {
|
|
|
- dm->dqb_isoftlimit = di->dqb_isoftlimit;
|
|
|
- dm->dqb_ihardlimit = di->dqb_ihardlimit;
|
|
|
+
|
|
|
+ if (di->d_fieldmask & FS_DQ_ISOFT)
|
|
|
+ dm->dqb_isoftlimit = di->d_ino_softlimit;
|
|
|
+ if (di->d_fieldmask & FS_DQ_IHARD)
|
|
|
+ dm->dqb_ihardlimit = di->d_ino_hardlimit;
|
|
|
+ if (di->d_fieldmask & (FS_DQ_ISOFT | FS_DQ_IHARD)) {
|
|
|
check_ilim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
|
|
|
}
|
|
|
- if (di->dqb_valid & QIF_BTIME) {
|
|
|
- dm->dqb_btime = di->dqb_btime;
|
|
|
+
|
|
|
+ if (di->d_fieldmask & FS_DQ_BTIMER) {
|
|
|
+ dm->dqb_btime = di->d_btimer;
|
|
|
check_blim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
|
|
|
}
|
|
|
- if (di->dqb_valid & QIF_ITIME) {
|
|
|
- dm->dqb_itime = di->dqb_itime;
|
|
|
+
|
|
|
+ if (di->d_fieldmask & FS_DQ_ITIMER) {
|
|
|
+ dm->dqb_itime = di->d_itimer;
|
|
|
check_ilim = 1;
|
|
|
set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
|
|
|
}
|
|
@@ -2361,7 +2401,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
|
|
|
dm->dqb_curspace < dm->dqb_bsoftlimit) {
|
|
|
dm->dqb_btime = 0;
|
|
|
clear_bit(DQ_BLKS_B, &dquot->dq_flags);
|
|
|
- } else if (!(di->dqb_valid & QIF_BTIME))
|
|
|
+ } else if (!(di->d_fieldmask & FS_DQ_BTIMER))
|
|
|
/* Set grace only if user hasn't provided his own... */
|
|
|
dm->dqb_btime = get_seconds() + dqi->dqi_bgrace;
|
|
|
}
|
|
@@ -2370,7 +2410,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
|
|
|
dm->dqb_curinodes < dm->dqb_isoftlimit) {
|
|
|
dm->dqb_itime = 0;
|
|
|
clear_bit(DQ_INODES_B, &dquot->dq_flags);
|
|
|
- } else if (!(di->dqb_valid & QIF_ITIME))
|
|
|
+ } else if (!(di->d_fieldmask & FS_DQ_ITIMER))
|
|
|
/* Set grace only if user hasn't provided his own... */
|
|
|
dm->dqb_itime = get_seconds() + dqi->dqi_igrace;
|
|
|
}
|
|
@@ -2386,7 +2426,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
|
|
|
}
|
|
|
|
|
|
int vfs_set_dqblk(struct super_block *sb, int type, qid_t id,
|
|
|
- struct if_dqblk *di)
|
|
|
+ struct fs_disk_quota *di)
|
|
|
{
|
|
|
struct dquot *dquot;
|
|
|
int rc;
|
|
@@ -2465,62 +2505,74 @@ const struct quotactl_ops vfs_quotactl_ops = {
|
|
|
.set_dqblk = vfs_set_dqblk
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+static int do_proc_dqstats(struct ctl_table *table, int write,
|
|
|
+ void __user *buffer, size_t *lenp, loff_t *ppos)
|
|
|
+{
|
|
|
+#ifdef CONFIG_SMP
|
|
|
+ /* Update global table */
|
|
|
+ unsigned int type = (int *)table->data - dqstats.stat;
|
|
|
+ dqstats.stat[type] = dqstats_read(type);
|
|
|
+#endif
|
|
|
+ return proc_dointvec(table, write, buffer, lenp, ppos);
|
|
|
+}
|
|
|
+
|
|
|
static ctl_table fs_dqstats_table[] = {
|
|
|
{
|
|
|
.procname = "lookups",
|
|
|
- .data = &dqstats.lookups,
|
|
|
+ .data = &dqstats.stat[DQST_LOOKUPS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "drops",
|
|
|
- .data = &dqstats.drops,
|
|
|
+ .data = &dqstats.stat[DQST_DROPS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "reads",
|
|
|
- .data = &dqstats.reads,
|
|
|
+ .data = &dqstats.stat[DQST_READS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "writes",
|
|
|
- .data = &dqstats.writes,
|
|
|
+ .data = &dqstats.stat[DQST_WRITES],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "cache_hits",
|
|
|
- .data = &dqstats.cache_hits,
|
|
|
+ .data = &dqstats.stat[DQST_CACHE_HITS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "allocated_dquots",
|
|
|
- .data = &dqstats.allocated_dquots,
|
|
|
+ .data = &dqstats.stat[DQST_ALLOC_DQUOTS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "free_dquots",
|
|
|
- .data = &dqstats.free_dquots,
|
|
|
+ .data = &dqstats.stat[DQST_FREE_DQUOTS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
{
|
|
|
.procname = "syncs",
|
|
|
- .data = &dqstats.syncs,
|
|
|
+ .data = &dqstats.stat[DQST_SYNCS],
|
|
|
.maxlen = sizeof(int),
|
|
|
.mode = 0444,
|
|
|
- .proc_handler = proc_dointvec,
|
|
|
+ .proc_handler = do_proc_dqstats,
|
|
|
},
|
|
|
#ifdef CONFIG_PRINT_QUOTA_WARNING
|
|
|
{
|
|
@@ -2572,6 +2624,13 @@ static int __init dquot_init(void)
|
|
|
if (!dquot_hash)
|
|
|
panic("Cannot create dquot hash table");
|
|
|
|
|
|
+#ifdef CONFIG_SMP
|
|
|
+ dqstats_pcpu = alloc_percpu(struct dqstats);
|
|
|
+ if (!dqstats_pcpu)
|
|
|
+ panic("Cannot create dquot stats table");
|
|
|
+#endif
|
|
|
+ memset(&dqstats, 0, sizeof(struct dqstats));
|
|
|
+
|
|
|
/* Find power-of-two hlist_heads which can fit into allocation */
|
|
|
nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
|
|
|
dq_hash_bits = 0;
|