Whamcloud - gitweb
Branch b1_6
authorbobijam <bobijam>
Thu, 16 Aug 2007 14:26:32 +0000 (14:26 +0000)
committerbobijam <bobijam>
Thu, 16 Aug 2007 14:26:32 +0000 (14:26 +0000)
b=12743
i=adilger, shadow

Description: df doesn't work properly if diskfs blocksize != 4K
Details    : Choose biggest blocksize of OST's as the LOV's blocksize.

lustre/ChangeLog
lustre/llite/llite_lib.c
lustre/lov/lov_request.c

index f3bc113..5f18835 100644 (file)
@@ -31,6 +31,11 @@ Description: llapi_file_create() does not allow some changes
 Details    : add llapi_file_open() that allows specifying the mode and 
              open flags, and also returns an open file handle.
 
+Severity   : normal
+Bugzilla   : 12743
+Description: df doesn't work properly if diskfs blocksize != 4K
+Details    : Choose biggest blocksize of OST's as the LOV's blocksize.
+
 --------------------------------------------------------------------------------
 
 2007-08-27         Cluster File Systems, Inc. <info@clusterfs.com>
index 47f4cdf..39990cd 100644 (file)
@@ -1418,6 +1418,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
                obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
                obd_osfs.os_files);
 
+        osfs->os_bsize = obd_osfs.os_bsize;
         osfs->os_blocks = obd_osfs.os_blocks;
         osfs->os_bfree = obd_osfs.os_bfree;
         osfs->os_bavail = obd_osfs.os_bavail;
index 439d34b..a8e43dc 100644 (file)
@@ -1485,6 +1485,8 @@ int lov_fini_statfs_set(struct lov_request_set *set)
 void lov_update_statfs(struct obd_device *obd, struct obd_statfs *osfs,
                        struct obd_statfs *lov_sfs, int success)
 {
+        int shift = 0, quit = 0;
+        __u64 tmp;
         spin_lock(&obd->obd_osfs_lock);
         memcpy(&obd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
         obd->obd_osfs_age = get_jiffies_64();
@@ -1493,6 +1495,33 @@ void lov_update_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         if (success == 0) {
                 memcpy(osfs, lov_sfs, sizeof(*lov_sfs));
         } else {
+                if (osfs->os_bsize != lov_sfs->os_bsize) {
+                        /* assume all block sizes are always powers of 2 */
+                        /* get the bits difference */
+                        tmp = osfs->os_bsize | lov_sfs->os_bsize;
+                        for (shift = 0; shift <= 64; ++shift) {
+                                if (tmp & 1) {
+                                        if (quit)
+                                                break;
+                                        else
+                                                quit = 1;
+                                        shift = 0;
+                                }
+                                tmp >>= 1;
+                        }
+                }
+
+                if (osfs->os_bsize < lov_sfs->os_bsize) {
+                        osfs->os_bsize = lov_sfs->os_bsize;
+
+                        osfs->os_bfree  >>= shift;
+                        osfs->os_bavail >>= shift;
+                        osfs->os_blocks >>= shift;
+                } else if (shift != 0) {
+                        lov_sfs->os_bfree  >>= shift;
+                        lov_sfs->os_bavail >>= shift;
+                        lov_sfs->os_blocks >>= shift;
+                }
 #ifdef MIN_DF
                 /* Sandia requested that df (and so, statfs) only
                    returned minimal available space on