public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH resend] Fix reading of bitmaps from filesystem image
@ 2008-01-09 19:54 Jan Kara
  2008-01-14 15:57 ` Theodore Tso
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2008-01-09 19:54 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4

  Hi Ted,

  I've sent you the attached fix some time ago but it didn't seem to get
merged yet...
								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR
---

Subject: Fix reading of bitmaps from filesystem image

Reading of bitmaps from image file could never work with more than one
group in a filesystem... Fix the loops so that we read appropriate number
of blocks.

Signed-off-by: Jan Kara <jack@suse.cz>

diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 1897ec3..abbe5e8 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -190,7 +190,7 @@ static errcode_t read_bitmaps(ext2_filsy
 	if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
 		blk = (fs->image_header->offset_inodemap / fs->blocksize);
 		ino_cnt = fs->super->s_inodes_count;
-		while (inode_nbytes > 0) {
+		while (do_inode && ino_cnt > 0) {
 			retval = io_channel_read_blk(fs->image_io, blk++,
 						     1, inode_bitmap);
 			if (retval)
@@ -202,15 +202,14 @@ static errcode_t read_bitmaps(ext2_filsy
 					       ino_itr, cnt, inode_bitmap);
 			if (retval)
 				goto cleanup;
-			ino_itr += fs->blocksize << 3;
-			ino_cnt -= fs->blocksize << 3;
-			inode_nbytes -= fs->blocksize;
+			ino_itr += cnt;
+			ino_cnt -= cnt;
 		}
 		blk = (fs->image_header->offset_blockmap /
 		       fs->blocksize);
 		blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * 
 			fs->group_desc_count;
-		while (block_nbytes > 0) {
+		while (do_block && blk_cnt > 0) {
 			retval = io_channel_read_blk(fs->image_io, blk++,
 						     1, block_bitmap);
 			if (retval)
@@ -222,9 +221,8 @@ static errcode_t read_bitmaps(ext2_filsy
 				       blk_itr, cnt, block_bitmap);
 			if (retval)
 				goto cleanup;
-			blk_itr += fs->blocksize << 3;
-			blk_cnt -= fs->blocksize << 3;
-			block_nbytes -= fs->blocksize;
+			blk_itr += cnt;
+			blk_cnt -= cnt;
 		}
 		goto success_cleanup;
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH resend] Fix reading of bitmaps from filesystem image
  2008-01-09 19:54 [PATCH resend] Fix reading of bitmaps from filesystem image Jan Kara
@ 2008-01-14 15:57 ` Theodore Tso
  2008-01-14 16:17   ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Tso @ 2008-01-14 15:57 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Wed, Jan 09, 2008 at 08:54:35PM +0100, Jan Kara wrote:
> 
> Reading of bitmaps from image file could never work with more than one
> group in a filesystem... Fix the loops so that we read appropriate number
> of blocks.

OK, so I'm probably being dense, but.... what's the problem?

You changed the loop from counting in bytes to inodes, but either
method should work.

						- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH resend] Fix reading of bitmaps from filesystem image
  2008-01-14 15:57 ` Theodore Tso
@ 2008-01-14 16:17   ` Jan Kara
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2008-01-14 16:17 UTC (permalink / raw)
  To: Theodore Tso; +Cc: linux-ext4

On Mon 14-01-08 10:57:18, Theodore Tso wrote:
> On Wed, Jan 09, 2008 at 08:54:35PM +0100, Jan Kara wrote:
> > 
> > Reading of bitmaps from image file could never work with more than one
> > group in a filesystem... Fix the loops so that we read appropriate number
> > of blocks.
> 
> OK, so I'm probably being dense, but.... what's the problem?
> 
> You changed the loop from counting in bytes to inodes, but either
> method should work.
  At the beginning of read_bitmap() there is:
        unsigned int block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
        unsigned inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;

  Therefore in the loop:
     while (inode_nbytes > 0)

  we end up reading bitmap for just one group...

										Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-14 16:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09 19:54 [PATCH resend] Fix reading of bitmaps from filesystem image Jan Kara
2008-01-14 15:57 ` Theodore Tso
2008-01-14 16:17   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox