From 6fc26ac190168ece24296c0a1b1b90989c41a02d Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 1 Nov 2016 10:38:45 +0900 Subject: [PATCH] Imported Upstream version 14.42.7 Change-Id: Idc7192cca1eec2a9430b6bb3524368f402339df5 Signed-off-by: DongHun Kwak --- VERSION.cmake | 4 ++-- package/libzypp.changes | 7 +++++++ zypp/DiskUsageCounter.cc | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index aa38e83..0e07d87 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -61,8 +61,8 @@ SET(LIBZYPP_MAJOR "14") SET(LIBZYPP_COMPATMINOR "39") SET(LIBZYPP_MINOR "42") -SET(LIBZYPP_PATCH "6") +SET(LIBZYPP_PATCH "7") # -# LAST RELEASED: 14.42.6 (39) +# LAST RELEASED: 14.42.7 (39) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/package/libzypp.changes b/package/libzypp.changes index ca5e9a2..47c088a 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Apr 15 11:28:42 CEST 2016 - ma@suse.de + +- DiskUsageCounter: Limit estimated waste per file (bsc#974275) +- Filter unwanted btrfs subvolumes (fixes #54, closes #55, bnc#949945) +- version 14.42.7 (39) + +------------------------------------------------------------------- Mon Apr 11 12:47:27 CEST 2016 - ma@suse.de - Use PluginExecutor for commit- and system-hooks (bnc#971637) diff --git a/zypp/DiskUsageCounter.cc b/zypp/DiskUsageCounter.cc index 6ce9c07..d9ea27e 100644 --- a/zypp/DiskUsageCounter.cc +++ b/zypp/DiskUsageCounter.cc @@ -71,10 +71,13 @@ namespace zypp unsigned idx = 0; for_( it, result.begin(), result.end() ) { - static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K) + // 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! + it->pkg_size = it->used_size // current usage + duchanges[idx].kbytes // package data size - + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file + + ( duchanges[idx].files * ( it->fstype == "btrfs" ? 4096 : it->block_size ) / blockAdjust ); // half block per file ++idx; } } @@ -127,6 +130,9 @@ namespace zypp { DiskUsageCounter::MountPointSet ret; + typedef std::map Btrfsfilter; + Btrfsfilter btrfsfilter; // see btrfs hack below + std::ifstream procmounts( "/proc/mounts" ); if ( !procmounts ) { @@ -213,7 +219,7 @@ namespace zypp // const char * mpunwanted[] = { "/mnt", "/media", "/mounts", "/floppy", "/cdrom", - "/suse", "/var/tmp", "/var/adm/mount", "/var/adm/YaST", + "/suse", "/tmp", "/var/tmp", "/var/adm/mount", "/var/adm/YaST", /*last*/0/*entry*/ }; @@ -252,8 +258,10 @@ 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; @@ -292,6 +300,25 @@ 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 ) ); @@ -300,6 +327,10 @@ namespace zypp } } + // collect filtered btrfs volumes + for ( auto && bmp : btrfsfilter ) + ret.insert( std::move(bmp.second) ); + return ret; } -- 2.7.4