lkml.org 
[lkml]   [2012]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 10/22] dio: add sdio_init() helper function
Date
From: Zach Brown <zab@zabbo.net>

This adds a helper function which initializes the sdio structure.
We'll be calling this from another entry point in an upcoming patch.

Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Cc: Zach Brown <zab@zabbo.net>
---
fs/direct-io.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1fbb4ab..1efe4f1 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1137,6 +1137,27 @@ static struct dio *dio_alloc_init(int flags, int rw, struct kiocb *iocb,
return dio;
}

+static void sdio_init(struct dio_submit *sdio, struct inode *inode,
+ loff_t offset, unsigned blkbits, get_block_t get_block,
+ dio_submit_t *submit_io)
+{
+ sdio->blkbits = blkbits;
+ sdio->blkfactor = inode->i_blkbits - blkbits;
+ sdio->block_in_file = offset >> blkbits;
+
+ sdio->get_block = get_block;
+ sdio->submit_io = submit_io;
+ sdio->final_block_in_bio = -1;
+ sdio->next_block_for_io = -1;
+
+ /*
+ * In case of non-aligned buffers, we may need 2 more
+ * pages since we need to zero out first and last block.
+ */
+ if (unlikely(sdio->blkfactor))
+ sdio->pages_in_io = 2;
+}
+
/*
* This is a library function for use by filesystem drivers.
*
@@ -1229,21 +1250,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,

retval = 0;

- sdio.blkbits = blkbits;
- sdio.blkfactor = inode->i_blkbits - blkbits;
- sdio.block_in_file = offset >> blkbits;
-
- sdio.get_block = get_block;
- sdio.submit_io = submit_io;
- sdio.final_block_in_bio = -1;
- sdio.next_block_for_io = -1;
-
- /*
- * In case of non-aligned buffers, we may need 2 more
- * pages since we need to zero out first and last block.
- */
- if (unlikely(sdio.blkfactor))
- sdio.pages_in_io = 2;
+ sdio_init(&sdio, inode, offset, blkbits, get_block, submit_io);

for (seg = 0; seg < nr_segs; seg++) {
user_addr = (unsigned long)iov[seg].iov_base;
--
1.7.9.2


\
 
 \ /
  Last update: 2012-02-27 22:27    [W:0.191 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site