From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Introduce ext4_find_next_bit
Date: Fri, 21 Sep 2007 12:13:13 +0530 [thread overview]
Message-ID: <46F36801.3070908@linux.vnet.ibm.com> (raw)
In-Reply-To: <11903523063349-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Aneesh Kumar K.V wrote:
> Also add generic_find_next_le_bit
>
> This gets used by the ext4 multi block allocator patches.
>
Looks like it's a straight forward on Little Endian Architectures.
I see something for powerpc, what about other architectures?
>
> +unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned
> + long size, unsigned long offset)
> +{
Docbook style comments on the function and arguments would be nice.
> + const unsigned long *p = addr + BITOP_WORD(offset);
> + unsigned long result = offset & ~(BITS_PER_LONG - 1);
> + unsigned long tmp;
> +
> + if (offset >= size)
> + return size;
> + size -= result;
> + offset &= (BITS_PER_LONG - 1UL);
> + if (offset) {
> + tmp = ext2_swabp(p++);
> + tmp &= (~0UL << offset);
> + if (size < BITS_PER_LONG)
> + goto found_first;
> + if (tmp)
> + goto found_middle;
> + size -= BITS_PER_LONG;
> + result += BITS_PER_LONG;
> + }
> +
> + while (size & ~(BITS_PER_LONG - 1)) {
> + tmp = *(p++);
> + if (tmp)
> + goto found_middle_swap;
> + result += BITS_PER_LONG;
> + size -= BITS_PER_LONG;
> + }
> + if (!size)
> + return result;
> + tmp = ext2_swabp(p);
> +found_first:
> + tmp &= (~0UL >> (BITS_PER_LONG - size));
> + if (tmp == 0UL) /* Are any bits set? */
> + return result + size; /* Nope. */
> +found_middle:
> + return result + __ffs(tmp);
> +
> +found_middle_swap:
> + return result + __ffs(ext2_swab(tmp));
> +}
> +EXPORT_SYMBOL(generic_find_next_le_bit);
> +
> #endif /* __BIG_ENDIAN */
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
next prev parent reply other threads:[~2007-09-21 6:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 5:25 [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
2007-09-21 5:25 ` [PATCH] ext4: Fix spare warnings Aneesh Kumar K.V
2007-09-21 6:02 ` Balbir Singh
2007-09-21 9:04 ` Aneesh Kumar K.V
2007-09-21 6:43 ` Balbir Singh [this message]
2007-09-21 9:08 ` [PATCH] Introduce ext4_find_next_bit Aneesh Kumar K.V
2007-11-13 7:59 ` Andrew Morton
2007-11-13 19:11 ` Aneesh Kumar K.V
2007-11-13 20:43 ` Andrew Morton
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=46F36801.3070908@linux.vnet.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@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