From: Gerd Hoffmann <kraxel@redhat.com>
To: Bandan Das <bsd@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring
Date: Fri, 13 Nov 2015 09:08:23 +0100 [thread overview]
Message-ID: <1447402103.1400.89.camel@redhat.com> (raw)
In-Reply-To: <jpgk2pmn8o8.fsf@linux.bootlegged.copy>
Hi,
> Maybe I am missing something but what if the watch on dir was
> added by qemu _after_ the file (say file1) was copied to it.
> Then, the kernel would generate events for file2, file3 and so on but
> never a CREATE event for file1. Isn't that a possibility ?
Yes.
> So, what I mean
> by that comment is that add a watchpoint soon enough but it could be
> possible that by the time the watch is added, a few files might have already
> been copied and will not generate events.
The readdir (in usb_mtp_object_readdir) will find them then.
While looking at the code: I think there is no need to add the watch
right away. We only read the directory when the guest actually requests
it. Watching the directories we actually have scanned due to the guest
requesting it should be enough.
So I think adding the inotify watch in usb_mtp_object_readdir should
work just fine. And the watch should be added before readdir to make
sure we don't miss anything.
File system events then can happen at three points in time: (a) before
we add the watch, (b) after we add the watch, and before readdir, and
(c) after readdir.
(a) we will see these files in the readdir call.
(b) we will see these files in the readdir call
*and* receive inotify events for them.
(c) we will only get events for them.
The (b) events look bogous at first glance (create events for files you
already have in the list, but also delete events for files you don't
have in your list).
cheers,
Gerd
next prev parent reply other threads:[~2015-11-13 8:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 0:00 [Qemu-devel] [PATCH 0/3] usb-mtp events support Bandan Das
2015-11-04 0:00 ` [Qemu-devel] [PATCH 1/3] usb-mtp: use a list for keeping track of children Bandan Das
2015-11-05 8:24 ` Gerd Hoffmann
2015-11-05 21:23 ` Bandan Das
2015-11-04 0:00 ` [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring Bandan Das
2015-11-05 8:37 ` Gerd Hoffmann
2015-11-05 21:28 ` Bandan Das
2015-11-05 8:49 ` Gerd Hoffmann
2015-11-09 23:12 ` Bandan Das
2015-11-09 23:28 ` Bandan Das
2015-11-12 8:16 ` Gerd Hoffmann
2015-11-12 22:40 ` Bandan Das
2015-11-13 8:08 ` Gerd Hoffmann [this message]
2015-11-05 8:49 ` Gerd Hoffmann
2015-11-09 23:13 ` Bandan Das
2015-11-04 0:00 ` [Qemu-devel] [PATCH 3/3] usb-mtp: add support for basic mtp events Bandan Das
2015-11-05 8:41 ` Gerd Hoffmann
2015-11-05 21:30 ` Bandan Das
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=1447402103.1400.89.camel@redhat.com \
--to=kraxel@redhat.com \
--cc=bsd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).