linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Erez Zilber <erezzi.list@gmail.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Should a block device enforce block atomicity?
Date: Mon, 30 Jun 2008 08:55:25 +0200	[thread overview]
Message-ID: <20080630065525.GI20826@kernel.dk> (raw)
In-Reply-To: <ce513bcc0806292351t7f4ad933l920112381f4ebb4@mail.gmail.com>

On Mon, Jun 30 2008, Erez Zilber wrote:
> Hi,
> 
> I have a question about block devices and whether they are required to
> enforce block atomicity:
> 
> I read the code of drivers/block/brd.c, and I didn't see any locking
> when blocks are read/written. I also looked at the block layer code
> that calls brd and didn't find any locking there. Does it mean that
> there's no block atomicity (i.e. multiple threads can write a single
> block at the same time)? Is there any hidden assumption here? Is this
> the responsibility of the application to do that (e.g. not start a
> WRITE request before other READ/WRITE requests to the same block were
> completed)?

The block layer doesn't give such guarentees, not for "regular" block
devices either. If the IO goes through the page cache then that will
serialize IO to a given page, but with eg O_DIRECT IO, you could have
the same block in flight several times. So if you are doing raw IO, the
application has to ensure ordering of the same block.

-- 
Jens Axboe


  reply	other threads:[~2008-06-30  6:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30  6:51 Should a block device enforce block atomicity? Erez Zilber
2008-06-30  6:55 ` Jens Axboe [this message]
2008-06-30  7:58   ` Erez Zilber
2008-06-30  8:24     ` Boaz Harrosh
2008-06-30  8:47       ` Zhao Forrest
2008-06-30  8:55         ` Jens Axboe

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=20080630065525.GI20826@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=erezzi.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.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).