I found that on BSD with recent coda, 'du' and 'ls -l' gave wacky
storage usage amounts. individual sizes on files were ok.
The problem was that in fsobj:GetVattr that the size was being
converted to bytes before the size was looked up, so the '-1' from
initting the vattr got used.
This has nothing to do with bsd, really, but I guess the Linux coda
kernel code does not use va_bytes for some reason. (It would be cool
to actually do the roundup/indirect block calcs for space on the
server, but probably pretty pointless. E.g for a 1371 byte file,
va_bytes should be 2048 for a 1024-byte fragment FFS server.)
With the patch, du and ls -l report sensible values, modulo failing to
account for round up to fs fragment size.
Index: fso1.cc
===================================================================
RCS file: /coda-src/coda/coda-src/venus/fso1.cc,v
retrieving revision 4.92
diff -u -u -r4.92 fso1.cc
--- fso1.cc 14 Mar 2002 22:29:12 -0000 4.92
+++ fso1.cc 28 Aug 2002 19:33:13 -0000
@@ -2207,7 +2207,6 @@
vap->va_blocksize = V_BLKSIZE;
vap->va_flags = 0;
vap->va_rdev = 1;
- vap->va_bytes = vap->va_size;
/* If the object is currently open for writing we must physically
stat it to get its size and time info. */
@@ -2225,6 +2224,9 @@
vap->va_mtime.tv_sec = (time_t)stat.Date;
vap->va_mtime.tv_nsec = 0;
}
+
+ /* Convert size of file to bytes of storage after getting size! */
+ vap->va_bytes = vap->va_size;
/* We don't keep track of atime/ctime, so keep them identical to mtime */
vap->va_atime = vap->va_mtime;
With this patch, files are rounded up to 1024 bytes, giving less
surprising answers (avoiding 2 blocks for 3 files!).
Index: fso1.cc
===================================================================
RCS file: /coda-src/coda/coda-src/venus/fso1.cc,v
retrieving revision 4.92
diff -u -u -r4.92 fso1.cc
--- fso1.cc 14 Mar 2002 22:29:12 -0000 4.92
+++ fso1.cc 28 Aug 2002 19:40:48 -0000
@@ -2207,7 +2207,6 @@
vap->va_blocksize = V_BLKSIZE;
vap->va_flags = 0;
vap->va_rdev = 1;
- vap->va_bytes = vap->va_size;
/* If the object is currently open for writing we must physically
stat it to get its size and time info. */
@@ -2225,6 +2224,14 @@
vap->va_mtime.tv_sec = (time_t)stat.Date;
vap->va_mtime.tv_nsec = 0;
}
+
+ /*
+ * Convert size of file to bytes of storage after getting size!
+ * Round up to 1024-byte fragments because they are typical,
+ * since we can't find out the server's underlying filesystem
+ * block size.
+ */
+ vap->va_bytes = (vap->va_size + 1023) & ~ 0x3ff;
/* We don't keep track of atime/ctime, so keep them identical to mtime */
vap->va_atime = vap->va_mtime;