From: Eric Sandeen <sandeen@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
rjones@redhat.com, sami.liedes@iki.fi
Subject: Re: [PATCH 1/3] libext2fs: add 32-bit compat code for ext2fs_find_first_zero_generic_bmap()
Date: Mon, 09 Apr 2012 09:14:41 -0700 [thread overview]
Message-ID: <4F830AF1.9090501@redhat.com> (raw)
In-Reply-To: <1333738746-5857-1-git-send-email-tytso@mit.edu>
On 4/6/12 11:59 AM, Theodore Ts'o wrote:
> The lack of 32-bit support was causing febootstrap to crash since it
> wasn't passing EXT2_FLAG_64BITS when opening the file system, so we
> were still using the legacy bitmaps.
Thanks Ted, these look good (and similar to the patch path I was going down)
-Eric
> Addresses-Red-Hat-Bugzilla: #808421
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
> lib/ext2fs/ext2fs.h | 3 +++
> lib/ext2fs/gen_bitmap.c | 25 +++++++++++++++++++++++++
> lib/ext2fs/gen_bitmap64.c | 32 ++++++++++++++++++++++++++++----
> 3 files changed, 56 insertions(+), 4 deletions(-)
>
> diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> index 68e94a3..fda6ade 100644
> --- a/lib/ext2fs/ext2fs.h
> +++ b/lib/ext2fs/ext2fs.h
> @@ -1169,6 +1169,9 @@ extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
> errcode_t magic,
> __u32 start, __u32 num,
> void *in);
> +extern errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
> + __u32 start, __u32 end,
> + __u32 *out);
>
> /* gen_bitmap64.c */
>
> diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c
> index 6679bff..0bff854 100644
> --- a/lib/ext2fs/gen_bitmap.c
> +++ b/lib/ext2fs/gen_bitmap.c
> @@ -504,6 +504,30 @@ static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap,
> return ext2fs_mem_is_zero(ADDR + start_byte, len_byte);
> }
>
> +errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
> + __u32 start, __u32 end,
> + __u32 *out)
> +{
> + blk_t b;
> +
> + if (start < bitmap->start || end > bitmap->end || start > end) {
> + ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
> + return EINVAL;
> + }
> +
> + while (start <= end) {
> + b = ext2fs_test_bit(start - bitmap->start, bitmap->bitmap);
> + if (!b) {
> + *out = start;
> + return 0;
> + }
> + start++;
> + }
> +
> + return ENOENT;
> +}
> +
> +
> int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
> blk_t block, int num)
> {
> @@ -558,3 +582,4 @@ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
> ext2fs_fast_clear_bit(block + i - bitmap->start,
> bitmap->bitmap);
> }
> +
> diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
> index e765d2c..07d6d52 100644
> --- a/lib/ext2fs/gen_bitmap64.c
> +++ b/lib/ext2fs/gen_bitmap64.c
> @@ -770,12 +770,36 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
> {
> int b;
>
> - if (bitmap->bitmap_ops->find_first_zero)
> - return bitmap->bitmap_ops->find_first_zero(bitmap, start, end, out);
> + if (!bitmap)
> + return EINVAL;
>
> - if (!bitmap || !EXT2FS_IS_64_BITMAP(bitmap) || bitmap->cluster_bits)
> + if (EXT2FS_IS_64_BITMAP(bitmap) && bitmap->bitmap_ops->find_first_zero)
> + return bitmap->bitmap_ops->find_first_zero(bitmap, start,
> + end, out);
> +
> + if (EXT2FS_IS_32_BITMAP(bitmap)) {
> + blk_t blk = 0;
> + errcode_t retval;
> +
> + if (((start) & ~0xffffffffULL) ||
> + ((end) & ~0xffffffffULL)) {
> + ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
> + return EINVAL;
> + }
> +
> + retval = ext2fs_find_first_zero_generic_bitmap(bitmap, start,
> + end, &blk);
> + if (retval == 0)
> + *out = blk;
> + return retval;
> + }
> +
> + if (!EXT2FS_IS_64_BITMAP(bitmap))
> return EINVAL;
>
> + start >>= bitmap->cluster_bits;
> + end >>= bitmap->cluster_bits;
> +
> if (start < bitmap->start || end > bitmap->end || start > end) {
> warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
> return EINVAL;
> @@ -784,7 +808,7 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
> while (start <= end) {
> b = bitmap->bitmap_ops->test_bmap(bitmap, start);
> if (!b) {
> - *out = start;
> + *out = start << bitmap->cluster_bits;
> return 0;
> }
> start++;
next prev parent reply other threads:[~2012-04-09 16:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 12:57 Commit c1a1e7fc24d6 causes segfault in ext2fs_new_inode Richard W.M. Jones
2012-03-30 13:19 ` Richard W.M. Jones
2012-03-30 19:38 ` Eric Sandeen
2012-03-30 22:25 ` Eric Sandeen
2012-04-06 19:14 ` Sami Liedes
2012-04-06 19:19 ` Eric Sandeen
2012-04-06 19:31 ` Eric Sandeen
2012-04-06 19:47 ` Sami Liedes
2012-04-06 19:49 ` Eric Sandeen
2012-04-06 19:22 ` Richard W.M. Jones
2012-04-06 20:06 ` Ted Ts'o
2012-04-06 18:57 ` Ted Ts'o
2012-04-06 18:59 ` [PATCH 1/3] libext2fs: add 32-bit compat code for ext2fs_find_first_zero_generic_bmap() Theodore Ts'o
2012-04-06 18:59 ` [PATCH 2/3] libext2fs: use correct types in ext2fs_find_first_zero_block_bitmap2() Theodore Ts'o
2012-04-06 18:59 ` [PATCH 3/3] libext2fs: improve testing coverage of tst_bitmaps Theodore Ts'o
2012-04-09 16:14 ` Eric Sandeen [this message]
2012-04-05 3:56 ` Commit c1a1e7fc24d6 causes segfault in ext2fs_new_inode Eric Sandeen
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=4F830AF1.9090501@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=rjones@redhat.com \
--cc=sami.liedes@iki.fi \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.