From patchwork Wed May 16 15:30:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saugata Das X-Patchwork-Id: 159690 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C62FFB6FB4 for ; Thu, 17 May 2012 01:31:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755480Ab2EPPbQ (ORCPT ); Wed, 16 May 2012 11:31:16 -0400 Received: from eu1sys200aog118.obsmtp.com ([207.126.144.145]:58664 "EHLO eu1sys200aog118.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754367Ab2EPPbM (ORCPT ); Wed, 16 May 2012 11:31:12 -0400 Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKT7PIOMBIIH11hBm8QLMG2Je40zz26V6S@postini.com; Wed, 16 May 2012 15:31:10 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id C4DC3C0; Wed, 16 May 2012 15:22:39 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 690E924C; Wed, 16 May 2012 15:31:00 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 8F97F24C080; Wed, 16 May 2012 17:30:51 +0200 (CEST) Received: from localhost (10.201.54.119) by exdcvycastm022.EQ1STM.local (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 16 May 2012 17:31:00 +0200 From: Saugata Das To: , , Cc: , , Subject: [RFC 1/3] block: Context support Date: Wed, 16 May 2012 21:00:28 +0530 Message-ID: <1337182230-11839-1-git-send-email-saugata.das@stericsson.com> X-Mailer: git-send-email 1.7.4.3 MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Saugata Das On eMMC and UFS devices there is a new feature of setting context with each read or write. The idea is to classify the data from different files and apply the realibility on the complete file instead of individual writes, which helps in performance. A new address space operation has been a added to get the context from file system and set up the bi_context field in bio. Then we need to ensure that bio from different contexts are not merged. The context is then passed to the underlying driver as part of the read or write request. Since the number of MMC contexts is limited, multiple file system contexts are mapped to single MMC context. Signed-off-by: Saugata Das --- block/blk-core.c | 1 + block/blk-merge.c | 3 +++ fs/mpage.c | 12 ++++++++++++ include/linux/blk_types.h | 1 + include/linux/blkdev.h | 1 + include/linux/buffer_head.h | 2 ++ include/linux/fs.h | 1 + 7 files changed, 21 insertions(+), 0 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 1f61b74..274e05d 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1309,6 +1309,7 @@ void init_request_from_bio(struct request *req, struct bio *bio) req->errors = 0; req->__sector = bio->bi_sector; req->ioprio = bio_prio(bio); + req->context = bio->bi_context; blk_rq_bio_prep(req->q, req, bio); } diff --git a/block/blk-merge.c b/block/blk-merge.c index 160035f..ed70d56 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -497,6 +497,9 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) if (bio_integrity(bio) != blk_integrity_rq(rq)) return false; + if (bio->bi_context != rq->bio->bi_context) + return false; + return true; } diff --git a/fs/mpage.c b/fs/mpage.c index 0face1c..4889842 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -293,6 +293,12 @@ alloc_new: goto confused; } + if (page && page->mapping && page->mapping->a_ops && + page->mapping->a_ops->get_context) + bio->bi_context = page->mapping->a_ops->get_context(page); + else + bio->bi_context = 0; + length = first_hole << blkbits; if (bio_add_page(bio, page, length, 0) < length) { bio = mpage_bio_submit(READ, bio); @@ -581,6 +587,12 @@ alloc_new: goto confused; } + if (page && page->mapping && page->mapping->a_ops && + page->mapping->a_ops->get_context) + bio->bi_context = page->mapping->a_ops->get_context(page); + else + bio->bi_context = 0; + /* * Must try to add the page before marking the buffer clean or * the confused fail path above (OOM) will be very confused when diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 4053cbd..f3ac448 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -42,6 +42,7 @@ struct bio { unsigned short bi_vcnt; /* how many bio_vec's */ unsigned short bi_idx; /* current index into bvl_vec */ + unsigned long bi_context; /* context of this bio */ /* Number of segments in this BIO after * physical address coalescing is performed. diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2aa2466..0dd9a08 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -167,6 +167,7 @@ struct request { struct list_head timeout_list; unsigned int timeout; int retries; + unsigned long context; /* context of this request */ /* * completion callback. diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 13bba17..0776564 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -72,6 +72,8 @@ struct buffer_head { struct list_head b_assoc_buffers; /* associated with another mapping */ struct address_space *b_assoc_map; /* mapping this buffer is associated with */ + unsigned long b_context; /* context for this buffer within the + storage device */ atomic_t b_count; /* users using this buffer_head */ }; diff --git a/include/linux/fs.h b/include/linux/fs.h index 8de6755..4b379d8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -626,6 +626,7 @@ struct address_space_operations { int (*is_partially_uptodate) (struct page *, read_descriptor_t *, unsigned long); int (*error_remove_page)(struct address_space *, struct page *); + int (*get_context)(struct page *); }; extern const struct address_space_operations empty_aops;