linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/24] udf: convert super_block macros to functions
@ 2007-12-23  1:50 marcin.slusarz
  2007-12-23  1:50 ` [PATCH 01/24] udf: fix coding style of super.c marcin.slusarz
                   ` (23 more replies)
  0 siblings, 24 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Hi
This patchset converts macros related to super_block handling into
functions. Besides that it fixes some sparse warnings (23rd and 24th),
improves coding style (1st) and fixes error handling (19th).

Note that udf files has really long lines and these patches won't validate
by checkpatch. I'm going to do more cleanups later.

PS: This is the first time I use git-send-email - tell me if I do something wrong.

Marcin Slusarz

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

* [PATCH 01/24] udf: fix coding style of super.c
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2008-01-07 11:13   ` Jan Kara
  2007-12-23  1:50 ` [PATCH 02/24] udf: rename UDF_SB to udf_sb marcin.slusarz
                   ` (22 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

fix coding style errors found by checkpatch:
- assignments in if conditions
- braces {} around single statement blocks
- no spaces after commas
- printks without KERN_*
- lines longer than 80 characters
before: total: 50 errors, 207 warnings, 1835 lines checked
after:  total: 0 errors, 164 warnings, 1872 lines checked

all 164 warnings left are lines longer than 80 characters;
this file has too much indentation with really long expressions
to break all those lines

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c |  295 +++++++++++++++++++++++++++++++------------------------
 1 files changed, 166 insertions(+), 129 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4360c7a..57788f1 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -33,8 +33,8 @@
  *  10/17/98      added freespace count for "df"
  *  11/11/98 gr   added novrs option
  *  11/26/98 dgb  added fileset,anchor mount options
- *  12/06/98 blf  really hosed things royally. vat/sparing support. sequenced vol descs
- *                rewrote option handling based on isofs
+ *  12/06/98 blf  really hosed things royally. vat/sparing support. sequenced
+ *                vol descs. rewrote option handling based on isofs
  *  12/20/98      find the free space bitmap (if it exists)
  */
 
@@ -116,7 +116,7 @@ static struct kmem_cache *udf_inode_cachep;
 static struct inode *udf_alloc_inode(struct super_block *sb)
 {
 	struct udf_inode_info *ei;
-	ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
+	ei = kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
 	if (!ei)
 		return NULL;
 
@@ -561,47 +561,52 @@ static int udf_vrs(struct super_block *sb, int silent)
 
 		/* Look for ISO  descriptors */
 		vsd = (struct volStructDesc *)(bh->b_data +
-					       (sector & (sb->s_blocksize - 1)));
+					      (sector & (sb->s_blocksize - 1)));
 
 		if (vsd->stdIdent[0] == 0) {
 			brelse(bh);
 			break;
-		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
+		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001,
+				    VSD_STD_ID_LEN)) {
 			iso9660 = sector;
 			switch (vsd->structType) {
 			case 0:
 				udf_debug("ISO9660 Boot Record found\n");
 				break;
 			case 1:
-				udf_debug
-				    ("ISO9660 Primary Volume Descriptor found\n");
+				udf_debug("ISO9660 Primary Volume Descriptor "
+					  "found\n");
 				break;
 			case 2:
-				udf_debug
-				    ("ISO9660 Supplementary Volume Descriptor found\n");
+				udf_debug("ISO9660 Supplementary Volume "
+					  "Descriptor found\n");
 				break;
 			case 3:
-				udf_debug
-				    ("ISO9660 Volume Partition Descriptor found\n");
+				udf_debug("ISO9660 Volume Partition Descriptor "
+					  "found\n");
 				break;
 			case 255:
-				udf_debug
-				    ("ISO9660 Volume Descriptor Set Terminator found\n");
+				udf_debug("ISO9660 Volume Descriptor Set "
+					  "Terminator found\n");
 				break;
 			default:
 				udf_debug("ISO9660 VRS (%u) found\n",
 					  vsd->structType);
 				break;
 			}
-		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
-		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
+		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01,
+				    VSD_STD_ID_LEN))
+			; /* nothing */
+		else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01,
+				    VSD_STD_ID_LEN)) {
 			brelse(bh);
 			break;
-		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
+		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02,
+				    VSD_STD_ID_LEN))
 			nsr02 = sector;
-		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
+		else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03,
+				    VSD_STD_ID_LEN))
 			nsr03 = sector;
-		}
 		brelse(bh);
 	}
 
@@ -658,21 +663,26 @@ static void udf_find_anchor(struct super_block *sb)
 		 *  however, if the disc isn't closed, it could be 512 */
 
 		for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {
-			if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) {
-				ident = location = 0;
-			} else {
-				ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
-				location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
-				brelse(bh);
+			ident = location = 0;
+			if (last[i] >= 0) {
+				bh = sb_bread(sb, last[i]);
+				if (bh) {
+					tag *t = (tag *)bh->b_data;
+					ident = le16_to_cpu(t->tagIdent);
+					location = le32_to_cpu(t->tagLocation);
+					brelse(bh);
+				}
 			}
 
 			if (ident == TAG_IDENT_AVDP) {
 				if (location == last[i] - UDF_SB_SESSION(sb)) {
-					lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
-					UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
+					lastblock = last[i] - UDF_SB_SESSION(sb);
+					UDF_SB_ANCHOR(sb)[0] = lastblock;
+					UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
 				} else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) {
 					UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
-					lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
+					lastblock = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
+					UDF_SB_ANCHOR(sb)[0] = lastblock;
 					UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
 				} else {
 					udf_debug("Anchor found at block %d, location mismatch %d.\n",
@@ -682,12 +692,15 @@ static void udf_find_anchor(struct super_block *sb)
 				lastblock = last[i];
 				UDF_SB_ANCHOR(sb)[3] = 512;
 			} else {
-				if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) {
-					ident = location = 0;
-				} else {
-					ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
-					location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
-					brelse(bh);
+				ident = location = 0;
+				if (last[i] >= 256) {
+					bh = sb_bread(sb, last[i] - 256);
+					if (bh) {
+						tag *t = (tag *)bh->b_data;
+						ident = le16_to_cpu(t->tagIdent);
+						location = le32_to_cpu(t->tagLocation);
+						brelse(bh);
+					}
 				}
 
 				if (ident == TAG_IDENT_AVDP &&
@@ -695,13 +708,15 @@ static void udf_find_anchor(struct super_block *sb)
 					lastblock = last[i];
 					UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
 				} else {
-					if (last[i] < 312 + UDF_SB_SESSION(sb) ||
-					    !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) {
-						ident = location = 0;
-					} else {
-						ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
-						location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
-						brelse(bh);
+					ident = location = 0;
+					if (last[i] >= 312 + UDF_SB_SESSION(sb)) {
+						bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb));
+						if (bh) {
+							tag *t = (tag *)bh->b_data;
+							ident = le16_to_cpu(t->tagIdent);
+							location = le32_to_cpu(t->tagLocation);
+							brelse(bh);
+						}
 					}
 
 					if (ident == TAG_IDENT_AVDP &&
@@ -716,10 +731,12 @@ static void udf_find_anchor(struct super_block *sb)
 	}
 
 	if (!lastblock) {
-		/* We havn't found the lastblock. check 312 */
-		if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) {
-			ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
-			location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
+		/* We haven't found the lastblock. check 312 */
+		bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb));
+		if (bh) {
+			tag *t = (tag *)bh->b_data;
+			ident = le16_to_cpu(t->tagIdent);
+			location = le32_to_cpu(t->tagLocation);
 			brelse(bh);
 
 			if (ident == TAG_IDENT_AVDP && location == 256)
@@ -729,15 +746,15 @@ static void udf_find_anchor(struct super_block *sb)
 
 	for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
 		if (UDF_SB_ANCHOR(sb)[i]) {
-			if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
-						   UDF_SB_ANCHOR(sb)[i], &ident))) {
+			bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
+					     UDF_SB_ANCHOR(sb)[i], &ident);
+			if (!bh)
 				UDF_SB_ANCHOR(sb)[i] = 0;
-			} else {
+			else {
 				brelse(bh);
 				if ((ident != TAG_IDENT_AVDP) &&
-				    (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) {
+				    (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE)))
 					UDF_SB_ANCHOR(sb)[i] = 0;
-				}
 			}
 		}
 	}
@@ -745,7 +762,9 @@ static void udf_find_anchor(struct super_block *sb)
 	UDF_SB_LASTBLOCK(sb) = lastblock;
 }
 
-static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
+static int udf_find_fileset(struct super_block *sb,
+			    kernel_lb_addr *fileset,
+			    kernel_lb_addr *root)
 {
 	struct buffer_head *bh = NULL;
 	long lastblock;
@@ -764,7 +783,8 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker
 
 	}
 
-	if (!bh) { /* Search backwards through the partitions */
+	if (!bh) {
+		/* Search backwards through the partitions */
 		kernel_lb_addr newfileset;
 
 /* --> cvg: FIXME - is it reasonable? */
@@ -775,11 +795,13 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker
 		      fileset->logicalBlockNum == 0xFFFFFFFF &&
 		      fileset->partitionReferenceNum == 0xFFFF);
 		     newfileset.partitionReferenceNum--) {
-			lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
+			lastblock = UDF_SB_PARTLEN(sb,
+					newfileset.partitionReferenceNum);
 			newfileset.logicalBlockNum = 0;
 
 			do {
-				bh = udf_read_ptagged(sb, newfileset, 0, &ident);
+				bh = udf_read_ptagged(sb, newfileset, 0,
+						      &ident);
 				if (!bh) {
 					newfileset.logicalBlockNum++;
 					continue;
@@ -840,7 +862,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
 			      lets_to_cpu(pvoldesc->recordingDateAndTime))) {
 		kernel_timestamp ts;
 		ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
-		udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
+		udf_debug("recording time %ld/%ld, %04u/%02u/%02u"
+			  " %02u:%02u (%x)\n",
 			  recording, recording_usec,
 			  ts.year, ts.month, ts.day, ts.hour,
 			  ts.minute, ts.typeAndTimezone);
@@ -888,19 +911,21 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 		udf_debug("Searching map: (%d == %d)\n",
 			  UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
 		if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
-			UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
-			UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
+			UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */
+			UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation);
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
-				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
+				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_READ_ONLY;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
-				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
+				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_WRITE_ONCE;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
-				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
+				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_REWRITABLE;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
-				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
+				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_OVERWRITABLE;
 
-			if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
-			    !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) {
+			if (!strcmp(p->partitionContents.ident,
+				    PD_PARTITION_CONTENTS_NSR02) ||
+			    !strcmp(p->partitionContents.ident,
+				    PD_PARTITION_CONTENTS_NSR03)) {
 				struct partitionHeaderDesc *phd;
 
 				phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
@@ -916,7 +941,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						udf_debug("cannot load unallocSpaceTable (part %d)\n", i);
 						return 1;
 					}
-					UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
+					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE;
 					udf_debug("unallocSpaceTable (part %d) @ %ld\n",
 						  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
 				}
@@ -927,7 +952,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 							le32_to_cpu(phd->unallocSpaceBitmap.extLength);
 						UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
-						UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
+						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
 						udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
 							  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
 					}
@@ -946,7 +971,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						udf_debug("cannot load freedSpaceTable (part %d)\n", i);
 						return 1;
 					}
-					UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
+					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE;
 					udf_debug("freedSpaceTable (part %d) @ %ld\n",
 						  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
 				}
@@ -957,7 +982,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 							le32_to_cpu(phd->freedSpaceBitmap.extLength);
 						UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->freedSpaceBitmap.extPosition);
-						UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
+						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP;
 						udf_debug("freedSpaceBitmap (part %d) @ %d\n",
 							  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
 					}
@@ -970,9 +995,11 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 		udf_debug("Partition (%d) not found in partition map\n",
 			  le16_to_cpu(p->partitionNumber));
 	} else {
-		udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
-			  le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
-			  UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
+		udf_debug("Partition (%d:%d type %x) starts at physical %d, "
+			  "block length %d\n",
+			  le16_to_cpu(p->partitionNumber), i,
+			  UDF_SB_PARTTYPE(sb, i), UDF_SB_PARTROOT(sb, i),
+			  UDF_SB_PARTLEN(sb, i));
 	}
 	return 0;
 }
@@ -994,19 +1021,19 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 		type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
 		if (type == 1) {
 			struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
-			UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
-			UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
-			UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
-			UDF_SB_PARTFUNC(sb,i) = NULL;
+			UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15;
+			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
+			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
+			UDF_SB_PARTFUNC(sb, i) = NULL;
 		} else if (type == 2) {
 			struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
 			if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
 				if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
-					UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
-					UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
+					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP15;
+					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt15;
 				} else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
-					UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
-					UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
+					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP20;
+					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt20;
 				}
 			} else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
 				uint32_t loc;
@@ -1014,39 +1041,41 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 				struct sparingTable *st;
 				struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
 
-				UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
-				UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
+				UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
+				UDF_SB_TYPESPAR(sb, i).s_packet_len = le16_to_cpu(spm->packetLength);
 				for (j = 0; j < spm->numSparingTables; j++) {
 					loc = le32_to_cpu(spm->locSparingTable[j]);
-					UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
+					UDF_SB_TYPESPAR(sb, i).s_spar_map[j] =
 						udf_read_tagged(sb, loc, loc, &ident);
-					if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
-						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
+					if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != NULL) {
+						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, i).s_spar_map[j]->b_data;
 						if (ident != 0 ||
 						    strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
-							brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
-							UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
+							brelse(UDF_SB_TYPESPAR(sb, i).s_spar_map[j]);
+							UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = NULL;
 						}
 					}
 				}
-				UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
+				UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15;
 			} else {
-				udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
+				udf_debug("Unknown ident: %s\n",
+					  upm2->partIdent.ident);
 				continue;
 			}
-			UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
-			UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
+			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum);
+			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum);
 		}
 		udf_debug("Partition (%d:%d) type %d on volume %d\n",
-			  i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
+			  i, UDF_SB_PARTNUM(sb, i), type,
+			  UDF_SB_PARTVSN(sb, i));
 	}
 
 	if (fileset) {
 		long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
 
 		*fileset = lelb_to_cpu(la->extLocation);
-		udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
-			  fileset->logicalBlockNum,
+		udf_debug("FileSet found in LogicalVolDesc at block=%d, "
+			  "partition=%d\n", fileset->logicalBlockNum,
 			  fileset->partitionReferenceNum);
 	}
 	if (lvd->integritySeqExt.extLength)
@@ -1071,7 +1100,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
 		UDF_SB_LVIDBH(sb) = bh;
 
 		if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
-			udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
+			udf_load_logicalvolint(sb,
+				leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
 
 		if (UDF_SB_LVIDBH(sb) != bh)
 			brelse(bh);
@@ -1097,8 +1127,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
  *	July 1, 1997 - Andrew E. Mileski
  *	Written, tested, and released.
  */
-static int udf_process_sequence(struct super_block *sb, long block, long lastblock,
-				 kernel_lb_addr *fileset)
+static int udf_process_sequence(struct super_block *sb, long block,
+				long lastblock, kernel_lb_addr *fileset)
 {
 	struct buffer_head *bh = NULL;
 	struct udf_vds_record vds[VDS_POS_LENGTH];
@@ -1178,7 +1208,8 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo
 	}
 	for (i = 0; i < VDS_POS_LENGTH; i++) {
 		if (vds[i].block) {
-			bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
+			bh = udf_read_tagged(sb, vds[i].block, vds[i].block,
+					     &ident);
 
 			if (i == VDS_POS_PRIMARY_VOL_DESC) {
 				udf_load_pvoldesc(sb, bh);
@@ -1190,11 +1221,14 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo
 					brelse(bh);
 					return 1;
 				}
-				for (j = vds[i].block + 1; j <  vds[VDS_POS_TERMINATING_DESC].block; j++) {
+				for (j = vds[i].block + 1;
+				     j <  vds[VDS_POS_TERMINATING_DESC].block;
+				     j++) {
 					bh2 = udf_read_tagged(sb, j, j, &ident);
 					gd = (struct generic_desc *)bh2->b_data;
 					if (ident == TAG_IDENT_PD)
-						if (udf_load_partdesc(sb, bh2)) {
+						if (udf_load_partdesc(sb,
+								      bh2)) {
 							brelse(bh);
 							brelse(bh2);
 							return 1;
@@ -1222,14 +1256,16 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
 	}
 	/* Check that it is NSR02 compliant */
 	/* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
-	else if ((block = udf_vrs(sb, silent)) == -1) {
-		udf_debug("Failed to read byte 32768. Assuming open disc. "
-			  "Skipping validity check\n");
-		if (!UDF_SB_LASTBLOCK(sb))
-			UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
-		return 0;
-	} else {
-		return !block;
+	else {
+		block = udf_vrs(sb, silent);
+		if (block == -1) {
+			udf_debug("Failed to read byte 32768. Assuming open "
+				  "disc. Skipping validity check\n");
+			if (!UDF_SB_LASTBLOCK(sb))
+				UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
+			return 0;
+		} else
+			return !block;
 	}
 }
 
@@ -1252,7 +1288,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 
 			/* Locate the main sequence */
 			main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
-			main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength );
+			main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
 			main_e = main_e >> sb->s_blocksize_bits;
 			main_e += main_s;
 
@@ -1267,9 +1303,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 			/* Process the main & reserve sequences */
 			/* responsible for finding the PartitionDesc(s) */
 			if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
-			      udf_process_sequence(sb, reserve_s, reserve_e, fileset))) {
+			      udf_process_sequence(sb, reserve_s, reserve_e, fileset)))
 				break;
-			}
 		}
 	}
 
@@ -1308,7 +1343,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 			if (j == UDF_SB_NUMPARTS(sb))
 				return 1;
 
-			if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
+			UDF_SB_VAT(sb) = udf_iget(sb, ino);
+			if (!UDF_SB_VAT(sb))
 				return 1;
 
 			if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
@@ -1481,8 +1517,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
 	UDF_SB_ANCHOR(sb)[3] = 256;
 
-	if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */
-		printk("UDF-fs: No VRS found\n");
+	if (udf_check_valid(sb, uopt.novrs, silent)) {
+		/* read volume recognition sequences */
+		printk(KERN_WARNING "UDF-fs: No VRS found\n");
 		goto error_out;
 	}
 
@@ -1496,7 +1533,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	sb->s_time_gran = 1000;
 
 	if (udf_load_partition(sb, &fileset)) {
-		printk("UDF-fs: No partition found (1)\n");
+		printk(KERN_WARNING "UDF-fs: No partition found (1)\n");
 		goto error_out;
 	}
 
@@ -1508,7 +1545,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		/* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
 
 		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
-			printk("UDF-fs: minUDFReadRev=%x (max is %x)\n",
+			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x (max is %x)\n",
 			       le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
 			       UDF_MAX_READ_VERSION);
 			goto error_out;
@@ -1525,17 +1562,17 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	}
 
 	if (!UDF_SB_NUMPARTS(sb)) {
-		printk("UDF-fs: No partition found (2)\n");
+		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
 		goto error_out;
 	}
 
 	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) {
-		printk("UDF-fs: Partition marked readonly; forcing readonly mount\n");
+		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
 
 	if (udf_find_fileset(sb, &fileset, &rootdir)) {
-		printk("UDF-fs: No fileset found\n");
+		printk(KERN_WARNING "UDF-fs: No fileset found\n");
 		goto error_out;
 	}
 
@@ -1556,7 +1593,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* perhaps it's not extensible enough, but for now ... */
 	inode = udf_iget(sb, rootdir);
 	if (!inode) {
-		printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
+		printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
 		       rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
 		goto error_out;
 	}
@@ -1564,7 +1601,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	/* Allocate a dentry for the root inode */
 	sb->s_root = d_alloc_root(inode);
 	if (!sb->s_root) {
-		printk("UDF-fs: Couldn't allocate root dentry\n");
+		printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n");
 		iput(inode);
 		goto error_out;
 	}
@@ -1580,9 +1617,9 @@ error_out:
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
 			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
+			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
+			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
 		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
 				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
@@ -1614,7 +1651,7 @@ void udf_error(struct super_block *sb, const char *function,
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
 	va_end(args);
-	printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
+	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
 		sb->s_id, function, error_buf);
 }
 
@@ -1655,9 +1692,9 @@ static void udf_put_super(struct super_block *sb)
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
 			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
+			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
+			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
 		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
 				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
@@ -1786,9 +1823,9 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t
 	epos.offset = sizeof(struct unallocSpaceEntry);
 	epos.bh = NULL;
 
-	while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
+	while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1)
 		accum += (elen >> table->i_sb->s_blocksize_bits);
-	}
+
 	brelse(epos.bh);
 
 	unlock_kernel();
@@ -1811,22 +1848,22 @@ static unsigned int udf_count_free(struct super_block *sb)
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
 					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
 	}
-	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
+	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
 					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
 	}
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		accum += udf_count_free_table(sb,
 					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 	}
-	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
+	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
 		accum += udf_count_free_table(sb,
 					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 	}
-- 
1.5.3.4


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

* [PATCH 02/24] udf: rename UDF_SB to udf_sb
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
  2007-12-23  1:50 ` [PATCH 01/24] udf: fix coding style of super.c marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23 12:04   ` Christoph Hellwig
  2007-12-23  1:50 ` [PATCH 03/24] udf: convert some macros to inline functions marcin.slusarz
                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

rename UDF_SB function to udf_sb

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c  |   12 ++++++------
 fs/udf/ialloc.c  |    4 ++--
 fs/udf/inode.c   |    6 +++---
 fs/udf/super.c   |   32 ++++++++++++++++----------------
 fs/udf/udf_sb.h  |   42 +++++++++++++++++++++---------------------
 fs/udf/unicode.c |    4 ++--
 6 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index ab26176..8374c91 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -144,7 +144,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 				   kernel_lb_addr bloc, uint32_t offset,
 				   uint32_t count)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	struct buffer_head *bh = NULL;
 	unsigned long block;
 	unsigned long block_group;
@@ -214,7 +214,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
 				      uint16_t partition, uint32_t first_block,
 				      uint32_t block_count)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	int alloc_count = 0;
 	int bit, block, block_group, group_start;
 	int nr_groups, bitmap_nr;
@@ -276,7 +276,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
 				struct udf_bitmap *bitmap, uint16_t partition,
 				uint32_t goal, int *err)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	int newbit, bit = 0, block, block_group, group_start;
 	int end_goal, nr_groups, bitmap_nr, i;
 	struct buffer_head *bh = NULL;
@@ -411,7 +411,7 @@ static void udf_table_free_blocks(struct super_block *sb,
 				  kernel_lb_addr bloc, uint32_t offset,
 				  uint32_t count)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	uint32_t start, end;
 	uint32_t elen;
 	kernel_lb_addr eloc;
@@ -620,7 +620,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 				     struct inode *table, uint16_t partition,
 				     uint32_t first_block, uint32_t block_count)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	int alloc_count = 0;
 	uint32_t elen, adsize;
 	kernel_lb_addr eloc;
@@ -685,7 +685,7 @@ static int udf_table_new_block(struct super_block *sb,
 			       struct inode *table, uint16_t partition,
 			       uint32_t goal, int *err)
 {
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
 	uint32_t newblock = 0, adsize;
 	uint32_t elen, goal_elen = 0;
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 636d8f6..92dc9ae 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -31,7 +31,7 @@
 void udf_free_inode(struct inode *inode)
 {
 	struct super_block *sb = inode->i_sb;
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 
 	/*
 	 * Note: we must free any quota before locking the superblock,
@@ -61,7 +61,7 @@ void udf_free_inode(struct inode *inode)
 struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 {
 	struct super_block *sb = dir->i_sb;
-	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_sb_info *sbi = udf_sb(sb);
 	struct inode *inode;
 	int block;
 	uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1178ae0..5afa19e 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1133,13 +1133,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 	if (inode->i_uid == -1 ||
 	    UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
 	    UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
-		inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
+		inode->i_uid = udf_sb(inode->i_sb)->s_uid;
 
 	inode->i_gid = le32_to_cpu(fe->gid);
 	if (inode->i_gid == -1 ||
 	    UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
 	    UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
-		inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
+		inode->i_gid = udf_sb(inode->i_sb)->s_gid;
 
 	inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
 	if (!inode->i_nlink)
@@ -1149,7 +1149,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 	UDF_I_LENEXTENTS(inode) = inode->i_size;
 
 	inode->i_mode = udf_convert_permissions(fe);
-	inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask;
+	inode->i_mode &= ~udf_sb(inode->i_sb)->s_umask;
 
 	if (UDF_I_EFE(inode) == 0) {
 		inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 57788f1..76c7dc4 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -462,18 +462,18 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 {
 	struct udf_options uopt;
 
-	uopt.flags = UDF_SB(sb)->s_flags;
-	uopt.uid   = UDF_SB(sb)->s_uid;
-	uopt.gid   = UDF_SB(sb)->s_gid;
-	uopt.umask = UDF_SB(sb)->s_umask;
+	uopt.flags = udf_sb(sb)->s_flags;
+	uopt.uid   = udf_sb(sb)->s_uid;
+	uopt.gid   = udf_sb(sb)->s_gid;
+	uopt.umask = udf_sb(sb)->s_umask;
 
 	if (!udf_parse_options(options, &uopt))
 		return -EINVAL;
 
-	UDF_SB(sb)->s_flags = uopt.flags;
-	UDF_SB(sb)->s_uid   = uopt.uid;
-	UDF_SB(sb)->s_gid   = uopt.gid;
-	UDF_SB(sb)->s_umask = uopt.umask;
+	udf_sb(sb)->s_flags = uopt.flags;
+	udf_sb(sb)->s_uid   = uopt.uid;
+	udf_sb(sb)->s_gid   = uopt.gid;
+	udf_sb(sb)->s_umask = uopt.umask;
 
 	if (UDF_SB_LVIDBH(sb)) {
 		int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
@@ -1467,7 +1467,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		return -ENOMEM;
 
 	sb->s_fs_info = sbi;
-	memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
+	memset(udf_sb(sb), 0x00, sizeof(struct udf_sb_info));
 
 	mutex_init(&sbi->s_alloc_mutex);
 
@@ -1495,11 +1495,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	fileset.logicalBlockNum = 0xFFFFFFFF;
 	fileset.partitionReferenceNum = 0xFFFF;
 
-	UDF_SB(sb)->s_flags = uopt.flags;
-	UDF_SB(sb)->s_uid = uopt.uid;
-	UDF_SB(sb)->s_gid = uopt.gid;
-	UDF_SB(sb)->s_umask = uopt.umask;
-	UDF_SB(sb)->s_nls_map = uopt.nls_map;
+	udf_sb(sb)->s_flags = uopt.flags;
+	udf_sb(sb)->s_uid = uopt.uid;
+	udf_sb(sb)->s_gid = uopt.gid;
+	udf_sb(sb)->s_umask = uopt.umask;
+	udf_sb(sb)->s_nls_map = uopt.nls_map;
 
 	/* Set the block size for all transfers */
 	if (!udf_set_blocksize(sb, uopt.blocksize))
@@ -1627,7 +1627,7 @@ error_out:
 	}
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
-		unload_nls(UDF_SB(sb)->s_nls_map);
+		unload_nls(udf_sb(sb)->s_nls_map);
 #endif
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
@@ -1702,7 +1702,7 @@ static void udf_put_super(struct super_block *sb)
 	}
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
-		unload_nls(UDF_SB(sb)->s_nls_map);
+		unload_nls(udf_sb(sb)->s_nls_map);
 #endif
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 3c29820..e3cc83b 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -36,14 +36,14 @@
 #define UDF_PART_FLAG_REWRITABLE	0x0040
 #define UDF_PART_FLAG_OVERWRITABLE	0x0080
 
-static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
+static inline struct udf_sb_info *udf_sb(struct super_block *sb)
 {
 	return sb->s_fs_info;
 }
 
 #define UDF_SB_FREE(X)\
 {\
-	if (UDF_SB(X)) {\
+	if (udf_sb(X)) {\
 		kfree(UDF_SB_PARTMAPS(X));\
 		UDF_SB_PARTMAPS(X) = NULL;\
 	}\
@@ -95,13 +95,13 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
 		vfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\
 }
 
-#define UDF_QUERY_FLAG(X,Y)			( UDF_SB(X)->s_flags & ( 1 << (Y) ) )
-#define UDF_SET_FLAG(X,Y)			( UDF_SB(X)->s_flags |= ( 1 << (Y) ) )
-#define UDF_CLEAR_FLAG(X,Y)			( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) )
+#define UDF_QUERY_FLAG(X,Y)			( udf_sb(X)->s_flags & ( 1 << (Y) ) )
+#define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
+#define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
 
 #define UDF_UPDATE_UDFREV(X,Y)			( ((Y) > UDF_SB_UDFREV(X)) ? UDF_SB_UDFREV(X) = (Y) : UDF_SB_UDFREV(X) )
 
-#define UDF_SB_PARTMAPS(X)			( UDF_SB(X)->s_partmaps )
+#define UDF_SB_PARTMAPS(X)			( udf_sb(X)->s_partmaps )
 #define UDF_SB_PARTTYPE(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_type )
 #define UDF_SB_PARTROOT(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_root )
 #define UDF_SB_PARTLEN(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_len )
@@ -114,23 +114,23 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_VOLIDENT(X)			( UDF_SB(X)->s_volident )
-#define UDF_SB_NUMPARTS(X)			( UDF_SB(X)->s_partitions )
-#define UDF_SB_PARTITION(X)			( UDF_SB(X)->s_partition )
-#define UDF_SB_SESSION(X)			( UDF_SB(X)->s_session )
-#define UDF_SB_ANCHOR(X)			( UDF_SB(X)->s_anchor )
-#define UDF_SB_LASTBLOCK(X)			( UDF_SB(X)->s_lastblock )
-#define UDF_SB_LVIDBH(X)			( UDF_SB(X)->s_lvidbh )
+#define UDF_SB_VOLIDENT(X)			( udf_sb(X)->s_volident )
+#define UDF_SB_NUMPARTS(X)			( udf_sb(X)->s_partitions )
+#define UDF_SB_PARTITION(X)			( udf_sb(X)->s_partition )
+#define UDF_SB_SESSION(X)			( udf_sb(X)->s_session )
+#define UDF_SB_ANCHOR(X)			( udf_sb(X)->s_anchor )
+#define UDF_SB_LASTBLOCK(X)			( udf_sb(X)->s_lastblock )
+#define UDF_SB_LVIDBH(X)			( udf_sb(X)->s_lvidbh )
 #define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data )
 #define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
 
-#define UDF_SB_UMASK(X)				( UDF_SB(X)->s_umask )
-#define UDF_SB_GID(X)				( UDF_SB(X)->s_gid )
-#define UDF_SB_UID(X)				( UDF_SB(X)->s_uid )
-#define UDF_SB_RECORDTIME(X)			( UDF_SB(X)->s_recordtime )
-#define UDF_SB_SERIALNUM(X)			( UDF_SB(X)->s_serialnum )
-#define UDF_SB_UDFREV(X)			( UDF_SB(X)->s_udfrev )
-#define UDF_SB_FLAGS(X)				( UDF_SB(X)->s_flags )
-#define UDF_SB_VAT(X)				( UDF_SB(X)->s_vat )
+#define UDF_SB_UMASK(X)				( udf_sb(X)->s_umask )
+#define UDF_SB_GID(X)				( udf_sb(X)->s_gid )
+#define UDF_SB_UID(X)				( udf_sb(X)->s_uid )
+#define UDF_SB_RECORDTIME(X)			( udf_sb(X)->s_recordtime )
+#define UDF_SB_SERIALNUM(X)			( udf_sb(X)->s_serialnum )
+#define UDF_SB_UDFREV(X)			( udf_sb(X)->s_udfrev )
+#define UDF_SB_FLAGS(X)				( udf_sb(X)->s_flags )
+#define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
 
 #endif /* __LINUX_UDF_SB_H */
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 9e6099c..a050727 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -340,7 +340,7 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
 			return 0;
 		}
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
+		if (!udf_CS0toNLS(udf_sb(sb)->s_nls_map, &filename, &unifilename)) {
 			udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
 			return 0;
 		}
@@ -373,7 +373,7 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
 			return 0;
 		}
 	} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
-		namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN);
+		namelen = udf_NLStoCS0(udf_sb(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN);
 		if (!namelen) {
 			return 0;
 		}
-- 
1.5.3.4


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

* [PATCH 03/24] udf: convert some macros to inline functions
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
  2007-12-23  1:50 ` [PATCH 01/24] udf: fix coding style of super.c marcin.slusarz
  2007-12-23  1:50 ` [PATCH 02/24] udf: rename UDF_SB to udf_sb marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23  1:50 ` [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function marcin.slusarz
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

macro UDF_SB_PARTMAPS -> function udf_sb_partmaps
macro UDF_SB_FREE -> function udf_sb_free

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c |   24 ++++++++++----------
 fs/udf/super.c  |   52 ++++++++++++++++++++++----------------------
 fs/udf/udf_sb.h |   65 +++++++++++++++++++++++++++++-------------------------
 3 files changed, 73 insertions(+), 68 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 8374c91..b5d09ae 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -792,19 +792,19 @@ inline void udf_free_blocks(struct super_block *sb,
 
 	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		return udf_bitmap_free_blocks(sb, inode,
-					      UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
+					      udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
 					      bloc, offset, count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_free_blocks(sb, inode,
-					     UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
+					     udf_sb_partmaps(sb)[partition].s_uspace.s_table,
 					     bloc, offset, count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_free_blocks(sb, inode,
-					      UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
+					      udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
 					      bloc, offset, count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_free_blocks(sb, inode,
-					     UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
+					     udf_sb_partmaps(sb)[partition].s_fspace.s_table,
 					     bloc, offset, count);
 	} else {
 		return;
@@ -818,19 +818,19 @@ inline int udf_prealloc_blocks(struct super_block *sb,
 {
 	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		return udf_bitmap_prealloc_blocks(sb, inode,
-						  UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
+						  udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
 						  partition, first_block, block_count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_prealloc_blocks(sb, inode,
-						 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
+						 udf_sb_partmaps(sb)[partition].s_uspace.s_table,
 						 partition, first_block, block_count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_prealloc_blocks(sb, inode,
-						  UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
+						  udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
 						  partition, first_block, block_count);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_prealloc_blocks(sb, inode,
-						 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
+						 udf_sb_partmaps(sb)[partition].s_fspace.s_table,
 						 partition, first_block, block_count);
 	} else {
 		return 0;
@@ -845,20 +845,20 @@ inline int udf_new_block(struct super_block *sb,
 
 	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		ret = udf_bitmap_new_block(sb, inode,
-					   UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
+					   udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
 					   partition, goal, err);
 		return ret;
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_new_block(sb, inode,
-					   UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
+					   udf_sb_partmaps(sb)[partition].s_uspace.s_table,
 					   partition, goal, err);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_new_block(sb, inode,
-					    UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
+					    udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
 					    partition, goal, err);
 	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_new_block(sb, inode,
-					   UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
+					   udf_sb_partmaps(sb)[partition].s_fspace.s_table,
 					   partition, goal, err);
 	} else {
 		*err = -EIO;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 76c7dc4..2c68272 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -909,8 +909,8 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 
 	for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
 		udf_debug("Searching map: (%d == %d)\n",
-			  UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
-		if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
+			  udf_sb_partmaps(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
+		if (udf_sb_partmaps(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
 			UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */
 			UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation);
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
@@ -935,26 +935,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						.partitionReferenceNum = i,
 					};
 
-					UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table =
+					udf_sb_partmaps(sb)[i].s_uspace.s_table =
 						udf_iget(sb, loc);
-					if (!UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table) {
+					if (!udf_sb_partmaps(sb)[i].s_uspace.s_table) {
 						udf_debug("cannot load unallocSpaceTable (part %d)\n", i);
 						return 1;
 					}
 					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE;
 					udf_debug("unallocSpaceTable (part %d) @ %ld\n",
-						  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
+						  i, udf_sb_partmaps(sb)[i].s_uspace.s_table->i_ino);
 				}
 				if (phd->unallocSpaceBitmap.extLength) {
 					UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
-					if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) {
-						UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength =
+					if (udf_sb_partmaps(sb)[i].s_uspace.s_bitmap != NULL) {
+						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extLength =
 							le32_to_cpu(phd->unallocSpaceBitmap.extLength);
-						UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
+						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
 						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
 						udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
-							  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
+							  i, udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition);
 					}
 				}
 				if (phd->partitionIntegrityTable.extLength)
@@ -965,26 +965,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						.partitionReferenceNum = i,
 					};
 
-					UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table =
+					udf_sb_partmaps(sb)[i].s_fspace.s_table =
 						udf_iget(sb, loc);
-					if (!UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table) {
+					if (!udf_sb_partmaps(sb)[i].s_fspace.s_table) {
 						udf_debug("cannot load freedSpaceTable (part %d)\n", i);
 						return 1;
 					}
 					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE;
 					udf_debug("freedSpaceTable (part %d) @ %ld\n",
-						  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
+						  i, udf_sb_partmaps(sb)[i].s_fspace.s_table->i_ino);
 				}
 				if (phd->freedSpaceBitmap.extLength) {
 					UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
-					if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) {
-						UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength =
+					if (udf_sb_partmaps(sb)[i].s_fspace.s_bitmap != NULL) {
+						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extLength =
 							le32_to_cpu(phd->freedSpaceBitmap.extLength);
-						UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
+						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->freedSpaceBitmap.extPosition);
 						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP;
 						udf_debug("freedSpaceBitmap (part %d) @ %d\n",
-							  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
+							  i, udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition);
 					}
 				}
 			}
@@ -1613,9 +1613,9 @@ error_out:
 		iput(UDF_SB_VAT(sb));
 	if (UDF_SB_NUMPARTS(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
+			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
+			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
@@ -1632,7 +1632,7 @@ error_out:
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
 	brelse(UDF_SB_LVIDBH(sb));
-	UDF_SB_FREE(sb);
+	udf_sb_free(sb);
 	kfree(sbi);
 	sb->s_fs_info = NULL;
 
@@ -1688,9 +1688,9 @@ static void udf_put_super(struct super_block *sb)
 		iput(UDF_SB_VAT(sb));
 	if (UDF_SB_NUMPARTS(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
+			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
+			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
@@ -1707,7 +1707,7 @@ static void udf_put_super(struct super_block *sb)
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
 	brelse(UDF_SB_LVIDBH(sb));
-	UDF_SB_FREE(sb);
+	udf_sb_free(sb);
 	kfree(sb->s_fs_info);
 	sb->s_fs_info = NULL;
 }
@@ -1850,22 +1850,22 @@ static unsigned int udf_count_free(struct super_block *sb)
 
 	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
+					       udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
 	}
 	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
+					       udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
 	}
 	if (accum)
 		return accum;
 
 	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		accum += udf_count_free_table(sb,
-					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
+					      udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 	}
 	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
 		accum += udf_count_free_table(sb,
-					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
+					      udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
 	}
 
 	return accum;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index e3cc83b..46ddfb0 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -41,20 +41,26 @@ static inline struct udf_sb_info *udf_sb(struct super_block *sb)
 	return sb->s_fs_info;
 }
 
-#define UDF_SB_FREE(X)\
-{\
-	if (udf_sb(X)) {\
-		kfree(UDF_SB_PARTMAPS(X));\
-		UDF_SB_PARTMAPS(X) = NULL;\
-	}\
+static inline struct udf_part_map *udf_sb_partmaps(struct super_block *sb)
+{
+	return udf_sb(sb)->s_partmaps;
+}
+
+static inline void udf_sb_free(struct super_block *sb)
+{
+	struct udf_sb_info *sb_info = udf_sb(sb);
+	if (sb_info) {
+		kfree(sb_info->s_partmaps);
+		sb_info->s_partmaps = NULL;
+	}
 }
 
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
-	UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
-	if (UDF_SB_PARTMAPS(X) != NULL) {\
+	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
+	if (udf_sb_partmaps(X) != NULL) {\
 		UDF_SB_NUMPARTS(X) = Y;\
-		memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
+		memset(udf_sb_partmaps(X), 0x00, sizeof(struct udf_part_map) * Y);\
 	} else {\
 		UDF_SB_NUMPARTS(X) = 0;\
 		udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
@@ -67,14 +73,14 @@ static inline struct udf_sb_info *udf_sb(struct super_block *sb)
 		((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);\
+		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;\
+		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);\
 	}\
@@ -90,9 +96,9 @@ static inline struct udf_sb_info *udf_sb(struct super_block *sb)
 			brelse(UDF_SB_BITMAP(X,Y,Z,i));\
 	}\
 	if (size <= PAGE_SIZE)\
-		kfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\
+		kfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
 	else\
-		vfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\
+		vfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
 }
 
 #define UDF_QUERY_FLAG(X,Y)			( udf_sb(X)->s_flags & ( 1 << (Y) ) )
@@ -101,18 +107,17 @@ static inline struct udf_sb_info *udf_sb(struct super_block *sb)
 
 #define UDF_UPDATE_UDFREV(X,Y)			( ((Y) > UDF_SB_UDFREV(X)) ? UDF_SB_UDFREV(X) = (Y) : UDF_SB_UDFREV(X) )
 
-#define UDF_SB_PARTMAPS(X)			( udf_sb(X)->s_partmaps )
-#define UDF_SB_PARTTYPE(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_type )
-#define UDF_SB_PARTROOT(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_root )
-#define UDF_SB_PARTLEN(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_len )
-#define UDF_SB_PARTVSN(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_volumeseqnum )
-#define UDF_SB_PARTNUM(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_num )
-#define UDF_SB_TYPESPAR(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_sparing )
-#define UDF_SB_TYPEVIRT(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_virtual )
-#define UDF_SB_PARTFUNC(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_func )
-#define UDF_SB_PARTFLAGS(X,Y)			( UDF_SB_PARTMAPS(X)[(Y)].s_partition_flags )
-#define UDF_SB_BITMAP(X,Y,Z,I)			( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
-#define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups )
+#define UDF_SB_PARTTYPE(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_type )
+#define UDF_SB_PARTROOT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_root )
+#define UDF_SB_PARTLEN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_len )
+#define UDF_SB_PARTVSN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_volumeseqnum )
+#define UDF_SB_PARTNUM(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_num )
+#define UDF_SB_TYPESPAR(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_sparing )
+#define UDF_SB_TYPEVIRT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_virtual )
+#define UDF_SB_PARTFUNC(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_func )
+#define UDF_SB_PARTFLAGS(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_flags )
+#define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
+#define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
 #define UDF_SB_VOLIDENT(X)			( udf_sb(X)->s_volident )
 #define UDF_SB_NUMPARTS(X)			( udf_sb(X)->s_partitions )
-- 
1.5.3.4


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

* [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (2 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 03/24] udf: convert some macros to inline functions marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23 12:08   ` Christoph Hellwig
  2007-12-23  1:50 ` [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function marcin.slusarz
                   ` (19 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_VOLIDENT macro to udf_sb_volume_ident inline function
- rename s_volident field to s_volume_ident

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/file.c             |    2 +-
 fs/udf/super.c            |    6 +++---
 fs/udf/udf_sb.h           |    6 +++++-
 include/linux/udf_fs_sb.h |    2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/udf/file.c b/fs/udf/file.c
index 7c7a1b3..7b61dae 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -192,7 +192,7 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 	switch (cmd) {
 	case UDF_GETVOLIDENT:
 		return copy_to_user((char __user *)arg,
-				    UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
+				    udf_sb_volume_ident(inode->i_sb), 32) ? -EFAULT : 0;
 	case UDF_RELOCATE_BLOCKS:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 2c68272..42de326 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -873,9 +873,9 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
 
 	if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) {
 		if (udf_CS0toUTF8(&outstr, &instr)) {
-			strncpy(UDF_SB_VOLIDENT(sb), outstr.u_name,
+			strncpy(udf_sb_volume_ident(sb), outstr.u_name,
 				outstr.u_len > 31 ? 31 : outstr.u_len);
-			udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb));
+			udf_debug("volIdent[] = '%s'\n", udf_sb_volume_ident(sb));
 		}
 	}
 
@@ -1582,7 +1582,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		udf_info("UDF %s (%s) Mounting volume '%s', "
 			 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
 			 UDFFS_VERSION, UDFFS_DATE,
-			 UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
+			 udf_sb_volume_ident(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
 			 ts.typeAndTimezone);
 	}
 	if (!(sb->s_flags & MS_RDONLY))
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 46ddfb0..fa7fdff 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -55,6 +55,11 @@ static inline void udf_sb_free(struct super_block *sb)
 	}
 }
 
+static inline __u8 *udf_sb_volume_ident(struct super_block *sb)
+{
+	return udf_sb(sb)->s_volume_ident;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -119,7 +124,6 @@ static inline void udf_sb_free(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_VOLIDENT(X)			( udf_sb(X)->s_volident )
 #define UDF_SB_NUMPARTS(X)			( udf_sb(X)->s_partitions )
 #define UDF_SB_PARTITION(X)			( udf_sb(X)->s_partition )
 #define UDF_SB_SESSION(X)			( udf_sb(X)->s_session )
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index 80ae9ef..a1addf6 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -75,7 +75,7 @@ struct udf_part_map
 struct udf_sb_info
 {
 	struct udf_part_map	*s_partmaps;
-	__u8			s_volident[32];
+	__u8			s_volume_ident[32];
 
 	/* Overall info */
 	__u16			s_partitions;
-- 
1.5.3.4


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

* [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (3 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23 12:09   ` Christoph Hellwig
  2007-12-23  1:50 ` [PATCH 06/24] udf: convert UDF_SB_PARTITION macro to udf_sb_partition function marcin.slusarz
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/partition.c |    6 +++---
 fs/udf/super.c     |   20 ++++++++++----------
 fs/udf/udf_sb.h    |   10 +++++++---
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index aaab24c..c904ddf 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -31,7 +31,7 @@
 inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 			       uint16_t partition, uint32_t offset)
 {
-	if (partition >= UDF_SB_NUMPARTS(sb)) {
+	if (partition >= udf_sb_num_parts(sb)) {
 		udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
 			  block, partition, offset);
 		return 0xFFFFFFFF;
@@ -133,7 +133,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 	uint32_t packet;
 	int i, j, k, l;
 
-	for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
+	for (i = 0; i < udf_sb_num_parts(sb); i++) {
 		if (old_block > UDF_SB_PARTROOT(sb,i) &&
 		    old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
 			sdata = &UDF_SB_TYPESPAR(sb,i);
@@ -194,7 +194,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 		} /* if old_block */
 	}
 
-	if (i == UDF_SB_NUMPARTS(sb)) {
+	if (i == udf_sb_num_parts(sb)) {
 		/* outside of partitions */
 		/* for now, fail =) */
 		return 1;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 42de326..10eaba7 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -790,7 +790,7 @@ static int udf_find_fileset(struct super_block *sb,
 /* --> cvg: FIXME - is it reasonable? */
 		return 1;
 
-		for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1;
+		for (newfileset.partitionReferenceNum = udf_sb_num_parts(sb) - 1;
 		     (newfileset.partitionReferenceNum != 0xFFFF &&
 		      fileset->logicalBlockNum == 0xFFFFFFFF &&
 		      fileset->partitionReferenceNum == 0xFFFF);
@@ -907,7 +907,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 
 	p = (struct partitionDesc *)bh->b_data;
 
-	for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
+	for (i = 0; i < udf_sb_num_parts(sb); i++) {
 		udf_debug("Searching map: (%d == %d)\n",
 			  udf_sb_partmaps(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
 		if (udf_sb_partmaps(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
@@ -991,7 +991,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 			break;
 		}
 	}
-	if (i == UDF_SB_NUMPARTS(sb)) {
+	if (i == udf_sb_num_parts(sb)) {
 		udf_debug("Partition (%d) not found in partition map\n",
 			  le16_to_cpu(p->partitionNumber));
 	} else {
@@ -1016,7 +1016,7 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 	UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
 
 	for (i = 0, offset = 0;
-	     i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength);
+	     i < udf_sb_num_parts(sb) && offset < le32_to_cpu(lvd->mapTableLength);
 	     i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) {
 		type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
 		if (type == 1) {
@@ -1314,7 +1314,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 	} else
 		udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
 
-	for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
+	for (i = 0; i < udf_sb_num_parts(sb); i++) {
 		kernel_lb_addr uninitialized_var(ino);
 		switch (UDF_SB_PARTTYPE(sb, i)) {
 		case UDF_VIRTUAL_MAP15:
@@ -1330,7 +1330,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 				return 1;
 			}
 
-			for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) {
+			for (j = 0; j < udf_sb_num_parts(sb); j++) {
 				if (j != i &&
 				    UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) &&
 				    UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) {
@@ -1340,7 +1340,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 				}
 			}
 
-			if (j == UDF_SB_NUMPARTS(sb))
+			if (j == udf_sb_num_parts(sb))
 				return 1;
 
 			UDF_SB_VAT(sb) = udf_iget(sb, ino);
@@ -1561,7 +1561,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 			UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS);
 	}
 
-	if (!UDF_SB_NUMPARTS(sb)) {
+	if (!udf_sb_num_parts(sb)) {
 		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
 		goto error_out;
 	}
@@ -1611,7 +1611,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 error_out:
 	if (UDF_SB_VAT(sb))
 		iput(UDF_SB_VAT(sb));
-	if (UDF_SB_NUMPARTS(sb)) {
+	if (udf_sb_num_parts(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
 			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
@@ -1686,7 +1686,7 @@ static void udf_put_super(struct super_block *sb)
 
 	if (UDF_SB_VAT(sb))
 		iput(UDF_SB_VAT(sb));
-	if (UDF_SB_NUMPARTS(sb)) {
+	if (udf_sb_num_parts(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
 			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
 		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index fa7fdff..983565d 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -60,14 +60,19 @@ static inline __u8 *udf_sb_volume_ident(struct super_block *sb)
 	return udf_sb(sb)->s_volume_ident;
 }
 
+static inline __u16 udf_sb_num_parts(struct super_block *sb)
+{
+	return udf_sb(sb)->s_partitions;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
 	if (udf_sb_partmaps(X) != NULL) {\
-		UDF_SB_NUMPARTS(X) = Y;\
+		udf_sb(X)->s_partitions = Y;\
 		memset(udf_sb_partmaps(X), 0x00, sizeof(struct udf_part_map) * Y);\
 	} else {\
-		UDF_SB_NUMPARTS(X) = 0;\
+		udf_sb(X)->s_partitions = 0;\
 		udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
 	}\
 }
@@ -124,7 +129,6 @@ static inline __u8 *udf_sb_volume_ident(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_NUMPARTS(X)			( udf_sb(X)->s_partitions )
 #define UDF_SB_PARTITION(X)			( udf_sb(X)->s_partition )
 #define UDF_SB_SESSION(X)			( udf_sb(X)->s_session )
 #define UDF_SB_ANCHOR(X)			( udf_sb(X)->s_anchor )
-- 
1.5.3.4


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

* [PATCH 06/24] udf: convert UDF_SB_PARTITION macro to udf_sb_partition function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (4 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23  1:50 ` [PATCH 07/24] udf: convert UDF_SB_SESSION macro to udf_sb_session function marcin.slusarz
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c |   10 ++++----
 fs/udf/super.c  |   68 +++++++++++++++++++++++++++---------------------------
 fs/udf/udf_sb.h |    6 ++++-
 3 files changed, 44 insertions(+), 40 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index b5d09ae..e313d80 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -88,7 +88,7 @@ static int read_block_bitmap(struct super_block *sb,
 	kernel_lb_addr loc;
 
 	loc.logicalBlockNum = bitmap->s_extPosition;
-	loc.partitionReferenceNum = UDF_SB_PARTITION(sb);
+	loc.partitionReferenceNum = udf_sb_partition(sb);
 
 	bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block));
 	if (!bh) {
@@ -189,8 +189,8 @@ do_more:
 			if (inode)
 				DQUOT_FREE_BLOCK(inode, 1);
 			if (UDF_SB_LVIDBH(sb)) {
-				UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
-					cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1);
+				UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
+					cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + 1);
 			}
 		}
 	}
@@ -433,8 +433,8 @@ static void udf_table_free_blocks(struct super_block *sb,
 	if (inode)
 		DQUOT_FREE_BLOCK(inode, count);
 	if (UDF_SB_LVIDBH(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
+		UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
+			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + count);
 		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
 	}
 
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 10eaba7..452e6f6 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -840,7 +840,7 @@ static int udf_find_fileset(struct super_block *sb,
 			  fileset->logicalBlockNum,
 			  fileset->partitionReferenceNum);
 
-		UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum;
+		udf_sb(sb)->s_partition = fileset->partitionReferenceNum;
 		udf_load_fileset(sb, bh, root);
 		brelse(bh);
 		return 0;
@@ -1566,7 +1566,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		goto error_out;
 	}
 
-	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) {
+	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_READ_ONLY) {
 		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
@@ -1612,17 +1612,17 @@ error_out:
 	if (UDF_SB_VAT(sb))
 		iput(UDF_SB_VAT(sb));
 	if (udf_sb_num_parts(sb)) {
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
-		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
+			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
+			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
+			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
+			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
+		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
-				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
+				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
 		}
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1687,17 +1687,17 @@ static void udf_put_super(struct super_block *sb)
 	if (UDF_SB_VAT(sb))
 		iput(UDF_SB_VAT(sb));
 	if (udf_sb_num_parts(sb)) {
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
-		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
-		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
+			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
+			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
+			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
+		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
+			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
+		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
-				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
+				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
 		}
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1731,7 +1731,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 	buf->f_type = UDF_SUPER_MAGIC;
 	buf->f_bsize = sb->s_blocksize;
-	buf->f_blocks = UDF_SB_PARTLEN(sb, UDF_SB_PARTITION(sb));
+	buf->f_blocks = UDF_SB_PARTLEN(sb, udf_sb_partition(sb));
 	buf->f_bfree = udf_count_free(sb);
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = (UDF_SB_LVIDBH(sb) ?
@@ -1764,7 +1764,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bit
 	lock_kernel();
 
 	loc.logicalBlockNum = bitmap->s_extPosition;
-	loc.partitionReferenceNum = UDF_SB_PARTITION(sb);
+	loc.partitionReferenceNum = udf_sb_partition(sb);
 	bh = udf_read_ptagged(sb, loc, 0, &ident);
 
 	if (!bh) {
@@ -1838,8 +1838,8 @@ static unsigned int udf_count_free(struct super_block *sb)
 	unsigned int accum = 0;
 
 	if (UDF_SB_LVIDBH(sb)) {
-		if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) {
-			accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]);
+		if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > udf_sb_partition(sb)) {
+			accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]);
 			if (accum == 0xFFFFFFFF)
 				accum = 0;
 		}
@@ -1848,24 +1848,24 @@ static unsigned int udf_count_free(struct super_block *sb)
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
+					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_bitmap);
 	}
-	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
+	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
+					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_bitmap);
 	}
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
 		accum += udf_count_free_table(sb,
-					      udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
+					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
 	}
-	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
+	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE) {
 		accum += udf_count_free_table(sb,
-					      udf_sb_partmaps(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
+					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
 	}
 
 	return accum;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 983565d..6eb9ef4 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -65,6 +65,11 @@ static inline __u16 udf_sb_num_parts(struct super_block *sb)
 	return udf_sb(sb)->s_partitions;
 }
 
+static inline __u16 udf_sb_partition(struct super_block *sb)
+{
+	return udf_sb(sb)->s_partition;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -129,7 +134,6 @@ static inline __u16 udf_sb_num_parts(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_PARTITION(X)			( udf_sb(X)->s_partition )
 #define UDF_SB_SESSION(X)			( udf_sb(X)->s_session )
 #define UDF_SB_ANCHOR(X)			( udf_sb(X)->s_anchor )
 #define UDF_SB_LASTBLOCK(X)			( udf_sb(X)->s_lastblock )
-- 
1.5.3.4


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

* [PATCH 07/24] udf: convert UDF_SB_SESSION macro to udf_sb_session function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (5 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 06/24] udf: convert UDF_SB_PARTITION macro to udf_sb_partition function marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23  1:50 ` [PATCH 08/24] udf: convert UDF_SB_ANCHOR macro to udf_sb_anchor function marcin.slusarz
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/misc.c   |    8 ++++----
 fs/udf/super.c  |   28 ++++++++++++++--------------
 fs/udf/udf_sb.h |    6 +++++-
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 15297de..95baad5 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -197,10 +197,10 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 	if (block == 0xFFFFFFFF)
 		return NULL;
 
-	bh = udf_tread(sb, block + UDF_SB_SESSION(sb));
+	bh = udf_tread(sb, block + udf_sb_session(sb));
 	if (!bh) {
 		udf_debug("block=%d, location=%d: read failed\n",
-			  block + UDF_SB_SESSION(sb), location);
+			  block + udf_sb_session(sb), location);
 		return NULL;
 	}
 
@@ -210,7 +210,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 
 	if (location != le32_to_cpu(tag_p->tagLocation)) {
 		udf_debug("location mismatch block %u, tag %u != %u\n",
-			  block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
+			  block + udf_sb_session(sb), le32_to_cpu(tag_p->tagLocation), location);
 		goto error_out;
 	}
 
@@ -240,7 +240,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
 		return bh;
 	}
 	udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
-		  block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
+		  block + udf_sb_session(sb), le16_to_cpu(tag_p->descCRC),
 		  le16_to_cpu(tag_p->descCRCLength));
 
 error_out:
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 452e6f6..903c0ec 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -548,7 +548,7 @@ static int udf_vrs(struct super_block *sb, int silent)
 	else
 		sectorsize = sb->s_blocksize;
 
-	sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits);
+	sector += (udf_sb_session(sb) << sb->s_blocksize_bits);
 
 	udf_debug("Starting at sector %u (%ld byte sectors)\n",
 		  (sector >> sb->s_blocksize_bits), sb->s_blocksize);
@@ -614,7 +614,7 @@ static int udf_vrs(struct super_block *sb, int silent)
 		return nsr03;
 	else if (nsr02)
 		return nsr02;
-	else if (sector - (UDF_SB_SESSION(sb) << sb->s_blocksize_bits) == 32768)
+	else if (sector - (udf_sb_session(sb) << sb->s_blocksize_bits) == 32768)
 		return -1;
 	else
 		return 0;
@@ -675,15 +675,15 @@ static void udf_find_anchor(struct super_block *sb)
 			}
 
 			if (ident == TAG_IDENT_AVDP) {
-				if (location == last[i] - UDF_SB_SESSION(sb)) {
-					lastblock = last[i] - UDF_SB_SESSION(sb);
+				if (location == last[i] - udf_sb_session(sb)) {
+					lastblock = last[i] - udf_sb_session(sb);
 					UDF_SB_ANCHOR(sb)[0] = lastblock;
 					UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
-				} else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) {
+				} else if (location == udf_variable_to_fixed(last[i]) - udf_sb_session(sb)) {
 					UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
-					lastblock = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
+					lastblock = udf_variable_to_fixed(last[i]) - udf_sb_session(sb);
 					UDF_SB_ANCHOR(sb)[0] = lastblock;
-					UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
+					UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - udf_sb_session(sb);
 				} else {
 					udf_debug("Anchor found at block %d, location mismatch %d.\n",
 						  last[i], location);
@@ -704,13 +704,13 @@ static void udf_find_anchor(struct super_block *sb)
 				}
 
 				if (ident == TAG_IDENT_AVDP &&
-				    location == last[i] - 256 - UDF_SB_SESSION(sb)) {
+				    location == last[i] - 256 - udf_sb_session(sb)) {
 					lastblock = last[i];
 					UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
 				} else {
 					ident = location = 0;
-					if (last[i] >= 312 + UDF_SB_SESSION(sb)) {
-						bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb));
+					if (last[i] >= 312 + udf_sb_session(sb)) {
+						bh = sb_bread(sb, last[i] - 312 - udf_sb_session(sb));
 						if (bh) {
 							tag *t = (tag *)bh->b_data;
 							ident = le16_to_cpu(t->tagIdent);
@@ -732,7 +732,7 @@ static void udf_find_anchor(struct super_block *sb)
 
 	if (!lastblock) {
 		/* We haven't found the lastblock. check 312 */
-		bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb));
+		bh = sb_bread(sb, 312 + udf_sb_session(sb));
 		if (bh) {
 			tag *t = (tag *)bh->b_data;
 			ident = le16_to_cpu(t->tagIdent);
@@ -1506,11 +1506,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		goto error_out;
 
 	if (uopt.session == 0xFFFFFFFF)
-		UDF_SB_SESSION(sb) = udf_get_last_session(sb);
+		udf_sb(sb)->s_session = udf_get_last_session(sb);
 	else
-		UDF_SB_SESSION(sb) = uopt.session;
+		udf_sb(sb)->s_session = uopt.session;
 
-	udf_debug("Multi-session=%d\n", UDF_SB_SESSION(sb));
+	udf_debug("Multi-session=%d\n", udf_sb_session(sb));
 
 	UDF_SB_LASTBLOCK(sb) = uopt.lastblock;
 	UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 6eb9ef4..f33d38e 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -70,6 +70,11 @@ static inline __u16 udf_sb_partition(struct super_block *sb)
 	return udf_sb(sb)->s_partition;
 }
 
+static inline __s32 udf_sb_session(struct super_block *sb)
+{
+	return udf_sb(sb)->s_session;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -134,7 +139,6 @@ static inline __u16 udf_sb_partition(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_SESSION(X)			( udf_sb(X)->s_session )
 #define UDF_SB_ANCHOR(X)			( udf_sb(X)->s_anchor )
 #define UDF_SB_LASTBLOCK(X)			( udf_sb(X)->s_lastblock )
 #define UDF_SB_LVIDBH(X)			( udf_sb(X)->s_lvidbh )
-- 
1.5.3.4


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

* [PATCH 08/24] udf: convert UDF_SB_ANCHOR macro to udf_sb_anchor function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (6 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 07/24] udf: convert UDF_SB_SESSION macro to udf_sb_session function marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23  1:50 ` [PATCH 09/24] udf: convert UDF_SB_LASTBLOCK macro to udf_sb_last_block function marcin.slusarz
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c  |   44 ++++++++++++++++++++++----------------------
 fs/udf/udf_sb.h |    6 +++++-
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 903c0ec..0120ac6 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -677,20 +677,20 @@ static void udf_find_anchor(struct super_block *sb)
 			if (ident == TAG_IDENT_AVDP) {
 				if (location == last[i] - udf_sb_session(sb)) {
 					lastblock = last[i] - udf_sb_session(sb);
-					UDF_SB_ANCHOR(sb)[0] = lastblock;
-					UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
+					udf_sb_anchor(sb)[0] = lastblock;
+					udf_sb_anchor(sb)[1] = lastblock - 256;
 				} else if (location == udf_variable_to_fixed(last[i]) - udf_sb_session(sb)) {
 					UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
 					lastblock = udf_variable_to_fixed(last[i]) - udf_sb_session(sb);
-					UDF_SB_ANCHOR(sb)[0] = lastblock;
-					UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - udf_sb_session(sb);
+					udf_sb_anchor(sb)[0] = lastblock;
+					udf_sb_anchor(sb)[1] = lastblock - 256 - udf_sb_session(sb);
 				} else {
 					udf_debug("Anchor found at block %d, location mismatch %d.\n",
 						  last[i], location);
 				}
 			} else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) {
 				lastblock = last[i];
-				UDF_SB_ANCHOR(sb)[3] = 512;
+				udf_sb_anchor(sb)[3] = 512;
 			} else {
 				ident = location = 0;
 				if (last[i] >= 256) {
@@ -706,7 +706,7 @@ static void udf_find_anchor(struct super_block *sb)
 				if (ident == TAG_IDENT_AVDP &&
 				    location == last[i] - 256 - udf_sb_session(sb)) {
 					lastblock = last[i];
-					UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
+					udf_sb_anchor(sb)[1] = last[i] - 256;
 				} else {
 					ident = location = 0;
 					if (last[i] >= 312 + udf_sb_session(sb)) {
@@ -723,7 +723,7 @@ static void udf_find_anchor(struct super_block *sb)
 					    location == udf_variable_to_fixed(last[i]) - 256) {
 						UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
 						lastblock = udf_variable_to_fixed(last[i]);
-						UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
+						udf_sb_anchor(sb)[1] = lastblock - 256;
 					}
 				}
 			}
@@ -744,17 +744,17 @@ static void udf_find_anchor(struct super_block *sb)
 		}
 	}
 
-	for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
-		if (UDF_SB_ANCHOR(sb)[i]) {
-			bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
-					     UDF_SB_ANCHOR(sb)[i], &ident);
+	for (i = 0; i < ARRAY_SIZE(udf_sb(sb)->s_anchor); i++) {
+		if (udf_sb_anchor(sb)[i]) {
+			bh = udf_read_tagged(sb, udf_sb_anchor(sb)[i],
+					     udf_sb_anchor(sb)[i], &ident);
 			if (!bh)
-				UDF_SB_ANCHOR(sb)[i] = 0;
+				udf_sb_anchor(sb)[i] = 0;
 			else {
 				brelse(bh);
 				if ((ident != TAG_IDENT_AVDP) &&
 				    (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE)))
-					UDF_SB_ANCHOR(sb)[i] = 0;
+					udf_sb_anchor(sb)[i] = 0;
 			}
 		}
 	}
@@ -1280,10 +1280,10 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 	if (!sb)
 		return 1;
 
-	for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
-		if (UDF_SB_ANCHOR(sb)[i] &&
-		    (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
-					  UDF_SB_ANCHOR(sb)[i], &ident))) {
+	for (i = 0; i < ARRAY_SIZE(udf_sb(sb)->s_anchor); i++) {
+		if (udf_sb_anchor(sb)[i] &&
+		    (bh = udf_read_tagged(sb, udf_sb_anchor(sb)[i],
+					  udf_sb_anchor(sb)[i], &ident))) {
 			anchor = (struct anchorVolDescPtr *)bh->b_data;
 
 			/* Locate the main sequence */
@@ -1308,11 +1308,11 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 		}
 	}
 
-	if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) {
+	if (i == ARRAY_SIZE(udf_sb(sb)->s_anchor)) {
 		udf_debug("No Anchor block found\n");
 		return 1;
 	} else
-		udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
+		udf_debug("Using anchor in block %d\n", udf_sb_anchor(sb)[i]);
 
 	for (i = 0; i < udf_sb_num_parts(sb); i++) {
 		kernel_lb_addr uninitialized_var(ino);
@@ -1513,9 +1513,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	udf_debug("Multi-session=%d\n", udf_sb_session(sb));
 
 	UDF_SB_LASTBLOCK(sb) = uopt.lastblock;
-	UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0;
-	UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
-	UDF_SB_ANCHOR(sb)[3] = 256;
+	udf_sb_anchor(sb)[0] = udf_sb_anchor(sb)[1] = 0;
+	udf_sb_anchor(sb)[2] = uopt.anchor;
+	udf_sb_anchor(sb)[3] = 256;
 
 	if (udf_check_valid(sb, uopt.novrs, silent)) {
 		/* read volume recognition sequences */
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index f33d38e..f00524f 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -75,6 +75,11 @@ static inline __s32 udf_sb_session(struct super_block *sb)
 	return udf_sb(sb)->s_session;
 }
 
+static inline __u32 *udf_sb_anchor(struct super_block *sb)
+{
+	return udf_sb(sb)->s_anchor;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -139,7 +144,6 @@ static inline __s32 udf_sb_session(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_ANCHOR(X)			( udf_sb(X)->s_anchor )
 #define UDF_SB_LASTBLOCK(X)			( udf_sb(X)->s_lastblock )
 #define UDF_SB_LVIDBH(X)			( udf_sb(X)->s_lvidbh )
 #define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data )
-- 
1.5.3.4


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

* [PATCH 09/24] udf: convert UDF_SB_LASTBLOCK macro to udf_sb_last_block function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (7 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 08/24] udf: convert UDF_SB_ANCHOR macro to udf_sb_anchor function marcin.slusarz
@ 2007-12-23  1:50 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 10/24] udf: convert UDF_SB_LVIDBH macro to udf_sb_lvid_bh function marcin.slusarz
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:50 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_LASTBLOCK macro to udf_sb_last_block inline function
- rename s_lastblock field to s_last_block

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c            |   20 ++++++++++----------
 fs/udf/udf_sb.h           |    6 +++++-
 include/linux/udf_fs_sb.h |    2 +-
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 0120ac6..e641d8f 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -639,7 +639,7 @@ static int udf_vrs(struct super_block *sb, int silent)
  */
 static void udf_find_anchor(struct super_block *sb)
 {
-	int lastblock = UDF_SB_LASTBLOCK(sb);
+	int lastblock = udf_sb_last_block(sb);
 	struct buffer_head *bh = NULL;
 	uint16_t ident;
 	uint32_t location;
@@ -759,7 +759,7 @@ static void udf_find_anchor(struct super_block *sb)
 		}
 	}
 
-	UDF_SB_LASTBLOCK(sb) = lastblock;
+	udf_sb(sb)->s_last_block = lastblock;
 }
 
 static int udf_find_fileset(struct super_block *sb,
@@ -1261,8 +1261,8 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
 		if (block == -1) {
 			udf_debug("Failed to read byte 32768. Assuming open "
 				  "disc. Skipping validity check\n");
-			if (!UDF_SB_LASTBLOCK(sb))
-				UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
+			if (!udf_sb_last_block(sb))
+				udf_sb(sb)->s_last_block = udf_get_last_block(sb);
 			return 0;
 		} else
 			return !block;
@@ -1319,12 +1319,12 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 		switch (UDF_SB_PARTTYPE(sb, i)) {
 		case UDF_VIRTUAL_MAP15:
 		case UDF_VIRTUAL_MAP20:
-			if (!UDF_SB_LASTBLOCK(sb)) {
-				UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
+			if (!udf_sb_last_block(sb)) {
+				udf_sb(sb)->s_last_block = udf_get_last_block(sb);
 				udf_find_anchor(sb);
 			}
 
-			if (!UDF_SB_LASTBLOCK(sb)) {
+			if (!udf_sb_last_block(sb)) {
 				udf_debug("Unable to determine Lastblock (For "
 					  "Virtual Partition)\n");
 				return 1;
@@ -1335,7 +1335,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 				    UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) &&
 				    UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) {
 					ino.partitionReferenceNum = j;
-					ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) - UDF_SB_PARTROOT(sb, j);
+					ino.logicalBlockNum = udf_sb_last_block(sb) - UDF_SB_PARTROOT(sb, j);
 					break;
 				}
 			}
@@ -1512,7 +1512,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	udf_debug("Multi-session=%d\n", udf_sb_session(sb));
 
-	UDF_SB_LASTBLOCK(sb) = uopt.lastblock;
+	udf_sb(sb)->s_last_block = uopt.lastblock;
 	udf_sb_anchor(sb)[0] = udf_sb_anchor(sb)[1] = 0;
 	udf_sb_anchor(sb)[2] = uopt.anchor;
 	udf_sb_anchor(sb)[3] = 256;
@@ -1537,7 +1537,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		goto error_out;
 	}
 
-	udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb));
+	udf_debug("Lastblock=%d\n", udf_sb_last_block(sb));
 
 	if (UDF_SB_LVIDBH(sb)) {
 		uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index f00524f..ea4ec0f 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -80,6 +80,11 @@ static inline __u32 *udf_sb_anchor(struct super_block *sb)
 	return udf_sb(sb)->s_anchor;
 }
 
+static inline __u32 udf_sb_last_block(struct super_block *sb)
+{
+	return udf_sb(sb)->s_last_block;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -144,7 +149,6 @@ static inline __u32 *udf_sb_anchor(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_LASTBLOCK(X)			( udf_sb(X)->s_lastblock )
 #define UDF_SB_LVIDBH(X)			( udf_sb(X)->s_lvidbh )
 #define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data )
 #define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index a1addf6..2f46ce6 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -84,7 +84,7 @@ struct udf_sb_info
 	/* Sector headers */
 	__s32			s_session;
 	__u32			s_anchor[4];
-	__u32			s_lastblock;
+	__u32			s_last_block;
 
 	struct buffer_head	*s_lvidbh;
 
-- 
1.5.3.4


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

* [PATCH 10/24] udf: convert UDF_SB_LVIDBH macro to udf_sb_lvid_bh function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (8 preceding siblings ...)
  2007-12-23  1:50 ` [PATCH 09/24] udf: convert UDF_SB_LASTBLOCK macro to udf_sb_last_block function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 11/24] udf: convert UDF_SB_LVID macro to udf_sb_lvid function marcin.slusarz
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_LVIDBH macro to udf_sb_lvid_bh inline function
- rename s_lvidbh field to s_lvid_bh

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c           |   26 +++++++++++++-------------
 fs/udf/ialloc.c           |    8 ++++----
 fs/udf/namei.c            |    8 ++++----
 fs/udf/super.c            |   26 +++++++++++++-------------
 fs/udf/udf_sb.h           |    8 ++++++--
 include/linux/udf_fs_sb.h |    2 +-
 6 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index e313d80..d689d16 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -188,7 +188,7 @@ do_more:
 		} else {
 			if (inode)
 				DQUOT_FREE_BLOCK(inode, 1);
-			if (UDF_SB_LVIDBH(sb)) {
+			if (udf_sb_lvid_bh(sb)) {
 				UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
 					cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + 1);
 			}
@@ -202,8 +202,8 @@ do_more:
 	}
 error_return:
 	sb->s_dirt = 1;
-	if (UDF_SB_LVIDBH(sb))
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+	if (udf_sb_lvid_bh(sb))
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	mutex_unlock(&sbi->s_alloc_mutex);
 	return;
 }
@@ -261,10 +261,10 @@ repeat:
 	if (block_count > 0)
 		goto repeat;
 out:
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
 			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 	sb->s_dirt = 1;
 	mutex_unlock(&sbi->s_alloc_mutex);
@@ -389,10 +389,10 @@ got_block:
 
 	mark_buffer_dirty(bh);
 
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
 			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 	sb->s_dirt = 1;
 	mutex_unlock(&sbi->s_alloc_mutex);
@@ -432,10 +432,10 @@ static void udf_table_free_blocks(struct super_block *sb,
 	   but.. oh well */
 	if (inode)
 		DQUOT_FREE_BLOCK(inode, count);
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
 			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + count);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 
 	start = bloc.logicalBlockNum + offset;
@@ -670,10 +670,10 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 
 	brelse(epos.bh);
 
-	if (alloc_count && UDF_SB_LVIDBH(sb)) {
+	if (alloc_count && udf_sb_lvid_bh(sb)) {
 		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
 			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 		sb->s_dirt = 1;
 	}
 	mutex_unlock(&sbi->s_alloc_mutex);
@@ -771,10 +771,10 @@ static int udf_table_new_block(struct super_block *sb,
 		udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
 	brelse(goal_epos.bh);
 
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
 			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 
 	sb->s_dirt = 1;
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 92dc9ae..5cfac06 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -43,7 +43,7 @@ void udf_free_inode(struct inode *inode)
 	clear_inode(inode);
 
 	mutex_lock(&sbi->s_alloc_mutex);
-	if (sbi->s_lvidbh) {
+	if (sbi->s_lvid_bh) {
 		if (S_ISDIR(inode->i_mode))
 			UDF_SB_LVIDIU(sb)->numDirs =
 				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
@@ -51,7 +51,7 @@ void udf_free_inode(struct inode *inode)
 			UDF_SB_LVIDIU(sb)->numFiles =
 				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
 
-		mark_buffer_dirty(sbi->s_lvidbh);
+		mark_buffer_dirty(sbi->s_lvid_bh);
 	}
 	mutex_unlock(&sbi->s_alloc_mutex);
 
@@ -88,7 +88,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 	}
 
 	mutex_lock(&sbi->s_alloc_mutex);
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
 		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
@@ -102,7 +102,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 		if (!(++uniqueID & 0x00000000FFFFFFFFUL))
 			uniqueID += 16;
 		lvhd->uniqueID = cpu_to_le64(uniqueID);
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 	inode->i_mode = mode;
 	inode->i_uid = current->fsuid;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 066153f..4122d2b 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1014,7 +1014,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 		goto out_no_entry;
 	cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
 	cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
-	if (UDF_SB_LVIDBH(inode->i_sb)) {
+	if (udf_sb_lvid_bh(inode->i_sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
 		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
@@ -1024,7 +1024,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 		if (!(++uniqueID & 0x00000000FFFFFFFFUL))
 			uniqueID += 16;
 		lvhd->uniqueID = cpu_to_le64(uniqueID);
-		mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(inode->i_sb));
 	}
 	udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
 	if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
@@ -1066,7 +1066,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 	}
 	cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
 	cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
-	if (UDF_SB_LVIDBH(inode->i_sb)) {
+	if (udf_sb_lvid_bh(inode->i_sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
 		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
@@ -1076,7 +1076,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 		if (!(++uniqueID & 0x00000000FFFFFFFFUL))
 			uniqueID += 16;
 		lvhd->uniqueID = cpu_to_le64(uniqueID);
-		mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(inode->i_sb));
 	}
 	udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
 	if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
diff --git a/fs/udf/super.c b/fs/udf/super.c
index e641d8f..b1f02a4 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -475,7 +475,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 	udf_sb(sb)->s_gid   = uopt.gid;
 	udf_sb(sb)->s_umask = uopt.umask;
 
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
 		if (write_rev > UDF_MAX_WRITE_VERSION)
 			*flags |= MS_RDONLY;
@@ -1097,18 +1097,18 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
 	       (bh = udf_read_tagged(sb, loc.extLocation,
 				     loc.extLocation, &ident)) &&
 	       ident == TAG_IDENT_LVID) {
-		UDF_SB_LVIDBH(sb) = bh;
+		udf_sb(sb)->s_lvid_bh = bh;
 
 		if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
 			udf_load_logicalvolint(sb,
 				leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
 
-		if (UDF_SB_LVIDBH(sb) != bh)
+		if (udf_sb_lvid_bh(sb) != bh)
 			brelse(bh);
 		loc.extLength -= sb->s_blocksize;
 		loc.extLocation++;
 	}
-	if (UDF_SB_LVIDBH(sb) != bh)
+	if (udf_sb_lvid_bh(sb) != bh)
 		brelse(bh);
 }
 
@@ -1377,7 +1377,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 
 static void udf_open_lvid(struct super_block *sb)
 {
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		int i;
 		kernel_timestamp cpu_time;
 
@@ -1396,7 +1396,7 @@ static void udf_open_lvid(struct super_block *sb)
 				UDF_SB_LVID(sb)->descTag.tagChecksum +=
 					((uint8_t *) &(UDF_SB_LVID(sb)->descTag))[i];
 
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 }
 
@@ -1405,7 +1405,7 @@ static void udf_close_lvid(struct super_block *sb)
 	kernel_timestamp cpu_time;
 	int i;
 
-	if (UDF_SB_LVIDBH(sb) &&
+	if (udf_sb_lvid_bh(sb) &&
 	    UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
@@ -1429,7 +1429,7 @@ static void udf_close_lvid(struct super_block *sb)
 				UDF_SB_LVID(sb)->descTag.tagChecksum +=
 					((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
 
-		mark_buffer_dirty(UDF_SB_LVIDBH(sb));
+		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 }
 
@@ -1539,7 +1539,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	udf_debug("Lastblock=%d\n", udf_sb_last_block(sb));
 
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
 		uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
 		/* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
@@ -1631,7 +1631,7 @@ error_out:
 #endif
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
-	brelse(UDF_SB_LVIDBH(sb));
+	brelse(udf_sb_lvid_bh(sb));
 	udf_sb_free(sb);
 	kfree(sbi);
 	sb->s_fs_info = NULL;
@@ -1706,7 +1706,7 @@ static void udf_put_super(struct super_block *sb)
 #endif
 	if (!(sb->s_flags & MS_RDONLY))
 		udf_close_lvid(sb);
-	brelse(UDF_SB_LVIDBH(sb));
+	brelse(udf_sb_lvid_bh(sb));
 	udf_sb_free(sb);
 	kfree(sb->s_fs_info);
 	sb->s_fs_info = NULL;
@@ -1734,7 +1734,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_blocks = UDF_SB_PARTLEN(sb, udf_sb_partition(sb));
 	buf->f_bfree = udf_count_free(sb);
 	buf->f_bavail = buf->f_bfree;
-	buf->f_files = (UDF_SB_LVIDBH(sb) ?
+	buf->f_files = (udf_sb_lvid_bh(sb) ?
 			(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
 			 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
 	buf->f_ffree = buf->f_bfree;
@@ -1837,7 +1837,7 @@ static unsigned int udf_count_free(struct super_block *sb)
 {
 	unsigned int accum = 0;
 
-	if (UDF_SB_LVIDBH(sb)) {
+	if (udf_sb_lvid_bh(sb)) {
 		if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > udf_sb_partition(sb)) {
 			accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]);
 			if (accum == 0xFFFFFFFF)
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index ea4ec0f..dd0ba67 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -85,6 +85,11 @@ static inline __u32 udf_sb_last_block(struct super_block *sb)
 	return udf_sb(sb)->s_last_block;
 }
 
+static inline struct buffer_head *udf_sb_lvid_bh(struct super_block *sb)
+{
+	return udf_sb(sb)->s_lvid_bh;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -149,8 +154,7 @@ static inline __u32 udf_sb_last_block(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_LVIDBH(X)			( udf_sb(X)->s_lvidbh )
-#define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data )
+#define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)udf_sb_lvid_bh(X)->b_data )
 #define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
 
 #define UDF_SB_UMASK(X)				( udf_sb(X)->s_umask )
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index 2f46ce6..a9f19ab 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -86,7 +86,7 @@ struct udf_sb_info
 	__u32			s_anchor[4];
 	__u32			s_last_block;
 
-	struct buffer_head	*s_lvidbh;
+	struct buffer_head	*s_lvid_bh;
 
 	/* Default permissions */
 	mode_t			s_umask;
-- 
1.5.3.4


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

* [PATCH 11/24] udf: convert UDF_SB_LVID macro to udf_sb_lvid function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (9 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 10/24] udf: convert UDF_SB_LVIDBH macro to udf_sb_lvid_bh function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 12/24] udf: convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function marcin.slusarz
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c |   24 ++++++++++++------------
 fs/udf/ialloc.c |    2 +-
 fs/udf/namei.c  |    4 ++--
 fs/udf/super.c  |   40 ++++++++++++++++++++--------------------
 fs/udf/udf_sb.h |    8 ++++++--
 5 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index d689d16..4c31666 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -189,8 +189,8 @@ do_more:
 			if (inode)
 				DQUOT_FREE_BLOCK(inode, 1);
 			if (udf_sb_lvid_bh(sb)) {
-				UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
-					cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + 1);
+				udf_sb_lvid(sb)->freeSpaceTable[udf_sb_partition(sb)] =
+					cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[udf_sb_partition(sb)]) + 1);
 			}
 		}
 	}
@@ -262,8 +262,8 @@ repeat:
 		goto repeat;
 out:
 	if (udf_sb_lvid_bh(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
+		udf_sb_lvid(sb)->freeSpaceTable[partition] =
+			cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[partition]) - alloc_count);
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 	sb->s_dirt = 1;
@@ -390,8 +390,8 @@ got_block:
 	mark_buffer_dirty(bh);
 
 	if (udf_sb_lvid_bh(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
+		udf_sb_lvid(sb)->freeSpaceTable[partition] =
+			cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[partition]) - 1);
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 	sb->s_dirt = 1;
@@ -433,8 +433,8 @@ static void udf_table_free_blocks(struct super_block *sb,
 	if (inode)
 		DQUOT_FREE_BLOCK(inode, count);
 	if (udf_sb_lvid_bh(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]) + count);
+		udf_sb_lvid(sb)->freeSpaceTable[udf_sb_partition(sb)] =
+			cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[udf_sb_partition(sb)]) + count);
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 
@@ -671,8 +671,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 	brelse(epos.bh);
 
 	if (alloc_count && udf_sb_lvid_bh(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
+		udf_sb_lvid(sb)->freeSpaceTable[partition] =
+			cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[partition]) - alloc_count);
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 		sb->s_dirt = 1;
 	}
@@ -772,8 +772,8 @@ static int udf_table_new_block(struct super_block *sb,
 	brelse(goal_epos.bh);
 
 	if (udf_sb_lvid_bh(sb)) {
-		UDF_SB_LVID(sb)->freeSpaceTable[partition] =
-			cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
+		udf_sb_lvid(sb)->freeSpaceTable[partition] =
+			cpu_to_le32(le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[partition]) - 1);
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
 
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 5cfac06..ddbf1e6 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -91,7 +91,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 	if (udf_sb_lvid_bh(sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
-		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
+		lvhd = (struct logicalVolHeaderDesc *)(udf_sb_lvid(sb)->logicalVolContentsUse);
 		if (S_ISDIR(mode))
 			UDF_SB_LVIDIU(sb)->numDirs =
 				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 4122d2b..4a18bfc 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1017,7 +1017,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 	if (udf_sb_lvid_bh(inode->i_sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
-		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
+		lvhd = (struct logicalVolHeaderDesc *)(udf_sb_lvid(inode->i_sb)->logicalVolContentsUse);
 		uniqueID = le64_to_cpu(lvhd->uniqueID);
 		*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
 			cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
@@ -1069,7 +1069,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 	if (udf_sb_lvid_bh(inode->i_sb)) {
 		struct logicalVolHeaderDesc *lvhd;
 		uint64_t uniqueID;
-		lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
+		lvhd = (struct logicalVolHeaderDesc *)(udf_sb_lvid(inode->i_sb)->logicalVolContentsUse);
 		uniqueID = le64_to_cpu(lvhd->uniqueID);
 		*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
 			cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index b1f02a4..f9109c5 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1099,9 +1099,9 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
 	       ident == TAG_IDENT_LVID) {
 		udf_sb(sb)->s_lvid_bh = bh;
 
-		if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
+		if (udf_sb_lvid(sb)->nextIntegrityExt.extLength)
 			udf_load_logicalvolint(sb,
-				leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
+				leea_to_cpu(udf_sb_lvid(sb)->nextIntegrityExt));
 
 		if (udf_sb_lvid_bh(sb) != bh)
 			brelse(bh);
@@ -1384,17 +1384,17 @@ static void udf_open_lvid(struct super_block *sb)
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
-			UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
-		UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN;
+			udf_sb_lvid(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
+		udf_sb_lvid(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN;
 
-		UDF_SB_LVID(sb)->descTag.descCRC = cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
-								       le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
+		udf_sb_lvid(sb)->descTag.descCRC = cpu_to_le16(udf_crc((char *)udf_sb_lvid(sb) + sizeof(tag),
+								       le16_to_cpu(udf_sb_lvid(sb)->descTag.descCRCLength), 0));
 
-		UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
+		udf_sb_lvid(sb)->descTag.tagChecksum = 0;
 		for (i = 0; i < 16; i++)
 			if (i != 4)
-				UDF_SB_LVID(sb)->descTag.tagChecksum +=
-					((uint8_t *) &(UDF_SB_LVID(sb)->descTag))[i];
+				udf_sb_lvid(sb)->descTag.tagChecksum +=
+					((uint8_t *) &(udf_sb_lvid(sb)->descTag))[i];
 
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
@@ -1406,28 +1406,28 @@ static void udf_close_lvid(struct super_block *sb)
 	int i;
 
 	if (udf_sb_lvid_bh(sb) &&
-	    UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
+	    udf_sb_lvid(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
 		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
-			UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
+			udf_sb_lvid(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
 		if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
 			UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
 		if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
 			UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
 		if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
 			UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
-		UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
+		udf_sb_lvid(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
 
-		UDF_SB_LVID(sb)->descTag.descCRC =
-			cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
-					    le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
+		udf_sb_lvid(sb)->descTag.descCRC =
+			cpu_to_le16(udf_crc((char *)udf_sb_lvid(sb) + sizeof(tag),
+					    le16_to_cpu(udf_sb_lvid(sb)->descTag.descCRCLength), 0));
 
-		UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
+		udf_sb_lvid(sb)->descTag.tagChecksum = 0;
 		for (i = 0; i < 16; i++)
 			if (i != 4)
-				UDF_SB_LVID(sb)->descTag.tagChecksum +=
-					((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
+				udf_sb_lvid(sb)->descTag.tagChecksum +=
+					((uint8_t *)&(udf_sb_lvid(sb)->descTag))[i];
 
 		mark_buffer_dirty(udf_sb_lvid_bh(sb));
 	}
@@ -1838,8 +1838,8 @@ static unsigned int udf_count_free(struct super_block *sb)
 	unsigned int accum = 0;
 
 	if (udf_sb_lvid_bh(sb)) {
-		if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > udf_sb_partition(sb)) {
-			accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[udf_sb_partition(sb)]);
+		if (le32_to_cpu(udf_sb_lvid(sb)->numOfPartitions) > udf_sb_partition(sb)) {
+			accum = le32_to_cpu(udf_sb_lvid(sb)->freeSpaceTable[udf_sb_partition(sb)]);
 			if (accum == 0xFFFFFFFF)
 				accum = 0;
 		}
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index dd0ba67..ac222f6 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -90,6 +90,11 @@ static inline struct buffer_head *udf_sb_lvid_bh(struct super_block *sb)
 	return udf_sb(sb)->s_lvid_bh;
 }
 
+static inline struct logicalVolIntegrityDesc *udf_sb_lvid(struct super_block *sb)
+{
+	return (struct logicalVolIntegrityDesc *)udf_sb_lvid_bh(sb)->b_data;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -154,8 +159,7 @@ static inline struct buffer_head *udf_sb_lvid_bh(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_LVID(X)				( (struct logicalVolIntegrityDesc *)udf_sb_lvid_bh(X)->b_data )
-#define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
+#define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(udf_sb_lvid(X)->impUse[le32_to_cpu(udf_sb_lvid(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
 
 #define UDF_SB_UMASK(X)				( udf_sb(X)->s_umask )
 #define UDF_SB_GID(X)				( udf_sb(X)->s_gid )
-- 
1.5.3.4


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

* [PATCH 12/24] udf: convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (10 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 11/24] udf: convert UDF_SB_LVID macro to udf_sb_lvid function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 13/24] udf: remove unused macros marcin.slusarz
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/ialloc.c |   16 ++++++++--------
 fs/udf/super.c  |   34 +++++++++++++++++-----------------
 fs/udf/udf_sb.h |   10 ++++++++--
 3 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index ddbf1e6..269f588 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -45,11 +45,11 @@ void udf_free_inode(struct inode *inode)
 	mutex_lock(&sbi->s_alloc_mutex);
 	if (sbi->s_lvid_bh) {
 		if (S_ISDIR(inode->i_mode))
-			UDF_SB_LVIDIU(sb)->numDirs =
-				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
+			udf_sb_lvidiu(sb)->numDirs =
+				cpu_to_le32(le32_to_cpu(udf_sb_lvidiu(sb)->numDirs) - 1);
 		else
-			UDF_SB_LVIDIU(sb)->numFiles =
-				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
+			udf_sb_lvidiu(sb)->numFiles =
+				cpu_to_le32(le32_to_cpu(udf_sb_lvidiu(sb)->numFiles) - 1);
 
 		mark_buffer_dirty(sbi->s_lvid_bh);
 	}
@@ -93,11 +93,11 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 		uint64_t uniqueID;
 		lvhd = (struct logicalVolHeaderDesc *)(udf_sb_lvid(sb)->logicalVolContentsUse);
 		if (S_ISDIR(mode))
-			UDF_SB_LVIDIU(sb)->numDirs =
-				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
+			udf_sb_lvidiu(sb)->numDirs =
+				cpu_to_le32(le32_to_cpu(udf_sb_lvidiu(sb)->numDirs) + 1);
 		else
-			UDF_SB_LVIDIU(sb)->numFiles =
-				cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
+			udf_sb_lvidiu(sb)->numFiles =
+				cpu_to_le32(le32_to_cpu(udf_sb_lvidiu(sb)->numFiles) + 1);
 		UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
 		if (!(++uniqueID & 0x00000000FFFFFFFFUL))
 			uniqueID += 16;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index f9109c5..6c14c4d 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -476,7 +476,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 	udf_sb(sb)->s_umask = uopt.umask;
 
 	if (udf_sb_lvid_bh(sb)) {
-		int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
+		int write_rev = le16_to_cpu(udf_sb_lvidiu(sb)->minUDFWriteRev);
 		if (write_rev > UDF_MAX_WRITE_VERSION)
 			*flags |= MS_RDONLY;
 	}
@@ -1381,8 +1381,8 @@ static void udf_open_lvid(struct super_block *sb)
 		int i;
 		kernel_timestamp cpu_time;
 
-		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
-		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
+		udf_sb_lvidiu(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
+		udf_sb_lvidiu(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
 			udf_sb_lvid(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
 		udf_sb_lvid(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN;
@@ -1407,16 +1407,16 @@ static void udf_close_lvid(struct super_block *sb)
 
 	if (udf_sb_lvid_bh(sb) &&
 	    udf_sb_lvid(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
-		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
-		UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
+		udf_sb_lvidiu(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
+		udf_sb_lvidiu(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
 			udf_sb_lvid(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
-		if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
-			UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
-		if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
-			UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
-		if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
-			UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
+		if (UDF_MAX_WRITE_VERSION > le16_to_cpu(udf_sb_lvidiu(sb)->maxUDFWriteRev))
+			udf_sb_lvidiu(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
+		if (UDF_SB_UDFREV(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFReadRev))
+			udf_sb_lvidiu(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
+		if (UDF_SB_UDFREV(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFWriteRev))
+			udf_sb_lvidiu(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
 		udf_sb_lvid(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
 
 		udf_sb_lvid(sb)->descTag.descCRC =
@@ -1540,13 +1540,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	udf_debug("Lastblock=%d\n", udf_sb_last_block(sb));
 
 	if (udf_sb_lvid_bh(sb)) {
-		uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
-		uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
-		/* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
+		uint16_t minUDFReadRev = le16_to_cpu(udf_sb_lvidiu(sb)->minUDFReadRev);
+		uint16_t minUDFWriteRev = le16_to_cpu(udf_sb_lvidiu(sb)->minUDFWriteRev);
+		/* uint16_t maxUDFWriteRev = le16_to_cpu(udf_sb_lvidiu(sb)->maxUDFWriteRev); */
 
 		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
 			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x (max is %x)\n",
-			       le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
+			       le16_to_cpu(udf_sb_lvidiu(sb)->minUDFReadRev),
 			       UDF_MAX_READ_VERSION);
 			goto error_out;
 		} else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) {
@@ -1735,8 +1735,8 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_bfree = udf_count_free(sb);
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = (udf_sb_lvid_bh(sb) ?
-			(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
-			 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
+			(le32_to_cpu(udf_sb_lvidiu(sb)->numFiles) +
+			 le32_to_cpu(udf_sb_lvidiu(sb)->numDirs)) : 0) + buf->f_bfree;
 	buf->f_ffree = buf->f_bfree;
 	/* __kernel_fsid_t f_fsid */
 	buf->f_namelen = UDF_NAME_LEN - 2;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index ac222f6..a9ff8fb 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -95,6 +95,14 @@ static inline struct logicalVolIntegrityDesc *udf_sb_lvid(struct super_block *sb
 	return (struct logicalVolIntegrityDesc *)udf_sb_lvid_bh(sb)->b_data;
 }
 
+static inline struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_block *sb)
+{
+	struct logicalVolIntegrityDesc *lvid = udf_sb_lvid(sb);
+	__u32 number_of_partitions = le32_to_cpu(lvid->numOfPartitions);
+	__u32 offset = number_of_partitions * 2 * sizeof(uint32_t)/sizeof(uint8_t);
+	return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]);
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -159,8 +167,6 @@ static inline struct logicalVolIntegrityDesc *udf_sb_lvid(struct super_block *sb
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_LVIDIU(X)			( (struct logicalVolIntegrityDescImpUse *)&(udf_sb_lvid(X)->impUse[le32_to_cpu(udf_sb_lvid(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) )
-
 #define UDF_SB_UMASK(X)				( udf_sb(X)->s_umask )
 #define UDF_SB_GID(X)				( udf_sb(X)->s_gid )
 #define UDF_SB_UID(X)				( udf_sb(X)->s_uid )
-- 
1.5.3.4


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

* [PATCH 13/24] udf: remove unused macros
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (11 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 12/24] udf: convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 14/24] udf: convert UDF_SB_RECORDTIME macro to udf_sb_record_time function marcin.slusarz
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/udf_sb.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index a9ff8fb..8683b71 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -167,13 +167,9 @@ static inline struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_b
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_UMASK(X)				( udf_sb(X)->s_umask )
-#define UDF_SB_GID(X)				( udf_sb(X)->s_gid )
-#define UDF_SB_UID(X)				( udf_sb(X)->s_uid )
 #define UDF_SB_RECORDTIME(X)			( udf_sb(X)->s_recordtime )
 #define UDF_SB_SERIALNUM(X)			( udf_sb(X)->s_serialnum )
 #define UDF_SB_UDFREV(X)			( udf_sb(X)->s_udfrev )
-#define UDF_SB_FLAGS(X)				( udf_sb(X)->s_flags )
 #define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
 
 #endif /* __LINUX_UDF_SB_H */
-- 
1.5.3.4


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

* [PATCH 14/24] udf: convert UDF_SB_RECORDTIME macro to udf_sb_record_time function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (12 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 13/24] udf: remove unused macros marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 15/24] udf: convert UDF_SB_SERIALNUM macro to udf_sb_serial_number function marcin.slusarz
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_RECORDTIME macro to udf_sb_record_time inline function
- rename s_recordtime field to s_record_time

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/inode.c            |   14 +++++++-------
 fs/udf/super.c            |    6 +++---
 fs/udf/udf_sb.h           |    6 +++++-
 include/linux/udf_fs_sb.h |    2 +-
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 5afa19e..8c725e2 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1160,7 +1160,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_atime.tv_sec = convtime;
 			inode->i_atime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_atime = udf_sb_record_time(inode->i_sb);
 		}
 
 		if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1168,7 +1168,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_mtime.tv_sec = convtime;
 			inode->i_mtime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_mtime = udf_sb_record_time(inode->i_sb);
 		}
 
 		if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1176,7 +1176,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_ctime.tv_sec = convtime;
 			inode->i_ctime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_ctime = udf_sb_record_time(inode->i_sb);
 		}
 
 		UDF_I_UNIQUE(inode) = le64_to_cpu(fe->uniqueID);
@@ -1192,7 +1192,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_atime.tv_sec = convtime;
 			inode->i_atime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_atime = udf_sb_record_time(inode->i_sb);
 		}
 
 		if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1200,7 +1200,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_mtime.tv_sec = convtime;
 			inode->i_mtime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_mtime = udf_sb_record_time(inode->i_sb);
 		}
 
 		if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1208,7 +1208,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			UDF_I_CRTIME(inode).tv_sec = convtime;
 			UDF_I_CRTIME(inode).tv_nsec = convtime_usec * 1000;
 		} else {
-			UDF_I_CRTIME(inode) = UDF_SB_RECORDTIME(inode->i_sb);
+			UDF_I_CRTIME(inode) = udf_sb_record_time(inode->i_sb);
 		}
 
 		if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1216,7 +1216,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
 			inode->i_ctime.tv_sec = convtime;
 			inode->i_ctime.tv_nsec = convtime_usec * 1000;
 		} else {
-			inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb);
+			inode->i_ctime = udf_sb_record_time(inode->i_sb);
 		}
 
 		UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 6c14c4d..eb01f25 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -867,8 +867,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
 			  recording, recording_usec,
 			  ts.year, ts.month, ts.day, ts.hour,
 			  ts.minute, ts.typeAndTimezone);
-		UDF_SB_RECORDTIME(sb).tv_sec = recording;
-		UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000;
+		udf_sb(sb)->s_record_time.tv_sec = recording;
+		udf_sb(sb)->s_record_time.tv_nsec = recording_usec * 1000;
 	}
 
 	if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) {
@@ -1578,7 +1578,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	if (!silent) {
 		kernel_timestamp ts;
-		udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb));
+		udf_time_to_stamp(&ts, udf_sb_record_time(sb));
 		udf_info("UDF %s (%s) Mounting volume '%s', "
 			 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
 			 UDFFS_VERSION, UDFFS_DATE,
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 8683b71..e9346c2 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -103,6 +103,11 @@ static inline struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_b
 	return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]);
 }
 
+static inline struct timespec udf_sb_record_time(struct super_block *sb)
+{
+	return udf_sb(sb)->s_record_time;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -167,7 +172,6 @@ static inline struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_b
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_RECORDTIME(X)			( udf_sb(X)->s_recordtime )
 #define UDF_SB_SERIALNUM(X)			( udf_sb(X)->s_serialnum )
 #define UDF_SB_UDFREV(X)			( udf_sb(X)->s_udfrev )
 #define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index a9f19ab..adfecc6 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -94,7 +94,7 @@ struct udf_sb_info
 	uid_t			s_uid;
 
 	/* Root Info */
-	struct timespec		s_recordtime;
+	struct timespec		s_record_time;
 
 	/* Fileset Info */
 	__u16			s_serialnum;
-- 
1.5.3.4


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

* [PATCH 15/24] udf: convert UDF_SB_SERIALNUM macro to udf_sb_serial_number function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (13 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 14/24] udf: convert UDF_SB_RECORDTIME macro to udf_sb_record_time function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 16/24] udf: convert UDF_SB_UDFREV macro to udf_sb_revision function marcin.slusarz
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_SERIALNUM macro to udf_sb_serial_number inline function
- rename s_serialnum field to s_serial_number

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/inode.c            |    2 +-
 fs/udf/misc.c             |    2 +-
 fs/udf/super.c            |    2 +-
 fs/udf/udf_sb.h           |    6 +++++-
 include/linux/udf_fs_sb.h |    2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 8c725e2..46cf40c 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1541,7 +1541,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 		fe->descTag.descVersion = cpu_to_le16(3);
 	else
 		fe->descTag.descVersion = cpu_to_le16(2);
-	fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
+	fe->descTag.tagSerialNum = cpu_to_le16(udf_sb_serial_number(inode->i_sb));
 	fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
 	crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag);
 	fe->descTag.descCRCLength = cpu_to_le16(crclen);
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 95baad5..42d731a 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -88,7 +88,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 				eahd->descTag.descVersion = cpu_to_le16(3);
 			else
 				eahd->descTag.descVersion = cpu_to_le16(2);
-			eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
+			eahd->descTag.tagSerialNum = cpu_to_le16(udf_sb_serial_number(inode->i_sb));
 			eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
 			eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
 			eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index eb01f25..5a2c474 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -894,7 +894,7 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh,
 
 	*root = lelb_to_cpu(fset->rootDirectoryICB.extLocation);
 
-	UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum);
+	udf_sb(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum);
 
 	udf_debug("Rootdir at block=%d, partition=%d\n",
 		  root->logicalBlockNum, root->partitionReferenceNum);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index e9346c2..bae6a74 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -108,6 +108,11 @@ static inline struct timespec udf_sb_record_time(struct super_block *sb)
 	return udf_sb(sb)->s_record_time;
 }
 
+static inline __u16 udf_sb_serial_number(struct super_block *sb)
+{
+	return udf_sb(sb)->s_serial_number;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -172,7 +177,6 @@ static inline struct timespec udf_sb_record_time(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_SERIALNUM(X)			( udf_sb(X)->s_serialnum )
 #define UDF_SB_UDFREV(X)			( udf_sb(X)->s_udfrev )
 #define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
 
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index adfecc6..dd16deb 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -97,7 +97,7 @@ struct udf_sb_info
 	struct timespec		s_record_time;
 
 	/* Fileset Info */
-	__u16			s_serialnum;
+	__u16			s_serial_number;
 
 	/* highest UDF revision we have recorded to this media */
 	__u16			s_udfrev;
-- 
1.5.3.4


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

* [PATCH 16/24] udf: convert UDF_SB_UDFREV macro to udf_sb_revision function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (14 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 15/24] udf: convert UDF_SB_SERIALNUM macro to udf_sb_serial_number function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 17/24] udf: convert UDF_SB_VAT macro to udf_sb_vat_inode function marcin.slusarz
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c   |    2 +-
 fs/udf/inode.c    |   14 +++++++-------
 fs/udf/misc.c     |    2 +-
 fs/udf/namei.c    |    2 +-
 fs/udf/super.c    |   10 +++++-----
 fs/udf/truncate.c |    6 +++---
 fs/udf/udf_sb.h   |    8 ++++++--
 7 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 4c31666..23aae18 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -559,7 +559,7 @@ static void udf_table_free_blocks(struct super_block *sb,
 				}
 				epos.offset = sizeof(struct allocExtDesc);
 			}
-			if (UDF_SB_UDFREV(sb) >= 0x0200)
+			if (udf_sb_revision(sb) >= 0x0200)
 				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1,
 					    epos.block.logicalBlockNum, sizeof(tag));
 			else
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 46cf40c..1cdb381 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1537,7 +1537,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 				ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY));
 
 	fe->icbTag.flags = cpu_to_le16(icbflags);
-	if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
+	if (udf_sb_revision(inode->i_sb) >= 0x0200)
 		fe->descTag.descVersion = cpu_to_le16(3);
 	else
 		fe->descTag.descVersion = cpu_to_le16(2);
@@ -1667,7 +1667,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
 				mark_inode_dirty(inode);
 			}
 		}
-		if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
+		if (udf_sb_revision(inode->i_sb) >= 0x0200)
 			udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1,
 				    epos->block.logicalBlockNum, sizeof(tag));
 		else
@@ -1690,7 +1690,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
 		}
 		if (epos->bh) {
 			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-			    UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+			    udf_sb_revision(inode->i_sb) >= 0x0201)
 				udf_update_tag(epos->bh->b_data, loffset);
 			else
 				udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
@@ -1711,7 +1711,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
 		aed = (struct allocExtDesc *)epos->bh->b_data;
 		aed->lengthAllocDescs =
 			cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
-		if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+		if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || udf_sb_revision(inode->i_sb) >= 0x0201)
 			udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize));
 		else
 			udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
@@ -1754,7 +1754,7 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos,
 
 	if (epos->bh) {
 		if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-		    UDF_SB_UDFREV(inode->i_sb) >= 0x0201) {
+		    udf_sb_revision(inode->i_sb) >= 0x0201) {
 			struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data;
 			udf_update_tag(epos->bh->b_data,
 				       le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc));
@@ -1907,7 +1907,7 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos,
 			aed->lengthAllocDescs =
 				cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize));
 			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-			    UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+			    udf_sb_revision(inode->i_sb) >= 0x0201)
 				udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize));
 			else
 				udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
@@ -1923,7 +1923,7 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos,
 			aed->lengthAllocDescs =
 				cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize);
 			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-			    UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+			    udf_sb_revision(inode->i_sb) >= 0x0201)
 				udf_update_tag(oepos.bh->b_data, epos.offset - adsize);
 			else
 				udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 42d731a..4854573 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -84,7 +84,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 			size -= sizeof(struct extendedAttrHeaderDesc);
 			UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
 			eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
-			if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
+			if (udf_sb_revision(inode->i_sb) >= 0x0200)
 				eahd->descTag.descVersion = cpu_to_le16(3);
 			else
 				eahd->descTag.descVersion = cpu_to_le16(2);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 4a18bfc..d5ef33a 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -535,7 +535,7 @@ add:
 	}
 
 	memset(cfi, 0, sizeof(struct fileIdentDesc));
-	if (UDF_SB_UDFREV(sb) >= 0x0200)
+	if (udf_sb_revision(sb) >= 0x0200)
 		udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag));
 	else
 		udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag));
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 5a2c474..c520543 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1413,10 +1413,10 @@ static void udf_close_lvid(struct super_block *sb)
 			udf_sb_lvid(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
 		if (UDF_MAX_WRITE_VERSION > le16_to_cpu(udf_sb_lvidiu(sb)->maxUDFWriteRev))
 			udf_sb_lvidiu(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
-		if (UDF_SB_UDFREV(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFReadRev))
-			udf_sb_lvidiu(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
-		if (UDF_SB_UDFREV(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFWriteRev))
-			udf_sb_lvidiu(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
+		if (udf_sb_revision(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFReadRev))
+			udf_sb_lvidiu(sb)->minUDFReadRev = cpu_to_le16(udf_sb_revision(sb));
+		if (udf_sb_revision(sb) > le16_to_cpu(udf_sb_lvidiu(sb)->minUDFWriteRev))
+			udf_sb_lvidiu(sb)->minUDFWriteRev = cpu_to_le16(udf_sb_revision(sb));
 		udf_sb_lvid(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
 
 		udf_sb_lvid(sb)->descTag.descCRC =
@@ -1553,7 +1553,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 			sb->s_flags |= MS_RDONLY;
 		}
 
-		UDF_SB_UDFREV(sb) = minUDFWriteRev;
+		udf_sb(sb)->s_udfrev = minUDFWriteRev;
 
 		if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE)
 			UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE);
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 7fc3912..79ba205 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -163,7 +163,7 @@ void udf_discard_prealloc(struct inode *inode)
 				cpu_to_le32(epos.offset -
 					    sizeof(struct allocExtDesc));
 			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-			    UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
+			    udf_sb_revision(inode->i_sb) >= 0x0201)
 				udf_update_tag(epos.bh->b_data, epos.offset);
 			else
 				udf_update_tag(epos.bh->b_data,
@@ -232,7 +232,7 @@ void udf_truncate_extents(struct inode *inode)
 						aed->lengthAllocDescs =
 						    cpu_to_le32(lenalloc);
 						if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
-						    UDF_SB_UDFREV(sb) >= 0x0201)
+						    udf_sb_revision(sb) >= 0x0201)
 							udf_update_tag(epos.bh->b_data,
 								       lenalloc +
 								       sizeof(struct allocExtDesc));
@@ -271,7 +271,7 @@ void udf_truncate_extents(struct inode *inode)
 				    (struct allocExtDesc *)(epos.bh->b_data);
 				aed->lengthAllocDescs = cpu_to_le32(lenalloc);
 				if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
-				    UDF_SB_UDFREV(sb) >= 0x0201)
+				    udf_sb_revision(sb) >= 0x0201)
 					udf_update_tag(epos.bh->b_data,
 						       lenalloc + sizeof(struct allocExtDesc));
 				else
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index bae6a74..53d77fc 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -113,6 +113,11 @@ static inline __u16 udf_sb_serial_number(struct super_block *sb)
 	return udf_sb(sb)->s_serial_number;
 }
 
+static inline __u16 udf_sb_revision(struct super_block *sb)
+{
+	return udf_sb(sb)->s_udfrev;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -163,7 +168,7 @@ static inline __u16 udf_sb_serial_number(struct super_block *sb)
 #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
 #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
 
-#define UDF_UPDATE_UDFREV(X,Y)			( ((Y) > UDF_SB_UDFREV(X)) ? UDF_SB_UDFREV(X) = (Y) : UDF_SB_UDFREV(X) )
+#define UDF_UPDATE_UDFREV(X,Y)			( ((Y) > udf_sb_revision(X)) ? udf_sb(X)->s_udfrev = (Y) : udf_sb_revision(X) )
 
 #define UDF_SB_PARTTYPE(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_type )
 #define UDF_SB_PARTROOT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_root )
@@ -177,7 +182,6 @@ static inline __u16 udf_sb_serial_number(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_UDFREV(X)			( udf_sb(X)->s_udfrev )
 #define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
 
 #endif /* __LINUX_UDF_SB_H */
-- 
1.5.3.4


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

* [PATCH 17/24] udf: convert UDF_SB_VAT macro to udf_sb_vat_inode function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (15 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 16/24] udf: convert UDF_SB_UDFREV macro to udf_sb_revision function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 18/24] udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function marcin.slusarz
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_VAT macro to udf_sb_vat_inode inline function
- rename s_vat field to s_vat_inode

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/partition.c        |    6 +++---
 fs/udf/super.c            |   24 ++++++++++++------------
 fs/udf/udf_sb.h           |    6 +++++-
 include/linux/udf_fs_sb.h |    2 +-
 4 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index c904ddf..99640a6 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -67,7 +67,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 		index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
 	}
 
-	loc = udf_block_map(UDF_SB_VAT(sb), newblock);
+	loc = udf_block_map(udf_sb_vat_inode(sb), newblock);
 
 	if (!(bh = sb_bread(sb, loc))) {
 		udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
@@ -79,13 +79,13 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 
 	brelse(bh);
 
-	if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) {
+	if (UDF_I_LOCATION(udf_sb_vat_inode(sb)).partitionReferenceNum == partition) {
 		udf_debug("recursive call to udf_get_pblock!\n");
 		return 0xFFFFFFFF;
 	}
 
 	return udf_get_pblock(sb, loc,
-			      UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum,
+			      UDF_I_LOCATION(udf_sb_vat_inode(sb)).partitionReferenceNum,
 			      offset);
 }
 
diff --git a/fs/udf/super.c b/fs/udf/super.c
index c520543..dcab9e8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1343,28 +1343,28 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 			if (j == udf_sb_num_parts(sb))
 				return 1;
 
-			UDF_SB_VAT(sb) = udf_iget(sb, ino);
-			if (!UDF_SB_VAT(sb))
+			udf_sb(sb)->s_vat_inode = udf_iget(sb, ino);
+			if (!udf_sb_vat_inode(sb))
 				return 1;
 
 			if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
 				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
-					udf_ext0_offset(UDF_SB_VAT(sb));
+					udf_ext0_offset(udf_sb_vat_inode(sb));
 				UDF_SB_TYPEVIRT(sb, i).s_num_entries =
-					(UDF_SB_VAT(sb)->i_size - 36) >> 2;
+					(udf_sb_vat_inode(sb)->i_size - 36) >> 2;
 			} else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) {
 				struct buffer_head *bh = NULL;
 				uint32_t pos;
 
-				pos = udf_block_map(UDF_SB_VAT(sb), 0);
+				pos = udf_block_map(udf_sb_vat_inode(sb), 0);
 				bh = sb_bread(sb, pos);
 				if (!bh)
 					return 1;
 				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
 					le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data +
-						     udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) +
-					udf_ext0_offset(UDF_SB_VAT(sb));
-				UDF_SB_TYPEVIRT(sb, i).s_num_entries = (UDF_SB_VAT(sb)->i_size -
+						     udf_ext0_offset(udf_sb_vat_inode(sb)))->lengthHeader) +
+					udf_ext0_offset(udf_sb_vat_inode(sb));
+				UDF_SB_TYPEVIRT(sb, i).s_num_entries = (udf_sb_vat_inode(sb)->i_size -
 									UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2;
 				brelse(bh);
 			}
@@ -1609,8 +1609,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	return 0;
 
 error_out:
-	if (UDF_SB_VAT(sb))
-		iput(UDF_SB_VAT(sb));
+	if (udf_sb_vat_inode(sb))
+		iput(udf_sb_vat_inode(sb));
 	if (udf_sb_num_parts(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
 			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
@@ -1684,8 +1684,8 @@ static void udf_put_super(struct super_block *sb)
 {
 	int i;
 
-	if (UDF_SB_VAT(sb))
-		iput(UDF_SB_VAT(sb));
+	if (udf_sb_vat_inode(sb))
+		iput(udf_sb_vat_inode(sb));
 	if (udf_sb_num_parts(sb)) {
 		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
 			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 53d77fc..fa09d50 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -118,6 +118,11 @@ static inline __u16 udf_sb_revision(struct super_block *sb)
 	return udf_sb(sb)->s_udfrev;
 }
 
+static inline struct inode *udf_sb_vat_inode(struct super_block *sb)
+{
+	return udf_sb(sb)->s_vat_inode;
+}
+
 #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
 {\
 	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
@@ -182,6 +187,5 @@ static inline __u16 udf_sb_revision(struct super_block *sb)
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-#define UDF_SB_VAT(X)				( udf_sb(X)->s_vat )
 
 #endif /* __LINUX_UDF_SB_H */
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index dd16deb..9bc4735 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -109,7 +109,7 @@ struct udf_sb_info
 	struct nls_table	*s_nls_map;
 
 	/* VAT inode */
-	struct inode		*s_vat;
+	struct inode		*s_vat_inode;
 
 	struct mutex		s_alloc_mutex;
 };
-- 
1.5.3.4


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

* [PATCH 18/24] udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (16 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 17/24] udf: convert UDF_SB_VAT macro to udf_sb_vat_inode function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 19/24] udf: check if udf_load_logicalvol failed marcin.slusarz
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

- change UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps inline function
- convert kmalloc + memset to kzalloc
- check if kzalloc failed (partially)

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c  |    6 ++++--
 fs/udf/udf_sb.h |   27 +++++++++++++++------------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index dcab9e8..4aef612 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1013,7 +1013,9 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 
 	lvd = (struct logicalVolDesc *)bh->b_data;
 
-	UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
+	i = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));
+	if (i != 0)
+		return i;
 
 	for (i = 0, offset = 0;
 	     i < udf_sb_num_parts(sb) && offset < le32_to_cpu(lvd->mapTableLength);
@@ -1214,7 +1216,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
 			if (i == VDS_POS_PRIMARY_VOL_DESC) {
 				udf_load_pvoldesc(sb, bh);
 			} else if (i == VDS_POS_LOGICAL_VOL_DESC) {
-				udf_load_logicalvol(sb, bh, fileset);
+				udf_load_logicalvol(sb, bh, fileset); /* TODO: check return value */
 			} else if (i == VDS_POS_PARTITION_DESC) {
 				struct buffer_head *bh2 = NULL;
 				if (udf_load_partdesc(sb, bh)) {
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index fa09d50..565c9ef 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -1,6 +1,8 @@
 #ifndef __LINUX_UDF_SB_H
 #define __LINUX_UDF_SB_H
 
+#include <linux/errno.h>
+
 /* Since UDF 2.01 is ISO 13346 based... */
 #define UDF_SUPER_MAGIC			0x15013346
 
@@ -46,6 +48,19 @@ static inline struct udf_part_map *udf_sb_partmaps(struct super_block *sb)
 	return udf_sb(sb)->s_partmaps;
 }
 
+static inline int __must_check udf_sb_alloc_partition_maps(struct super_block *sb, __u32 count)
+{
+	struct udf_sb_info *info = udf_sb(sb);
+	info->s_partmaps = kzalloc(sizeof(struct udf_part_map) * count, GFP_KERNEL);
+	if (info->s_partmaps != NULL)
+		info->s_partitions = count;
+	else {
+		info->s_partitions = 0;
+		udf_error(sb, __FUNCTION__, "Unable to allocate space for %d partition maps", count);
+	}
+	return info->s_partmaps != NULL ? 0 : -ENOMEM;
+}
+
 static inline void udf_sb_free(struct super_block *sb)
 {
 	struct udf_sb_info *sb_info = udf_sb(sb);
@@ -123,18 +138,6 @@ static inline struct inode *udf_sb_vat_inode(struct super_block *sb)
 	return udf_sb(sb)->s_vat_inode;
 }
 
-#define UDF_SB_ALLOC_PARTMAPS(X,Y)\
-{\
-	udf_sb(X)->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
-	if (udf_sb_partmaps(X) != NULL) {\
-		udf_sb(X)->s_partitions = Y;\
-		memset(udf_sb_partmaps(X), 0x00, sizeof(struct udf_part_map) * Y);\
-	} else {\
-		udf_sb(X)->s_partitions = 0;\
-		udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
-	}\
-}
-
 #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
 {\
 	int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\
-- 
1.5.3.4


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

* [PATCH 19/24] udf: check if udf_load_logicalvol failed
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (17 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 18/24] udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2008-01-07 11:29   ` Jan Kara
  2007-12-23  1:51 ` [PATCH 20/24] udf: convert UDF_UPDATE_UDFREV macro to udf_update_revision function marcin.slusarz
                   ` (4 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

udf_load_logicalvol may fail eg in out of memory conditions - check it
and propagate error further

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4aef612..f8c5794 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1141,6 +1141,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
 	uint32_t vdsn;
 	uint16_t ident;
 	long next_s = 0, next_e = 0;
+	int ret;
 
 	memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
 
@@ -1216,7 +1217,11 @@ static int udf_process_sequence(struct super_block *sb, long block,
 			if (i == VDS_POS_PRIMARY_VOL_DESC) {
 				udf_load_pvoldesc(sb, bh);
 			} else if (i == VDS_POS_LOGICAL_VOL_DESC) {
-				udf_load_logicalvol(sb, bh, fileset); /* TODO: check return value */
+				ret = udf_load_logicalvol(sb, bh, fileset);
+				if (ret != 0) {
+					brelse(bh);
+					return ret;
+				}
 			} else if (i == VDS_POS_PARTITION_DESC) {
 				struct buffer_head *bh2 = NULL;
 				if (udf_load_partdesc(sb, bh)) {
-- 
1.5.3.4


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

* [PATCH 20/24] udf: convert UDF_UPDATE_UDFREV macro to udf_update_revision function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (18 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 19/24] udf: check if udf_load_logicalvol failed marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2007-12-23  1:51 ` [PATCH 21/24] udf: remove some UDF_SB_* macros marcin.slusarz
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/ialloc.c |    2 +-
 fs/udf/udf_sb.h |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 269f588..4d1684c 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -123,7 +123,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
 	UDF_I_USE(inode) = 0;
 	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
 		UDF_I_EFE(inode) = 1;
-		UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
+		udf_update_revision(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
 		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
 	} else {
 		UDF_I_EFE(inode) = 0;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 565c9ef..aee5942 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -138,6 +138,12 @@ static inline struct inode *udf_sb_vat_inode(struct super_block *sb)
 	return udf_sb(sb)->s_vat_inode;
 }
 
+static inline void udf_update_revision(struct super_block *sb, __u16 revision)
+{
+	if (revision > udf_sb_revision(sb))
+		udf_sb(sb)->s_udfrev = revision;
+}
+
 #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
 {\
 	int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\
@@ -176,8 +182,6 @@ static inline struct inode *udf_sb_vat_inode(struct super_block *sb)
 #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
 #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
 
-#define UDF_UPDATE_UDFREV(X,Y)			( ((Y) > udf_sb_revision(X)) ? udf_sb(X)->s_udfrev = (Y) : udf_sb_revision(X) )
-
 #define UDF_SB_PARTTYPE(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_type )
 #define UDF_SB_PARTROOT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_root )
 #define UDF_SB_PARTLEN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_len )
-- 
1.5.3.4


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

* [PATCH 21/24] udf: remove some UDF_SB_* macros
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (19 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 20/24] udf: convert UDF_UPDATE_UDFREV macro to udf_update_revision function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2008-01-07 11:34   ` Jan Kara
  2007-12-23  1:51 ` [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function marcin.slusarz
                   ` (2 subsequent siblings)
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

remove macros:
- UDF_SB_PARTTYPE
- UDF_SB_PARTROOT
- UDF_SB_PARTLEN
- UDF_SB_PARTVSN
- UDF_SB_PARTNUM
- UDF_SB_TYPESPAR
- UDF_SB_TYPEVIRT
- UDF_SB_PARTFUNC
- UDF_SB_PARTFLAGS
and replace all uses

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/balloc.c    |   76 +++++++++++----------
 fs/udf/inode.c     |    2 +-
 fs/udf/partition.c |   49 ++++++++------
 fs/udf/super.c     |  191 ++++++++++++++++++++++++++++------------------------
 fs/udf/udf_sb.h    |   16 ++---
 5 files changed, 179 insertions(+), 155 deletions(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 23aae18..4fe8635 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -155,10 +155,10 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
 
 	mutex_lock(&sbi->s_alloc_mutex);
 	if (bloc.logicalBlockNum < 0 ||
-	    (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
+	    (bloc.logicalBlockNum + count) > udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
 			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
-			  UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
+			  udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len);
 		goto error_return;
 	}
 
@@ -219,16 +219,18 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
 	int bit, block, block_group, group_start;
 	int nr_groups, bitmap_nr;
 	struct buffer_head *bh;
+	__u32 part_len;
 
 	mutex_lock(&sbi->s_alloc_mutex);
-	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
+	part_len = udf_sb_partmap(sb, partition)->s_partition_len;
+	if (first_block < 0 || first_block >= part_len)
 		goto out;
 
-	if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
-		block_count = UDF_SB_PARTLEN(sb, partition) - first_block;
+	if (first_block + block_count > part_len)
+		block_count = part_len - first_block;
 
 repeat:
-	nr_groups = (UDF_SB_PARTLEN(sb, partition) +
+	nr_groups = (udf_sb_partmap(sb, partition)->s_partition_len +
 		     (sizeof(struct spaceBitmapDesc) << 3) +
 		     (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
 	block = first_block + (sizeof(struct spaceBitmapDesc) << 3);
@@ -287,7 +289,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
 	mutex_lock(&sbi->s_alloc_mutex);
 
 repeat:
-	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
+	if (goal < 0 || goal >= udf_sb_partmap(sb, partition)->s_partition_len)
 		goal = 0;
 
 	nr_groups = bitmap->s_nr_groups;
@@ -421,10 +423,10 @@ static void udf_table_free_blocks(struct super_block *sb,
 
 	mutex_lock(&sbi->s_alloc_mutex);
 	if (bloc.logicalBlockNum < 0 ||
-	    (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
+	    (bloc.logicalBlockNum + count) > udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len) {
 		udf_debug("%d < %d || %d + %d > %d\n",
 			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
-			  UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
+			  udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len);
 		goto error_return;
 	}
 
@@ -627,7 +629,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 	struct extent_position epos;
 	int8_t etype = -1;
 
-	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
+	if (first_block < 0 || first_block >= udf_sb_partmap(sb, partition)->s_partition_len)
 		return 0;
 
 	if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
@@ -703,7 +705,7 @@ static int udf_table_new_block(struct super_block *sb,
 		return newblock;
 
 	mutex_lock(&sbi->s_alloc_mutex);
-	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
+	if (goal < 0 || goal >= udf_sb_partmap(sb, partition)->s_partition_len)
 		goal = 0;
 
 	/* We search for the closest matching block to goal. If we find a exact hit,
@@ -789,22 +791,23 @@ inline void udf_free_blocks(struct super_block *sb,
 			    uint32_t count)
 {
 	uint16_t partition = bloc.partitionReferenceNum;
+	struct udf_part_map *map = udf_sb_partmap(sb, partition);
 
-	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		return udf_bitmap_free_blocks(sb, inode,
-					      udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
+					      map->s_uspace.s_bitmap,
 					      bloc, offset, count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_free_blocks(sb, inode,
-					     udf_sb_partmaps(sb)[partition].s_uspace.s_table,
+					     map->s_uspace.s_table,
 					     bloc, offset, count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_free_blocks(sb, inode,
-					      udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
+					      map->s_fspace.s_bitmap,
 					      bloc, offset, count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_free_blocks(sb, inode,
-					     udf_sb_partmaps(sb)[partition].s_fspace.s_table,
+					     map->s_fspace.s_table,
 					     bloc, offset, count);
 	} else {
 		return;
@@ -816,21 +819,23 @@ inline int udf_prealloc_blocks(struct super_block *sb,
 			       uint16_t partition, uint32_t first_block,
 			       uint32_t block_count)
 {
-	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	struct udf_part_map *map = udf_sb_partmap(sb, partition);
+
+	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		return udf_bitmap_prealloc_blocks(sb, inode,
-						  udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
+						  map->s_uspace.s_bitmap,
 						  partition, first_block, block_count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_prealloc_blocks(sb, inode,
-						 udf_sb_partmaps(sb)[partition].s_uspace.s_table,
+						 map->s_uspace.s_table,
 						 partition, first_block, block_count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_prealloc_blocks(sb, inode,
-						  udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
+						  map->s_fspace.s_bitmap,
 						  partition, first_block, block_count);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_prealloc_blocks(sb, inode,
-						 udf_sb_partmaps(sb)[partition].s_fspace.s_table,
+						 map->s_fspace.s_table,
 						 partition, first_block, block_count);
 	} else {
 		return 0;
@@ -842,23 +847,24 @@ inline int udf_new_block(struct super_block *sb,
 			 uint16_t partition, uint32_t goal, int *err)
 {
 	int ret;
+	struct udf_part_map *map = udf_sb_partmap(sb, partition);
 
-	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		ret = udf_bitmap_new_block(sb, inode,
-					   udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
+					   map->s_uspace.s_bitmap,
 					   partition, goal, err);
 		return ret;
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
 		return udf_table_new_block(sb, inode,
-					   udf_sb_partmaps(sb)[partition].s_uspace.s_table,
+					   map->s_uspace.s_table,
 					   partition, goal, err);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
 		return udf_bitmap_new_block(sb, inode,
-					    udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
+					    map->s_fspace.s_bitmap,
 					    partition, goal, err);
-	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
+	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
 		return udf_table_new_block(sb, inode,
-					   udf_sb_partmaps(sb)[partition].s_fspace.s_table,
+					   map->s_fspace.s_table,
 					   partition, goal, err);
 	} else {
 		*err = -EIO;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1cdb381..8aa0fc6 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1585,7 +1585,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino)
 	if (is_bad_inode(inode))
 		goto out_iput;
 
-	if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) {
+	if (ino.logicalBlockNum >= udf_sb_partmap(sb, ino.partitionReferenceNum)->s_partition_len) {
 		udf_debug("block=%d, partition=%d out of range\n",
 			  ino.logicalBlockNum, ino.partitionReferenceNum);
 		make_bad_inode(inode);
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index 99640a6..4959d53 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -31,15 +31,17 @@
 inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
 			       uint16_t partition, uint32_t offset)
 {
+	struct udf_part_map *map;
 	if (partition >= udf_sb_num_parts(sb)) {
 		udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
 			  block, partition, offset);
 		return 0xFFFFFFFF;
 	}
-	if (UDF_SB_PARTFUNC(sb, partition))
-		return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
+	map = udf_sb_partmap(sb, partition);
+	if (map->s_partition_func)
+		return map->s_partition_func(sb, block, partition, offset);
 	else
-		return UDF_SB_PARTROOT(sb, partition) + block + offset;
+		return map->s_partition_root + block + offset;
 }
 
 uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
@@ -49,12 +51,14 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 	uint32_t newblock;
 	uint32_t index;
 	uint32_t loc;
+	struct udf_part_map *map;
 
-	index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
+	map = udf_sb_partmap(sb, partition);
+	index = (sb->s_blocksize - map->s_type_specific.s_virtual.s_start_offset) / sizeof(uint32_t);
 
-	if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) {
+	if (block > map->s_type_specific.s_virtual.s_num_entries) {
 		udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
-			  block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
+			  block, map->s_type_specific.s_virtual.s_num_entries);
 		return 0xFFFFFFFF;
 	}
 
@@ -64,7 +68,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
 		index = block % (sb->s_blocksize / sizeof(uint32_t));
 	} else {
 		newblock = 0;
-		index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
+		index = map->s_type_specific.s_virtual.s_start_offset / sizeof(uint32_t) + block;
 	}
 
 	loc = udf_block_map(udf_sb_vat_inode(sb), newblock);
@@ -100,11 +104,15 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
 {
 	int i;
 	struct sparingTable *st = NULL;
-	uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
+	struct udf_part_map *map;
+	uint32_t packet;
+
+	map = udf_sb_partmap(sb, partition);
+	packet = (block + offset) & ~(map->s_type_specific.s_sparing.s_packet_len - 1);
 
 	for (i = 0; i < 4; i++) {
-		if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) {
-			st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
+		if (map->s_type_specific.s_sparing.s_spar_map[i] != NULL) {
+			st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[i]->b_data;
 			break;
 		}
 	}
@@ -115,14 +123,14 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
 				break;
 			} else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) {
 				return le32_to_cpu(st->mapEntry[i].mappedLocation) +
-					((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
+					((block + offset) & (map->s_type_specific.s_sparing.s_packet_len - 1));
 			} else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) {
 				break;
 			}
 		}
 	}
 
-	return UDF_SB_PARTROOT(sb,partition) + block + offset;
+	return map->s_partition_root + block + offset;
 }
 
 int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
@@ -134,13 +142,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 	int i, j, k, l;
 
 	for (i = 0; i < udf_sb_num_parts(sb); i++) {
-		if (old_block > UDF_SB_PARTROOT(sb,i) &&
-		    old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
-			sdata = &UDF_SB_TYPESPAR(sb,i);
-			packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
+		struct udf_part_map *map = udf_sb_partmap(sb, i);
+		if (old_block > map->s_partition_root &&
+		    old_block < map->s_partition_root + map->s_partition_len) {
+			sdata = &map->s_type_specific.s_sparing;
+			packet = (old_block - map->s_partition_root) & ~(sdata->s_packet_len - 1);
 
 			for (j = 0; j < 4; j++) {
-				if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
+				if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) {
 					st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
 					break;
 				}
@@ -160,11 +169,11 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 						}
 					}
 					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
-						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
+						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
 					return 0;
 				} else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) {
 					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
-						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
+						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
 					return 0;
 				} else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) {
 					break;
@@ -185,7 +194,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 						}
 					}
 					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
-						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
+						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
 					return 0;
 				}
 			}
diff --git a/fs/udf/super.c b/fs/udf/super.c
index f8c5794..33ccf66 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -795,8 +795,9 @@ static int udf_find_fileset(struct super_block *sb,
 		      fileset->logicalBlockNum == 0xFFFFFFFF &&
 		      fileset->partitionReferenceNum == 0xFFFF);
 		     newfileset.partitionReferenceNum--) {
-			lastblock = UDF_SB_PARTLEN(sb,
-					newfileset.partitionReferenceNum);
+			lastblock = udf_sb_partmap(sb,
+					newfileset.partitionReferenceNum)->
+						s_partition_len;
 			newfileset.logicalBlockNum = 0;
 
 			do {
@@ -904,23 +905,25 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 {
 	struct partitionDesc *p;
 	int i;
+	struct udf_part_map *map;
 
 	p = (struct partitionDesc *)bh->b_data;
 
 	for (i = 0; i < udf_sb_num_parts(sb); i++) {
+		map = udf_sb_partmap(sb, i);
 		udf_debug("Searching map: (%d == %d)\n",
-			  udf_sb_partmaps(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
-		if (udf_sb_partmaps(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
-			UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */
-			UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation);
+			  map->s_partition_num, le16_to_cpu(p->partitionNumber));
+		if (map->s_partition_num == le16_to_cpu(p->partitionNumber)) {
+			map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
+			map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
-				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_READ_ONLY;
+				map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
-				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_WRITE_ONCE;
+				map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
-				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_REWRITABLE;
+				map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE;
 			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
-				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_OVERWRITABLE;
+				map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
 
 			if (!strcmp(p->partitionContents.ident,
 				    PD_PARTITION_CONTENTS_NSR02) ||
@@ -935,26 +938,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						.partitionReferenceNum = i,
 					};
 
-					udf_sb_partmaps(sb)[i].s_uspace.s_table =
+					map->s_uspace.s_table =
 						udf_iget(sb, loc);
-					if (!udf_sb_partmaps(sb)[i].s_uspace.s_table) {
+					if (!map->s_uspace.s_table) {
 						udf_debug("cannot load unallocSpaceTable (part %d)\n", i);
 						return 1;
 					}
-					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE;
+					map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
 					udf_debug("unallocSpaceTable (part %d) @ %ld\n",
-						  i, udf_sb_partmaps(sb)[i].s_uspace.s_table->i_ino);
+						  i, map->s_uspace.s_table->i_ino);
 				}
 				if (phd->unallocSpaceBitmap.extLength) {
 					UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
-					if (udf_sb_partmaps(sb)[i].s_uspace.s_bitmap != NULL) {
-						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extLength =
+					if (map->s_uspace.s_bitmap != NULL) {
+						map->s_uspace.s_bitmap->s_extLength =
 							le32_to_cpu(phd->unallocSpaceBitmap.extLength);
-						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition =
+						map->s_uspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
-						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
+						map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
 						udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
-							  i, udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition);
+							  i, map->s_uspace.s_bitmap->s_extPosition);
 					}
 				}
 				if (phd->partitionIntegrityTable.extLength)
@@ -965,26 +968,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 						.partitionReferenceNum = i,
 					};
 
-					udf_sb_partmaps(sb)[i].s_fspace.s_table =
+					map->s_fspace.s_table =
 						udf_iget(sb, loc);
-					if (!udf_sb_partmaps(sb)[i].s_fspace.s_table) {
+					if (!map->s_fspace.s_table) {
 						udf_debug("cannot load freedSpaceTable (part %d)\n", i);
 						return 1;
 					}
-					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE;
+					map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
 					udf_debug("freedSpaceTable (part %d) @ %ld\n",
-						  i, udf_sb_partmaps(sb)[i].s_fspace.s_table->i_ino);
+						  i, map->s_fspace.s_table->i_ino);
 				}
 				if (phd->freedSpaceBitmap.extLength) {
 					UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
-					if (udf_sb_partmaps(sb)[i].s_fspace.s_bitmap != NULL) {
-						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extLength =
+					if (map->s_fspace.s_bitmap != NULL) {
+						map->s_fspace.s_bitmap->s_extLength =
 							le32_to_cpu(phd->freedSpaceBitmap.extLength);
-						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition =
+						map->s_fspace.s_bitmap->s_extPosition =
 							le32_to_cpu(phd->freedSpaceBitmap.extPosition);
-						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP;
+						map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
 						udf_debug("freedSpaceBitmap (part %d) @ %d\n",
-							  i, udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition);
+							  i, map->s_fspace.s_bitmap->s_extPosition);
 					}
 				}
 			}
@@ -998,8 +1001,9 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
 		udf_debug("Partition (%d:%d type %x) starts at physical %d, "
 			  "block length %d\n",
 			  le16_to_cpu(p->partitionNumber), i,
-			  UDF_SB_PARTTYPE(sb, i), UDF_SB_PARTROOT(sb, i),
-			  UDF_SB_PARTLEN(sb, i));
+			  map->s_partition_type,
+			  map->s_partition_root,
+			  map->s_partition_len);
 	}
 	return 0;
 }
@@ -1020,22 +1024,23 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 	for (i = 0, offset = 0;
 	     i < udf_sb_num_parts(sb) && offset < le32_to_cpu(lvd->mapTableLength);
 	     i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) {
+	     	struct udf_part_map *map = udf_sb_partmap(sb, i);
 		type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
 		if (type == 1) {
 			struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
-			UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15;
-			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
-			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
-			UDF_SB_PARTFUNC(sb, i) = NULL;
+			map->s_partition_type = UDF_TYPE1_MAP15;
+			map->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum);
+			map->s_partition_num = le16_to_cpu(gpm1->partitionNum);
+			map->s_partition_func = NULL;
 		} else if (type == 2) {
 			struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
 			if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
 				if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
-					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP15;
-					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt15;
+					map->s_partition_type = UDF_VIRTUAL_MAP15;
+					map->s_partition_func = udf_get_pblock_virt15;
 				} else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
-					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP20;
-					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt20;
+					map->s_partition_type = UDF_VIRTUAL_MAP20;
+					map->s_partition_func = udf_get_pblock_virt20;
 				}
 			} else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
 				uint32_t loc;
@@ -1043,33 +1048,33 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
 				struct sparingTable *st;
 				struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
 
-				UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
-				UDF_SB_TYPESPAR(sb, i).s_packet_len = le16_to_cpu(spm->packetLength);
+				map->s_partition_type = UDF_SPARABLE_MAP15;
+				map->s_type_specific.s_sparing.s_packet_len = le16_to_cpu(spm->packetLength);
 				for (j = 0; j < spm->numSparingTables; j++) {
 					loc = le32_to_cpu(spm->locSparingTable[j]);
-					UDF_SB_TYPESPAR(sb, i).s_spar_map[j] =
+					map->s_type_specific.s_sparing.s_spar_map[j] =
 						udf_read_tagged(sb, loc, loc, &ident);
-					if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != NULL) {
-						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, i).s_spar_map[j]->b_data;
+					if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) {
+						st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[j]->b_data;
 						if (ident != 0 ||
 						    strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
-							brelse(UDF_SB_TYPESPAR(sb, i).s_spar_map[j]);
-							UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = NULL;
+							brelse(map->s_type_specific.s_sparing.s_spar_map[j]);
+							map->s_type_specific.s_sparing.s_spar_map[j] = NULL;
 						}
 					}
 				}
-				UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15;
+				map->s_partition_func = udf_get_pblock_spar15;
 			} else {
 				udf_debug("Unknown ident: %s\n",
 					  upm2->partIdent.ident);
 				continue;
 			}
-			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum);
-			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum);
+			map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);
+			map->s_partition_num = le16_to_cpu(upm2->partitionNum);
 		}
 		udf_debug("Partition (%d:%d) type %d on volume %d\n",
-			  i, UDF_SB_PARTNUM(sb, i), type,
-			  UDF_SB_PARTVSN(sb, i));
+			  i, map->s_partition_num, type,
+			  map->s_volumeseqnum);
 	}
 
 	if (fileset) {
@@ -1323,7 +1328,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 
 	for (i = 0; i < udf_sb_num_parts(sb); i++) {
 		kernel_lb_addr uninitialized_var(ino);
-		switch (UDF_SB_PARTTYPE(sb, i)) {
+		struct udf_part_map *map = udf_sb_partmap(sb, i);
+		switch (map->s_partition_type) {
 		case UDF_VIRTUAL_MAP15:
 		case UDF_VIRTUAL_MAP20:
 			if (!udf_sb_last_block(sb)) {
@@ -1338,11 +1344,12 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 			}
 
 			for (j = 0; j < udf_sb_num_parts(sb); j++) {
+				struct udf_part_map *map2 = udf_sb_partmap(sb, j);
 				if (j != i &&
-				    UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) &&
-				    UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) {
+				    map->s_volumeseqnum == map2->s_volumeseqnum &&
+				    map->s_partition_num == map2->s_partition_num) {
 					ino.partitionReferenceNum = j;
-					ino.logicalBlockNum = udf_sb_last_block(sb) - UDF_SB_PARTROOT(sb, j);
+					ino.logicalBlockNum = udf_sb_last_block(sb) - map2->s_partition_root;
 					break;
 				}
 			}
@@ -1354,12 +1361,12 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 			if (!udf_sb_vat_inode(sb))
 				return 1;
 
-			if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
-				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
+			if (map->s_partition_type == UDF_VIRTUAL_MAP15) {
+				map->s_type_specific.s_virtual.s_start_offset =
 					udf_ext0_offset(udf_sb_vat_inode(sb));
-				UDF_SB_TYPEVIRT(sb, i).s_num_entries =
+				map->s_type_specific.s_virtual.s_num_entries =
 					(udf_sb_vat_inode(sb)->i_size - 36) >> 2;
-			} else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) {
+			} else if (map->s_partition_type == UDF_VIRTUAL_MAP20) {
 				struct buffer_head *bh = NULL;
 				uint32_t pos;
 
@@ -1367,16 +1374,18 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 				bh = sb_bread(sb, pos);
 				if (!bh)
 					return 1;
-				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
+				map->s_type_specific.s_virtual.s_start_offset =
 					le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data +
 						     udf_ext0_offset(udf_sb_vat_inode(sb)))->lengthHeader) +
 					udf_ext0_offset(udf_sb_vat_inode(sb));
-				UDF_SB_TYPEVIRT(sb, i).s_num_entries = (udf_sb_vat_inode(sb)->i_size -
-									UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2;
+				map->s_type_specific.s_virtual.s_num_entries = (udf_sb_vat_inode(sb)->i_size -
+									map->s_type_specific.s_virtual.s_start_offset) >> 2;
 				brelse(bh);
 			}
-			UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0);
-			UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, ino.partitionReferenceNum);
+			map->s_partition_root = udf_get_pblock(sb, 0, i, 0);
+			map->s_partition_len =
+				udf_sb_partmap(sb, ino.partitionReferenceNum)->
+								s_partition_len;
 		}
 	}
 	return 0;
@@ -1573,7 +1582,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		goto error_out;
 	}
 
-	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_READ_ONLY) {
+	if (udf_sb_partmap(sb, udf_sb_partition(sb))->s_partition_flags & UDF_PART_FLAG_READ_ONLY) {
 		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n");
 		sb->s_flags |= MS_RDONLY;
 	}
@@ -1619,17 +1628,18 @@ error_out:
 	if (udf_sb_vat_inode(sb))
 		iput(udf_sb_vat_inode(sb));
 	if (udf_sb_num_parts(sb)) {
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
+		struct udf_part_map *map = udf_sb_partmap(sb, udf_sb_partition(sb));
+		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
+			iput(map->s_uspace.s_table);
+		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
+			iput(map->s_fspace.s_table);
+		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
+		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
-		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
+		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
-				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
+				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
 		}
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1694,17 +1704,18 @@ static void udf_put_super(struct super_block *sb)
 	if (udf_sb_vat_inode(sb))
 		iput(udf_sb_vat_inode(sb));
 	if (udf_sb_num_parts(sb)) {
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
-			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
-			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
+		struct udf_part_map *map = udf_sb_partmap(sb, udf_sb_partition(sb));
+		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
+			iput(map->s_uspace.s_table);
+		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
+			iput(map->s_fspace.s_table);
+		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
-		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
+		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
 			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
-		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
+		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
-				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
+				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
 		}
 	}
 #ifdef CONFIG_UDF_NLS
@@ -1738,7 +1749,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 	buf->f_type = UDF_SUPER_MAGIC;
 	buf->f_bsize = sb->s_blocksize;
-	buf->f_blocks = UDF_SB_PARTLEN(sb, udf_sb_partition(sb));
+	buf->f_blocks = udf_sb_partmap(sb, udf_sb_partition(sb))->s_partition_len;
 	buf->f_bfree = udf_count_free(sb);
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = (udf_sb_lvid_bh(sb) ?
@@ -1843,6 +1854,7 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t
 static unsigned int udf_count_free(struct super_block *sb)
 {
 	unsigned int accum = 0;
+	struct udf_part_map *map;
 
 	if (udf_sb_lvid_bh(sb)) {
 		if (le32_to_cpu(udf_sb_lvid(sb)->numOfPartitions) > udf_sb_partition(sb)) {
@@ -1855,24 +1867,25 @@ static unsigned int udf_count_free(struct super_block *sb)
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
+	map = udf_sb_partmap(sb, udf_sb_partition(sb));
+	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_bitmap);
+					       map->s_uspace.s_bitmap);
 	}
-	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
+	if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
 		accum += udf_count_free_bitmap(sb,
-					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_bitmap);
+					       map->s_fspace.s_bitmap);
 	}
 	if (accum)
 		return accum;
 
-	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
+	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
 		accum += udf_count_free_table(sb,
-					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
+					      map->s_uspace.s_table);
 	}
-	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE) {
+	if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
 		accum += udf_count_free_table(sb,
-					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
+					      map->s_fspace.s_table);
 	}
 
 	return accum;
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index aee5942..a5805c5 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -48,6 +48,11 @@ static inline struct udf_part_map *udf_sb_partmaps(struct super_block *sb)
 	return udf_sb(sb)->s_partmaps;
 }
 
+static inline struct udf_part_map *udf_sb_partmap(struct super_block *sb, __u32 index)
+{
+	return udf_sb_partmaps(sb) + index;
+}
+
 static inline int __must_check udf_sb_alloc_partition_maps(struct super_block *sb, __u32 count)
 {
 	struct udf_sb_info *info = udf_sb(sb);
@@ -146,7 +151,7 @@ static inline void udf_update_revision(struct super_block *sb, __u16 revision)
 
 #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
 {\
-	int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\
+	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)\
@@ -182,15 +187,6 @@ static inline void udf_update_revision(struct super_block *sb, __u16 revision)
 #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
 #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
 
-#define UDF_SB_PARTTYPE(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_type )
-#define UDF_SB_PARTROOT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_root )
-#define UDF_SB_PARTLEN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_len )
-#define UDF_SB_PARTVSN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_volumeseqnum )
-#define UDF_SB_PARTNUM(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_num )
-#define UDF_SB_TYPESPAR(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_sparing )
-#define UDF_SB_TYPEVIRT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_virtual )
-#define UDF_SB_PARTFUNC(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_func )
-#define UDF_SB_PARTFLAGS(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_flags )
 #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
 #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
 
-- 
1.5.3.4


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

* [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (20 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 21/24] udf: remove some UDF_SB_* macros marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2008-01-07 11:35   ` Jan Kara
  2007-12-23  1:51 ` [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function marcin.slusarz
  2007-12-23  1:51 ` [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition) marcin.slusarz
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 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 <linux/errno.h>
+#include <linux/vmalloc.h>
 
 /* 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


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

* [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (21 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2008-01-07 11:36   ` Jan Kara
  2007-12-23  1:51 ` [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition) marcin.slusarz
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

additionally fix sparse warnings:
fs/udf/super.c:1636:4: warning: symbol 'i' shadows an earlier one
fs/udf/super.c:1469:6: originally declared here
fs/udf/super.c:1638:4: warning: symbol 'i' shadows an earlier one
fs/udf/super.c:1469:6: originally declared here
fs/udf/super.c:1712:4: warning: symbol 'i' shadows an earlier one
fs/udf/super.c:1701:6: originally declared here
fs/udf/super.c:1714:4: warning: symbol 'i' shadows an earlier one
fs/udf/super.c:1701:6: originally declared here

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c  |    8 ++++----
 fs/udf/udf_sb.h |   31 ++++++++++++++-----------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 1afea58..f6c911b 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1634,9 +1634,9 @@ error_out:
 		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
 			iput(map->s_fspace.s_table);
 		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
+			udf_sb_free_bitmap(map->s_uspace.s_bitmap);
 		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
+			udf_sb_free_bitmap(map->s_fspace.s_bitmap);
 		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
 				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
@@ -1710,9 +1710,9 @@ static void udf_put_super(struct super_block *sb)
 		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
 			iput(map->s_fspace.s_table);
 		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
+			udf_sb_free_bitmap(map->s_uspace.s_bitmap);
 		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
-			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
+			udf_sb_free_bitmap(map->s_fspace.s_bitmap);
 		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
 			for (i = 0; i < 4; i++)
 				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 4cf91f2..8fc2be9 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -171,27 +171,24 @@ static inline struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, __u
 	return bitmap;
 }
 
-#define UDF_SB_FREE_BITMAP(X,Y,Z)\
-{\
-	int i;\
-	int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
-	int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
-	for (i = 0; i < nr_groups; i++) {\
-		if (UDF_SB_BITMAP(X,Y,Z,i))\
-			brelse(UDF_SB_BITMAP(X,Y,Z,i));\
-	}\
-	if (size <= PAGE_SIZE)\
-		kfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
-	else\
-		vfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
+static inline void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
+{
+	int i;
+	int nr_groups = bitmap->s_nr_groups;
+	int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);
+
+	for (i = 0; i < nr_groups; i++) {
+		if (bitmap->s_block_bitmap[i])
+			brelse(bitmap->s_block_bitmap[i]);
+	}
+	if (size <= PAGE_SIZE)
+		kfree(bitmap);
+	else
+		vfree(bitmap);
 }
 
 #define UDF_QUERY_FLAG(X,Y)			( udf_sb(X)->s_flags & ( 1 << (Y) ) )
 #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
 #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
 
-#define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
-#define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
-
-
 #endif /* __LINUX_UDF_SB_H */
-- 
1.5.3.4


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

* [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition)
  2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
                   ` (22 preceding siblings ...)
  2007-12-23  1:51 ` [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function marcin.slusarz
@ 2007-12-23  1:51 ` marcin.slusarz
  2008-01-07 11:37   ` Jan Kara
  23 siblings, 1 reply; 35+ messages in thread
From: marcin.slusarz @ 2007-12-23  1:51 UTC (permalink / raw)
  To: LKML; +Cc: Ben Fennema, Jan Kara, Marcin Slusarz

fix warnings:
fs/udf/super.c:1370:24: warning: symbol 'bh' shadows an earlier one
fs/udf/super.c:1288:21: originally declared here
fs/udf/super.c:450:6: warning: symbol 'udf_write_super' was not declared. Should it be static?

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
CC: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index f6c911b..da68130 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -447,7 +447,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt)
 	return 1;
 }
 
-void udf_write_super(struct super_block *sb)
+static void udf_write_super(struct super_block *sb)
 {
 	lock_kernel();
 
@@ -1367,7 +1367,6 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
 				map->s_type_specific.s_virtual.s_num_entries =
 					(udf_sb_vat_inode(sb)->i_size - 36) >> 2;
 			} else if (map->s_partition_type == UDF_VIRTUAL_MAP20) {
-				struct buffer_head *bh = NULL;
 				uint32_t pos;
 
 				pos = udf_block_map(udf_sb_vat_inode(sb), 0);
-- 
1.5.3.4


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

* Re: [PATCH 02/24] udf: rename UDF_SB to udf_sb
  2007-12-23  1:50 ` [PATCH 02/24] udf: rename UDF_SB to udf_sb marcin.slusarz
@ 2007-12-23 12:04   ` Christoph Hellwig
  0 siblings, 0 replies; 35+ messages in thread
From: Christoph Hellwig @ 2007-12-23 12:04 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema, Jan Kara

On Sun, Dec 23, 2007 at 02:50:52AM +0100, marcin.slusarz@gmail.com wrote:
> rename UDF_SB function to udf_sb

FOO_SB is a convention used by most filesystems, so I don't really see
any point in changing it.


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

* Re: [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function
  2007-12-23  1:50 ` [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function marcin.slusarz
@ 2007-12-23 12:08   ` Christoph Hellwig
  0 siblings, 0 replies; 35+ messages in thread
From: Christoph Hellwig @ 2007-12-23 12:08 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema, Jan Kara

On Sun, Dec 23, 2007 at 02:50:54AM +0100, marcin.slusarz@gmail.com wrote:
> - change UDF_SB_VOLIDENT macro to udf_sb_volume_ident inline function
> - rename s_volident field to s_volume_ident

Please just use the field directly without an accessor.  And as usual
there's a lot of opportunity to have a nice local variable for the udf
superblock.


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

* Re: [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function
  2007-12-23  1:50 ` [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function marcin.slusarz
@ 2007-12-23 12:09   ` Christoph Hellwig
  0 siblings, 0 replies; 35+ messages in thread
From: Christoph Hellwig @ 2007-12-23 12:09 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema, Jan Kara

Same comment applies to this one.  And probably the following patches
aswell so I'm not going to comment on this issue for them.


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

* Re: [PATCH 01/24] udf: fix coding style of super.c
  2007-12-23  1:50 ` [PATCH 01/24] udf: fix coding style of super.c marcin.slusarz
@ 2008-01-07 11:13   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:13 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:50:51, marcin.slusarz@gmail.com wrote:
> fix coding style errors found by checkpatch:
> - assignments in if conditions
> - braces {} around single statement blocks
> - no spaces after commas
> - printks without KERN_*
> - lines longer than 80 characters
> before: total: 50 errors, 207 warnings, 1835 lines checked
> after:  total: 0 errors, 164 warnings, 1872 lines checked
> 
> all 164 warnings left are lines longer than 80 characters;
> this file has too much indentation with really long expressions
> to break all those lines
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  Thanks for doing the cleanup.  I've reviewed the changes and all look
fine. You can add: Acked-by: Jan Kara <jack@suse.cz>

									Honza

> ---
>  fs/udf/super.c |  295 +++++++++++++++++++++++++++++++------------------------
>  1 files changed, 166 insertions(+), 129 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 4360c7a..57788f1 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -33,8 +33,8 @@
>   *  10/17/98      added freespace count for "df"
>   *  11/11/98 gr   added novrs option
>   *  11/26/98 dgb  added fileset,anchor mount options
> - *  12/06/98 blf  really hosed things royally. vat/sparing support. sequenced vol descs
> - *                rewrote option handling based on isofs
> + *  12/06/98 blf  really hosed things royally. vat/sparing support. sequenced
> + *                vol descs. rewrote option handling based on isofs
>   *  12/20/98      find the free space bitmap (if it exists)
>   */
>  
> @@ -116,7 +116,7 @@ static struct kmem_cache *udf_inode_cachep;
>  static struct inode *udf_alloc_inode(struct super_block *sb)
>  {
>  	struct udf_inode_info *ei;
> -	ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
> +	ei = kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
>  	if (!ei)
>  		return NULL;
>  
> @@ -561,47 +561,52 @@ static int udf_vrs(struct super_block *sb, int silent)
>  
>  		/* Look for ISO  descriptors */
>  		vsd = (struct volStructDesc *)(bh->b_data +
> -					       (sector & (sb->s_blocksize - 1)));
> +					      (sector & (sb->s_blocksize - 1)));
>  
>  		if (vsd->stdIdent[0] == 0) {
>  			brelse(bh);
>  			break;
> -		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
> +		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001,
> +				    VSD_STD_ID_LEN)) {
>  			iso9660 = sector;
>  			switch (vsd->structType) {
>  			case 0:
>  				udf_debug("ISO9660 Boot Record found\n");
>  				break;
>  			case 1:
> -				udf_debug
> -				    ("ISO9660 Primary Volume Descriptor found\n");
> +				udf_debug("ISO9660 Primary Volume Descriptor "
> +					  "found\n");
>  				break;
>  			case 2:
> -				udf_debug
> -				    ("ISO9660 Supplementary Volume Descriptor found\n");
> +				udf_debug("ISO9660 Supplementary Volume "
> +					  "Descriptor found\n");
>  				break;
>  			case 3:
> -				udf_debug
> -				    ("ISO9660 Volume Partition Descriptor found\n");
> +				udf_debug("ISO9660 Volume Partition Descriptor "
> +					  "found\n");
>  				break;
>  			case 255:
> -				udf_debug
> -				    ("ISO9660 Volume Descriptor Set Terminator found\n");
> +				udf_debug("ISO9660 Volume Descriptor Set "
> +					  "Terminator found\n");
>  				break;
>  			default:
>  				udf_debug("ISO9660 VRS (%u) found\n",
>  					  vsd->structType);
>  				break;
>  			}
> -		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
> -		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
> +		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01,
> +				    VSD_STD_ID_LEN))
> +			; /* nothing */
> +		else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01,
> +				    VSD_STD_ID_LEN)) {
>  			brelse(bh);
>  			break;
> -		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
> +		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02,
> +				    VSD_STD_ID_LEN))
>  			nsr02 = sector;
> -		} else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
> +		else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03,
> +				    VSD_STD_ID_LEN))
>  			nsr03 = sector;
> -		}
>  		brelse(bh);
>  	}
>  
> @@ -658,21 +663,26 @@ static void udf_find_anchor(struct super_block *sb)
>  		 *  however, if the disc isn't closed, it could be 512 */
>  
>  		for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {
> -			if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) {
> -				ident = location = 0;
> -			} else {
> -				ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
> -				location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
> -				brelse(bh);
> +			ident = location = 0;
> +			if (last[i] >= 0) {
> +				bh = sb_bread(sb, last[i]);
> +				if (bh) {
> +					tag *t = (tag *)bh->b_data;
> +					ident = le16_to_cpu(t->tagIdent);
> +					location = le32_to_cpu(t->tagLocation);
> +					brelse(bh);
> +				}
>  			}
>  
>  			if (ident == TAG_IDENT_AVDP) {
>  				if (location == last[i] - UDF_SB_SESSION(sb)) {
> -					lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
> -					UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
> +					lastblock = last[i] - UDF_SB_SESSION(sb);
> +					UDF_SB_ANCHOR(sb)[0] = lastblock;
> +					UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
>  				} else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) {
>  					UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
> -					lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
> +					lastblock = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
> +					UDF_SB_ANCHOR(sb)[0] = lastblock;
>  					UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
>  				} else {
>  					udf_debug("Anchor found at block %d, location mismatch %d.\n",
> @@ -682,12 +692,15 @@ static void udf_find_anchor(struct super_block *sb)
>  				lastblock = last[i];
>  				UDF_SB_ANCHOR(sb)[3] = 512;
>  			} else {
> -				if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) {
> -					ident = location = 0;
> -				} else {
> -					ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
> -					location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
> -					brelse(bh);
> +				ident = location = 0;
> +				if (last[i] >= 256) {
> +					bh = sb_bread(sb, last[i] - 256);
> +					if (bh) {
> +						tag *t = (tag *)bh->b_data;
> +						ident = le16_to_cpu(t->tagIdent);
> +						location = le32_to_cpu(t->tagLocation);
> +						brelse(bh);
> +					}
>  				}
>  
>  				if (ident == TAG_IDENT_AVDP &&
> @@ -695,13 +708,15 @@ static void udf_find_anchor(struct super_block *sb)
>  					lastblock = last[i];
>  					UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
>  				} else {
> -					if (last[i] < 312 + UDF_SB_SESSION(sb) ||
> -					    !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) {
> -						ident = location = 0;
> -					} else {
> -						ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
> -						location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
> -						brelse(bh);
> +					ident = location = 0;
> +					if (last[i] >= 312 + UDF_SB_SESSION(sb)) {
> +						bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb));
> +						if (bh) {
> +							tag *t = (tag *)bh->b_data;
> +							ident = le16_to_cpu(t->tagIdent);
> +							location = le32_to_cpu(t->tagLocation);
> +							brelse(bh);
> +						}
>  					}
>  
>  					if (ident == TAG_IDENT_AVDP &&
> @@ -716,10 +731,12 @@ static void udf_find_anchor(struct super_block *sb)
>  	}
>  
>  	if (!lastblock) {
> -		/* We havn't found the lastblock. check 312 */
> -		if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) {
> -			ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
> -			location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
> +		/* We haven't found the lastblock. check 312 */
> +		bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb));
> +		if (bh) {
> +			tag *t = (tag *)bh->b_data;
> +			ident = le16_to_cpu(t->tagIdent);
> +			location = le32_to_cpu(t->tagLocation);
>  			brelse(bh);
>  
>  			if (ident == TAG_IDENT_AVDP && location == 256)
> @@ -729,15 +746,15 @@ static void udf_find_anchor(struct super_block *sb)
>  
>  	for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
>  		if (UDF_SB_ANCHOR(sb)[i]) {
> -			if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
> -						   UDF_SB_ANCHOR(sb)[i], &ident))) {
> +			bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
> +					     UDF_SB_ANCHOR(sb)[i], &ident);
> +			if (!bh)
>  				UDF_SB_ANCHOR(sb)[i] = 0;
> -			} else {
> +			else {
>  				brelse(bh);
>  				if ((ident != TAG_IDENT_AVDP) &&
> -				    (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) {
> +				    (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE)))
>  					UDF_SB_ANCHOR(sb)[i] = 0;
> -				}
>  			}
>  		}
>  	}
> @@ -745,7 +762,9 @@ static void udf_find_anchor(struct super_block *sb)
>  	UDF_SB_LASTBLOCK(sb) = lastblock;
>  }
>  
> -static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
> +static int udf_find_fileset(struct super_block *sb,
> +			    kernel_lb_addr *fileset,
> +			    kernel_lb_addr *root)
>  {
>  	struct buffer_head *bh = NULL;
>  	long lastblock;
> @@ -764,7 +783,8 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker
>  
>  	}
>  
> -	if (!bh) { /* Search backwards through the partitions */
> +	if (!bh) {
> +		/* Search backwards through the partitions */
>  		kernel_lb_addr newfileset;
>  
>  /* --> cvg: FIXME - is it reasonable? */
> @@ -775,11 +795,13 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker
>  		      fileset->logicalBlockNum == 0xFFFFFFFF &&
>  		      fileset->partitionReferenceNum == 0xFFFF);
>  		     newfileset.partitionReferenceNum--) {
> -			lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
> +			lastblock = UDF_SB_PARTLEN(sb,
> +					newfileset.partitionReferenceNum);
>  			newfileset.logicalBlockNum = 0;
>  
>  			do {
> -				bh = udf_read_ptagged(sb, newfileset, 0, &ident);
> +				bh = udf_read_ptagged(sb, newfileset, 0,
> +						      &ident);
>  				if (!bh) {
>  					newfileset.logicalBlockNum++;
>  					continue;
> @@ -840,7 +862,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
>  			      lets_to_cpu(pvoldesc->recordingDateAndTime))) {
>  		kernel_timestamp ts;
>  		ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
> -		udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
> +		udf_debug("recording time %ld/%ld, %04u/%02u/%02u"
> +			  " %02u:%02u (%x)\n",
>  			  recording, recording_usec,
>  			  ts.year, ts.month, ts.day, ts.hour,
>  			  ts.minute, ts.typeAndTimezone);
> @@ -888,19 +911,21 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  		udf_debug("Searching map: (%d == %d)\n",
>  			  UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
>  		if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
> -			UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
> -			UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
> +			UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */
> +			UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation);
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
> -				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
> +				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_READ_ONLY;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
> -				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
> +				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_WRITE_ONCE;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
> -				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
> +				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_REWRITABLE;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
> -				UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
> +				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_OVERWRITABLE;
>  
> -			if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
> -			    !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) {
> +			if (!strcmp(p->partitionContents.ident,
> +				    PD_PARTITION_CONTENTS_NSR02) ||
> +			    !strcmp(p->partitionContents.ident,
> +				    PD_PARTITION_CONTENTS_NSR03)) {
>  				struct partitionHeaderDesc *phd;
>  
>  				phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
> @@ -916,7 +941,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  						udf_debug("cannot load unallocSpaceTable (part %d)\n", i);
>  						return 1;
>  					}
> -					UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
> +					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE;
>  					udf_debug("unallocSpaceTable (part %d) @ %ld\n",
>  						  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
>  				}
> @@ -927,7 +952,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  							le32_to_cpu(phd->unallocSpaceBitmap.extLength);
>  						UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
>  							le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
> -						UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
> +						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
>  						udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
>  							  i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
>  					}
> @@ -946,7 +971,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  						udf_debug("cannot load freedSpaceTable (part %d)\n", i);
>  						return 1;
>  					}
> -					UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
> +					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE;
>  					udf_debug("freedSpaceTable (part %d) @ %ld\n",
>  						  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
>  				}
> @@ -957,7 +982,7 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  							le32_to_cpu(phd->freedSpaceBitmap.extLength);
>  						UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
>  							le32_to_cpu(phd->freedSpaceBitmap.extPosition);
> -						UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
> +						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP;
>  						udf_debug("freedSpaceBitmap (part %d) @ %d\n",
>  							  i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
>  					}
> @@ -970,9 +995,11 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  		udf_debug("Partition (%d) not found in partition map\n",
>  			  le16_to_cpu(p->partitionNumber));
>  	} else {
> -		udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
> -			  le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
> -			  UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
> +		udf_debug("Partition (%d:%d type %x) starts at physical %d, "
> +			  "block length %d\n",
> +			  le16_to_cpu(p->partitionNumber), i,
> +			  UDF_SB_PARTTYPE(sb, i), UDF_SB_PARTROOT(sb, i),
> +			  UDF_SB_PARTLEN(sb, i));
>  	}
>  	return 0;
>  }
> @@ -994,19 +1021,19 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
>  		type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
>  		if (type == 1) {
>  			struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
> -			UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
> -			UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
> -			UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
> -			UDF_SB_PARTFUNC(sb,i) = NULL;
> +			UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15;
> +			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
> +			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
> +			UDF_SB_PARTFUNC(sb, i) = NULL;
>  		} else if (type == 2) {
>  			struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
>  			if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
>  				if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
> -					UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
> -					UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
> +					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP15;
> +					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt15;
>  				} else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
> -					UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
> -					UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
> +					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP20;
> +					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt20;
>  				}
>  			} else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
>  				uint32_t loc;
> @@ -1014,39 +1041,41 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
>  				struct sparingTable *st;
>  				struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
>  
> -				UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
> -				UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
> +				UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
> +				UDF_SB_TYPESPAR(sb, i).s_packet_len = le16_to_cpu(spm->packetLength);
>  				for (j = 0; j < spm->numSparingTables; j++) {
>  					loc = le32_to_cpu(spm->locSparingTable[j]);
> -					UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
> +					UDF_SB_TYPESPAR(sb, i).s_spar_map[j] =
>  						udf_read_tagged(sb, loc, loc, &ident);
> -					if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
> -						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
> +					if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != NULL) {
> +						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, i).s_spar_map[j]->b_data;
>  						if (ident != 0 ||
>  						    strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
> -							brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
> -							UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
> +							brelse(UDF_SB_TYPESPAR(sb, i).s_spar_map[j]);
> +							UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = NULL;
>  						}
>  					}
>  				}
> -				UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
> +				UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15;
>  			} else {
> -				udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
> +				udf_debug("Unknown ident: %s\n",
> +					  upm2->partIdent.ident);
>  				continue;
>  			}
> -			UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
> -			UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
> +			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum);
> +			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum);
>  		}
>  		udf_debug("Partition (%d:%d) type %d on volume %d\n",
> -			  i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
> +			  i, UDF_SB_PARTNUM(sb, i), type,
> +			  UDF_SB_PARTVSN(sb, i));
>  	}
>  
>  	if (fileset) {
>  		long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
>  
>  		*fileset = lelb_to_cpu(la->extLocation);
> -		udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
> -			  fileset->logicalBlockNum,
> +		udf_debug("FileSet found in LogicalVolDesc at block=%d, "
> +			  "partition=%d\n", fileset->logicalBlockNum,
>  			  fileset->partitionReferenceNum);
>  	}
>  	if (lvd->integritySeqExt.extLength)
> @@ -1071,7 +1100,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
>  		UDF_SB_LVIDBH(sb) = bh;
>  
>  		if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
> -			udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
> +			udf_load_logicalvolint(sb,
> +				leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
>  
>  		if (UDF_SB_LVIDBH(sb) != bh)
>  			brelse(bh);
> @@ -1097,8 +1127,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
>   *	July 1, 1997 - Andrew E. Mileski
>   *	Written, tested, and released.
>   */
> -static int udf_process_sequence(struct super_block *sb, long block, long lastblock,
> -				 kernel_lb_addr *fileset)
> +static int udf_process_sequence(struct super_block *sb, long block,
> +				long lastblock, kernel_lb_addr *fileset)
>  {
>  	struct buffer_head *bh = NULL;
>  	struct udf_vds_record vds[VDS_POS_LENGTH];
> @@ -1178,7 +1208,8 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo
>  	}
>  	for (i = 0; i < VDS_POS_LENGTH; i++) {
>  		if (vds[i].block) {
> -			bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
> +			bh = udf_read_tagged(sb, vds[i].block, vds[i].block,
> +					     &ident);
>  
>  			if (i == VDS_POS_PRIMARY_VOL_DESC) {
>  				udf_load_pvoldesc(sb, bh);
> @@ -1190,11 +1221,14 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo
>  					brelse(bh);
>  					return 1;
>  				}
> -				for (j = vds[i].block + 1; j <  vds[VDS_POS_TERMINATING_DESC].block; j++) {
> +				for (j = vds[i].block + 1;
> +				     j <  vds[VDS_POS_TERMINATING_DESC].block;
> +				     j++) {
>  					bh2 = udf_read_tagged(sb, j, j, &ident);
>  					gd = (struct generic_desc *)bh2->b_data;
>  					if (ident == TAG_IDENT_PD)
> -						if (udf_load_partdesc(sb, bh2)) {
> +						if (udf_load_partdesc(sb,
> +								      bh2)) {
>  							brelse(bh);
>  							brelse(bh2);
>  							return 1;
> @@ -1222,14 +1256,16 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
>  	}
>  	/* Check that it is NSR02 compliant */
>  	/* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
> -	else if ((block = udf_vrs(sb, silent)) == -1) {
> -		udf_debug("Failed to read byte 32768. Assuming open disc. "
> -			  "Skipping validity check\n");
> -		if (!UDF_SB_LASTBLOCK(sb))
> -			UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
> -		return 0;
> -	} else {
> -		return !block;
> +	else {
> +		block = udf_vrs(sb, silent);
> +		if (block == -1) {
> +			udf_debug("Failed to read byte 32768. Assuming open "
> +				  "disc. Skipping validity check\n");
> +			if (!UDF_SB_LASTBLOCK(sb))
> +				UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
> +			return 0;
> +		} else
> +			return !block;
>  	}
>  }
>  
> @@ -1252,7 +1288,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  
>  			/* Locate the main sequence */
>  			main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
> -			main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength );
> +			main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
>  			main_e = main_e >> sb->s_blocksize_bits;
>  			main_e += main_s;
>  
> @@ -1267,9 +1303,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  			/* Process the main & reserve sequences */
>  			/* responsible for finding the PartitionDesc(s) */
>  			if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
> -			      udf_process_sequence(sb, reserve_s, reserve_e, fileset))) {
> +			      udf_process_sequence(sb, reserve_s, reserve_e, fileset)))
>  				break;
> -			}
>  		}
>  	}
>  
> @@ -1308,7 +1343,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  			if (j == UDF_SB_NUMPARTS(sb))
>  				return 1;
>  
> -			if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
> +			UDF_SB_VAT(sb) = udf_iget(sb, ino);
> +			if (!UDF_SB_VAT(sb))
>  				return 1;
>  
>  			if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
> @@ -1481,8 +1517,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
>  	UDF_SB_ANCHOR(sb)[3] = 256;
>  
> -	if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */
> -		printk("UDF-fs: No VRS found\n");
> +	if (udf_check_valid(sb, uopt.novrs, silent)) {
> +		/* read volume recognition sequences */
> +		printk(KERN_WARNING "UDF-fs: No VRS found\n");
>  		goto error_out;
>  	}
>  
> @@ -1496,7 +1533,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	sb->s_time_gran = 1000;
>  
>  	if (udf_load_partition(sb, &fileset)) {
> -		printk("UDF-fs: No partition found (1)\n");
> +		printk(KERN_WARNING "UDF-fs: No partition found (1)\n");
>  		goto error_out;
>  	}
>  
> @@ -1508,7 +1545,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  		/* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
>  
>  		if (minUDFReadRev > UDF_MAX_READ_VERSION) {
> -			printk("UDF-fs: minUDFReadRev=%x (max is %x)\n",
> +			printk(KERN_ERR "UDF-fs: minUDFReadRev=%x (max is %x)\n",
>  			       le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
>  			       UDF_MAX_READ_VERSION);
>  			goto error_out;
> @@ -1525,17 +1562,17 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	}
>  
>  	if (!UDF_SB_NUMPARTS(sb)) {
> -		printk("UDF-fs: No partition found (2)\n");
> +		printk(KERN_WARNING "UDF-fs: No partition found (2)\n");
>  		goto error_out;
>  	}
>  
>  	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) {
> -		printk("UDF-fs: Partition marked readonly; forcing readonly mount\n");
> +		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n");
>  		sb->s_flags |= MS_RDONLY;
>  	}
>  
>  	if (udf_find_fileset(sb, &fileset, &rootdir)) {
> -		printk("UDF-fs: No fileset found\n");
> +		printk(KERN_WARNING "UDF-fs: No fileset found\n");
>  		goto error_out;
>  	}
>  
> @@ -1556,7 +1593,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	/* perhaps it's not extensible enough, but for now ... */
>  	inode = udf_iget(sb, rootdir);
>  	if (!inode) {
> -		printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
> +		printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
>  		       rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
>  		goto error_out;
>  	}
> @@ -1564,7 +1601,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	/* Allocate a dentry for the root inode */
>  	sb->s_root = d_alloc_root(inode);
>  	if (!sb->s_root) {
> -		printk("UDF-fs: Couldn't allocate root dentry\n");
> +		printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n");
>  		iput(inode);
>  		goto error_out;
>  	}
> @@ -1580,9 +1617,9 @@ error_out:
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
>  			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
> +			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
> +			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
>  		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
>  				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
> @@ -1614,7 +1651,7 @@ void udf_error(struct super_block *sb, const char *function,
>  	va_start(args, fmt);
>  	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
>  	va_end(args);
> -	printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
> +	printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
>  		sb->s_id, function, error_buf);
>  }
>  
> @@ -1655,9 +1692,9 @@ static void udf_put_super(struct super_block *sb)
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
>  			iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
> +			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
>  		if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
> +			UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
>  		if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
>  				brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
> @@ -1786,9 +1823,9 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t
>  	epos.offset = sizeof(struct unallocSpaceEntry);
>  	epos.bh = NULL;
>  
> -	while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
> +	while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1)
>  		accum += (elen >> table->i_sb->s_blocksize_bits);
> -	}
> +
>  	brelse(epos.bh);
>  
>  	unlock_kernel();
> @@ -1811,22 +1848,22 @@ static unsigned int udf_count_free(struct super_block *sb)
>  	if (accum)
>  		return accum;
>  
> -	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
> +	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
>  		accum += udf_count_free_bitmap(sb,
>  					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
>  	}
> -	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
> +	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
>  		accum += udf_count_free_bitmap(sb,
>  					       UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
>  	}
>  	if (accum)
>  		return accum;
>  
> -	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
> +	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
>  		accum += udf_count_free_table(sb,
>  					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
>  	}
> -	if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
> +	if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
>  		accum += udf_count_free_table(sb,
>  					      UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
>  	}
> -- 
> 1.5.3.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 19/24] udf: check if udf_load_logicalvol failed
  2007-12-23  1:51 ` [PATCH 19/24] udf: check if udf_load_logicalvol failed marcin.slusarz
@ 2008-01-07 11:29   ` Jan Kara
  2008-01-07 19:19     ` Marcin Slusarz
  0 siblings, 1 reply; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:29 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:51:09, marcin.slusarz@gmail.com wrote:
> udf_load_logicalvol may fail eg in out of memory conditions - check it
> and propagate error further
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  I certainly agree with the idea of the change. Just note that
udf_process_sequence() returns 1 in case of failure so propagating an error
is not ideal - we should keep things consistent. And also note that the
actual value is disregarded in udf_load_partition() anyway.

									Honza
> ---
>  fs/udf/super.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 4aef612..f8c5794 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1141,6 +1141,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
>  	uint32_t vdsn;
>  	uint16_t ident;
>  	long next_s = 0, next_e = 0;
> +	int ret;
>  
>  	memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
>  
> @@ -1216,7 +1217,11 @@ static int udf_process_sequence(struct super_block *sb, long block,
>  			if (i == VDS_POS_PRIMARY_VOL_DESC) {
>  				udf_load_pvoldesc(sb, bh);
>  			} else if (i == VDS_POS_LOGICAL_VOL_DESC) {
> -				udf_load_logicalvol(sb, bh, fileset); /* TODO: check return value */
> +				ret = udf_load_logicalvol(sb, bh, fileset);
> +				if (ret != 0) {
> +					brelse(bh);
> +					return ret;
> +				}
>  			} else if (i == VDS_POS_PARTITION_DESC) {
>  				struct buffer_head *bh2 = NULL;
>  				if (udf_load_partdesc(sb, bh)) {
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 21/24] udf: remove some UDF_SB_* macros
  2007-12-23  1:51 ` [PATCH 21/24] udf: remove some UDF_SB_* macros marcin.slusarz
@ 2008-01-07 11:34   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:34 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:51:11, marcin.slusarz@gmail.com wrote:
> remove macros:
> - UDF_SB_PARTTYPE
> - UDF_SB_PARTROOT
> - UDF_SB_PARTLEN
> - UDF_SB_PARTVSN
> - UDF_SB_PARTNUM
> - UDF_SB_TYPESPAR
> - UDF_SB_TYPEVIRT
> - UDF_SB_PARTFUNC
> - UDF_SB_PARTFLAGS
> and replace all uses
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  Looks fine. Acked-by: Jan Kara <jack@suse.cz>

										Honza

> ---
>  fs/udf/balloc.c    |   76 +++++++++++----------
>  fs/udf/inode.c     |    2 +-
>  fs/udf/partition.c |   49 ++++++++------
>  fs/udf/super.c     |  191 ++++++++++++++++++++++++++++------------------------
>  fs/udf/udf_sb.h    |   16 ++---
>  5 files changed, 179 insertions(+), 155 deletions(-)
> 
> diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
> index 23aae18..4fe8635 100644
> --- a/fs/udf/balloc.c
> +++ b/fs/udf/balloc.c
> @@ -155,10 +155,10 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
>  
>  	mutex_lock(&sbi->s_alloc_mutex);
>  	if (bloc.logicalBlockNum < 0 ||
> -	    (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
> +	    (bloc.logicalBlockNum + count) > udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len) {
>  		udf_debug("%d < %d || %d + %d > %d\n",
>  			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
> -			  UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
> +			  udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len);
>  		goto error_return;
>  	}
>  
> @@ -219,16 +219,18 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
>  	int bit, block, block_group, group_start;
>  	int nr_groups, bitmap_nr;
>  	struct buffer_head *bh;
> +	__u32 part_len;
>  
>  	mutex_lock(&sbi->s_alloc_mutex);
> -	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
> +	part_len = udf_sb_partmap(sb, partition)->s_partition_len;
> +	if (first_block < 0 || first_block >= part_len)
>  		goto out;
>  
> -	if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
> -		block_count = UDF_SB_PARTLEN(sb, partition) - first_block;
> +	if (first_block + block_count > part_len)
> +		block_count = part_len - first_block;
>  
>  repeat:
> -	nr_groups = (UDF_SB_PARTLEN(sb, partition) +
> +	nr_groups = (udf_sb_partmap(sb, partition)->s_partition_len +
>  		     (sizeof(struct spaceBitmapDesc) << 3) +
>  		     (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
>  	block = first_block + (sizeof(struct spaceBitmapDesc) << 3);
> @@ -287,7 +289,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
>  	mutex_lock(&sbi->s_alloc_mutex);
>  
>  repeat:
> -	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
> +	if (goal < 0 || goal >= udf_sb_partmap(sb, partition)->s_partition_len)
>  		goal = 0;
>  
>  	nr_groups = bitmap->s_nr_groups;
> @@ -421,10 +423,10 @@ static void udf_table_free_blocks(struct super_block *sb,
>  
>  	mutex_lock(&sbi->s_alloc_mutex);
>  	if (bloc.logicalBlockNum < 0 ||
> -	    (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
> +	    (bloc.logicalBlockNum + count) > udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len) {
>  		udf_debug("%d < %d || %d + %d > %d\n",
>  			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
> -			  UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
> +			  udf_sb_partmap(sb, bloc.partitionReferenceNum)->s_partition_len);
>  		goto error_return;
>  	}
>  
> @@ -627,7 +629,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
>  	struct extent_position epos;
>  	int8_t etype = -1;
>  
> -	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
> +	if (first_block < 0 || first_block >= udf_sb_partmap(sb, partition)->s_partition_len)
>  		return 0;
>  
>  	if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
> @@ -703,7 +705,7 @@ static int udf_table_new_block(struct super_block *sb,
>  		return newblock;
>  
>  	mutex_lock(&sbi->s_alloc_mutex);
> -	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
> +	if (goal < 0 || goal >= udf_sb_partmap(sb, partition)->s_partition_len)
>  		goal = 0;
>  
>  	/* We search for the closest matching block to goal. If we find a exact hit,
> @@ -789,22 +791,23 @@ inline void udf_free_blocks(struct super_block *sb,
>  			    uint32_t count)
>  {
>  	uint16_t partition = bloc.partitionReferenceNum;
> +	struct udf_part_map *map = udf_sb_partmap(sb, partition);
>  
> -	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
> +	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
>  		return udf_bitmap_free_blocks(sb, inode,
> -					      udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
> +					      map->s_uspace.s_bitmap,
>  					      bloc, offset, count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
>  		return udf_table_free_blocks(sb, inode,
> -					     udf_sb_partmaps(sb)[partition].s_uspace.s_table,
> +					     map->s_uspace.s_table,
>  					     bloc, offset, count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
>  		return udf_bitmap_free_blocks(sb, inode,
> -					      udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
> +					      map->s_fspace.s_bitmap,
>  					      bloc, offset, count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
>  		return udf_table_free_blocks(sb, inode,
> -					     udf_sb_partmaps(sb)[partition].s_fspace.s_table,
> +					     map->s_fspace.s_table,
>  					     bloc, offset, count);
>  	} else {
>  		return;
> @@ -816,21 +819,23 @@ inline int udf_prealloc_blocks(struct super_block *sb,
>  			       uint16_t partition, uint32_t first_block,
>  			       uint32_t block_count)
>  {
> -	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
> +	struct udf_part_map *map = udf_sb_partmap(sb, partition);
> +
> +	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
>  		return udf_bitmap_prealloc_blocks(sb, inode,
> -						  udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
> +						  map->s_uspace.s_bitmap,
>  						  partition, first_block, block_count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
>  		return udf_table_prealloc_blocks(sb, inode,
> -						 udf_sb_partmaps(sb)[partition].s_uspace.s_table,
> +						 map->s_uspace.s_table,
>  						 partition, first_block, block_count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
>  		return udf_bitmap_prealloc_blocks(sb, inode,
> -						  udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
> +						  map->s_fspace.s_bitmap,
>  						  partition, first_block, block_count);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
>  		return udf_table_prealloc_blocks(sb, inode,
> -						 udf_sb_partmaps(sb)[partition].s_fspace.s_table,
> +						 map->s_fspace.s_table,
>  						 partition, first_block, block_count);
>  	} else {
>  		return 0;
> @@ -842,23 +847,24 @@ inline int udf_new_block(struct super_block *sb,
>  			 uint16_t partition, uint32_t goal, int *err)
>  {
>  	int ret;
> +	struct udf_part_map *map = udf_sb_partmap(sb, partition);
>  
> -	if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
> +	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
>  		ret = udf_bitmap_new_block(sb, inode,
> -					   udf_sb_partmaps(sb)[partition].s_uspace.s_bitmap,
> +					   map->s_uspace.s_bitmap,
>  					   partition, goal, err);
>  		return ret;
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
>  		return udf_table_new_block(sb, inode,
> -					   udf_sb_partmaps(sb)[partition].s_uspace.s_table,
> +					   map->s_uspace.s_table,
>  					   partition, goal, err);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
>  		return udf_bitmap_new_block(sb, inode,
> -					    udf_sb_partmaps(sb)[partition].s_fspace.s_bitmap,
> +					    map->s_fspace.s_bitmap,
>  					    partition, goal, err);
> -	} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
> +	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
>  		return udf_table_new_block(sb, inode,
> -					   udf_sb_partmaps(sb)[partition].s_fspace.s_table,
> +					   map->s_fspace.s_table,
>  					   partition, goal, err);
>  	} else {
>  		*err = -EIO;
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 1cdb381..8aa0fc6 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -1585,7 +1585,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino)
>  	if (is_bad_inode(inode))
>  		goto out_iput;
>  
> -	if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) {
> +	if (ino.logicalBlockNum >= udf_sb_partmap(sb, ino.partitionReferenceNum)->s_partition_len) {
>  		udf_debug("block=%d, partition=%d out of range\n",
>  			  ino.logicalBlockNum, ino.partitionReferenceNum);
>  		make_bad_inode(inode);
> diff --git a/fs/udf/partition.c b/fs/udf/partition.c
> index 99640a6..4959d53 100644
> --- a/fs/udf/partition.c
> +++ b/fs/udf/partition.c
> @@ -31,15 +31,17 @@
>  inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
>  			       uint16_t partition, uint32_t offset)
>  {
> +	struct udf_part_map *map;
>  	if (partition >= udf_sb_num_parts(sb)) {
>  		udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
>  			  block, partition, offset);
>  		return 0xFFFFFFFF;
>  	}
> -	if (UDF_SB_PARTFUNC(sb, partition))
> -		return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
> +	map = udf_sb_partmap(sb, partition);
> +	if (map->s_partition_func)
> +		return map->s_partition_func(sb, block, partition, offset);
>  	else
> -		return UDF_SB_PARTROOT(sb, partition) + block + offset;
> +		return map->s_partition_root + block + offset;
>  }
>  
>  uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
> @@ -49,12 +51,14 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
>  	uint32_t newblock;
>  	uint32_t index;
>  	uint32_t loc;
> +	struct udf_part_map *map;
>  
> -	index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
> +	map = udf_sb_partmap(sb, partition);
> +	index = (sb->s_blocksize - map->s_type_specific.s_virtual.s_start_offset) / sizeof(uint32_t);
>  
> -	if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) {
> +	if (block > map->s_type_specific.s_virtual.s_num_entries) {
>  		udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
> -			  block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
> +			  block, map->s_type_specific.s_virtual.s_num_entries);
>  		return 0xFFFFFFFF;
>  	}
>  
> @@ -64,7 +68,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
>  		index = block % (sb->s_blocksize / sizeof(uint32_t));
>  	} else {
>  		newblock = 0;
> -		index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
> +		index = map->s_type_specific.s_virtual.s_start_offset / sizeof(uint32_t) + block;
>  	}
>  
>  	loc = udf_block_map(udf_sb_vat_inode(sb), newblock);
> @@ -100,11 +104,15 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
>  {
>  	int i;
>  	struct sparingTable *st = NULL;
> -	uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
> +	struct udf_part_map *map;
> +	uint32_t packet;
> +
> +	map = udf_sb_partmap(sb, partition);
> +	packet = (block + offset) & ~(map->s_type_specific.s_sparing.s_packet_len - 1);
>  
>  	for (i = 0; i < 4; i++) {
> -		if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) {
> -			st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
> +		if (map->s_type_specific.s_sparing.s_spar_map[i] != NULL) {
> +			st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[i]->b_data;
>  			break;
>  		}
>  	}
> @@ -115,14 +123,14 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
>  				break;
>  			} else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) {
>  				return le32_to_cpu(st->mapEntry[i].mappedLocation) +
> -					((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
> +					((block + offset) & (map->s_type_specific.s_sparing.s_packet_len - 1));
>  			} else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) {
>  				break;
>  			}
>  		}
>  	}
>  
> -	return UDF_SB_PARTROOT(sb,partition) + block + offset;
> +	return map->s_partition_root + block + offset;
>  }
>  
>  int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
> @@ -134,13 +142,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
>  	int i, j, k, l;
>  
>  	for (i = 0; i < udf_sb_num_parts(sb); i++) {
> -		if (old_block > UDF_SB_PARTROOT(sb,i) &&
> -		    old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
> -			sdata = &UDF_SB_TYPESPAR(sb,i);
> -			packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
> +		struct udf_part_map *map = udf_sb_partmap(sb, i);
> +		if (old_block > map->s_partition_root &&
> +		    old_block < map->s_partition_root + map->s_partition_len) {
> +			sdata = &map->s_type_specific.s_sparing;
> +			packet = (old_block - map->s_partition_root) & ~(sdata->s_packet_len - 1);
>  
>  			for (j = 0; j < 4; j++) {
> -				if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
> +				if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) {
>  					st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
>  					break;
>  				}
> @@ -160,11 +169,11 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
>  						}
>  					}
>  					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
> -						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
> +						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
>  					return 0;
>  				} else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) {
>  					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
> -						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
> +						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
>  					return 0;
>  				} else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) {
>  					break;
> @@ -185,7 +194,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
>  						}
>  					}
>  					*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
> -						((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
> +						((old_block - map->s_partition_root) & (sdata->s_packet_len - 1));
>  					return 0;
>  				}
>  			}
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index f8c5794..33ccf66 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -795,8 +795,9 @@ static int udf_find_fileset(struct super_block *sb,
>  		      fileset->logicalBlockNum == 0xFFFFFFFF &&
>  		      fileset->partitionReferenceNum == 0xFFFF);
>  		     newfileset.partitionReferenceNum--) {
> -			lastblock = UDF_SB_PARTLEN(sb,
> -					newfileset.partitionReferenceNum);
> +			lastblock = udf_sb_partmap(sb,
> +					newfileset.partitionReferenceNum)->
> +						s_partition_len;
>  			newfileset.logicalBlockNum = 0;
>  
>  			do {
> @@ -904,23 +905,25 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  {
>  	struct partitionDesc *p;
>  	int i;
> +	struct udf_part_map *map;
>  
>  	p = (struct partitionDesc *)bh->b_data;
>  
>  	for (i = 0; i < udf_sb_num_parts(sb); i++) {
> +		map = udf_sb_partmap(sb, i);
>  		udf_debug("Searching map: (%d == %d)\n",
> -			  udf_sb_partmaps(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
> -		if (udf_sb_partmaps(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
> -			UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */
> -			UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation);
> +			  map->s_partition_num, le16_to_cpu(p->partitionNumber));
> +		if (map->s_partition_num == le16_to_cpu(p->partitionNumber)) {
> +			map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
> +			map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
> -				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_READ_ONLY;
> +				map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
> -				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_WRITE_ONCE;
> +				map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
> -				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_REWRITABLE;
> +				map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE;
>  			if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
> -				UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_OVERWRITABLE;
> +				map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
>  
>  			if (!strcmp(p->partitionContents.ident,
>  				    PD_PARTITION_CONTENTS_NSR02) ||
> @@ -935,26 +938,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  						.partitionReferenceNum = i,
>  					};
>  
> -					udf_sb_partmaps(sb)[i].s_uspace.s_table =
> +					map->s_uspace.s_table =
>  						udf_iget(sb, loc);
> -					if (!udf_sb_partmaps(sb)[i].s_uspace.s_table) {
> +					if (!map->s_uspace.s_table) {
>  						udf_debug("cannot load unallocSpaceTable (part %d)\n", i);
>  						return 1;
>  					}
> -					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE;
> +					map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
>  					udf_debug("unallocSpaceTable (part %d) @ %ld\n",
> -						  i, udf_sb_partmaps(sb)[i].s_uspace.s_table->i_ino);
> +						  i, map->s_uspace.s_table->i_ino);
>  				}
>  				if (phd->unallocSpaceBitmap.extLength) {
>  					UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
> -					if (udf_sb_partmaps(sb)[i].s_uspace.s_bitmap != NULL) {
> -						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extLength =
> +					if (map->s_uspace.s_bitmap != NULL) {
> +						map->s_uspace.s_bitmap->s_extLength =
>  							le32_to_cpu(phd->unallocSpaceBitmap.extLength);
> -						udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition =
> +						map->s_uspace.s_bitmap->s_extPosition =
>  							le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
> -						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
> +						map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
>  						udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
> -							  i, udf_sb_partmaps(sb)[i].s_uspace.s_bitmap->s_extPosition);
> +							  i, map->s_uspace.s_bitmap->s_extPosition);
>  					}
>  				}
>  				if (phd->partitionIntegrityTable.extLength)
> @@ -965,26 +968,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  						.partitionReferenceNum = i,
>  					};
>  
> -					udf_sb_partmaps(sb)[i].s_fspace.s_table =
> +					map->s_fspace.s_table =
>  						udf_iget(sb, loc);
> -					if (!udf_sb_partmaps(sb)[i].s_fspace.s_table) {
> +					if (!map->s_fspace.s_table) {
>  						udf_debug("cannot load freedSpaceTable (part %d)\n", i);
>  						return 1;
>  					}
> -					UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE;
> +					map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
>  					udf_debug("freedSpaceTable (part %d) @ %ld\n",
> -						  i, udf_sb_partmaps(sb)[i].s_fspace.s_table->i_ino);
> +						  i, map->s_fspace.s_table->i_ino);
>  				}
>  				if (phd->freedSpaceBitmap.extLength) {
>  					UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
> -					if (udf_sb_partmaps(sb)[i].s_fspace.s_bitmap != NULL) {
> -						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extLength =
> +					if (map->s_fspace.s_bitmap != NULL) {
> +						map->s_fspace.s_bitmap->s_extLength =
>  							le32_to_cpu(phd->freedSpaceBitmap.extLength);
> -						udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition =
> +						map->s_fspace.s_bitmap->s_extPosition =
>  							le32_to_cpu(phd->freedSpaceBitmap.extPosition);
> -						UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP;
> +						map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
>  						udf_debug("freedSpaceBitmap (part %d) @ %d\n",
> -							  i, udf_sb_partmaps(sb)[i].s_fspace.s_bitmap->s_extPosition);
> +							  i, map->s_fspace.s_bitmap->s_extPosition);
>  					}
>  				}
>  			}
> @@ -998,8 +1001,9 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
>  		udf_debug("Partition (%d:%d type %x) starts at physical %d, "
>  			  "block length %d\n",
>  			  le16_to_cpu(p->partitionNumber), i,
> -			  UDF_SB_PARTTYPE(sb, i), UDF_SB_PARTROOT(sb, i),
> -			  UDF_SB_PARTLEN(sb, i));
> +			  map->s_partition_type,
> +			  map->s_partition_root,
> +			  map->s_partition_len);
>  	}
>  	return 0;
>  }
> @@ -1020,22 +1024,23 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
>  	for (i = 0, offset = 0;
>  	     i < udf_sb_num_parts(sb) && offset < le32_to_cpu(lvd->mapTableLength);
>  	     i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) {
> +	     	struct udf_part_map *map = udf_sb_partmap(sb, i);
>  		type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
>  		if (type == 1) {
>  			struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
> -			UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15;
> -			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
> -			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
> -			UDF_SB_PARTFUNC(sb, i) = NULL;
> +			map->s_partition_type = UDF_TYPE1_MAP15;
> +			map->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum);
> +			map->s_partition_num = le16_to_cpu(gpm1->partitionNum);
> +			map->s_partition_func = NULL;
>  		} else if (type == 2) {
>  			struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
>  			if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
>  				if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
> -					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP15;
> -					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt15;
> +					map->s_partition_type = UDF_VIRTUAL_MAP15;
> +					map->s_partition_func = udf_get_pblock_virt15;
>  				} else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
> -					UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP20;
> -					UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt20;
> +					map->s_partition_type = UDF_VIRTUAL_MAP20;
> +					map->s_partition_func = udf_get_pblock_virt20;
>  				}
>  			} else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
>  				uint32_t loc;
> @@ -1043,33 +1048,33 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
>  				struct sparingTable *st;
>  				struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
>  
> -				UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
> -				UDF_SB_TYPESPAR(sb, i).s_packet_len = le16_to_cpu(spm->packetLength);
> +				map->s_partition_type = UDF_SPARABLE_MAP15;
> +				map->s_type_specific.s_sparing.s_packet_len = le16_to_cpu(spm->packetLength);
>  				for (j = 0; j < spm->numSparingTables; j++) {
>  					loc = le32_to_cpu(spm->locSparingTable[j]);
> -					UDF_SB_TYPESPAR(sb, i).s_spar_map[j] =
> +					map->s_type_specific.s_sparing.s_spar_map[j] =
>  						udf_read_tagged(sb, loc, loc, &ident);
> -					if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != NULL) {
> -						st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, i).s_spar_map[j]->b_data;
> +					if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) {
> +						st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[j]->b_data;
>  						if (ident != 0 ||
>  						    strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
> -							brelse(UDF_SB_TYPESPAR(sb, i).s_spar_map[j]);
> -							UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = NULL;
> +							brelse(map->s_type_specific.s_sparing.s_spar_map[j]);
> +							map->s_type_specific.s_sparing.s_spar_map[j] = NULL;
>  						}
>  					}
>  				}
> -				UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15;
> +				map->s_partition_func = udf_get_pblock_spar15;
>  			} else {
>  				udf_debug("Unknown ident: %s\n",
>  					  upm2->partIdent.ident);
>  				continue;
>  			}
> -			UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum);
> -			UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum);
> +			map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);
> +			map->s_partition_num = le16_to_cpu(upm2->partitionNum);
>  		}
>  		udf_debug("Partition (%d:%d) type %d on volume %d\n",
> -			  i, UDF_SB_PARTNUM(sb, i), type,
> -			  UDF_SB_PARTVSN(sb, i));
> +			  i, map->s_partition_num, type,
> +			  map->s_volumeseqnum);
>  	}
>  
>  	if (fileset) {
> @@ -1323,7 +1328,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  
>  	for (i = 0; i < udf_sb_num_parts(sb); i++) {
>  		kernel_lb_addr uninitialized_var(ino);
> -		switch (UDF_SB_PARTTYPE(sb, i)) {
> +		struct udf_part_map *map = udf_sb_partmap(sb, i);
> +		switch (map->s_partition_type) {
>  		case UDF_VIRTUAL_MAP15:
>  		case UDF_VIRTUAL_MAP20:
>  			if (!udf_sb_last_block(sb)) {
> @@ -1338,11 +1344,12 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  			}
>  
>  			for (j = 0; j < udf_sb_num_parts(sb); j++) {
> +				struct udf_part_map *map2 = udf_sb_partmap(sb, j);
>  				if (j != i &&
> -				    UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) &&
> -				    UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) {
> +				    map->s_volumeseqnum == map2->s_volumeseqnum &&
> +				    map->s_partition_num == map2->s_partition_num) {
>  					ino.partitionReferenceNum = j;
> -					ino.logicalBlockNum = udf_sb_last_block(sb) - UDF_SB_PARTROOT(sb, j);
> +					ino.logicalBlockNum = udf_sb_last_block(sb) - map2->s_partition_root;
>  					break;
>  				}
>  			}
> @@ -1354,12 +1361,12 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  			if (!udf_sb_vat_inode(sb))
>  				return 1;
>  
> -			if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
> -				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
> +			if (map->s_partition_type == UDF_VIRTUAL_MAP15) {
> +				map->s_type_specific.s_virtual.s_start_offset =
>  					udf_ext0_offset(udf_sb_vat_inode(sb));
> -				UDF_SB_TYPEVIRT(sb, i).s_num_entries =
> +				map->s_type_specific.s_virtual.s_num_entries =
>  					(udf_sb_vat_inode(sb)->i_size - 36) >> 2;
> -			} else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) {
> +			} else if (map->s_partition_type == UDF_VIRTUAL_MAP20) {
>  				struct buffer_head *bh = NULL;
>  				uint32_t pos;
>  
> @@ -1367,16 +1374,18 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  				bh = sb_bread(sb, pos);
>  				if (!bh)
>  					return 1;
> -				UDF_SB_TYPEVIRT(sb, i).s_start_offset =
> +				map->s_type_specific.s_virtual.s_start_offset =
>  					le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data +
>  						     udf_ext0_offset(udf_sb_vat_inode(sb)))->lengthHeader) +
>  					udf_ext0_offset(udf_sb_vat_inode(sb));
> -				UDF_SB_TYPEVIRT(sb, i).s_num_entries = (udf_sb_vat_inode(sb)->i_size -
> -									UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2;
> +				map->s_type_specific.s_virtual.s_num_entries = (udf_sb_vat_inode(sb)->i_size -
> +									map->s_type_specific.s_virtual.s_start_offset) >> 2;
>  				brelse(bh);
>  			}
> -			UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0);
> -			UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, ino.partitionReferenceNum);
> +			map->s_partition_root = udf_get_pblock(sb, 0, i, 0);
> +			map->s_partition_len =
> +				udf_sb_partmap(sb, ino.partitionReferenceNum)->
> +								s_partition_len;
>  		}
>  	}
>  	return 0;
> @@ -1573,7 +1582,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  		goto error_out;
>  	}
>  
> -	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_READ_ONLY) {
> +	if (udf_sb_partmap(sb, udf_sb_partition(sb))->s_partition_flags & UDF_PART_FLAG_READ_ONLY) {
>  		printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n");
>  		sb->s_flags |= MS_RDONLY;
>  	}
> @@ -1619,17 +1628,18 @@ error_out:
>  	if (udf_sb_vat_inode(sb))
>  		iput(udf_sb_vat_inode(sb));
>  	if (udf_sb_num_parts(sb)) {
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
> -			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
> -			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
> +		struct udf_part_map *map = udf_sb_partmap(sb, udf_sb_partition(sb));
> +		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
> +			iput(map->s_uspace.s_table);
> +		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
> +			iput(map->s_fspace.s_table);
> +		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
>  			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
> +		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
>  			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
> -		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
> +		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
> -				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
> +				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
>  		}
>  	}
>  #ifdef CONFIG_UDF_NLS
> @@ -1694,17 +1704,18 @@ static void udf_put_super(struct super_block *sb)
>  	if (udf_sb_vat_inode(sb))
>  		iput(udf_sb_vat_inode(sb));
>  	if (udf_sb_num_parts(sb)) {
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
> -			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE)
> -			iput(udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
> +		struct udf_part_map *map = udf_sb_partmap(sb, udf_sb_partition(sb));
> +		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
> +			iput(map->s_uspace.s_table);
> +		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
> +			iput(map->s_fspace.s_table);
> +		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
>  			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
> -		if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP)
> +		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
>  			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
> -		if (UDF_SB_PARTTYPE(sb, udf_sb_partition(sb)) == UDF_SPARABLE_MAP15) {
> +		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
> -				brelse(UDF_SB_TYPESPAR(sb, udf_sb_partition(sb)).s_spar_map[i]);
> +				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
>  		}
>  	}
>  #ifdef CONFIG_UDF_NLS
> @@ -1738,7 +1749,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
>  
>  	buf->f_type = UDF_SUPER_MAGIC;
>  	buf->f_bsize = sb->s_blocksize;
> -	buf->f_blocks = UDF_SB_PARTLEN(sb, udf_sb_partition(sb));
> +	buf->f_blocks = udf_sb_partmap(sb, udf_sb_partition(sb))->s_partition_len;
>  	buf->f_bfree = udf_count_free(sb);
>  	buf->f_bavail = buf->f_bfree;
>  	buf->f_files = (udf_sb_lvid_bh(sb) ?
> @@ -1843,6 +1854,7 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t
>  static unsigned int udf_count_free(struct super_block *sb)
>  {
>  	unsigned int accum = 0;
> +	struct udf_part_map *map;
>  
>  	if (udf_sb_lvid_bh(sb)) {
>  		if (le32_to_cpu(udf_sb_lvid(sb)->numOfPartitions) > udf_sb_partition(sb)) {
> @@ -1855,24 +1867,25 @@ static unsigned int udf_count_free(struct super_block *sb)
>  	if (accum)
>  		return accum;
>  
> -	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
> +	map = udf_sb_partmap(sb, udf_sb_partition(sb));
> +	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
>  		accum += udf_count_free_bitmap(sb,
> -					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_bitmap);
> +					       map->s_uspace.s_bitmap);
>  	}
> -	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
> +	if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
>  		accum += udf_count_free_bitmap(sb,
> -					       udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_bitmap);
> +					       map->s_fspace.s_bitmap);
>  	}
>  	if (accum)
>  		return accum;
>  
> -	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
> +	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
>  		accum += udf_count_free_table(sb,
> -					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_uspace.s_table);
> +					      map->s_uspace.s_table);
>  	}
> -	if (UDF_SB_PARTFLAGS(sb, udf_sb_partition(sb)) & UDF_PART_FLAG_FREED_TABLE) {
> +	if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
>  		accum += udf_count_free_table(sb,
> -					      udf_sb_partmaps(sb)[udf_sb_partition(sb)].s_fspace.s_table);
> +					      map->s_fspace.s_table);
>  	}
>  
>  	return accum;
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index aee5942..a5805c5 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -48,6 +48,11 @@ static inline struct udf_part_map *udf_sb_partmaps(struct super_block *sb)
>  	return udf_sb(sb)->s_partmaps;
>  }
>  
> +static inline struct udf_part_map *udf_sb_partmap(struct super_block *sb, __u32 index)
> +{
> +	return udf_sb_partmaps(sb) + index;
> +}
> +
>  static inline int __must_check udf_sb_alloc_partition_maps(struct super_block *sb, __u32 count)
>  {
>  	struct udf_sb_info *info = udf_sb(sb);
> @@ -146,7 +151,7 @@ static inline void udf_update_revision(struct super_block *sb, __u16 revision)
>  
>  #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\
>  {\
> -	int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\
> +	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)\
> @@ -182,15 +187,6 @@ static inline void udf_update_revision(struct super_block *sb, __u16 revision)
>  #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
>  #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
>  
> -#define UDF_SB_PARTTYPE(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_type )
> -#define UDF_SB_PARTROOT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_root )
> -#define UDF_SB_PARTLEN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_len )
> -#define UDF_SB_PARTVSN(X,Y)			( udf_sb_partmaps(X)[(Y)].s_volumeseqnum )
> -#define UDF_SB_PARTNUM(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_num )
> -#define UDF_SB_TYPESPAR(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_sparing )
> -#define UDF_SB_TYPEVIRT(X,Y)			( udf_sb_partmaps(X)[(Y)].s_type_specific.s_virtual )
> -#define UDF_SB_PARTFUNC(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_func )
> -#define UDF_SB_PARTFLAGS(X,Y)			( udf_sb_partmaps(X)[(Y)].s_partition_flags )
>  #define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
>  #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
>  
> -- 
> 1.5.3.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function
  2007-12-23  1:51 ` [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function marcin.slusarz
@ 2008-01-07 11:35   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:35 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:51:12, marcin.slusarz@gmail.com wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  Looks much better :). Acked-by: Jan Kara <jack@suse.cz>

									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 <linux/errno.h>
> +#include <linux/vmalloc.h>
>  
>  /* 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 <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function
  2007-12-23  1:51 ` [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function marcin.slusarz
@ 2008-01-07 11:36   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:36 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:51:13, marcin.slusarz@gmail.com wrote:
> additionally fix sparse warnings:
> fs/udf/super.c:1636:4: warning: symbol 'i' shadows an earlier one
> fs/udf/super.c:1469:6: originally declared here
> fs/udf/super.c:1638:4: warning: symbol 'i' shadows an earlier one
> fs/udf/super.c:1469:6: originally declared here
> fs/udf/super.c:1712:4: warning: symbol 'i' shadows an earlier one
> fs/udf/super.c:1701:6: originally declared here
> fs/udf/super.c:1714:4: warning: symbol 'i' shadows an earlier one
> fs/udf/super.c:1701:6: originally declared here
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  Looks fine. Acked-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/udf/super.c  |    8 ++++----
>  fs/udf/udf_sb.h |   31 ++++++++++++++-----------------
>  2 files changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 1afea58..f6c911b 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1634,9 +1634,9 @@ error_out:
>  		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
>  			iput(map->s_fspace.s_table);
>  		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
> +			udf_sb_free_bitmap(map->s_uspace.s_bitmap);
>  		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
> +			udf_sb_free_bitmap(map->s_fspace.s_bitmap);
>  		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
>  				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
> @@ -1710,9 +1710,9 @@ static void udf_put_super(struct super_block *sb)
>  		if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
>  			iput(map->s_fspace.s_table);
>  		if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_uspace);
> +			udf_sb_free_bitmap(map->s_uspace.s_bitmap);
>  		if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
> -			UDF_SB_FREE_BITMAP(sb, udf_sb_partition(sb), s_fspace);
> +			udf_sb_free_bitmap(map->s_fspace.s_bitmap);
>  		if (map->s_partition_type == UDF_SPARABLE_MAP15) {
>  			for (i = 0; i < 4; i++)
>  				brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index 4cf91f2..8fc2be9 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -171,27 +171,24 @@ static inline struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, __u
>  	return bitmap;
>  }
>  
> -#define UDF_SB_FREE_BITMAP(X,Y,Z)\
> -{\
> -	int i;\
> -	int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
> -	int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
> -	for (i = 0; i < nr_groups; i++) {\
> -		if (UDF_SB_BITMAP(X,Y,Z,i))\
> -			brelse(UDF_SB_BITMAP(X,Y,Z,i));\
> -	}\
> -	if (size <= PAGE_SIZE)\
> -		kfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
> -	else\
> -		vfree(udf_sb_partmaps(X)[Y].Z.s_bitmap);\
> +static inline void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
> +{
> +	int i;
> +	int nr_groups = bitmap->s_nr_groups;
> +	int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);
> +
> +	for (i = 0; i < nr_groups; i++) {
> +		if (bitmap->s_block_bitmap[i])
> +			brelse(bitmap->s_block_bitmap[i]);
> +	}
> +	if (size <= PAGE_SIZE)
> +		kfree(bitmap);
> +	else
> +		vfree(bitmap);
>  }
>  
>  #define UDF_QUERY_FLAG(X,Y)			( udf_sb(X)->s_flags & ( 1 << (Y) ) )
>  #define UDF_SET_FLAG(X,Y)			( udf_sb(X)->s_flags |= ( 1 << (Y) ) )
>  #define UDF_CLEAR_FLAG(X,Y)			( udf_sb(X)->s_flags &= ~( 1 << (Y) ) )
>  
> -#define UDF_SB_BITMAP(X,Y,Z,I)			( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] )
> -#define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z)		( udf_sb_partmaps(X)[(Y)].Z.s_bitmap->s_nr_groups )
> -
> -
>  #endif /* __LINUX_UDF_SB_H */
> -- 
> 1.5.3.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition)
  2007-12-23  1:51 ` [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition) marcin.slusarz
@ 2008-01-07 11:37   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2008-01-07 11:37 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: LKML, Ben Fennema

On Sun 23-12-07 02:51:14, marcin.slusarz@gmail.com wrote:
> fix warnings:
> fs/udf/super.c:1370:24: warning: symbol 'bh' shadows an earlier one
> fs/udf/super.c:1288:21: originally declared here
> fs/udf/super.c:450:6: warning: symbol 'udf_write_super' was not declared. Should it be static?
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> CC: Jan Kara <jack@suse.cz>
  Looks fine. Acked-by: Jan Kara <jack@suse.cz>

											Honza

> ---
>  fs/udf/super.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index f6c911b..da68130 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -447,7 +447,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt)
>  	return 1;
>  }
>  
> -void udf_write_super(struct super_block *sb)
> +static void udf_write_super(struct super_block *sb)
>  {
>  	lock_kernel();
>  
> @@ -1367,7 +1367,6 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
>  				map->s_type_specific.s_virtual.s_num_entries =
>  					(udf_sb_vat_inode(sb)->i_size - 36) >> 2;
>  			} else if (map->s_partition_type == UDF_VIRTUAL_MAP20) {
> -				struct buffer_head *bh = NULL;
>  				uint32_t pos;
>  
>  				pos = udf_block_map(udf_sb_vat_inode(sb), 0);
> -- 
> 1.5.3.4
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 19/24] udf: check if udf_load_logicalvol failed
  2008-01-07 11:29   ` Jan Kara
@ 2008-01-07 19:19     ` Marcin Slusarz
  0 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2008-01-07 19:19 UTC (permalink / raw)
  To: Jan Kara; +Cc: LKML, Ben Fennema

On Mon, Jan 07, 2008 at 12:29:51PM +0100, Jan Kara wrote:
> On Sun 23-12-07 02:51:09, marcin.slusarz@gmail.com wrote:
> > udf_load_logicalvol may fail eg in out of memory conditions - check it
> > and propagate error further
> > 
> > Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> > CC: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
> > CC: Jan Kara <jack@suse.cz>
>   I certainly agree with the idea of the change. Just note that
> udf_process_sequence() returns 1 in case of failure so propagating an error
> is not ideal - we should keep things consistent. And also note that the
> actual value is disregarded in udf_load_partition() anyway.
OK, I will make it consistent in next version.

Marcin

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

end of thread, other threads:[~2008-01-07 19:18 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-23  1:50 [PATCH 00/24] udf: convert super_block macros to functions marcin.slusarz
2007-12-23  1:50 ` [PATCH 01/24] udf: fix coding style of super.c marcin.slusarz
2008-01-07 11:13   ` Jan Kara
2007-12-23  1:50 ` [PATCH 02/24] udf: rename UDF_SB to udf_sb marcin.slusarz
2007-12-23 12:04   ` Christoph Hellwig
2007-12-23  1:50 ` [PATCH 03/24] udf: convert some macros to inline functions marcin.slusarz
2007-12-23  1:50 ` [PATCH 04/24] udf: convert UDF_SB_VOLIDENT macro to udf_sb_volume_ident function marcin.slusarz
2007-12-23 12:08   ` Christoph Hellwig
2007-12-23  1:50 ` [PATCH 05/24] udf: convert UDF_SB_NUMPARTS macro to udf_sb_num_parts function marcin.slusarz
2007-12-23 12:09   ` Christoph Hellwig
2007-12-23  1:50 ` [PATCH 06/24] udf: convert UDF_SB_PARTITION macro to udf_sb_partition function marcin.slusarz
2007-12-23  1:50 ` [PATCH 07/24] udf: convert UDF_SB_SESSION macro to udf_sb_session function marcin.slusarz
2007-12-23  1:50 ` [PATCH 08/24] udf: convert UDF_SB_ANCHOR macro to udf_sb_anchor function marcin.slusarz
2007-12-23  1:50 ` [PATCH 09/24] udf: convert UDF_SB_LASTBLOCK macro to udf_sb_last_block function marcin.slusarz
2007-12-23  1:51 ` [PATCH 10/24] udf: convert UDF_SB_LVIDBH macro to udf_sb_lvid_bh function marcin.slusarz
2007-12-23  1:51 ` [PATCH 11/24] udf: convert UDF_SB_LVID macro to udf_sb_lvid function marcin.slusarz
2007-12-23  1:51 ` [PATCH 12/24] udf: convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function marcin.slusarz
2007-12-23  1:51 ` [PATCH 13/24] udf: remove unused macros marcin.slusarz
2007-12-23  1:51 ` [PATCH 14/24] udf: convert UDF_SB_RECORDTIME macro to udf_sb_record_time function marcin.slusarz
2007-12-23  1:51 ` [PATCH 15/24] udf: convert UDF_SB_SERIALNUM macro to udf_sb_serial_number function marcin.slusarz
2007-12-23  1:51 ` [PATCH 16/24] udf: convert UDF_SB_UDFREV macro to udf_sb_revision function marcin.slusarz
2007-12-23  1:51 ` [PATCH 17/24] udf: convert UDF_SB_VAT macro to udf_sb_vat_inode function marcin.slusarz
2007-12-23  1:51 ` [PATCH 18/24] udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function marcin.slusarz
2007-12-23  1:51 ` [PATCH 19/24] udf: check if udf_load_logicalvol failed marcin.slusarz
2008-01-07 11:29   ` Jan Kara
2008-01-07 19:19     ` Marcin Slusarz
2007-12-23  1:51 ` [PATCH 20/24] udf: convert UDF_UPDATE_UDFREV macro to udf_update_revision function marcin.slusarz
2007-12-23  1:51 ` [PATCH 21/24] udf: remove some UDF_SB_* macros marcin.slusarz
2008-01-07 11:34   ` Jan Kara
2007-12-23  1:51 ` [PATCH 22/24] udf: convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function marcin.slusarz
2008-01-07 11:35   ` Jan Kara
2007-12-23  1:51 ` [PATCH 23/24] udf: convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function marcin.slusarz
2008-01-07 11:36   ` Jan Kara
2007-12-23  1:51 ` [PATCH 24/24] udf: fix sparse warnings (shadowing & mismatch between declaration and definition) marcin.slusarz
2008-01-07 11:37   ` Jan Kara

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).