Skip to contentSkip to conversation

fs/quota: use unsigned int helper for sysctl fs.quota.*

PATCH In review Konstantin Khlebnikov 2 participants 3 messages Nov 7, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/quota: use unsigned int helper for sysctl fs.quota.*

Report counters as unsigned, otherwise they turn negative at overflow:

# sysctl fs.quota
fs.quota.allocated_dquots = 22327
fs.quota.cache_hits = -489852115
fs.quota.drops = -487288718
fs.quota.free_dquots = 22083
fs.quota.lookups = -486883485
fs.quota.reads = 22327
fs.quota.syncs = 335064
fs.quota.writes = 3088689
---
 fs/quota/dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/quota/dquot.c +1 -1
index 6e826b454082..606e1e39674b 100644
@@ -2865,7 +2865,7 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
 	/* Update global table */
 	dqstats.stat[type] =
 			percpu_counter_sum_positive(&dqstats.counter[type]);
-	return proc_dointvec(table, write, buffer, lenp, ppos);
+	return proc_douintvec(table, write, buffer, lenp, ppos);
 }
 
 static struct ctl_table fs_dqstats_table[] = {
reviewer
#1 lore raw
Quoted 12 lines · Konstantin Khlebnikov

Report counters as unsigned, otherwise they turn negative at overflow:

# sysctl fs.quota
fs.quota.allocated_dquots = 22327
fs.quota.cache_hits = -489852115
fs.quota.drops = -487288718
fs.quota.free_dquots = 22083
fs.quota.lookups = -486883485
fs.quota.reads = 22327
fs.quota.syncs = 335064
fs.quota.writes = 3088689
Quoted 1 line

Fair enough but then 'stats' array in dqstats should be unsigned as well for consistency and why not actually make everything long when we are at it? percpu_counter we use is s64 anyway...

Honza

Quoted 18 lines
---
 fs/quota/dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/quota/dquot.c +1 -1
index 6e826b454082..606e1e39674b 100644
@@ -2865,7 +2865,7 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
 	/* Update global table */
 	dqstats.stat[type] =
 			percpu_counter_sum_positive(&dqstats.counter[type]);
-	return proc_dointvec(table, write, buffer, lenp, ppos);
+	return proc_douintvec(table, write, buffer, lenp, ppos);
 }
 
 static struct ctl_table fs_dqstats_table[] = {
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw
Quoted 13 lines · Jan Kara
Quoted 12 lines · Konstantin Khlebnikov

Report counters as unsigned, otherwise they turn negative at overflow:

# sysctl fs.quota
fs.quota.allocated_dquots = 22327
fs.quota.cache_hits = -489852115
fs.quota.drops = -487288718
fs.quota.free_dquots = 22083
fs.quota.lookups = -486883485
fs.quota.reads = 22327
fs.quota.syncs = 335064
fs.quota.writes = 3088689
Quoted 5 lines
Quoted 1 line

Fair enough but then 'stats' array in dqstats should be unsigned as well for consistency and why not actually make everything long when we are at it? percpu_counter we use is s64 anyway...

Ok. I'll patch this too.

Quoted 21 lines

Honza

Quoted 18 lines
---
  fs/quota/dquot.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/quota/dquot.c +1 -1
index 6e826b454082..606e1e39674b 100644
@@ -2865,7 +2865,7 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
  	/* Update global table */
  	dqstats.stat[type] =
  			percpu_counter_sum_positive(&dqstats.counter[type]);
-	return proc_dointvec(table, write, buffer, lenp, ppos);
+	return proc_douintvec(table, write, buffer, lenp, ppos);
  }
 
  static struct ctl_table fs_dqstats_table[] = {