]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_fsr: file reads should be O_DIRECT
authorDave Chinner <dchinner@redhat.com>
Thu, 9 May 2013 12:16:09 +0000 (07:16 -0500)
committerRich Johnston <rjohnston@sgi.com>
Thu, 9 May 2013 12:16:09 +0000 (07:16 -0500)
When running xfs_fsr on a sparse filesystem image containing
approximately 8 million extents and 80GB of data, I noticed that the
page cache grew and consumed all the memory in the machine. It turns
out that xfs_fsr is using direct IO to write data, but buffered IO
to read data. Convert the read side to use direct IO to prevent page
cache blowouts.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
fsr/xfs_fsr.c

index 6852b3f7aa2e8841d8a79abfd53e9c851ee3856a..d4ec9a3be35623903f51004ea840d6b8e51472cc 100644 (file)
@@ -732,7 +732,8 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)
                             (p->bs_extents < 2))
                                continue;
 
-                       if ((fd = jdm_open(fshandlep, p, O_RDWR)) < 0) {
+                       fd = jdm_open(fshandlep, p, O_RDWR|O_DIRECT);
+                       if (fd < 0) {
                                /* This probably means the file was
                                 * removed while in progress of handling
                                 * it.  Just quietly ignore this file.
@@ -836,7 +837,7 @@ fsrfile(char *fname, xfs_ino_t ino)
                return -1;
        }
 
-       fd = jdm_open( fshandlep, &statbuf, O_RDWR);
+       fd = jdm_open(fshandlep, &statbuf, O_RDWR|O_DIRECT);
        if (fd < 0) {
                fsrprintf(_("unable to open handle %s: %s\n"),
                        fname, strerror(errno));