Re: 2.6.23-rc2-mm1: silly df numbers on 32bit extN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 9 Aug 2007, Andrew Morton wrote:
> 
> +lib-make-percpu_counter_add-take-s64.patch

lib-make-percpu_counter_add-take-s64.patch looks sensible, but it doesn't
actually work on 32-bit architectures: several users of percpu_counter_add
are passing -unsignedlong as the amount, which is not promoted to s64 in
the desired way, so "df" on extN filesystems is showing silly numbers.

The hack below (say long instead of s64 or s32) may be good as hotfix for
2.6.23-rc2-mm1, but is probably the worst of solutions.  Perhaps take-s64
should be reverted, perhaps there should be a percpu_counter_sub and the
filesystems use that instead of saying -unsignedlong, perhaps they should
use a cast or a long or an s64.  I don't know, but here's this for now...

Signed-off-by: Hugh Dickins <[email protected]>
---

 include/linux/percpu_counter.h |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- 2.6.23-rc2-mm1/include/linux/percpu_counter.h	2007-08-09 13:15:35.000000000 +0100
+++ linux/include/linux/percpu_counter.h	2007-08-09 20:34:23.000000000 +0100
@@ -37,7 +37,7 @@ void percpu_counter_set(struct percpu_co
 void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch);
 s64 __percpu_counter_sum(struct percpu_counter *fbc);
 
-static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
+static inline void percpu_counter_add(struct percpu_counter *fbc, long amount)
 {
 	__percpu_counter_add(fbc, amount, FBC_BATCH);
 }
@@ -96,11 +96,16 @@ static inline void percpu_counter_set(st
 	fbc->count = amount;
 }
 
-#define __percpu_counter_add(fbc, amount, batch) \
-	percpu_counter_add(fbc, amount)
+static inline void
+__percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
+{
+	preempt_disable();
+	fbc->count += amount;
+	preempt_enable();
+}
 
 static inline void
-percpu_counter_add(struct percpu_counter *fbc, s64 amount)
+percpu_counter_add(struct percpu_counter *fbc, long amount)
 {
 	preempt_disable();
 	fbc->count += amount;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux