Re: [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function

2008-01-07 Thread Jan Kara
On Sun 23-12-07 02:51:12, [EMAIL PROTECTED] wrote:
> Signed-off-by: Marcin Slusarz <[EMAIL PROTECTED]>
> CC: Ben Fennema <[EMAIL PROTECTED]>
> CC: Jan Kara <[EMAIL PROTECTED]>
  Looks much better :). Acked-by: Jan Kara <[EMAIL PROTECTED]>

Honza

> ---
>  fs/udf/super.c  |4 ++--
>  fs/udf/udf_sb.h |   37 -
>  2 files changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 33ccf66..1afea58 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -949,7 +949,7 @@ static int udf_load_partdesc(struct super_block *sb, 
> struct buffer_head *bh)
> i, 
> map->s_uspace.s_table->i_ino);
>   }
>   if (phd->unallocSpaceBitmap.extLength) {
> - UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
> + map->s_uspace.s_bitmap = 
> udf_sb_alloc_bitmap(sb, i);
>   if (map->s_uspace.s_bitmap != NULL) {
>   
> map->s_uspace.s_bitmap->s_extLength =
>   
> le32_to_cpu(phd->unallocSpaceBitmap.extLength);
> @@ -979,7 +979,7 @@ static int udf_load_partdesc(struct super_block *sb, 
> struct buffer_head *bh)
> i, 
> map->s_fspace.s_table->i_ino);
>   }
>   if (phd->freedSpaceBitmap.extLength) {
> - UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
> + map->s_fspace.s_bitmap = 
> udf_sb_alloc_bitmap(sb, i);
>   if (map->s_fspace.s_bitmap != NULL) {
>   
> map->s_fspace.s_bitmap->s_extLength =
>   
> le32_to_cpu(phd->freedSpaceBitmap.extLength);
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index a5805c5..4cf91f2 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -2,6 +2,7 @@
>  #define __LINUX_UDF_SB_H
>  
>  #include 
> +#include 
>  
>  /* Since UDF 2.01 is ISO 13346 based... */
>  #define UDF_SUPER_MAGIC  0x15013346
> @@ -149,23 +150,25 @@ static inline void udf_update_revision(struct 
> super_block *sb, __u16 revision)
>   udf_sb(sb)->s_udfrev = revision;
>  }
>  
> -#define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
> -{\
> - int nr_groups = ((udf_sb_partmap((X),(Y))->s_partition_len + 
> (sizeof(struct spaceBitmapDesc) << 3) +\
> - ((X)->s_blocksize * 8) - 1) / ((X)->s_blocksize * 8));\
> - int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 
> nr_groups);\
> - if (size <= PAGE_SIZE)\
> - udf_sb_partmaps(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
> - else\
> - udf_sb_partmaps(X)[(Y)].Z.s_bitmap = vmalloc(size);\
> - if (udf_sb_partmaps(X)[(Y)].Z.s_bitmap != NULL) {\
> - memset(udf_sb_partmaps(X)[(Y)].Z.s_bitmap, 0x00, size);\
> - udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
> - (struct buffer_head 
> **)(udf_sb_partmaps(X)[(Y)].Z.s_bitmap + 1);\
> - udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
> - } else {\
> - udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap 
> and %d buffer_head pointers", nr_groups);\
> - }\
> +static inline struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, 
> __u32 index)
> +{
> + struct udf_part_map *map = udf_sb_partmap(sb, index);
> + int nr_groups = (map->s_partition_len + (sizeof(struct spaceBitmapDesc) 
> << 3) +
> + (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
> + int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 
> nr_groups);
> + struct udf_bitmap *bitmap;
> +
> + if (size <= PAGE_SIZE)
> + bitmap = kmalloc(size, GFP_KERNEL);
> + else
> + bitmap = vmalloc(size);
> + if (bitmap != NULL) {
> + memset(bitmap, 0x00, size);
> + bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
> + bitmap->s_nr_groups = nr_groups;
> + } else
> + udf_error(sb, __FUNCTION__, "Unable to allocate space for 
> bitmap and %d buffer_head pointers", nr_groups);
> + return bitmap;
>  }
>  
>  #define UDF_SB_FREE_BITMAP(X,Y,Z)\
> -- 
> 1.5.3.4
> 
-- 
Jan Kara <[EMAIL PROTECTED]>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function

2007-12-22 Thread marcin . slusarz
Signed-off-by: Marcin Slusarz <[EMAIL PROTECTED]>
CC: Ben Fennema <[EMAIL PROTECTED]>
CC: Jan Kara <[EMAIL PROTECTED]>
---
 fs/udf/super.c  |4 ++--
 fs/udf/udf_sb.h |   37 -
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 33ccf66..1afea58 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -949,7 +949,7 @@ static int udf_load_partdesc(struct super_block *sb, struct 
buffer_head *bh)
  i, 
map->s_uspace.s_table->i_ino);
}
if (phd->unallocSpaceBitmap.extLength) {
-   UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
+   map->s_uspace.s_bitmap = 
udf_sb_alloc_bitmap(sb, i);
if (map->s_uspace.s_bitmap != NULL) {

map->s_uspace.s_bitmap->s_extLength =

le32_to_cpu(phd->unallocSpaceBitmap.extLength);
@@ -979,7 +979,7 @@ static int udf_load_partdesc(struct super_block *sb, struct 
buffer_head *bh)
  i, 
map->s_fspace.s_table->i_ino);
}
if (phd->freedSpaceBitmap.extLength) {
-   UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
+   map->s_fspace.s_bitmap = 
udf_sb_alloc_bitmap(sb, i);
if (map->s_fspace.s_bitmap != NULL) {

map->s_fspace.s_bitmap->s_extLength =

le32_to_cpu(phd->freedSpaceBitmap.extLength);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index a5805c5..4cf91f2 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -2,6 +2,7 @@
 #define __LINUX_UDF_SB_H
 
 #include 
+#include 
 
 /* Since UDF 2.01 is ISO 13346 based... */
 #define UDF_SUPER_MAGIC0x15013346
@@ -149,23 +150,25 @@ static inline void udf_update_revision(struct super_block 
*sb, __u16 revision)
udf_sb(sb)->s_udfrev = revision;
 }
 
-#define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
-{\
-   int nr_groups = ((udf_sb_partmap((X),(Y))->s_partition_len + 
(sizeof(struct spaceBitmapDesc) << 3) +\
-   ((X)->s_blocksize * 8) - 1) / ((X)->s_blocksize * 8));\
-   int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 
nr_groups);\
-   if (size <= PAGE_SIZE)\
-   udf_sb_partmaps(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
-   else\
-   udf_sb_partmaps(X)[(Y)].Z.s_bitmap = vmalloc(size);\
-   if (udf_sb_partmaps(X)[(Y)].Z.s_bitmap != NULL) {\
-   memset(udf_sb_partmaps(X)[(Y)].Z.s_bitmap, 0x00, size);\
-   udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
-   (struct buffer_head 
**)(udf_sb_partmaps(X)[(Y)].Z.s_bitmap + 1);\
-   udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
-   } else {\
-   udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap 
and %d buffer_head pointers", nr_groups);\
-   }\
+static inline struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, 
__u32 index)
+{
+   struct udf_part_map *map = udf_sb_partmap(sb, index);
+   int nr_groups = (map->s_partition_len + (sizeof(struct spaceBitmapDesc) 
<< 3) +
+   (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
+   int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * 
nr_groups);
+   struct udf_bitmap *bitmap;
+
+   if (size <= PAGE_SIZE)
+   bitmap = kmalloc(size, GFP_KERNEL);
+   else
+   bitmap = vmalloc(size);
+   if (bitmap != NULL) {
+   memset(bitmap, 0x00, size);
+   bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
+   bitmap->s_nr_groups = nr_groups;
+   } else
+   udf_error(sb, __FUNCTION__, "Unable to allocate space for 
bitmap and %d buffer_head pointers", nr_groups);
+   return bitmap;
 }
 
 #define UDF_SB_FREE_BITMAP(X,Y,Z)\
-- 
1.5.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/