linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saugata Das <saugata.das@stericsson.com>
To: <linux-ext4@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<linux-mmc@vger.kernel.org>
Cc: <patches@linaro.org>, <venkat@linaro.org>,
	Saugata Das <saugata.das@linaro.org>
Subject: [PATCH 2/3] ext4: Context support
Date: Mon, 11 Jun 2012 16:16:01 +0530	[thread overview]
Message-ID: <1339411562-17100-2-git-send-email-saugata.das@stericsson.com> (raw)
In-Reply-To: <1339411562-17100-1-git-send-email-saugata.das@stericsson.com>

From: Saugata Das <saugata.das@linaro.org>

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 <saugata.das@linaro.org>
---
 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;
 
-- 
1.7.4.3


  reply	other threads:[~2012-06-11 10:46 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-11 10:46 [PATCH 1/3] block: Context support Saugata Das
2012-06-11 10:46 ` Saugata Das [this message]
2012-06-11 11:41   ` [PATCH 2/3] ext4: " Artem Bityutskiy
2012-06-11 12:27     ` Ted Ts'o
2012-06-12 12:21       ` Saugata Das
2012-06-12 12:32         ` Ted Ts'o
2012-06-12 13:29         ` Arnd Bergmann
2012-06-12 14:26           ` Saugata Das
2012-06-12 14:55             ` Arnd Bergmann
2012-06-12 18:19               ` Ted Ts'o
2012-06-12 20:07                 ` Arnd Bergmann
2012-06-12 20:41                   ` Ted Ts'o
2012-06-13 19:44                     ` Arnd Bergmann
2012-06-13 20:00                       ` Ted Ts'o
2012-06-13 20:43                         ` Arnd Bergmann
2012-06-14  2:07                           ` Ted Ts'o
2012-06-14 16:14                             ` Nicolas Pitre
2012-06-14 16:24                               ` Artem Bityutskiy
2012-06-14 17:05                               ` Ted Ts'o
2012-06-14 19:08                                 ` Nicolas Pitre
2012-06-15  9:19                                   ` Arnd Bergmann
2012-06-15 21:30                                     ` Ted Ts'o
2012-06-16  6:49                                       ` Arnd Bergmann
2012-06-14 21:55                             ` Arnd Bergmann
2012-06-15  5:18                               ` Andreas Dilger
2012-06-15  9:25                                 ` Arnd Bergmann
2012-06-15  9:40                                   ` Andreas Dilger
2012-06-15 10:54                                     ` Arnd Bergmann
2012-06-15 22:04                               ` Ted Ts'o
2012-06-15 22:25                                 ` Andreas Dilger
2012-06-16  7:14                                   ` Arnd Bergmann
2012-06-16  7:28                                     ` Arnd Bergmann
2012-06-16  7:26                                 ` Arnd Bergmann
2012-06-16 13:49                                   ` Ted Ts'o
2012-06-16 17:41                                     ` Arnd Bergmann
2012-06-18 17:42                                       ` Ted Ts'o
2012-06-19 15:17                                         ` Arnd Bergmann
2012-06-20 15:09                                           ` Luca Porzio (lporzio)
2012-06-20 15:46                                             ` Arnd Bergmann
2012-06-22 13:29                       ` Artem Bityutskiy
2012-06-22 14:07                         ` Luca Porzio (lporzio)
2012-06-11 10:46 ` [PATCH 3/3] mmc: " Saugata Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1339411562-17100-2-git-send-email-saugata.das@stericsson.com \
    --to=saugata.das@stericsson.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=saugata.das@linaro.org \
    --cc=venkat@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).