linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: ksumrall@google.com, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 3/5] libext2fs: make read_bitmaps() more efficient when using direct I/O
Date: Mon,  7 May 2012 14:56:23 -0400	[thread overview]
Message-ID: <1336416985-24605-4-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1336416985-24605-1-git-send-email-tytso@mit.edu>

Read in a full block for each allocation bitmap, to avoid using a
kernel bounce buffer when using direct I/O.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ext2fs/rw_bitmaps.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 1d5f7b2..81e09c0 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -166,6 +166,9 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
+	if ((block_nbytes > fs->blocksize) || (inode_nbytes > fs->blocksize))
+		return EXT2_ET_CORRUPT_SUPERBLOCK;
+
 	fs->write_bitmaps = ext2fs_write_bitmaps;
 
 	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
@@ -186,7 +189,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 		if (do_image)
 			retval = ext2fs_get_mem(fs->blocksize, &block_bitmap);
 		else
-			retval = ext2fs_get_memalign((unsigned) block_nbytes,
+			retval = ext2fs_get_memalign(fs->blocksize,
 						     fs->blocksize,
 						     &block_bitmap);
 			
@@ -202,8 +205,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 		retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
 		if (retval)
 			goto cleanup;
-		retval = ext2fs_get_mem(do_image ? fs->blocksize :
-					(unsigned) inode_nbytes, &inode_bitmap);
+		retval = ext2fs_get_mem(fs->blocksize, &inode_bitmap);
 		if (retval)
 			goto cleanup;
 	} else
@@ -261,7 +263,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 				blk = 0;
 			if (blk) {
 				retval = io_channel_read_blk64(fs->io, blk,
-					     -block_nbytes, block_bitmap);
+							       1, block_bitmap);
 				if (retval) {
 					retval = EXT2_ET_BLOCK_BITMAP_READ;
 					goto cleanup;
@@ -283,7 +285,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 				blk = 0;
 			if (blk) {
 				retval = io_channel_read_blk64(fs->io, blk,
-					     -inode_nbytes, inode_bitmap);
+							       1, inode_bitmap);
 				if (retval) {
 					retval = EXT2_ET_INODE_BITMAP_READ;
 					goto cleanup;
-- 
1.7.10.rc3


  parent reply	other threads:[~2012-05-07 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07 18:56 [PATCH 0/5] Clean up I/O buffer allocation in e2fsprogs Theodore Ts'o
2012-05-07 18:56 ` [PATCH 1/5] libext2fs: move the alignment field from unix_io to the io_manager Theodore Ts'o
2012-05-07 18:56 ` [PATCH 2/5] libext2fs: refactor Direct I/O alignment requirement calculations Theodore Ts'o
2012-05-07 18:56 ` Theodore Ts'o [this message]
2012-05-07 18:56 ` [PATCH 4/5] libext2fs: factor out I/O buffer allocation Theodore Ts'o
2012-05-07 18:56 ` [PATCH 5/5] Support systems without posix_memalign() and memalign() Theodore Ts'o

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=1336416985-24605-4-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=ksumrall@google.com \
    --cc=linux-ext4@vger.kernel.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).