Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[firefly-linux-kernel-4.4.55.git] / fs / ext4 / balloc.c
index d0f13eada0ed5799295a5378642cd3786cf32595..58339393fa6e55c689adfa375b804a108a25c924 100644 (file)
@@ -682,11 +682,15 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb)
 
 static inline int test_root(ext4_group_t a, int b)
 {
-       int num = b;
-
-       while (a > num)
-               num *= b;
-       return num == a;
+       while (1) {
+               if (a < b)
+                       return 0;
+               if (a == b)
+                       return 1;
+               if ((a % b) != 0)
+                       return 0;
+               a = a / b;
+       }
 }
 
 static int ext4_group_sparse(ext4_group_t group)