Whamcloud - gitweb
Allos statfs to return values larger than 16TB.
authoradilger <adilger>
Thu, 12 Sep 2002 15:39:20 +0000 (15:39 +0000)
committeradilger <adilger>
Thu, 12 Sep 2002 15:39:20 +0000 (15:39 +0000)
lustre/lib/ll_pack.c
lustre/llite/super.c

index a71f564..184c2c1 100644 (file)
@@ -53,31 +53,14 @@ void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs)
         osfs->os_namelen = sfs->f_namelen;
 }
 
-#if BITS_PER_LONG > 32
-#define statfs_max(val) val
-#else
-static inline long statfs_max(__u64 val)
-{
-        return ((long)val < val) ? (long)-1 : val;
-}
-#endif
-
-/*
- * Note: since linux statfs is limited to a "long" for the statfs
- * fields, we quickly overflow that.  If we wanted, we could start
- * playing games with the blocksize until the blocks count fit into
- * a long.  Note that it also appears that userspace interprets these
- * fields as an unsigned long, which is helps us a bit, and it also
- * appears to do 64-bit math for at least some of the computations.
- */
 void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs)
 {
         sfs->f_type = osfs->os_type;
-        sfs->f_blocks = statfs_max(osfs->os_blocks);
-        sfs->f_bfree = statfs_max(osfs->os_bfree);
-        sfs->f_bavail = statfs_max(osfs->os_bavail);
-        sfs->f_files = statfs_max(osfs->os_files);
-        sfs->f_ffree = statfs_max(osfs->os_ffree);
+        sfs->f_blocks = osfs->os_blocks;
+        sfs->f_bfree = osfs->os_bfree;
+        sfs->f_bavail = osfs->os_bavail;
+        sfs->f_files = osfs->os_files;
+        sfs->f_ffree = osfs->os_ffree;
         sfs->f_bsize = osfs->os_bsize;
         sfs->f_namelen = osfs->os_namelen;
 }
index d012327..7d63874 100644 (file)
@@ -385,10 +385,7 @@ static int ll_statfs(struct super_block *sb, struct statfs *sfs)
 
         /* temporary until mds_statfs returns statfs info for all OSTs */
         if (!rc) {
-                struct statfs obd_sfs;
-
                 rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
-                statfs_unpack(&obd_sfs, &osfs);
                 if (rc) {
                         CERROR("obd_statfs fails: rc = %d\n", rc);
                         GOTO(out, rc);
@@ -398,11 +395,18 @@ static int ll_statfs(struct super_block *sb, struct statfs *sfs)
                        osfs.os_bavail, osfs.os_blocks,
                        osfs.os_ffree, osfs.os_files);
 
-                sfs->f_bfree = obd_sfs.f_bfree;
-                sfs->f_bavail = obd_sfs.f_bavail;
-                sfs->f_blocks = obd_sfs.f_blocks;
-                if (obd_sfs.f_ffree < sfs->f_ffree)
-                        sfs->f_ffree = obd_sfs.f_ffree;
+                while (osfs.os_blocks > ~0UL) {
+                        sfs->f_bsize <<= 1;
+
+                        osfs.os_blocks >>= 1;
+                        osfs.os_bfree >>= 1;
+                        osfs.os_bavail >>= 1;
+                }
+                sfs->f_blocks = osfs.os_blocks;
+                sfs->f_bfree = osfs.os_bfree;
+                sfs->f_bavail = osfs.os_bavail;
+                if (osfs.os_ffree < (__u64)sfs->f_ffree)
+                        sfs->f_ffree = osfs.os_ffree;
         }
 
 out: