From: Cyril Hrubis <chrubis@suse.cz>
To: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Cc: vasily.isaenko@oracle.com, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] detach_device: Wait until the kernel frees the loop device
Date: Wed, 10 Jun 2015 12:08:45 +0200 [thread overview]
Message-ID: <20150610100845.GA31366@rei.suse.de> (raw)
In-Reply-To: <1433923871-10933-1-git-send-email-stanislav.kholmanskikh@oracle.com>
Hi!
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
> lib/tst_device.c | 17 ++++++-----------
> 1 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/lib/tst_device.c b/lib/tst_device.c
> index 3bded53..9a92fc8 100644
> --- a/lib/tst_device.c
> +++ b/lib/tst_device.c
> @@ -150,30 +150,25 @@ static void attach_device(void (*cleanup_fn)(void),
>
> static void detach_device(void (*cleanup_fn)(void), const char *dev)
> {
> - int dev_fd, err, i;
> + int dev_fd, ret, i;
>
> dev_fd = SAFE_OPEN(cleanup_fn, dev, O_RDONLY);
>
> - /* keep trying to clear LOOPDEV fd if EBUSY, a quick succession
> + /* keep trying to clear LOOPDEV until we get ENXIO, a quick succession
> * of attach/detach might not give udev enough time to complete */
> for (i = 0; i < 40; i++) {
> - if (ioctl(dev_fd, LOOP_CLR_FD, 0) == 0) {
> + ret = ioctl(dev_fd, LOOP_CLR_FD, 0);
> +
> + if (ret && (errno == ENXIO)) {
> close(dev_fd);
> return;
> }
> - if (errno != EBUSY) {
> - err = errno;
> - close(dev_fd);
> - tst_brkm(TBROK, cleanup_fn,
> - "ioctl(%s, LOOP_CLR_FD, 0) failed: %s",
> - dev, tst_strerrno(err));
> - }
I would be a bit more verbose and would print an TINFO or TWARN message
if we get error different from the expected EBUSY or ENXIO.
Otherwise it looks fine, acked.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2015-06-10 10:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1433923871-10933-1-git-send-email-stanislav.kholmanskikh@oracle.com>
2015-06-10 8:16 ` [LTP] [PATCH] detach_device: Wait until the kernel frees the loop device Stanislav Kholmanskikh
2015-06-10 10:08 ` Cyril Hrubis [this message]
[not found] ` <55780FC7.1090100@oracle.com>
2015-06-10 10:24 ` Cyril Hrubis
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=20150610100845.GA31366@rei.suse.de \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=stanislav.kholmanskikh@oracle.com \
--cc=vasily.isaenko@oracle.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