All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Daniel.E.Messinger@seagate.com, tomof@acm.org,
	linux-scsi@vger.kernel.org
Subject: Re: bidi bsg is non-blocking
Date: Tue, 8 May 2007 14:21:34 +0200	[thread overview]
Message-ID: <20070508122134.GI4163@kernel.dk> (raw)
In-Reply-To: <20070508163138G.fujita.tomonori@lab.ntt.co.jp>

On Tue, May 08 2007, FUJITA Tomonori wrote:
> > From: Daniel.E.Messinger@seagate.com
> > Subject: bidi bsg is non-blocking
> > Date: Mon, 7 May 2007 10:21:18 -0500
> > 
> > > I'm attempting to use the bidi variant of bsg to talk to an OSD target
> > > device. I've run into an undesirable situation.
> > > 
> > > My application has a free-running receive loop (doing a read() on the bsg
> > > device) waiting for responses to commands sent to bsg by another thread.
> > > The problem is that the receive thread is getting ENODATA from the read()
> > > when there are no commands pending.  I have NOT set non-blocking.
> > > 
> > > Note that the old sg driver was quite willing to block until there was a
> > > response available. I find this scenario greatly preferable.
> > > 
> > > Could bsg be fixed so that read() blocks when there is nothing to return?
> > 
> > I think that this is a bug.
> > 
> > This patch is against the bsg branch in the Jens' git tree.
> > 
> > I guess that it would be nice to do more cleanups on these parts.
> > 
> > 
> > From 52a9fcf0af72f212ddd93918b7f9f0f0e706c215 Mon Sep 17 00:00:00 2001
> > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > Date: Tue, 8 May 2007 15:57:43 +0900
> > Subject: [PATCH] fix read ENODATA bug
> > 
> > This patch fixes a bug that read() gives ENODATA even with a blocking
> > file descriptor when there are no commands pending.
> > 
> > This also includes some cleanups.
> > 
> > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> 
> Oops, I sent a wrong patch. This is a right one.

Patch looks good, I agree this is the way that bsg should act for a
blocking read on an "empty" queue.

> +		ret = wait_event_interruptible(bd->wq_done, bd->done_cmds);
> +		if (ret) {
> +			bc = ERR_PTR(-ERESTARTSYS);
> +			break;
> +		} else
> +			continue;
>  	} while (1);

The else clause is pointless.

Apart from that, it looks sounds. Can you resend?

-- 
Jens Axboe


  reply	other threads:[~2007-05-08 12:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-07 15:21 bidi bsg is non-blocking Daniel.E.Messinger
2007-05-08  7:23 ` FUJITA Tomonori
2007-05-08  7:31   ` FUJITA Tomonori
2007-05-08 12:21     ` Jens Axboe [this message]
2007-05-08 12:56       ` FUJITA Tomonori
2007-05-08 13:00         ` Jens Axboe
2007-05-08 13:30           ` FUJITA Tomonori

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=20070508122134.GI4163@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=Daniel.E.Messinger@seagate.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tomof@acm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.