From patchwork Mon Jun 11 10:46:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saugata Das X-Patchwork-Id: 9186 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9493623E4F for ; Mon, 11 Jun 2012 10:46:34 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 62EE1A1818A for ; Mon, 11 Jun 2012 10:46:34 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so2558876yen.11 for ; Mon, 11 Jun 2012 03:46:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=xyMFdshjJwx0850LjMwz4Owsoh+E2+RNnMc36Vmggks=; b=VztRMBycP19r2YTpjeU0/rZNYA5zDqdHlqZF8DOrZJ9PdphHQryY5PBFTN6E6ukiqa Qgya+8bhMWtu+mMU+YnzOaHXHF9DV/IIurcs1KnUzoO4omOsiAO0PPkaXlsMORg/z8GP O8SXihw5uRH79/Q4NaUqIFctq0ncP1y9vM/awP+jKgo49TRR4ECgtPe9T9o/B3+KQUvK SQiTvrf7wc4m2JuBmsxGSYs+aO5dpi9n5Ca11gaUxc68S75mvUyg8VOfp93nemghFbRm GD19hQRqz2EeBC1KGfMCneZ0hcAssY5BqZkJUE6smuVPhXL1mg4q8dVSZqr60iWL87C+ 7+Ew== Received: by 10.50.193.196 with SMTP id hq4mr5819956igc.57.1339411593989; Mon, 11 Jun 2012 03:46:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp100703ibb; Mon, 11 Jun 2012 03:46:33 -0700 (PDT) Received: by 10.14.119.138 with SMTP id n10mr1219058eeh.38.1339411592811; Mon, 11 Jun 2012 03:46:32 -0700 (PDT) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com. [207.126.144.149]) by mx.google.com with SMTP id f45si7307392eec.100.2012.06.11.03.46.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jun 2012 03:46:32 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of saugata.das@stericsson.com) client-ip=207.126.144.149; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of saugata.das@stericsson.com) smtp.mail=saugata.das@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKT9XMhhf8eXZeGeAbMvyJf5s3NGsb/H0L@postini.com; Mon, 11 Jun 2012 10:46:32 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 134A1E4; Mon, 11 Jun 2012 10:46:28 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BD35D2802; Mon, 11 Jun 2012 10:46:28 +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 6EF5D24C07D; Mon, 11 Jun 2012 12:46:22 +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; Mon, 11 Jun 2012 12:46:28 +0200 From: Saugata Das To: , , Cc: , , Saugata Das Subject: [PATCH 2/3] ext4: Context support Date: Mon, 11 Jun 2012 16:16:01 +0530 Message-ID: <1339411562-17100-2-git-send-email-saugata.das@stericsson.com> X-Mailer: git-send-email 1.7.4.3 In-Reply-To: <1339411562-17100-1-git-send-email-saugata.das@stericsson.com> References: <1339411562-17100-1-git-send-email-saugata.das@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm57nt8/6OZqxG7fVrNvwUA7tcnZ+UUtYV+/pFwCX7o0b2nd1ysC67wb+02k9VDW+jx1mtv 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. On ext4 file system, the inode number of the file is passed as b_context in the bh structure during write and via the get_context callback function during read. Since number of MMC contexts is limited, multiple file system contexts are mapped to single MMC context. Signed-off-by: Saugata Das --- fs/ext4/inode.c | 33 +++++++++++++++++++++++++++++++++ fs/ext4/page-io.c | 1 + 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 754fe77..2667396 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -790,6 +790,21 @@ static int do_journal_get_write_access(handle_t *handle, return ret; } +/* Get the context of the buffer within the underlying storage device */ +static int ext4_get_context(struct page *page) +{ + if (page && page->mapping && page->mapping->host) + return page->mapping->host->i_ino; + else + return 0; +} + +static int ext4_set_buffer_context(handle_t *handle, struct buffer_head *bh) +{ + bh->b_context = ext4_get_context(bh->b_page); + return 0; +} + static int ext4_get_block_write(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create); static int ext4_write_begin(struct file *file, struct address_space *mapping, @@ -843,6 +858,11 @@ retry: from, to, NULL, do_journal_get_write_access); } + if (!ret && walk_page_buffers(NULL, page_buffers(page), + from, to, NULL, ext4_set_buffer_context)) { + ext4_warning(inode->i_sb, "Couldn't set context\n"); + } + if (ret) { unlock_page(page); page_cache_release(page); @@ -2394,8 +2414,11 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, pgoff_t index; struct inode *inode = mapping->host; handle_t *handle; + unsigned from, to; index = pos >> PAGE_CACHE_SHIFT; + from = pos & (PAGE_CACHE_SIZE - 1); + to = from + len; if (ext4_nonda_switch(inode->i_sb)) { *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; @@ -2444,6 +2467,12 @@ retry: if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) goto retry; + + if (walk_page_buffers(NULL, page_buffers(page), + from, to, NULL, ext4_set_buffer_context)) { + ext4_warning(inode->i_sb, "Couldn't set context\n"); + } + out: return ret; } @@ -3040,6 +3069,7 @@ static const struct address_space_operations ext4_ordered_aops = { .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .get_context = ext4_get_context, }; static const struct address_space_operations ext4_writeback_aops = { @@ -3055,6 +3085,7 @@ static const struct address_space_operations ext4_writeback_aops = { .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .get_context = ext4_get_context, }; static const struct address_space_operations ext4_journalled_aops = { @@ -3070,6 +3101,7 @@ static const struct address_space_operations ext4_journalled_aops = { .direct_IO = ext4_direct_IO, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .get_context = ext4_get_context, }; static const struct address_space_operations ext4_da_aops = { @@ -3086,6 +3118,7 @@ static const struct address_space_operations ext4_da_aops = { .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, + .get_context = ext4_get_context, }; void ext4_set_aops(struct inode *inode) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index dcdeef1..bf1381e 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -296,6 +296,7 @@ static int io_submit_init(struct ext4_io_submit *io, bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES)); bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio->bi_bdev = bh->b_bdev; + bio->bi_context = bh->b_context; bio->bi_private = io->io_end = io_end; bio->bi_end_io = ext4_end_bio;