Imported Upstream version 15.0.0
[platform/upstream/libzypp.git] / zypp / DiskUsageCounter.cc
index d9ea27e..6ce9c07 100644 (file)
@@ -71,13 +71,10 @@ namespace zypp
         unsigned idx = 0;
         for_( it, result.begin(), result.end() )
         {
-         // Limit estimated waste (half block per file) as it does not apply to
-         // btrfs, which reports up to 64K blocksize (bsc#974275,bsc#965322)
-         static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / 2 / 1K; result value in K!
-
+          static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
           it->pkg_size = it->used_size          // current usage
                        + duchanges[idx].kbytes  // package data size
-                       + ( duchanges[idx].files * ( it->fstype == "btrfs" ? 4096 : it->block_size ) / blockAdjust ); // half block per file
+                       + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
           ++idx;
         }
       }
@@ -130,9 +127,6 @@ namespace zypp
   {
     DiskUsageCounter::MountPointSet ret;
 
-    typedef std::map<std::string, MountPoint> Btrfsfilter;
-    Btrfsfilter btrfsfilter;   // see btrfs hack below
-
       std::ifstream procmounts( "/proc/mounts" );
 
       if ( !procmounts ) {
@@ -219,7 +213,7 @@ namespace zypp
            //
            const char * mpunwanted[] = {
              "/mnt", "/media", "/mounts", "/floppy", "/cdrom",
-             "/suse", "/tmp", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
+             "/suse", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
              /*last*/0/*entry*/
            };
 
@@ -258,10 +252,8 @@ namespace zypp
            //
            // check for snapshotting btrfs
            //
-           bool btrfshack = false;
            if ( words[2] == "btrfs" )
            {
-             btrfshack = true;
              if ( geteuid() != 0 )
              {
                DBG << "Assume snapshots on " << words[1] << ": non-root user can't check" << std::endl;
@@ -300,25 +292,6 @@ namespace zypp
                DBG << "Filter zero-sized mount point : " << l << std::endl;
                continue;
              }
-             if ( btrfshack )
-             {
-               // HACK:
-               // Collect just the top/1st mountpoint of each btrfs volume
-               // (by device). This filters away nested subvolumes
-               // which otherwise break per package disk usage computation.
-               // FIX: Computation must learn to handle multiple mount points
-               // contributing to the same file system.
-               MountPoint & bmp( btrfsfilter[words[0]] );
-               if ( bmp.fstype.empty() )       // 1st occurance
-               {
-                 bmp = DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
-                                                     ((long long)sb.f_blocks)*sb.f_bsize/1024,
-                                                     ((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints );
-               }
-               else if ( bmp.dir > mp )
-                 bmp.dir = mp;
-               continue;
-             }
              ret.insert( DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
                ((long long)sb.f_blocks)*sb.f_bsize/1024,
                ((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints ) );
@@ -327,10 +300,6 @@ namespace zypp
        }
     }
 
-    // collect filtered btrfs volumes
-    for ( auto && bmp : btrfsfilter )
-      ret.insert( std::move(bmp.second) );
-
     return ret;
   }