linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Phil Davis <pmdhazy@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: btrfs send 'leaks' open files
Date: Tue, 22 Oct 2013 18:22:49 +0100	[thread overview]
Message-ID: <20131022172249.GV13318@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAERquQ78pOig3oQoom2e0Jcsv1i3-_8ET0ewAWUUo+nt2vk4Mg@mail.gmail.com>

On Sun, Oct 20, 2013 at 11:33:56AM +0100, Phil Davis wrote:

> The reason I think btrfs send is leaking open files is if you watch
> /proc/sys/fs/file-nr you see the
> number of open files increasing  but if you kill the btrfs send
> process then the open
> files count reduces back down.  In fact suspending the process also
> reduces the open file count but
> resuming it then makes the count start increasing again.

What does lsof show while you are running that?  AFAICS, btrfs_ioctl_send()
should be neutral wrt file references - we do fget() on entry and
fput() of the result on exit, with nothing else looking relevant in
sight...  OTOH, btrfs-progs number of calls of that ioctl() seems to
be bounded by the length of argument list.  So the interesting questions
are
	a) how many btrfs send instances are running at the time?
	b) what do their arg lists look like?
	c) who (if anyone) has all those opened files in their descriptor
tables?

BTW, looking at do_send()...
        if (g_verbose > 0)
                fprintf(stderr, "joining genl thread\n");

        close(pipefd[1]);
        pipefd[1] = 0;

        ret = pthread_join(t_read, &t_err);
...
        if (subvol_fd != -1)
                close(subvol_fd);
        if (pipefd[0] != -1)
                close(pipefd[0]);
        if (pipefd[1] != -1)
                close(pipefd[1]);

That pipefd[1] = 0; looks bogus; it doesn't look like it could result in
what you are seeing, but unless I'm misreading that code it ought to be
pipefd[1] = -1...

  parent reply	other threads:[~2013-10-22 17:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-20 10:33 btrfs send 'leaks' open files Phil Davis
2013-10-21 13:02 ` David Sterba
2013-10-22 17:22 ` Al Viro [this message]
2013-10-22 17:39   ` Al Viro
2013-10-22 20:41   ` Al Viro
2013-10-22 21:07     ` Josef Bacik
2013-10-22 21:22   ` Zach Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131022172249.GV13318@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=pmdhazy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).