|
|
DescriptionReturn correct disk free/available size when FS is mounted with size = 0
When tmpfs is mounted with size = 0 (i.e. without any limit), then statvfs
will return 0 for f_bfree, f_bavail, and f_blocks. Catch this case and return
max_int64 instead.
BUG=628710
Committed: https://crrev.com/6c917630660164bb28d57f31b970b38591c0b8b1
Cr-Commit-Position: refs/heads/master@{#406473}
Patch Set 1 #
Total comments: 6
Patch Set 2 : Use GetFileSystemType to special case "f_block == 0" only for memory FS #
Total comments: 6
Patch Set 3 : Updated based on CR comments. #Patch Set 4 : Format the file before submitting #Messages
Total messages: 25 (10 generated)
The CQ bit was checked by sriramsr@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
sriramsr@chromium.org changed reviewers: + reveman@chromium.org, thestig@chromium.org
https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc File base/sys_info_posix.cc (right): https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:83: // f_blocks is 0 when tmpfs is mounted without any size limit (i.e. size set You need to check that the file system is tmpfs. The f_blocks == 0 case may not mean the same thing for other file systems. On Linux, you can use GetFileSystemType(), but keep in mind the code here is cross-platform.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc File base/sys_info_posix.cc (right): https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:83: // f_blocks is 0 when tmpfs is mounted without any size limit (i.e. size set On 2016/07/16 00:19:12, Lei Zhang wrote: > You need to check that the file system is tmpfs. The f_blocks == 0 case may not > mean the same thing for other file systems. On Linux, you can use > GetFileSystemType(), but keep in mind the code here is cross-platform. Basically something like the following, though it may not be 100% correct because GetFileSystemType() can return FILE_SYSTEM_MEMORY for ramfs and hugetlbfs as well, and I don't know if the 0 -> unlimited characteristic applies to those file systems as well. Can you check on that? If not, you'll have just to put in a specific check for tmpfs here instead. With the const bool for non-Linux builds, hopefully the compiler can just optimize it as though this CL never happened. #if defined(OS_LINUX) // On Linux, stats.f_blocks is 0 when tmpfs is mounted without any size limit // (i.e. size set to 0). FileSystemType fs_type; const bool zero_size_means_unlimited = stats.f_blocks == 0 && GetFileSystemType(path, &fs_type) && fs_type == FILE_SYSTEM_MEMORY; #else const bool zero_size_means_unlimited = false; #endif https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:101: namespace base { If you can move this up to wrap the anonymous namespace, then you don't have to use base:: to refer to GetFileSystemType().
https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc File base/sys_info_posix.cc (right): https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:83: // f_blocks is 0 when tmpfs is mounted without any size limit (i.e. size set On 2016/07/16 00:19:12, Lei Zhang wrote: > You need to check that the file system is tmpfs. The f_blocks == 0 case may not > mean the same thing for other file systems. On Linux, you can use > GetFileSystemType(), but keep in mind the code here is cross-platform. Acknowledged. https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:83: // f_blocks is 0 when tmpfs is mounted without any size limit (i.e. size set On 2016/07/18 19:05:07, Lei Zhang wrote: > On 2016/07/16 00:19:12, Lei Zhang wrote: > > You need to check that the file system is tmpfs. The f_blocks == 0 case may > not > > mean the same thing for other file systems. On Linux, you can use > > GetFileSystemType(), but keep in mind the code here is cross-platform. > > Basically something like the following, though it may not be 100% correct > because GetFileSystemType() can return FILE_SYSTEM_MEMORY for ramfs and > hugetlbfs as well, and I don't know if the 0 -> unlimited characteristic applies > to those file systems as well. Can you check on that? If not, you'll have just > to put in a specific check for tmpfs here instead. > > With the const bool for non-Linux builds, hopefully the compiler can just > optimize it as though this CL never happened. > > #if defined(OS_LINUX) > // On Linux, stats.f_blocks is 0 when tmpfs is mounted without any size limit > // (i.e. size set to 0). > FileSystemType fs_type; > const bool zero_size_means_unlimited = stats.f_blocks == 0 && > GetFileSystemType(path, &fs_type) && > fs_type == FILE_SYSTEM_MEMORY; > #else > const bool zero_size_means_unlimited = false; > #endif Done. https://codereview.chromium.org/2152283003/diff/1/base/sys_info_posix.cc#newc... base/sys_info_posix.cc:101: namespace base { On 2016/07/18 19:05:07, Lei Zhang wrote: > If you can move this up to wrap the anonymous namespace, then you don't have to > use base:: to refer to GetFileSystemType(). Done.
The CQ bit was checked by sriramsr@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc File base/sys_info_posix.cc (right): https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:76: } // namespace No, that's not what I meant. namespace base { namespace { // all the existing anonymous bits now no longer needs base:: } // namespace // all the existing non-anoynymous bits } // namespace base https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:89: // ramfs, or hugetlbfs (all memory file systems). the is mounted without any So have you checked the ramfs / hugetlbfs behavior w.r.t. size == 0? https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:89: // ramfs, or hugetlbfs (all memory file systems). the is mounted without any typo: "the is mounted"
https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc File base/sys_info_posix.cc (right): https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:76: } // namespace On 2016/07/19 23:45:10, Lei Zhang wrote: > No, that's not what I meant. > > namespace base { > > namespace { > > // all the existing anonymous bits now no longer needs base:: > > } // namespace > > // all the existing non-anoynymous bits > > } // namespace base Done. https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:89: // ramfs, or hugetlbfs (all memory file systems). the is mounted without any On 2016/07/19 23:45:10, Lei Zhang wrote: > So have you checked the ramfs / hugetlbfs behavior w.r.t. size == 0? Yes, See Linux code for: hugetlbfs - http://lxr.free-electrons.com/source/fs/hugetlbfs/inode.c#L869 /* If no limits set, just report 0 for max/free/used * blocks, like simple_statfs() */ For Ramfs: http://lxr.free-electrons.com/source/fs/libfs.c#L33 Which uses simple_statfs(). https://codereview.chromium.org/2152283003/diff/20001/base/sys_info_posix.cc#... base/sys_info_posix.cc:89: // ramfs, or hugetlbfs (all memory file systems). the is mounted without any On 2016/07/19 23:45:10, Lei Zhang wrote: > typo: "the is mounted" Done.
lgtm, thanks for doing the homework. Can you do me one last favor and run "git cl format" if you haven't already, and upload the clang-formatted CL for the commit queue?
On 2016/07/20 00:02:25, Lei Zhang wrote: > lgtm, thanks for doing the homework. > > Can you do me one last favor and run "git cl format" if you haven't already, and > upload the clang-formatted CL for the commit queue? Thanks! Done.
The CQ bit was checked by sriramsr@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from thestig@chromium.org Link to the patchset: https://codereview.chromium.org/2152283003/#ps60001 (title: "Format the file before submitting")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #4 (id:60001)
Message was sent while issue was closed.
CQ bit was unchecked.
Message was sent while issue was closed.
Description was changed from ========== Return correct disk free/available size when FS is mounted with size = 0 When tmpfs is mounted with size = 0 (i.e. without any limit), then statvfs will return 0 for f_bfree, f_bavail, and f_blocks. Catch this case and return max_int64 instead. BUG=628710 ========== to ========== Return correct disk free/available size when FS is mounted with size = 0 When tmpfs is mounted with size = 0 (i.e. without any limit), then statvfs will return 0 for f_bfree, f_bavail, and f_blocks. Catch this case and return max_int64 instead. BUG=628710 Committed: https://crrev.com/6c917630660164bb28d57f31b970b38591c0b8b1 Cr-Commit-Position: refs/heads/master@{#406473} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/6c917630660164bb28d57f31b970b38591c0b8b1 Cr-Commit-Position: refs/heads/master@{#406473}
Message was sent while issue was closed.
A revert of this CL (patchset #4 id:60001) has been created in https://codereview.chromium.org/2168843002/ by phoglund@chromium.org. The reason for reverting is: Breaks host_forwarder on WebRTC bots: https://build.chromium.org/p/tryserver.webrtc/builders/android_arm64_rel/buil...: obj.host/chromium/src/base/base.sys_info_posix.o: In function `base::(anonymous namespace)::GetDiskSpaceInfo(base::FilePath const&, long*, long*)': ../../chromium/src/base/sys_info_posix.cc:(.text._ZN4base12_GLOBAL__N_116GetDiskSpaceInfoERKNS_8FilePathEPlS4_+0x4c): undefined reference to `base::GetFileSystemType(base::FilePath const&, base::FileSystemType*)' I really don't know why it goes into the OS_LINUX branch since the bot is an Android bot though. host_forwarder is in the Chromium codebase. I would have understood it if it was WebRTC code since we have different macros (e.g. WEBRTC_LINUX) which would explain this breakage, but it appears to break host_forwarder. Note that WebRTC will be on GYP a couple more weeks, so this could be a gyp-only problem. Presumably you'll be able to repro if you generate with gyp and try to build host_forwarder in a chromium checkout..
Message was sent while issue was closed.
How can I reproduce the breakage? I tried doing an android build and it does not cause the build break (as it did not in CQ too). On Thu, Jul 21, 2016 at 4:31 AM, <phoglund@chromium.org> wrote: > A revert of this CL (patchset #4 id:60001) has been created in > https://codereview.chromium.org/2168843002/ by phoglund@chromium.org. > > The reason for reverting is: Breaks host_forwarder on WebRTC bots: > > https://build.chromium.org/p/tryserver.webrtc/builders/android_arm64_rel/buil... > : > > obj.host/chromium/src/base/base.sys_info_posix.o: In function > `base::(anonymous > namespace)::GetDiskSpaceInfo(base::FilePath const&, long*, long*)': > > ../../chromium/src/base/sys_info_posix.cc:(.text._ZN4base12_GLOBAL__N_116GetDiskSpaceInfoERKNS_8FilePathEPlS4_+0x4c): > undefined reference to `base::GetFileSystemType(base::FilePath const&, > base::FileSystemType*)' > > I really don't know why it goes into the OS_LINUX branch since the bot is > an > Android bot though. host_forwarder is in the Chromium codebase. I would > have > understood it if it was WebRTC code since we have different macros (e.g. > WEBRTC_LINUX) which would explain this breakage, but it appears to break > host_forwarder. > > Note that WebRTC will be on GYP a couple more weeks, so this could be a > gyp-only > problem. Presumably you'll be able to repro if you generate with gyp and > try to > build host_forwarder in a chromium checkout.. > > https://codereview.chromium.org/2152283003/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Message was sent while issue was closed.
On 2016/07/22 21:39:50, Sriram wrote: > How can I reproduce the breakage? I tried doing an android build and it > does not cause the build break (as it did not in CQ too). See the discussion on https://codereview.chromium.org/2168843002/ which you should have gotten emails for. |