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: 164120 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 49E9FB701D for ; Mon, 11 Jun 2012 20:46:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753405Ab2FKKqg (ORCPT ); Mon, 11 Jun 2012 06:46:36 -0400 Received: from eu1sys200aog120.obsmtp.com ([207.126.144.149]:38399 "EHLO eu1sys200aog120.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752192Ab2FKKqd (ORCPT ); Mon, 11 Jun 2012 06:46:33 -0400 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 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. 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;