mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ajith Kumar <ajithb.kumar@gmail.com>
To: fa.linux.kernel@googlegroups.com
Cc: ajithb.kumar@gmail.com, linux-kernel@vger.kernel.org,
	Jens Axboe <jaxboe@fusionio.com>
Subject: Re: [block] allow blk_flush_policy to return REQ_FSEQ_DATA independent of *FLUSH
Date: Sat, 12 Jan 2013 23:01:02 -0800 (PST)	[thread overview]
Message-ID: <eaf37464-ae9d-4192-9044-2b2d90906a17@googlegroups.com> (raw)
In-Reply-To: <f419d12f-2594-43c3-b894-f4d4c21a3166@googlegroups.com>

Hello,
Re-reading the code, I see that I was wrong with the previous comment of mine.  So, in summary

i) If block driver does not support FLUSH and FUA, then __generic_make_request() checks will clear BIO FLUSH and FUA flags and hence blk_insert_flush() will not be invoked.

ii) If block driver clears FLUSH & FUA flags while IO is in flight, then there is possibility of IO missing __generic_make_request() checks and hitting issue with blk_insert_flush() being discussed here.

iii) If block driver sets only REQ_FUA without REQ_FLUSH then __generic_make_request() checks will not clear BIO flags and hence blk_insert_flush() will be invoked which will hit the blk_insert_flush() issue being discussed here.  However, setting REQ_FUA without REQ_FLUSH is not as per documentation and it is invalid for block driver to do so.

Thanks,
Ajith

On Wednesday, 9 January 2013 09:44:55 UTC+5:30, Ajith Kumar  wrote:
> Hello,
> 
> Thanks for the response.
> 
> A block device driver during initialization would decide if it is capable of supporting FLUSH/FUA or not.  Suppose driver claims FLUSH/FUA support then any bio targeted at this driver with FLUSH bit set(which is commonly set by file system like XFS for doing internal logging) has a data corruption vulnerability in case of an abrupt shutdown.  So, IMO the vulnerability is not open to rare window where driver changes q->flush_flags while IO is in flight, but for a much larger window from time driver comes up and throughout it's life.
> 
> 
> 
> Thanks,
> 
> Ajith
> 
> 
> 
> On Wednesday, 9 January 2013 00:15:31 UTC+5:30, Tejun Heo  wrote:
> 
> > Hello,
> 
> > 
> 
> > 
> 
> > 
> 
> > On Tue, Jan 08, 2013 at 10:04:23AM -0800, ajithb.kumar@gmail.com wrote:
> 
> > 
> 
> > > Hi,
> 
> > 
> 
> > > Could you please provide clarity on the following.
> 
> > 
> 
> > > ">   Hmmm... yes, this can become a correctness issue if (and only if)
> 
> > 
> 
> > > >   blk_queue_flush() is called to change q->flush_flags while requests
> 
> > 
> 
> > > >   are in-flight;"
> 
> > 
> 
> > >
> 
> > 
> 
> > > Could you please clarify as to why is it a correctness issue only if
> 
> > 
> 
> > > blk_queue_flush() is used to change flush_flags when requests are in
> 
> > 
> 
> > > flight ?  As I understand, XFS does set WRITE_FLUSH_FUA flag in
> 
> > 
> 
> > > _xfs_buf_ioapply() function irrespective of whether the underlying
> 
> > 
> 
> > > device supports flush capabilities or not which will flow into
> 
> > 
> 
> > > blk_insert_flush().  Is my reading of the code correct and is there
> 
> > 
> 
> > > a general correctness issue here which potentially results in XFS
> 
> > 
> 
> > > file system corruption in case of an abrupt shutdown independent of
> 
> > 
> 
> > > q->flush_flags getting changed while request is in flight.
> 
> > 
> 
> > 
> 
> > 
> 
> > My memory is kinda fuzzy at this point but if a queue doesn't support
> 
> > 
> 
> > flush, its flush_flags should be zero and
> 
> > 
> 
> > generic_make_request_checks() will clear REQ_FLUSH|REQ_FUA from
> 
> > 
> 
> > bio->bi_rw so we never hit blk_insert_flush() and the request will be
> 
> > 
> 
> > processed as a normal IO one; however, if REQ_FLUSH goes off after a
> 
> > 
> 
> > request passed generic_make_request_checks() but before
> 
> > 
> 
> > blk_flush_policy(), it'll become null op and its data payload won't
> 
> > 
> 
> > get written out to the underlying device, which is data corruption.
> 
> > 
> 
> > 
> 
> > 
> 
> > Thanks.
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > tejun
> 
> > 
> 
> > --
> 
> > 
> 
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> 
> > 
> 
> > the body of a message to majordomo@vger.kernel.org
> 
> > 
> 
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> > 
> 
> > Please read the FAQ at  http://www.tux.org/lkml/


  reply	other threads:[~2013-01-13  7:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.Y0FHvNmq3PUOPFTOjxSNqjMULHc@ifi.uio.no>
     [not found] ` <fa.brRV/ZItJPfVkucfEAnS6B1Vfow@ifi.uio.no>
     [not found]   ` <fa.h/6oWR6kmOBuicuev7/0gdVAyU4@ifi.uio.no>
2013-01-09  4:14     ` Ajith Kumar
2013-01-13  7:01       ` Ajith Kumar [this message]
     [not found] <fa.WShHQz59YhGkw1sSCIqXCXLEJ3Q@ifi.uio.no>
2013-01-08 18:04 ` ajithb.kumar
2013-01-08 18:45   ` Tejun Heo
2011-08-09 15:24 Jeff Moyer
2011-08-09 18:29 ` 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=eaf37464-ae9d-4192-9044-2b2d90906a17@googlegroups.com \
    --to=ajithb.kumar@gmail.com \
    --cc=fa.linux.kernel@googlegroups.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®