From: David Woodhouse Subject: Re: [PATCH 0/7] Discard requests, v2 Date: Tue, 12 Aug 2008 12:16:37 +0100 Message-ID: <1218539797.2977.147.camel@pmac.infradead.org> References: <1218299181.26926.88.camel@pmac.infradead.org> <20080812091446.GF20055@kernel.dk> <1218535205.2977.131.camel@pmac.infradead.org> <20080812105428.GG20055@kernel.dk> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andrew Morton , Ric Wheeler , linux-fsdevel@vger.kernel.org, gilad@codefidence.com, matthew@wil.cx To: Jens Axboe Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:39967 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbYHLLRV (ORCPT ); Tue, 12 Aug 2008 07:17:21 -0400 In-Reply-To: <20080812105428.GG20055@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, 2008-08-12 at 12:54 +0200, Jens Axboe wrote: > The easy fix is would just be to > change init_request_from_bio() to do something ala: > > if (bio_barrier(bio)) { > if (bio_has_data(bio)) > req->cmd_flags |= REQ_HARDBARRIER; > else > req->cmd_flags |= REQ_SOFTBARRIER; > } > > since there's no real data dependency when you don't have data > attached. There's a check in __make_request() which will return -EOPNOTSUPP for bios with BIO_RW_BARRIER set, in some circumstances. Is that OK too? I was thinking of using the READ/WRITE bit for it -- just (1<cmd_flags |= (REQ_HARDBARRIER | REQ_NOMERGE); if (unlikely(bio_discard(bio))) { req->cmd_flags |= REQ_DISCARD; + /* + * READ discard requests are soft barriers; WRITE + * indicates the file system will take care of that + * for itself. + */ + if (!bio_data_dir(bio)) + req->cmd_flags |= REQ_SOFTBARRIER; req->q->prepare_discard_fn(req->q, req); } diff --git a/include/linux/fs.h b/include/linux/fs.h index 88358ca..5cfacb3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -87,7 +87,8 @@ extern int dir_notify_enable; #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) #define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) #define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER)) -#define WRITE_DISCARD (WRITE | (1 << BIO_RW_DISCARD)) +#define DISCARD_NOBARRIER (WRITE | (1 << BIO_RW_DISCARD)) +#define DISCARD_BARRIER (1 << BIO_RW_DISCARD) #define SEL_IN 1 #define SEL_OUT 2 -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation