/[gentoo-x86]/sys-fs/btrfs-progs/files/btrfs-progs-3.12-defrag-sockets.patch
Gentoo

Contents of /sys-fs/btrfs-progs/files/btrfs-progs-3.12-defrag-sockets.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Mar 10 19:34:28 2014 UTC (4 years, 6 months ago) by slyfox
Branch: MAIN
CVS Tags: HEAD
Fix recursive defrag failures on non-files (bug #503514 by Antoine Lemoine).

(Portage version: 2.2.8_p62/cvs/Linux x86_64, signed Manifest commit with key 611FF3AA)

1 From: Pascal VITOUX <vitoux.pascal@gmail.com>
2 To: linux-btrfs@vger.kernel.org
3 Cc: Pascal VITOUX <vitoux.pascal@gmail.com>
4 Subject: [PATCH] btrfs-progs: skip non-regular files while defragmenting
5 Date: Thu, 9 Jan 2014 23:47:14 +0100
6 Message-Id: <1389307634-8226-1-git-send-email-vitoux.pascal@gmail.com>
7 X-Mailer: git-send-email 1.8.5.2
8 Sender: linux-btrfs-owner@vger.kernel.org
9 Precedence: bulk
10 List-ID: <linux-btrfs.vger.kernel.org>
11 X-Mailing-List: linux-btrfs@vger.kernel.org
12
13 Skip non-regular files to avoid ioctl errors while defragmenting.
14
15 They are silently ignored in recursive mode but reported as errors when
16 used as command-line arguments.
17
18 Signed-off-by: Pascal VITOUX <vitoux.pascal@gmail.com>
19 Gentoo-bug: https://bugs.gentoo.org/503514
20 Reported-by: Antoine Lemoine
21 ---
22 cmds-filesystem.c | 26 ++++++++++++++++----------
23 1 file changed, 16 insertions(+), 10 deletions(-)
24
25 diff --git a/cmds-filesystem.c b/cmds-filesystem.c
26 index 1c1926b..54fba10 100644
27 --- a/cmds-filesystem.c
28 +++ b/cmds-filesystem.c
29 @@ -646,7 +646,7 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
30 int e = 0;
31 int fd = 0;
32
33 - if (typeflag == FTW_F) {
34 + if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
35 if (defrag_global_verbose)
36 printf("%s\n", fpath);
37 fd = open(fpath, O_RDWR);
38 @@ -748,6 +748,7 @@ static int cmd_defrag(int argc, char **argv)
39 defrag_global_range.flags |= BTRFS_DEFRAG_RANGE_START_IO;
40
41 for (i = optind; i < argc; i++) {
42 + struct stat st;
43 dirstream = NULL;
44 fd = open_file_or_dir(argv[i], &dirstream);
45 if (fd < 0) {
46 @@ -757,16 +758,21 @@ static int cmd_defrag(int argc, char **argv)
47 close_file_or_dir(fd, dirstream);
48 continue;
49 }
50 + if (fstat(fd, &st)) {
51 + fprintf(stderr, "ERROR: failed to stat %s - %s\n",
52 + argv[i], strerror(errno));
53 + defrag_global_errors++;
54 + close_file_or_dir(fd, dirstream);
55 + continue;
56 + }
57 + if (!(S_ISDIR(st.st_mode) || S_ISREG(st.st_mode))) {
58 + fprintf(stderr, "ERROR: %s is not a directory or a regular "
59 + "file.\n", argv[i]);
60 + defrag_global_errors++;
61 + close_file_or_dir(fd, dirstream);
62 + continue;
63 + }
64 if (recursive) {
65 - struct stat st;
66 -
67 - if (fstat(fd, &st)) {
68 - fprintf(stderr, "ERROR: failed to stat %s - %s\n",
69 - argv[i], strerror(errno));
70 - defrag_global_errors++;
71 - close_file_or_dir(fd, dirstream);
72 - continue;
73 - }
74 if (S_ISDIR(st.st_mode)) {
75 ret = nftw(argv[i], defrag_callback, 10,
76 FTW_MOUNT | FTW_PHYS);
77 --
78 1.8.5.2

  ViewVC Help
Powered by ViewVC 1.1.20