block: introduce REQ_FLUSH flag
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Sat, 3 Jul 2010 08:45:32 +0000 (17:45 +0900)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:23:53 +0000 (18:23 +0200)
SCSI-ml needs a way to mark a request as flush request in
q->prepare_flush_fn because it needs to identify them later (e.g. in
q->request_fn or prep_rq_fn).

queue_flush sets REQ_HARDBARRIER in rq->cmd_flags however the block
layer also sends normal REQ_TYPE_FS requests with REQ_HARDBARRIER. So
SCSI-ml can't use REQ_HARDBARRIER to identify flush requests.

We could change the block layer to clear REQ_HARDBARRIER bit before
sending non flush requests to the lower layers. However, intorudcing
the new flag looks cleaner (surely easier).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James Bottomley <James.Bottomley@suse.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Alasdair G Kergon <agk@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
block/blk-barrier.c
include/linux/bio.h

index 7c6f4a714687e177a14123887fce87f3a337bbec..a3482425c507a0b1217ea04de663adc409140fc5 100644 (file)
@@ -143,7 +143,7 @@ static void queue_flush(struct request_queue *q, unsigned which)
        }
 
        blk_rq_init(q, rq);
-       rq->cmd_flags = REQ_HARDBARRIER;
+       rq->cmd_flags = REQ_HARDBARRIER | REQ_FLUSH;
        rq->rq_disk = q->bar_rq.rq_disk;
        rq->end_io = end_io;
        q->prepare_flush_fn(q, rq);
index 4d379c8250aea32d9fd21b0331a3aab9d9e85923..f655b54c9ef3c9732ad1dbe21b18a7620678e4b1 100644 (file)
@@ -174,6 +174,7 @@ enum rq_flag_bits {
        __REQ_ALLOCED,          /* request came from our alloc pool */
        __REQ_COPY_USER,        /* contains copies of user pages */
        __REQ_INTEGRITY,        /* integrity metadata has been remapped */
+       __REQ_FLUSH,            /* request for cache flush */
        __REQ_IO_STAT,          /* account I/O stat */
        __REQ_MIXED_MERGE,      /* merge of different types, fail separately */
        __REQ_NR_BITS,          /* stops here */
@@ -213,6 +214,7 @@ enum rq_flag_bits {
 #define REQ_ALLOCED            (1 << __REQ_ALLOCED)
 #define REQ_COPY_USER          (1 << __REQ_COPY_USER)
 #define REQ_INTEGRITY          (1 << __REQ_INTEGRITY)
+#define REQ_FLUSH              (1 << __REQ_FLUSH)
 #define REQ_IO_STAT            (1 << __REQ_IO_STAT)
 #define REQ_MIXED_MERGE                (1 << __REQ_MIXED_MERGE)