Re: [Ext2-devel] Re: [RFC][PATCH 0/3] ext3 percpu counter fixes to suppport for ext3 unsigned long type free blocks counter

From: Andreas Dilger
Date: Wed Apr 12 2006 - 17:50:38 EST


On Apr 12, 2006 14:28 -0700, Mingming Cao wrote:
> where the check for unsigned long overflow is only turned on 32 bit
> platforms.
>
> > Or make the counter s64? so that it stays 64 bit on all arches?
> >
>
> Well, don't we have the problem : 64 bit counter add/dec/update is not
> always atomic on all 32 bit platforms? There are risk that we will get
> bogus global value.

My thought here is that the per-cpu counter could still be a 32-bit counter
and the global value could be a 64-bit value. That way, we don't need to
mess with 64-bit math in the common case, and we can still have a 64-bit
global value. The minor drawback would be that we can't have a per-cpu
delta of more than 2^31 at a time, but I don't think this is a worry here.

> > why not change the global per-cpu counter type to unsigned long (as we
> > discussed earlier), so we don't need the extra "ul" flags and interfaces,
> > and all arches get a standard unsigned long return type?
> > We could also
> > do away with percpu_read_positive then no? The applications for per-cpu
> > counters is going to be upcounters always methinks...

The "percpu_read_positive" usage is broken in any case, since it doesn't
correctly handle the case where there is no space in the filesystem at
all. The calling code (ext3_statfs) really needs to just call percpu_read()
and then return zero if this is negative.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/