Re: [RFC 7/7] ext3 blocks: convert ext3_fsblk_t to sector_t

Andreas Dilger <[email protected]>
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
On May 19, 2006  11:19 -0700, Badari Pulavarty wrote:
> On Fri, 2006-05-19 at 09:42 -0700, Mingming Cao wrote:
> > But checking the rest of 64 bit arch where sector_t is defined, found
> > previous assumption not always true: about on 64 bit machine
> > sector_t/u64 is always unsigned long. At least, cscope shows asm-sh
> > arch, BITS_PER_LONG is 64, while, u64/sector_t is unsigned long long, so
> > this won't work for this case.
> 
> It should work on 64-bit machines also as "long long" is equal to "long"
> (64-bit) on these machines (verified it atleast on x86-64, ppc64)

No, even though the sizes of long and long long are the same on a 64-bit
arch you get compile warnings because this isn't a safe assumption on all
systems.  It is even worse on e.g. x86_64 and SPARC because the types in
userspace aren't the same as in the kernel.  I've had to deal with this for
a long time with Lustre, and we have defined LPU64, LPX64, LPD64 that are
used in all the printks in our code:

#if (defined(__x86_64__) && defined(__KERNEL__))
/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
# define LPU64 "%Lu"
# define LPD64 "%Ld"
# define LPX64 "%#Lx"
#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
# define LPU64 "%Lu"
# define LPD64 "%Ld"
# define LPX64 "%#Lx"
#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
# define LPU64 "%lu"
# define LPD64 "%ld"
# define LPX64 "%#lx"
#endif

That said, I think I'd still prefer to have Dave's original SECTOR_FMT patch
since it is completely unambiguous that the format matches the type.  If it
so happens that we get LPU64 into the kernel (which I doubt, since I had
suggested this a long time ago, but maybe things change) then we can
redefine SECTOR_FMT in terms of LPU64.

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



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.