Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
btrfsprogs
2224-btrfs-progs-du-fix-to-skip-not-btrfs-dir-f...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2224-btrfs-progs-du-fix-to-skip-not-btrfs-dir-file.patch of Package btrfsprogs
From 2e2b10db26cbe8371369b675b5a570ec8081bf06 Mon Sep 17 00:00:00 2001 From: Wang Shilong <wangshilong1991@gmail.com> Date: Thu, 7 Jul 2016 18:43:38 +0900 Subject: [PATCH] btrfs-progs: du: fix to skip not btrfs dir/file 'btrfs file du' is a very useful tool to watch my system file usage information with snapshot aware. when trying to run following commands: [root@localhost btrfs-progs]# btrfs file du / Total Exclusive Set shared Filename ERROR: Failed to lookup root id - Inappropriate ioctl for device ERROR: cannot check space of '/': Unknown error -1 and My Filesystem looks like this: [root@localhost btrfs-progs]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 16G 0 16G 0% /dev tmpfs tmpfs 16G 368K 16G 1% /dev/shm tmpfs tmpfs 16G 1.4M 16G 1% /run tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda3 btrfs 60G 19G 40G 33% / tmpfs tmpfs 16G 332K 16G 1% /tmp /dev/sdc btrfs 2.8T 166G 1.7T 9% /data /dev/sda2 xfs 2.0G 452M 1.6G 23% /boot /dev/sda1 vfat 1.9G 11M 1.9G 1% /boot/efi tmpfs tmpfs 3.2G 24K 3.2G 1% /run/user/1000 So I installed Btrfs as my root partition, but boot partition can be other fs. We can Let btrfs tool aware of this is not a btrfs file or directory and skip those files, so that someone like me could just run 'btrfs file du /' to scan all btrfs filesystems. After patch, it will look like: Total Exclusive Set shared Filename 0.00B 0.00B - //root/.bash_logout 0.00B 0.00B - //root/.bash_profile 0.00B 0.00B - //root/.bashrc 0.00B 0.00B - //root/.cshrc 0.00B 0.00B - //root/.tcshrc This works for me to analysis system usage and analysis performaces. Signed-off-by: Wang Shilong <wangshilong1991@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com> --- cmds-fi-du.c | 8 +++++++- cmds-inspect.c | 2 +- utils.c | 9 ++++----- 3 files changed, 12 insertions(+), 7 deletions(-) Index: btrfs-progs-v4.5.3/cmds-fi-du.c =================================================================== --- btrfs-progs-v4.5.3.orig/cmds-fi-du.c +++ btrfs-progs-v4.5.3/cmds-fi-du.c @@ -389,8 +389,14 @@ static int du_walk_dir(struct du_dir_ctx dirfd(dirstream), shared_extents, &tot, &shr, 0); - if (ret) + if (ret == -ENOTTY) { + continue; + } else if (ret) { + fprintf(stderr, + "failed to walk dir/file: %s :%s\n", + entry->d_name, strerror(-ret)); break; + } ctxt->bytes_total += tot; ctxt->bytes_shared += shr; Index: btrfs-progs-v4.5.3/cmds-inspect.c =================================================================== --- btrfs-progs-v4.5.3.orig/cmds-inspect.c +++ btrfs-progs-v4.5.3/cmds-inspect.c @@ -323,7 +323,7 @@ static int cmd_inspect_rootid(int argc, ret = lookup_ino_rootid(fd, &rootid); if (ret) { - error("rootid failed with ret=%d", ret); + error("failed to lookup root id: %s", strerror(-ret)); goto out; } Index: btrfs-progs-v4.5.3/utils.c =================================================================== --- btrfs-progs-v4.5.3.orig/utils.c +++ btrfs-progs-v4.5.3/utils.c @@ -2818,6 +2818,8 @@ path: if (fd < 0) goto err; ret = lookup_ino_rootid(fd, &id); + if (ret) + error("failed to lookup root id: %s", strerror(-ret)); close(fd); if (ret < 0) goto err; @@ -3502,11 +3504,8 @@ int lookup_ino_rootid(int fd, u64 *rooti args.objectid = BTRFS_FIRST_FREE_OBJECTID; ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); - if (ret < 0) { - fprintf(stderr, "ERROR: Failed to lookup root id - %s\n", - strerror(errno)); - return ret; - } + if (ret < 0) + return -errno; *rootid = args.treeid;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor