udf: cleanup
cover udf: cleanup
Hi
This patchset contains various UDF fs cleanups.
It deprecates two patchsets I sent lately:
http://lkml.org/lkml/2008/1/5/196 [PATCH 0/6] udf: improve code related to super_block v3
http://lkml.org/lkml/2008/1/5/211 [PATCH 0/7] udf: more cleanups
I hope I addressed all comments sent by Christoph Hellwig and Jan Kara. Thanks for review!
[PATCH 01/16] udf: fix coding style of super.c
[PATCH 02/16] udf: remove some ugly macros
[PATCH 03/16] udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function [PATCH 04/16] udf: check if udf_load_logicalvol failed
[PATCH 05/16] udf: convert macros related to bitmaps to functions
[PATCH 06/16] udf: move calculating of nr_groups into helper function
[PATCH 07/16] udf: fix sparse warnings (shadowing & mismatch between declaration and definition) [PATCH 08/16] udf: fix coding style
[PATCH 09/16] udf: create common function for tag checksumming
[PATCH 10/16] udf: create common function for changing free space counter
[PATCH 11/16] udf: replace loops coded with goto to real loops
[PATCH 12/16] udf: convert byte order of constant instead of variable
[PATCH 13/16] udf: remove UDF_I_* macros and open code them
[PATCH 14/16] udf: cache struct udf_inode_info
These patches are new:
[PATCH 15/16] udf: fix udf_debug macro
[PATCH 16/16] udf: improve readability of udf_load_partition
fs/udf/balloc.c | 491 ++++++++++++--------- fs/udf/crc.c | 2 +- fs/udf/dir.c | 8 +- fs/udf/directory.c | 94 +++-- fs/udf/file.c | 43 ++- fs/udf/ialloc.c | 94 +++-- fs/udf/inode.c | 957 +++++++++++++++++++++++----------------- fs/udf/misc.c | 146 ++++--- fs/udf/namei.c | 413 ++++++++++------- fs/udf/partition.c | 197 ++++++--- fs/udf/super.c | 1081 ++++++++++++++++++++++++++++----------------- fs/udf/symlink.c | 9 +- fs/udf/truncate.c | 100 +++-- fs/udf/udf_i.h | 16 - fs/udf/udf_sb.h | 88 +---- fs/udf/udfdecl.h | 11 +- fs/udf/udftime.c | 59 ++-- fs/udf/unicode.c | 85 ++-- include/linux/udf_fs.h | 4 +- include/linux/udf_fs_sb.h | 12 +- 20 files changed, 2261 insertions(+), 1649 deletions(-)
This patchset depends on udf patches in -mm. Runtime tested: mount, open, read, seek, close, unmount.
Marcin Slusarz
PATCH 1/16 udf: fix coding style of super.c
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 now; will fix later
--- fs/udf/super.c | 295 +++++++++++++++++++++++++++++++------------------------ 1 files changed, 166 insertions(+), 129 deletions(-)
fs/udf/super.c +166 -129
@@ -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 lastblobrelse (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); }
Signature · 1 line
1.5.3.7
PATCH 2/16 udf: remove some ugly macros
In reply to [email protected]remove macros:
- UDF_SB_PARTMAPS
- 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
- UDF_SB_VOLIDENT
- UDF_SB_NUMPARTS
- UDF_SB_PARTITION
- UDF_SB_SESSION
- UDF_SB_ANCHOR
- UDF_SB_LASTBLOCK
- UDF_SB_LVIDBH
- UDF_SB_LVID
- UDF_SB_UMASK
- UDF_SB_GID
- UDF_SB_UID
- UDF_SB_RECORDTIME
- UDF_SB_SERIALNUM
- UDF_SB_UDFREV
- UDF_SB_FLAGS
- UDF_SB_VAT
- UDF_UPDATE_UDFREV
- UDF_SB_FREE
and open code them
convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function
rename some struct udf_sb_info fields:
- s_volident to s_volume_ident
- s_lastblock to s_last_block
- s_lvidbh to s_lvid_bh
- s_recordtime to s_record_time
- s_serialnum to s_serial_number;
- s_vat to s_vat_inode;
--- fs/udf/balloc.c | 136 ++++++----- fs/udf/file.c | 2 +- fs/udf/ialloc.c | 33 ++-- fs/udf/inode.c | 34 ++-- fs/udf/misc.c | 15 +- fs/udf/namei.c | 24 ++- fs/udf/partition.c | 67 ++++--- fs/udf/super.c | 548 +++++++++++++++++++++++++-------------------- fs/udf/truncate.c | 7 +- fs/udf/udf_sb.h | 75 ++----- include/linux/udf_fs_sb.h | 12 +- 11 files changed, 510 insertions(+), 443 deletions(-)
fs/udf/balloc.c +74 -62
@@ -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 (sb)->s_partition; bh =udf_tread (sb,udf_get_lb_pblock (sb, loc, block));if (!bh) {
@@ -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) > sbi->s_partmaps[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)); + sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len); goto error_return; }
@@ -188,9 +188,10 @@ do_more: }else {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 ); +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[sbi->s_partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) +1 ); } } }
@@ -202,8 +203,8 @@ do_more: } error_return: sb->s_dirt =1 ; -if (UDF_SB_LVIDBH (sb)) -mark_buffer_dirty (UDF_SB_LVIDBH (sb)); +if (sbi->s_lvid_bh) +mark_buffer_dirty (sbi->s_lvid_bh);mutex_unlock (&sbi->s_alloc_mutex);return ; }
@@ -219,16 +220,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 = sbi->s_partmaps[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 = (sbi->s_partmaps[partition].s_partition_len + (sizeof (struct spaceBitmapDesc ) <<3 ) + (sb->s_blocksize *8 ) -1 ) / (sb->s_blocksize *8 ); block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 );
@@ -261,10 +264,11 @@ repeat:if (block_count >0 ) goto repeat; out: -if (UDF_SB_LVIDBH (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)); +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +mark_buffer_dirty (sbi->s_lvid_bh); } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);
@@ -287,7 +291,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 >= sbi->s_partmaps[partition].s_partition_len) goal =0 ; nr_groups = bitmap->s_nr_groups;
@@ -389,10 +393,11 @@ got_block:mark_buffer_dirty (bh); -if (UDF_SB_LVIDBH (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)); +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +mark_buffer_dirty (sbi->s_lvid_bh); } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);
@@ -421,10 +426,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) > sbi->s_partmaps[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)); + sbi->s_partmaps[bloc.partitionReferenceNum]->s_partition_len); goto error_return; }
@@ -432,10 +437,11 @@ 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)) { -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)); +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[sbi->s_partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) + count); +mark_buffer_dirty (sbi->s_lvid_bh); } start = bloc.logicalBlockNum + offset;
@@ -559,7 +565,7 @@ static void udf_table_free_blocks(struct super_block *sb, } epos.offset =sizeof (struct allocExtDesc ); } -if (UDF_SB_UDFREV (sb) >=0x0200 ) +if (sbi->s_udfrev >=0x0200 )udf_new_tag (epos.bh->b_data,TAG_IDENT_AED ,3 ,1 , epos.block.logicalBlockNum,sizeof (tag));else
@@ -627,7 +633,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 >= sbi->s_partmaps[partition].s_partition_len)return 0 ;if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_SHORT )
@@ -670,10 +676,11 @@ static int udf_table_prealloc_blocks(struct super_block *sb,brelse (epos.bh); -if (alloc_count &&UDF_SB_LVIDBH (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)); +if (alloc_count && sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +mark_buffer_dirty (sbi->s_lvid_bh); sb->s_dirt =1 ; }mutex_unlock (&sbi->s_alloc_mutex);
@@ -703,7 +710,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 >= sbi->s_partmaps[partition].s_partition_len) goal =0 ;/* We search for the closest matching block to goal. If we find a exact hit,
@@ -771,10 +778,11 @@ 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)) { -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)); +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] = +cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +mark_buffer_dirty (sbi->s_lvid_bh); } sb->s_dirt =1 ;
@@ -789,22 +797,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 (sb)->s_partmaps[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 +825,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(sb)->s_partmaps[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 +853,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 (sb)->s_partmaps[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 ;
fs/udf/file.c +1 -1
@@ -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 (inode->i_sb)->s_volume_ident,32 ) ? -EFAULT :0 ;case UDF_RELOCATE_BLOCKS :if (!capable (CAP_SYS_ADMIN ))return -EACCES ;
fs/udf/ialloc.c +19 -14
@@ -43,15 +43,17 @@ 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) { +struct logicalVolIntegrityDescImpUse *lvidiu = +udf_sb_lvidiu (sbi);if (S_ISDIR (inode->i_mode)) -UDF_SB_LVIDIU (sb)->numDirs = -cpu_to_le32 (le32_to_cpu (UDF_SB_LVIDIU (sb)->numDirs) -1 ); + lvidiu->numDirs = +cpu_to_le32 (le32_to_cpu (lvidiu->numDirs) -1 );else -UDF_SB_LVIDIU (sb)->numFiles = -cpu_to_le32 (le32_to_cpu (UDF_SB_LVIDIU (sb)->numFiles) -1 ); + lvidiu->numFiles = +cpu_to_le32 (le32_to_cpu (lvidiu->numFiles) -1 ); -mark_buffer_dirty (sbi->s_lvidbh); +mark_buffer_dirty (sbi->s_lvid_bh); }mutex_unlock (&sbi->s_alloc_mutex);
@@ -88,21 +90,23 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) }mutex_lock (&sbi->s_alloc_mutex); -if (UDF_SB_LVIDBH (sb)) { +if (sbi->s_lvid_bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; +struct logicalVolIntegrityDescImpUse *lvidiu =udf_sb_lvidiu (sbi);struct logicalVolHeaderDesc *lvhd;uint64_t uniqueID; - lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID (sb)->logicalVolContentsUse); + lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse);if (S_ISDIR (mode)) -UDF_SB_LVIDIU (sb)->numDirs = -cpu_to_le32 (le32_to_cpu (UDF_SB_LVIDIU (sb)->numDirs) +1 ); + lvidiu->numDirs = +cpu_to_le32 (le32_to_cpu (lvidiu->numDirs) +1 );else -UDF_SB_LVIDIU (sb)->numFiles = -cpu_to_le32 (le32_to_cpu (UDF_SB_LVIDIU (sb)->numFiles) +1 ); + lvidiu->numFiles = +cpu_to_le32 (le32_to_cpu (lvidiu->numFiles) +1 );UDF_I_UNIQUE (inode) = uniqueID =le64_to_cpu (lvhd->uniqueID);if (!(++uniqueID &0x00000000FFFFFFFFUL )) uniqueID +=16 ; lvhd->uniqueID =cpu_to_le64 (uniqueID); -mark_buffer_dirty (UDF_SB_LVIDBH (sb)); +mark_buffer_dirty (sbi->s_lvid_bh); } inode->i_mode = mode; inode->i_uid = current->fsuid;
@@ -123,7 +127,8 @@ 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 ); +if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev) + sbi->s_udfrev =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 ;
fs/udf/inode.c +18 -16
@@ -1081,6 +1081,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)time_t convtime;long convtime_usec;int offset; +struct udf_sb_info *sbi =UDF_SB (inode->i_sb); fe = (struct fileEntry *)bh->b_data; efe = (struct extendedFileEntry *)bh->b_data;
@@ -1160,7 +1161,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 = sbi->s_record_time; } if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1168,7 +1169,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 = sbi->s_record_time; } if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1176,7 +1177,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 = sbi->s_record_time; }UDF_I_UNIQUE (inode) =le64_to_cpu (fe->uniqueID);
@@ -1192,7 +1193,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 = sbi->s_record_time; } if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1200,7 +1201,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 = sbi->s_record_time; } if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1208,7 +1209,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) = sbi->s_record_time; } if (udf_stamp_to_time(&convtime, &convtime_usec,
@@ -1216,7 +1217,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 = sbi->s_record_time; }UDF_I_UNIQUE (inode) =le64_to_cpu (efe->uniqueID);
@@ -1353,6 +1354,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)int i;kernel_timestamp cpu_time;int err =0 ; +struct udf_sb_info *sbi =UDF_SB (inode->i_sb); bh =udf_tread (inode->i_sb,udf_get_lb_pblock (inode->i_sb,UDF_I_LOCATION (inode),0 ));if (!bh) {
@@ -1537,11 +1539,11 @@ 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 (sbi->s_udfrev >=0x0200 ) 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 (sbi->s_serial_number); 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);
@@ -1585,7 +1587,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 (sb)->s_partmaps[ino.partitionReferenceNum].s_partition_len) {udf_debug ("block=%d, partition=%d out of range\n" , ino.logicalBlockNum, ino.partitionReferenceNum);make_bad_inode (inode);
@@ -1667,7 +1669,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 (inode->i_sb)->s_udfrev >=0x0200 )udf_new_tag (nbh->b_data,TAG_IDENT_AED ,3 ,1 , epos->block.logicalBlockNum,sizeof (tag));else
@@ -1690,7 +1692,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 (inode->i_sb)->s_udfrev >=0x0201 )udf_update_tag (epos->bh->b_data, loffset);else udf_update_tag (epos->bh->b_data,sizeof (struct allocExtDesc ));
@@ -1711,7 +1713,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 (inode->i_sb)->s_udfrev >=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 +1756,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 (inode->i_sb)->s_udfrev >=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 +1909,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 (inode->i_sb)->s_udfrev >=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 +1925,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 (inode->i_sb)->s_udfrev >=0x0201 )udf_update_tag (oepos.bh->b_data, epos.offset - adsize);else udf_update_tag (oepos.bh->b_data,sizeof (struct allocExtDesc ));
fs/udf/misc.c +9 -6
@@ -81,14 +81,16 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,return NULL ; } }else { +struct udf_sb_info *sbi =UDF_SB (inode->i_sb); + 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 (sbi->s_udfrev >=0x0200 ) 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 (sbi->s_serial_number); eahd->descTag.tagLocation =cpu_to_le32 (UDF_I_LOCATION (inode).logicalBlockNum); eahd->impAttrLocation =cpu_to_le32 (0xFFFFFFFF ); eahd->appAttrLocation =cpu_to_le32 (0xFFFFFFFF );
@@ -192,15 +194,16 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,struct buffer_head *bh =NULL ; registeruint8_t checksum; registerint i; +struct udf_sb_info *sbi =UDF_SB (sb);/* Read the block */ if (block ==0xFFFFFFFF )return NULL ; - bh =udf_tread (sb, block +UDF_SB_SESSION (sb)); + bh =udf_tread (sb, block + sbi->s_session);if (!bh) {udf_debug ("block=%d, location=%d: read failed\n" , - block +UDF_SB_SESSION (sb), location); + block + sbi->s_session, location);return NULL ; }
@@ -210,7 +213,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 + sbi->s_session,le32_to_cpu (tag_p->tagLocation), location); goto error_out; }
@@ -240,7 +243,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 + sbi->s_session,le16_to_cpu (tag_p->descCRC),le16_to_cpu (tag_p->descCRCLength)); error_out:
fs/udf/namei.c +14 -10
@@ -325,7 +325,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,struct udf_fileident_bh *fibh, struct fileIdentDesc *cfi, int *err) { - struct super_block *sb; + struct super_block *sb = dir->i_sb;struct fileIdentDesc *fi =NULL ;char name[UDF_NAME_LEN ], fname[UDF_NAME_LEN ];int namelen;
@@ -342,8 +342,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,sector_t offset;struct extent_position epos = {}; - sb = dir->i_sb; -if (dentry) {if (!dentry->d_name.len) { *err = -EINVAL ;
@@ -535,7 +533,7 @@ add: }memset (cfi,0 ,sizeof (struct fileIdentDesc )); -if (UDF_SB_UDFREV (sb) >=0x0200 ) +if (UDF_SB (sb)->s_udfrev >=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));
@@ -901,6 +899,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,int block;char name[UDF_NAME_LEN ];int namelen; +struct buffer_head *bh;lock_kernel ();if (!(inode =udf_new_inode (dir,S_IFLNK , &err)))
@@ -1014,17 +1013,19 @@ 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)) { + bh =UDF_SB (inode->i_sb)->s_lvid_bh; +if (bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data;struct logicalVolHeaderDesc *lvhd;uint64_t uniqueID; - lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID (inode->i_sb)->logicalVolContentsUse); + lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); uniqueID =le64_to_cpu (lvhd->uniqueID); *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =cpu_to_le32 (uniqueID &0x00000000FFFFFFFFUL );if (!(++uniqueID &0x00000000FFFFFFFFUL )) uniqueID +=16 ; lvhd->uniqueID =cpu_to_le64 (uniqueID); -mark_buffer_dirty (UDF_SB_LVIDBH (inode->i_sb)); +mark_buffer_dirty (bh); }udf_write_fi (dir, &cfi, fi, &fibh,NULL ,NULL );if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_IN_ICB ) {
@@ -1053,6 +1054,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,struct udf_fileident_bh fibh;struct fileIdentDesc cfi, *fi;int err; +struct buffer_head *bh;lock_kernel ();if (inode->i_nlink >= (256 <<sizeof (inode->i_nlink)) -1 ) {
@@ -1066,17 +1068,19 @@ 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)) { + bh =UDF_SB (inode->i_sb)->s_lvid_bh; +if (bh) { +struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data;struct logicalVolHeaderDesc *lvhd;uint64_t uniqueID; - lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID (inode->i_sb)->logicalVolContentsUse); + lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); uniqueID =le64_to_cpu (lvhd->uniqueID); *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =cpu_to_le32 (uniqueID &0x00000000FFFFFFFFUL );if (!(++uniqueID &0x00000000FFFFFFFFUL )) uniqueID +=16 ; lvhd->uniqueID =cpu_to_le64 (uniqueID); -mark_buffer_dirty (UDF_SB_LVIDBH (inode->i_sb)); +mark_buffer_dirty (bh); }udf_write_fi (dir, &cfi, fi, &fibh,NULL ,NULL );if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_IN_ICB ) {
fs/udf/partition.c +40 -27
160 lines not on this page · raw message
fs/udf/super.c +305 -243
1,022 lines not on this page · raw message
fs/udf/truncate.c +4 -3
@@ -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 (inode->i_sb)->s_udfrev >=0x0201 )udf_update_tag (epos.bh->b_data, epos.offset);else udf_update_tag(epos.bh->b_data,
@@ -184,6 +184,7 @@ void udf_truncate_extents(struct inode *inode)uint32_t elen, nelen =0 , indirect_ext_len =0 , lenalloc;int8_t etype;struct super_block *sb = inode->i_sb; +struct udf_sb_info *sbi =UDF_SB (sb);sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;loff_t byte_offset;int adsize;
@@ -232,7 +233,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 ) + sbi->s_udfrev >=0x0201 )udf_update_tag (epos.bh->b_data, lenalloc +sizeof (struct allocExtDesc ));
@@ -271,7 +272,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 ) + sbi->s_udfrev >=0x0201 )udf_update_tag (epos.bh->b_data, lenalloc +sizeof (struct allocExtDesc ));else
fs/udf/udf_sb.h +20 -55
107 lines not on this page · raw message
include/linux/udf_fs_sb.h +6 -6
@@ -75,7 +75,7 @@ struct udf_part_mapstruct udf_sb_info {struct udf_part_map *s_partmaps; -__u8 s_volident[32 ]; +__u8 s_volume_ident[32 ];/* Overall info */ __u16 s_partitions;
@@ -84,9 +84,9 @@ 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; +struct buffer_head *s_lvid_bh;/* Default permissions */ mode_t s_umask;
@@ -94,10 +94,10 @@ struct udf_sb_infouid_t s_uid;/* Root Info */ -struct timespec s_recordtime; +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;
@@ -109,7 +109,7 @@ struct udf_sb_infostruct nls_table *s_nls_map;/* VAT inode */ -struct inode *s_vat; +struct inode *s_vat_inode;struct mutex s_alloc_mutex; };
Signature · 1 line
1.5.3.7
PATCH 3/16 udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function
In reply to [email protected]- convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function
- convert kmalloc + memset to kcalloc
- check if kcalloc failed (partially)
--- fs/udf/super.c | 25 +++++++++++++++++++++++-- fs/udf/udf_sb.h | 13 ------------- 2 files changed, 23 insertions(+), 15 deletions(-)
fs/udf/super.c +23 -2
@@ -52,6 +52,7 @@#include <linux/buffer_head.h> #include <linux/vfs.h> #include <linux/vmalloc.h> +#include <linux/errno.h> #include <asm/byteorder.h> #include <linux/udf_fs.h>
@@ -226,6 +227,24 @@ static void __exit exit_udf_fs(void)module_init (init_udf_fs)module_exit (exit_udf_fs) +static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count) +{ +struct udf_sb_info *sbi =UDF_SB (sb); + + sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map), +GFP_KERNEL ); + if (!sbi->s_partmaps) { +udf_error (sb, __FUNCTION__, +"Unable to allocate space for %d partition maps" , + count); + sbi->s_partitions =0 ; +return -ENOMEM ; + } + + sbi->s_partitions = count; +return 0 ; +} +/* * udf_parse_options *
@@ -1037,7 +1056,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 < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength);
@@ -1242,7 +1263,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)) {
fs/udf/udf_sb.h +0 -13
@@ -43,19 +43,6 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu (struct udf_sb_info *sbi); -#define UDF_SB_ALLOC_PARTMAPS (X ,Y )\ -{\ - struct udf_sb_info *sbi = UDF_SB(X);\ - sbi->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ - if (sbi->s_partmaps != NULL) {\ - sbi->s_partitions = Y;\ - memset(sbi->s_partmaps, 0x00, sizeof(struct udf_part_map) * Y);\ - } else {\ - sbi->s_partitions = 0;\ - udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ - }\ -} -#define UDF_SB_ALLOC_BITMAP (X ,Y ,Z )\ {\ struct udf_sb_info *sbi = UDF_SB(X);\
Signature · 1 line
1.5.3.7
PATCH 4/16 udf: check if udf_load_logicalvol failed
In reply to [email protected]udf_load_logicalvol may fail eg in out of memory conditions - check it and propagate error further
--- fs/udf/super.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
fs/udf/super.c +4 -1
@@ -1263,7 +1263,10 @@ 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 */ +if (udf_load_logicalvol (sb, bh, fileset)) { +brelse (bh); +return 1 ; + } }else if (i ==VDS_POS_PARTITION_DESC ) {struct buffer_head *bh2 =NULL ;if (udf_load_partdesc (sb, bh)) {
Signature · 1 line
1.5.3.7
Re: [PATCH 04/16] udf: check if udf_load_logicalvol failed
Quoted 7 lines · On Thu 10-01-08 23:06:20, [email protected] wrote:
udf_load_logicalvolmay fail eg in out of memory conditions - check it and propagate error furtherSigned-off-by Marcin Slusarz <[email protected]>CC Ben Fennema <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 23 lines
--- fs/udf/super.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)fs/udf/super.c +4
-1@@ -1263,7 +1263,10 @@ 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 */ +if (udf_load_logicalvol (sb, bh, fileset)) { +brelse (bh); +return 1 ; + } }else if (i ==VDS_POS_PARTITION_DESC ) {struct buffer_head *bh2 =NULL ;if (udf_load_partdesc (sb, bh)) {Signature · 1 line
1.5.3.7
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 5/16 udf: convert macros related to bitmaps to functions
In reply to [email protected]convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function
--- fs/udf/super.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++----- fs/udf/udf_sb.h | 38 ---------------------------------- 2 files changed, 55 insertions(+), 44 deletions(-)
fs/udf/super.c +55 -6
@@ -937,6 +937,39 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, root->logicalBlockNum, root->partitionReferenceNum); } +static struct udf_bitmap *udf_sb_alloc_bitmap (struct super_block *sb,u32 index) +{ +struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[index]; +struct udf_bitmap *bitmap; +int nr_groups; +int size; + +/* TODO: move calculating of nr_groups into helper function */ + nr_groups = (map->s_partition_len + + (sizeof (struct spaceBitmapDesc ) <<3 ) + + (sb->s_blocksize *8 ) -1 ) / + (sb->s_blocksize *8 ); + size =sizeof (struct udf_bitmap ) + + (sizeof (struct buffer_head *) * nr_groups); + +if (size <=PAGE_SIZE ) + bitmap =kmalloc (size,GFP_KERNEL ); +else + bitmap =vmalloc (size);/* TODO: get rid of vmalloc */ + +if (bitmap ==NULL ) { +udf_error (sb, __FUNCTION__, +"Unable to allocate space for bitmap " +"and %d buffer_head pointers" , nr_groups); +return NULL ; + } + +memset (bitmap,0x00 , size); + bitmap->s_block_bitmap = (struct buffer_head **)(bitmap +1 ); + bitmap->s_nr_groups = nr_groups; +return bitmap; +} +static int udf_load_partdesc (struct super_block *sb,struct buffer_head *bh) {struct partitionDesc *p;
@@ -987,7 +1020,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);
@@ -1017,7 +1050,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);
@@ -1504,6 +1537,22 @@ static void udf_close_lvid(struct super_block *sb) } } +static 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); +} +/* * udf_read_super *
@@ -1689,9 +1738,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, sbi->s_partition, 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, sbi->s_partition, 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]);
@@ -1767,9 +1816,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, sbi->s_partition, 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, sbi->s_partition, 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]);
fs/udf/udf_sb.h +0 -38
@@ -43,46 +43,8 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu (struct udf_sb_info *sbi); -#define UDF_SB_ALLOC_BITMAP (X ,Y ,Z )\ -{\ - struct udf_sb_info *sbi = UDF_SB(X);\ - int nr_groups = ((sbi->s_partmaps[(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)\ - sbi->s_partmaps[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ - else\ - sbi->s_partmaps[(Y)].Z.s_bitmap = vmalloc(size);\ - if (sbi->s_partmaps[(Y)].Z.s_bitmap != NULL) {\ - memset(sbi->s_partmaps[(Y)].Z.s_bitmap, 0x00, size);\ - sbi->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap =\ - (struct buffer_head **)(sbi->s_partmaps[(Y)].Z.s_bitmap + 1);\ - sbi->s_partmaps[(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);\ - }\ -} - -#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(X)->s_partmaps[Y].Z.s_bitmap);\ - else\ - vfree(UDF_SB(X)->s_partmaps[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_SB_BITMAP (X ,Y ,Z ,I ) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap[I] ) -#define UDF_SB_BITMAP_NR_GROUPS (X ,Y ,Z ) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_nr_groups ) -#endif /* __LINUX_UDF_SB_H */
Signature · 1 line
1.5.3.7
Re: [PATCH 05/16] udf: convert macros related to bitmaps to functions
Quoted 7 lines · On Thu 10-01-08 23:06:21, [email protected] wrote:
convert
UDF_SB_ALLOC_BITMAPmacro toudf_sb_alloc_bitmapfunction convertUDF_SB_FREE_BITMAPmacro toudf_sb_free_bitmapfunctionSigned-off-by Marcin Slusarz <[email protected]>CC Ben Fennema <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 167 lines
--- fs/udf/super.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++----- fs/udf/udf_sb.h | 38 ---------------------------------- 2 files changed, 55 insertions(+), 44 deletions(-)fs/udf/super.c +55
-6@@ -937,6 +937,39 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, root->logicalBlockNum, root->partitionReferenceNum); } +static struct udf_bitmap *udf_sb_alloc_bitmap (struct super_block *sb,u32 index) +{ +struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[index]; +struct udf_bitmap *bitmap; +int nr_groups; +int size; + +/* TODO: move calculating of nr_groups into helper function */ + nr_groups = (map->s_partition_len + + (sizeof (struct spaceBitmapDesc ) <<3 ) + + (sb->s_blocksize *8 ) -1 ) / + (sb->s_blocksize *8 ); + size =sizeof (struct udf_bitmap ) + + (sizeof (struct buffer_head *) * nr_groups); + +if (size <=PAGE_SIZE ) + bitmap =kmalloc (size,GFP_KERNEL ); +else + bitmap =vmalloc (size);/* TODO: get rid of vmalloc */ + +if (bitmap ==NULL ) { +udf_error (sb, __FUNCTION__, +"Unable to allocate space for bitmap " +"and %d buffer_head pointers" , nr_groups); +return NULL ; + } + +memset (bitmap,0x00 , size); + bitmap->s_block_bitmap = (struct buffer_head **)(bitmap +1 ); + bitmap->s_nr_groups = nr_groups; +return bitmap; +} +static int udf_load_partdesc (struct super_block *sb,struct buffer_head *bh) {struct partitionDesc *p;@@ -987,7 +1020,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);@@ -1017,7 +1050,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);@@ -1504,6 +1537,22 @@ static void udf_close_lvid(struct super_block *sb) } } +static 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); +} +/* * udf_read_super * @@ -1689,9 +1738,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, sbi->s_partition, 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, sbi->s_partition, 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]);@@ -1767,9 +1816,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, sbi->s_partition, 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, sbi->s_partition, 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]);fs/udf/udf_sb.h +0
-38@@ -43,46 +43,8 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu (struct udf_sb_info *sbi); -#define UDF_SB_ALLOC_BITMAP (X ,Y ,Z )\ -{\ - struct udf_sb_info *sbi = UDF_SB(X);\ - int nr_groups = ((sbi->s_partmaps[(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)\ - sbi->s_partmaps[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ - else\ - sbi->s_partmaps[(Y)].Z.s_bitmap = vmalloc(size);\ - if (sbi->s_partmaps[(Y)].Z.s_bitmap != NULL) {\ - memset(sbi->s_partmaps[(Y)].Z.s_bitmap, 0x00, size);\ - sbi->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap =\ - (struct buffer_head **)(sbi->s_partmaps[(Y)].Z.s_bitmap + 1);\ - sbi->s_partmaps[(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);\ - }\ -} - -#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(X)->s_partmaps[Y].Z.s_bitmap);\ - else\ - vfree(UDF_SB(X)->s_partmaps[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_SB_BITMAP (X ,Y ,Z ,I ) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap[I] ) -#define UDF_SB_BITMAP_NR_GROUPS (X ,Y ,Z ) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_nr_groups ) -#endif /* __LINUX_UDF_SB_H */ Signature · 1 line
1.5.3.7
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 6/16 udf: move calculating of nr_groups into helper function
In reply to [email protected]--- fs/udf/balloc.c | 4 +--- fs/udf/super.c | 16 ++++++++++------ fs/udf/udf_sb.h | 2 ++ 3 files changed, 13 insertions(+), 9 deletions(-)
fs/udf/balloc.c +1 -3
@@ -231,9 +231,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, block_count = part_len - first_block; repeat: - nr_groups = (sbi->s_partmaps[partition].s_partition_len + - (sizeof (struct spaceBitmapDesc ) <<3 ) + - (sb->s_blocksize *8 ) -1 ) / (sb->s_blocksize *8 ); + nr_groups =udf_compute_nr_groups (sb, partition); block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); block_group = block >> (sb->s_blocksize_bits +3 ); group_start = block_group ?0 :sizeof (struct spaceBitmapDesc );
fs/udf/super.c +10 -6
@@ -937,18 +937,22 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, root->logicalBlockNum, root->partitionReferenceNum); } +int udf_compute_nr_groups (struct super_block *sb,u32 partition) +{ +struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[partition]; +return (map->s_partition_len + + (sizeof (struct spaceBitmapDesc ) <<3 ) + + (sb->s_blocksize *8 ) -1 ) / + (sb->s_blocksize *8 ); +} +static struct udf_bitmap *udf_sb_alloc_bitmap (struct super_block *sb,u32 index) { -struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[index];struct udf_bitmap *bitmap;int nr_groups;int size; -/* TODO: move calculating of nr_groups into helper function */ - nr_groups = (map->s_partition_len + - (sizeof (struct spaceBitmapDesc ) <<3 ) + - (sb->s_blocksize *8 ) -1 ) / - (sb->s_blocksize *8 ); + nr_groups =udf_compute_nr_groups (sb, index); size =sizeof (struct udf_bitmap ) + (sizeof (struct buffer_head *) * nr_groups);
fs/udf/udf_sb.h +2 -0
@@ -43,6 +43,8 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu (struct udf_sb_info *sbi); +int udf_compute_nr_groups (struct super_block *sb,u32 partition); +#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) ) )
Signature · 1 line
1.5.3.7
Re: [PATCH 06/16] udf: move calculating of nr_groups into helper function
Quoted 4 lines · On Thu 10-01-08 23:06:22, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Ben Fennema <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 70 lines
--- fs/udf/balloc.c | 4 +--- fs/udf/super.c | 16 ++++++++++------ fs/udf/udf_sb.h | 2 ++ 3 files changed, 13 insertions(+), 9 deletions(-)fs/udf/balloc.c +1
-3@@ -231,9 +231,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, block_count = part_len - first_block; repeat: - nr_groups = (sbi->s_partmaps[partition].s_partition_len + - (sizeof (struct spaceBitmapDesc ) <<3 ) + - (sb->s_blocksize *8 ) -1 ) / (sb->s_blocksize *8 ); + nr_groups =udf_compute_nr_groups (sb, partition); block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); block_group = block >> (sb->s_blocksize_bits +3 ); group_start = block_group ?0 :sizeof (struct spaceBitmapDesc );fs/udf/super.c +10
-6@@ -937,18 +937,22 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, root->logicalBlockNum, root->partitionReferenceNum); } +int udf_compute_nr_groups (struct super_block *sb,u32 partition) +{ +struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[partition]; +return (map->s_partition_len + + (sizeof (struct spaceBitmapDesc ) <<3 ) + + (sb->s_blocksize *8 ) -1 ) / + (sb->s_blocksize *8 ); +} +static struct udf_bitmap *udf_sb_alloc_bitmap (struct super_block *sb,u32 index) { -struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[index];struct udf_bitmap *bitmap;int nr_groups;int size; -/* TODO: move calculating of nr_groups into helper function */ - nr_groups = (map->s_partition_len + - (sizeof (struct spaceBitmapDesc ) <<3 ) + - (sb->s_blocksize *8 ) -1 ) / - (sb->s_blocksize *8 ); + nr_groups =udf_compute_nr_groups (sb, index); size =sizeof (struct udf_bitmap ) + (sizeof (struct buffer_head *) * nr_groups);fs/udf/udf_sb.h +2
-0@@ -43,6 +43,8 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu (struct udf_sb_info *sbi); +int udf_compute_nr_groups (struct super_block *sb,u32 partition); +#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) ) )Signature · 1 line
1.5.3.7
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 7/16 udf: fix sparse warnings (shadowing & mismatch between declaration and definition)
In reply to [email protected]fix sparse warnings:fs/udf/super.c:1431:24: warning: symbol 'bh' shadows an earlier one fs/udf/super.c:1347:21: originally declared herefs/udf/super.c:472:6: warning: symbol 'udf_write_super' was not declared. Should it be static?
--- fs/udf/super.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
fs/udf/super.c +1 -2
@@ -474,7 +474,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 ();
@@ -1447,7 +1447,6 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) map->s_type_specific.s_virtual.s_num_entries = (sbi->s_vat_inode->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 (sbi->s_vat_inode,0 );
Signature · 1 line
1.5.3.7
PATCH 8/16 udf: fix coding style
In reply to [email protected]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
- spaces between "type *" and variable name
before: 192 errors, 561 warnings, 8987 lines checked
after: 1 errors, 38 warnings, 9468 lines checked
--- fs/udf/balloc.c | 231 +++++++++++------- fs/udf/crc.c | 2 +- fs/udf/directory.c | 83 ++++--- fs/udf/file.c | 18 +- fs/udf/ialloc.c | 24 ++- fs/udf/inode.c | 665 +++++++++++++++++++++++++++++++--------------------- fs/udf/misc.c | 76 ++++--- fs/udf/namei.c | 298 ++++++++++++++---------- fs/udf/partition.c | 160 ++++++++----- fs/udf/super.c | 383 +++++++++++++++++++----------- fs/udf/symlink.c | 3 +- fs/udf/truncate.c | 58 +++-- fs/udf/udftime.c | 59 +++--- fs/udf/unicode.c | 85 ++++--- 14 files changed, 1311 insertions(+), 834 deletions(-)
patch (160kB) available at: http://www.kadu.net/~joi/kernel/2008.01.10/0008-udf-fix-coding-style.patch
md5: 00816fa02cf2541bee51e71a05d9dd94
Tell me if I should post it to LKML...
PATCH 9/16 udf: create common function for tag checksumming
In reply to [email protected]--- fs/udf/inode.c | 15 ++------------- fs/udf/misc.c | 35 ++++++++++++++--------------------- fs/udf/namei.c | 9 +-------- fs/udf/super.c | 16 ++-------------- fs/udf/udfdecl.h | 3 +++ 5 files changed, 22 insertions(+), 56 deletions(-)
fs/udf/inode.c +2 -13
@@ -1440,7 +1440,6 @@ static int udf_update_inode(struct inode *inode, int do_sync)uint32_t udfperms;uint16_t icbflags;uint16_t crclen; -int i;kernel_timestamp cpu_time;int err =0 ;struct udf_sb_info *sbi =UDF_SB (inode->i_sb);
@@ -1476,12 +1475,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) use->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)use +sizeof (tag), crclen,0 )); - - use->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - use->descTag.tagChecksum += - ((uint8_t *)&(use->descTag))[i]; + use->descTag.tagChecksum =udf_tag_checksum (&use->descTag);mark_buffer_dirty (bh);brelse (bh);
@@ -1650,12 +1644,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) fe->descTag.descCRCLength =cpu_to_le16 (crclen); fe->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)fe +sizeof (tag), crclen,0 )); - - fe->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - fe->descTag.tagChecksum += - ((uint8_t *)&(fe->descTag))[i]; + fe->descTag.tagChecksum =udf_tag_checksum (&fe->descTag);/* write the data blocks */ mark_buffer_dirty (bh);
fs/udf/misc.c +14 -21
@@ -51,7 +51,6 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,uint8_t *ea =NULL , *ad =NULL ;int offset;uint16_t crclen; -int i; ea =UDF_I_DATA (inode);if (UDF_I_LENEATTR (inode)) {
@@ -138,11 +137,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.descCRCLength =cpu_to_le16 (crclen); eahd->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)eahd +sizeof (tag), crclen,0 )); - eahd->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - eahd->descTag.tagChecksum += - ((uint8_t *)&(eahd->descTag))[i]; + eahd->descTag.tagChecksum =udf_tag_checksum (&eahd->descTag);UDF_I_LENEATTR (inode) += size;return (struct genericFormat *)&ea[offset]; }
@@ -207,8 +202,6 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, {tag *tag_p;struct buffer_head *bh =NULL ; - registeruint8_t checksum; - registerint i;struct udf_sb_info *sbi =UDF_SB (sb);/* Read the block */
@@ -234,12 +227,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, }/* Verify the tag checksum */ - checksum =0U ; -for (i =0 ; i <4 ; i++) - checksum += (uint8_t )(bh->b_data[i]); -for (i =5 ; i <16 ; i++) - checksum += (uint8_t )(bh->b_data[i]); -if (checksum != tag_p->tagChecksum) { +if (udf_tag_checksum (tag_p) != tag_p->tagChecksum) {printk (KERN_ERR "udf: tag checksum failed block %d\n" , block); goto error_out; }
@@ -277,17 +265,11 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,void udf_update_tag (char *data,int length) {tag *tptr = (tag *)data; -int i; - length -=sizeof (tag); - tptr->tagChecksum =0 ; tptr->descCRCLength =cpu_to_le16 (length); tptr->descCRC =cpu_to_le16 (udf_crc (data +sizeof (tag), length,0 )); - -for (i =0 ; i <16 ; i++) -if (i !=4 ) - tptr->tagChecksum += (uint8_t )(data[i]); + tptr->tagChecksum =udf_tag_checksum (tptr); } void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
@@ -300,3 +282,14 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, tptr->tagLocation =cpu_to_le32 (loc);udf_update_tag (data, length); } + +u8 udf_tag_checksum (const tag *t) +{ +u8 *data = (u8 *)t; +u8 checksum =0 ; +int i; +for (i =0 ; i <sizeof (tag); ++i) +if (i !=4 )/* position of checksum */ + checksum += data[i]; +return checksum; +}
fs/udf/namei.c +1 -8
@@ -47,8 +47,6 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, {uint16_t crclen = fibh->eoffset - fibh->soffset -sizeof (tag);uint16_t crc; -uint8_t checksum =0 ; -int i;int offset;uint16_t liu =le16_to_cpu (cfi->lengthOfImpUse);uint8_t lfi = cfi->lengthFileIdent;
@@ -122,13 +120,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, cfi->descTag.descCRC =cpu_to_le16 (crc); cfi->descTag.descCRCLength =cpu_to_le16 (crclen); + cfi->descTag.tagChecksum =udf_tag_checksum (&cfi->descTag); -for (i =0 ; i <16 ; i++) { -if (i !=4 ) - checksum += ((uint8_t *)&cfi->descTag)[i]; - } - - cfi->descTag.tagChecksum = checksum;if (adinicb || (sizeof (struct fileIdentDesc ) <= -fibh->soffset)) {memcpy ((uint8_t *)sfi, (uint8_t *)cfi,sizeof (struct fileIdentDesc ));
fs/udf/super.c +2 -14
@@ -1564,7 +1564,6 @@ static void udf_open_lvid(struct super_block *sb)struct udf_sb_info *sbi =UDF_SB (sb);struct buffer_head *bh = sbi->s_lvid_bh;if (bh) { -int i;kernel_timestamp cpu_time;struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data;
@@ -1582,12 +1581,7 @@ static void udf_open_lvid(struct super_block *sb)le16_to_cpu (lvid->descTag.descCRCLength), 0)); - lvid->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - lvid->descTag.tagChecksum += - ((uint8_t *) &(lvid->descTag))[i]; - + lvid->descTag.tagChecksum =udf_tag_checksum (&lvid->descTag);mark_buffer_dirty (bh); } }
@@ -1595,7 +1589,6 @@ static void udf_open_lvid(struct super_block *sb)static void udf_close_lvid (struct super_block *sb) {kernel_timestamp cpu_time; -int i;struct udf_sb_info *sbi =UDF_SB (sb);struct buffer_head *bh = sbi->s_lvid_bh;struct logicalVolIntegrityDesc *lvid;
@@ -1626,12 +1619,7 @@ static void udf_close_lvid(struct super_block *sb)le16_to_cpu (lvid->descTag.descCRCLength), 0)); - lvid->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - lvid->descTag.tagChecksum += - ((uint8_t *)&(lvid->descTag))[i]; - + lvid->descTag.tagChecksum =udf_tag_checksum (&lvid->descTag);mark_buffer_dirty (bh); } }
fs/udf/udfdecl.h +3 -0
@@ -36,6 +36,9 @@#define udf_get_lb_pblock (sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) +/* computes tag checksum */ +u8 udf_tag_checksum (const tag *t); +struct dentry ;struct inode ;struct task_struct ;
Signature · 1 line
1.5.3.7
Re: [PATCH 09/16] udf: create common function for tag checksumming
Quoted 3 lines · On Thu 10-01-08 23:06:25, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 211 lines
--- fs/udf/inode.c | 15 ++------------- fs/udf/misc.c | 35 ++++++++++++++--------------------- fs/udf/namei.c | 9 +-------- fs/udf/super.c | 16 ++-------------- fs/udf/udfdecl.h | 3 +++ 5 files changed, 22 insertions(+), 56 deletions(-)fs/udf/inode.c +2
-13@@ -1440,7 +1440,6 @@ static int udf_update_inode(struct inode *inode, int do_sync)uint32_t udfperms;uint16_t icbflags;uint16_t crclen; -int i;kernel_timestamp cpu_time;int err =0 ;struct udf_sb_info *sbi =UDF_SB (inode->i_sb);@@ -1476,12 +1475,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) use->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)use +sizeof (tag), crclen,0 )); - - use->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - use->descTag.tagChecksum += - ((uint8_t *)&(use->descTag))[i]; + use->descTag.tagChecksum =udf_tag_checksum (&use->descTag);mark_buffer_dirty (bh);brelse (bh);@@ -1650,12 +1644,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) fe->descTag.descCRCLength =cpu_to_le16 (crclen); fe->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)fe +sizeof (tag), crclen,0 )); - - fe->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - fe->descTag.tagChecksum += - ((uint8_t *)&(fe->descTag))[i]; + fe->descTag.tagChecksum =udf_tag_checksum (&fe->descTag);/* write the data blocks */ mark_buffer_dirty (bh);fs/udf/misc.c +14
-21@@ -51,7 +51,6 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,uint8_t *ea =NULL , *ad =NULL ;int offset;uint16_t crclen; -int i; ea =UDF_I_DATA (inode);if (UDF_I_LENEATTR (inode)) {@@ -138,11 +137,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.descCRCLength =cpu_to_le16 (crclen); eahd->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)eahd +sizeof (tag), crclen,0 )); - eahd->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - eahd->descTag.tagChecksum += - ((uint8_t *)&(eahd->descTag))[i]; + eahd->descTag.tagChecksum =udf_tag_checksum (&eahd->descTag);UDF_I_LENEATTR (inode) += size;return (struct genericFormat *)&ea[offset]; }@@ -207,8 +202,6 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, {tag *tag_p;struct buffer_head *bh =NULL ; - registeruint8_t checksum; - registerint i;struct udf_sb_info *sbi =UDF_SB (sb);/* Read the block */ @@ -234,12 +227,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, }/* Verify the tag checksum */ - checksum =0U ; -for (i =0 ; i <4 ; i++) - checksum += (uint8_t )(bh->b_data[i]); -for (i =5 ; i <16 ; i++) - checksum += (uint8_t )(bh->b_data[i]); -if (checksum != tag_p->tagChecksum) { +if (udf_tag_checksum (tag_p) != tag_p->tagChecksum) {printk (KERN_ERR "udf: tag checksum failed block %d\n" , block); goto error_out; }@@ -277,17 +265,11 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,void udf_update_tag (char *data,int length) {tag *tptr = (tag *)data; -int i; - length -=sizeof (tag); - tptr->tagChecksum =0 ; tptr->descCRCLength =cpu_to_le16 (length); tptr->descCRC =cpu_to_le16 (udf_crc (data +sizeof (tag), length,0 )); - -for (i =0 ; i <16 ; i++) -if (i !=4 ) - tptr->tagChecksum += (uint8_t )(data[i]); + tptr->tagChecksum =udf_tag_checksum (tptr); } void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,@@ -300,3 +282,14 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, tptr->tagLocation =cpu_to_le32 (loc);udf_update_tag (data, length); } + +u8 udf_tag_checksum (const tag *t) +{ +u8 *data = (u8 *)t; +u8 checksum =0 ; +int i; +for (i =0 ; i <sizeof (tag); ++i) +if (i !=4 )/* position of checksum */ + checksum += data[i]; +return checksum; +}fs/udf/namei.c +1
-8@@ -47,8 +47,6 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, {uint16_t crclen = fibh->eoffset - fibh->soffset -sizeof (tag);uint16_t crc; -uint8_t checksum =0 ; -int i;int offset;uint16_t liu =le16_to_cpu (cfi->lengthOfImpUse);uint8_t lfi = cfi->lengthFileIdent;@@ -122,13 +120,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, cfi->descTag.descCRC =cpu_to_le16 (crc); cfi->descTag.descCRCLength =cpu_to_le16 (crclen); + cfi->descTag.tagChecksum =udf_tag_checksum (&cfi->descTag); -for (i =0 ; i <16 ; i++) { -if (i !=4 ) - checksum += ((uint8_t *)&cfi->descTag)[i]; - } - - cfi->descTag.tagChecksum = checksum;if (adinicb || (sizeof (struct fileIdentDesc ) <= -fibh->soffset)) {memcpy ((uint8_t *)sfi, (uint8_t *)cfi,sizeof (struct fileIdentDesc ));fs/udf/super.c +2
-14@@ -1564,7 +1564,6 @@ static void udf_open_lvid(struct super_block *sb)struct udf_sb_info *sbi =UDF_SB (sb);struct buffer_head *bh = sbi->s_lvid_bh;if (bh) { -int i;kernel_timestamp cpu_time;struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data;@@ -1582,12 +1581,7 @@ static void udf_open_lvid(struct super_block *sb)le16_to_cpu (lvid->descTag.descCRCLength), 0)); - lvid->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - lvid->descTag.tagChecksum += - ((uint8_t *) &(lvid->descTag))[i]; - + lvid->descTag.tagChecksum =udf_tag_checksum (&lvid->descTag);mark_buffer_dirty (bh); } }@@ -1595,7 +1589,6 @@ static void udf_open_lvid(struct super_block *sb)static void udf_close_lvid (struct super_block *sb) {kernel_timestamp cpu_time; -int i;struct udf_sb_info *sbi =UDF_SB (sb);struct buffer_head *bh = sbi->s_lvid_bh;struct logicalVolIntegrityDesc *lvid;@@ -1626,12 +1619,7 @@ static void udf_close_lvid(struct super_block *sb)le16_to_cpu (lvid->descTag.descCRCLength), 0)); - lvid->descTag.tagChecksum =0 ; -for (i =0 ; i <16 ; i++) -if (i !=4 ) - lvid->descTag.tagChecksum += - ((uint8_t *)&(lvid->descTag))[i]; - + lvid->descTag.tagChecksum =udf_tag_checksum (&lvid->descTag);mark_buffer_dirty (bh); } }fs/udf/udfdecl.h +0
-0
fs/udf/udfdecl.h line 44
Quoted 9 lines
fs/udf/udfdecl.h +3
-0@@ -36,6 +36,9 @@#define udf_get_lb_pblock (sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) +/* computes tag checksum */ +u8 udf_tag_checksum (const tag *t); +struct dentry ;struct inode ;struct task_struct ;
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 10/16 udf: create common function for changing free space counter
In reply to [email protected]--- fs/udf/balloc.c | 49 ++++++++++++++++++++----------------------------- 1 files changed, 20 insertions(+), 29 deletions(-)
fs/udf/balloc.c +20 -29
@@ -140,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb,return slot; } +static bool udf_inc_free_space (struct udf_sb_info *sbi, +u16 partition,u32 cnt) +{ +struct logicalVolIntegrityDesc *lvid; + +if (sbi->s_lvid_bh) +return false; + + lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] =cpu_to_le32 (le32_to_cpu ( + lvid->freeSpaceTable[partition]) + cnt); +return true; +} + static void udf_bitmap_free_blocks(struct super_block *sb, struct inode *inode, struct udf_bitmap *bitmap,
@@ -194,11 +208,7 @@ do_more: }else {if (inode)DQUOT_FREE_BLOCK (inode,1 ); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[sbi->s_partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) +1 ); - } +udf_inc_free_space (sbi, sbi->s_partition,1 ); } }mark_buffer_dirty (bh);
@@ -268,12 +278,8 @@ repeat:if (block_count >0 ) goto repeat; out: -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +if (udf_inc_free_space (sbi, partition, -alloc_count))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);return alloc_count;
@@ -404,12 +410,8 @@ got_block:mark_buffer_dirty (bh); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +if (udf_inc_free_space (sbi, partition,-1 ))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex); *err =0 ;
@@ -450,12 +452,8 @@ static void udf_table_free_blocks(struct super_block *sb,could occure, but.. oh well */ if (inode)DQUOT_FREE_BLOCK (inode, count); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[sbi->s_partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) + count); +if (udf_inc_free_space (sbi, sbi->s_partition, count))mark_buffer_dirty (sbi->s_lvid_bh); - } start = bloc.logicalBlockNum + offset; end = bloc.logicalBlockNum + offset + count -1 ;
@@ -719,10 +717,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,brelse (epos.bh); -if (alloc_count && sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +if (alloc_count &&udf_inc_free_space (sbi, partition, -alloc_count)) {mark_buffer_dirty (sbi->s_lvid_bh); sb->s_dirt =1 ; }
@@ -822,12 +817,8 @@ 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 (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +if (udf_inc_free_space (sbi, partition,-1 ))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);
Signature · 1 line
1.5.3.7
Re: [PATCH 10/16] udf: create common function for changing free space counter
Quoted 3 lines · On Thu 10-01-08 23:06:26, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Just two minor comment...
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 143
Quoted 13 lines
--- fs/udf/balloc.c | 49 ++++++++++++++++++++----------------------------- 1 files changed, 20 insertions(+), 29 deletions(-)fs/udf/balloc.c +1
-0@@ -140,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb,return slot; } +static bool udf_inc_free_space(struct udf_sb_info *sbi,
Maybe because you use the function for both increasing and decreasing
free space, you could call is udf_add_free_space?
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 153
Quoted 10 lines
fs/udf/balloc.c +10
-0+ u16 partition, u32 cnt) +{ +struct logicalVolIntegrityDesc *lvid; + +if (sbi->s_lvid_bh) +return false; + + lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] =cpu_to_le32 (le32_to_cpu ( + lvid->freeSpaceTable[partition]) + cnt);
I think macro like le32_add_cpu() just went into the kernel so you could
use that...
Quoted 77 lines
fs/udf/balloc.c +8
-24+return true; +} + static void udf_bitmap_free_blocks(struct super_block *sb, struct inode *inode, struct udf_bitmap *bitmap,@@ -194,11 +208,7 @@ do_more: }else {if (inode)DQUOT_FREE_BLOCK (inode,1 ); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[sbi->s_partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) +1 ); - } +udf_inc_free_space (sbi, sbi->s_partition,1 ); } }mark_buffer_dirty (bh);@@ -268,12 +278,8 @@ repeat:if (block_count >0 ) goto repeat; out: -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +if (udf_inc_free_space (sbi, partition, -alloc_count))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);return alloc_count;@@ -404,12 +410,8 @@ got_block:mark_buffer_dirty (bh); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +if (udf_inc_free_space (sbi, partition,-1 ))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex); *err =0 ;@@ -450,12 +452,8 @@ static void udf_table_free_blocks(struct super_block *sb,could occure, but.. oh well */ if (inode)DQUOT_FREE_BLOCK (inode, count); -if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[sbi->s_partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[sbi->s_partition]) + count); +if (udf_inc_free_space (sbi, sbi->s_partition, count))mark_buffer_dirty (sbi->s_lvid_bh); - } start = bloc.logicalBlockNum + offset; end = bloc.logicalBlockNum + offset + count -1 ;@@ -719,10 +717,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,brelse (epos.bh); -if (alloc_count && sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) - alloc_count); +if (alloc_count &&udf_inc_free_space (sbi, partition, -alloc_count)) {mark_buffer_dirty (sbi->s_lvid_bh); sb->s_dirt =1 ; }@@ -822,12 +817,8 @@ static int udf_table_new_block(struct super_block *sb,udf_delete_aext (table, goal_epos, goal_eloc, goal_elen);brelse (goal_epos.bh);
fs/udf/balloc.c static int udf_table_new_block(struct super_block *sb, · line 824
Quoted 10 lines
fs/udf/balloc.c +1
-5-if (sbi->s_lvid_bh) { -struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; - lvid->freeSpaceTable[partition] = -cpu_to_le32 (le32_to_cpu (lvid->freeSpaceTable[partition]) -1 ); +if (udf_inc_free_space (sbi, partition,-1 ))mark_buffer_dirty (sbi->s_lvid_bh); - } sb->s_dirt =1 ;mutex_unlock (&sbi->s_alloc_mutex);
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 10/16] udf: create common function for changing free space counter
Quoted 18 lines · Jan Kara
Quoted 3 lines · On Thu 10-01-08 23:06:26, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>Just two minor comment...
Quoted 12 lines
--- fs/udf/balloc.c | 49 ++++++++++++++++++++----------------------------- 1 files changed, 20 insertions(+), 29 deletions(-)fs/udf/balloc.c +0
-0@@ -140,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb,return slot; }
Quoted 3 lines
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 143
Quoted 1 line
fs/udf/balloc.c +1
-0+static bool udf_inc_free_space(struct udf_sb_info *sbi,Maybe because you use the function for both increasing and decreasing
free space, you could call isudf_add_free_space?
Ok. Done.
Quoted 13 lines
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 153
Quoted 11 lines
fs/udf/balloc.c +10
-0+ u16 partition, u32 cnt) +{ +struct logicalVolIntegrityDesc *lvid; + +if (sbi->s_lvid_bh) +return false; + + lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] =cpu_to_le32 (le32_to_cpu ( + lvid->freeSpaceTable[partition]) + cnt);I think macro like
le32_add_cpu()just went into the kernel so you could
use that...
I didn't want to rely on too many patches, so I intentionally left it. I'll convert it together with other le*_add_cpu changes.
Can you ack this patch with udf_inc_free_space rename?
Marcin
Jan Kara
Acked-byRe: [PATCH 10/16] udf: create common function for changing free space counter
Quoted 37 lines · Marcin Slusarz
Quoted 18 lines · Jan Kara
Quoted 3 lines · On Thu 10-01-08 23:06:26, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>Just two minor comment...
Quoted 12 lines
--- fs/udf/balloc.c | 49 ++++++++++++++++++++----------------------------- 1 files changed, 20 insertions(+), 29 deletions(-)fs/udf/balloc.c +0
-0@@ -140,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb,return slot; }Quoted 3 lines
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 143
Quoted 1 line
fs/udf/balloc.c +1
-0+static bool udf_inc_free_space(struct udf_sb_info *sbi,Maybe because you use the function for both increasing and decreasing
free space, you could call isudf_add_free_space?Ok. Done.
Quoted 13 lines
fs/udf/balloc.c static inline int load_block_bitmap(struct super_block *sb, · line 153
Quoted 11 lines
fs/udf/balloc.c +10
-0+ u16 partition, u32 cnt) +{ +struct logicalVolIntegrityDesc *lvid; + +if (sbi->s_lvid_bh) +return false; + + lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; + lvid->freeSpaceTable[partition] =cpu_to_le32 (le32_to_cpu ( + lvid->freeSpaceTable[partition]) + cnt);I think macro like
le32_add_cpu()just went into the kernel so you could
use that...
Quoted 2 lines
I didn't want to rely on too many patches, so I intentionally left it. I'll convert it together with other le*_add_cpu changes.
OK, fair enough.
Quoted 1 line
Can you ack this patch with
udf_inc_free_spacerename?
Yes.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 11/16 udf: replace loops coded with goto to real loops
In reply to [email protected]--- fs/udf/balloc.c | 118 +++++++++++++++++++++++++++--------------------------- 1 files changed, 59 insertions(+), 59 deletions(-)
fs/udf/balloc.c +59 -59
@@ -183,46 +183,46 @@ static void udf_bitmap_free_blocks(struct super_block *sb, block = bloc.logicalBlockNum + offset + (sizeof (struct spaceBitmapDesc ) <<3 ); -do_more: - overflow =0 ; - block_group = block >> (sb->s_blocksize_bits +3 ); - bit = block % (sb->s_blocksize <<3 ); +do { + overflow =0 ; + block_group = block >> (sb->s_blocksize_bits +3 ); + bit = block % (sb->s_blocksize <<3 ); -/* -* Check to see if we are freeing blocks across a group boundary. -*/ -if (bit + count > (sb->s_blocksize <<3 )) { - overflow = bit + count - (sb->s_blocksize <<3 ); - count -= overflow; - } - bitmap_nr =load_block_bitmap (sb, bitmap, block_group); -if (bitmap_nr <0 ) - goto error_return; +/* +* Check to see if we are freeing blocks across a group boundary. +*/ +if (bit + count > (sb->s_blocksize <<3 )) { + overflow = bit + count - (sb->s_blocksize <<3 ); + count -= overflow; + } + bitmap_nr =load_block_bitmap (sb, bitmap, block_group); +if (bitmap_nr <0 ) + goto error_return; - bh = bitmap->s_block_bitmap[bitmap_nr]; -for (i =0 ; i < count; i++) { -if (udf_set_bit (bit + i, bh->b_data)) { -udf_debug ("bit %ld already set\n" , bit + i); -udf_debug ("byte=%2x\n" , - ((char *)bh->b_data)[(bit + i) >>3 ]); - }else { -if (inode) -DQUOT_FREE_BLOCK (inode,1 ); -udf_inc_free_space (sbi, sbi->s_partition,1 ); + bh = bitmap->s_block_bitmap[bitmap_nr]; +for (i =0 ; i < count; i++) { +if (udf_set_bit (bit + i, bh->b_data)) { +udf_debug ("bit %ld already set\n" , bit + i); +udf_debug ("byte=%2x\n" , + ((char *)bh->b_data)[(bit + i) >>3 ]); + }else { +if (inode) +DQUOT_FREE_BLOCK (inode,1 ); +udf_inc_free_space (sbi, sbi->s_partition,1 ); + } } - } -mark_buffer_dirty (bh); -if (overflow) { - block += count; - count = overflow; - goto do_more; - } +mark_buffer_dirty (bh); +if (overflow) { + block += count; + count = overflow; + } + }while (overflow); + error_return: sb->s_dirt =1 ;if (sbi->s_lvid_bh)mark_buffer_dirty (sbi->s_lvid_bh);mutex_unlock (&sbi->s_alloc_mutex); -return ; } static int udf_bitmap_prealloc_blocks(struct super_block *sb,
@@ -246,37 +246,37 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,if (first_block + block_count > part_len) block_count = part_len - first_block; -repeat: - nr_groups =udf_compute_nr_groups (sb, partition); - block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); - block_group = block >> (sb->s_blocksize_bits +3 ); - group_start = block_group ?0 :sizeof (struct spaceBitmapDesc ); +do { + nr_groups =udf_compute_nr_groups (sb, partition); + block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); + block_group = block >> (sb->s_blocksize_bits +3 ); + group_start = block_group ?0 :sizeof (struct spaceBitmapDesc ); - bitmap_nr =load_block_bitmap (sb, bitmap, block_group); -if (bitmap_nr <0 ) - goto out; - bh = bitmap->s_block_bitmap[bitmap_nr]; + bitmap_nr =load_block_bitmap (sb, bitmap, block_group); +if (bitmap_nr <0 ) + goto out; + bh = bitmap->s_block_bitmap[bitmap_nr]; - bit = block % (sb->s_blocksize <<3 ); + bit = block % (sb->s_blocksize <<3 ); -while (bit < (sb->s_blocksize <<3 ) && block_count >0 ) { -if (!udf_test_bit (bit, bh->b_data)) { - goto out; - }else if (DQUOT_PREALLOC_BLOCK (inode,1 )) { - goto out; - }else if (!udf_clear_bit (bit, bh->b_data)) { -udf_debug ("bit already cleared for block %d\n" , bit); -DQUOT_FREE_BLOCK (inode,1 ); - goto out; +while (bit < (sb->s_blocksize <<3 ) && block_count >0 ) { +if (!udf_test_bit (bit, bh->b_data)) + goto out; +else if (DQUOT_PREALLOC_BLOCK (inode,1 )) + goto out; +else if (!udf_clear_bit (bit, bh->b_data)) { +udf_debug ("bit already cleared for block %d\n" , bit); +DQUOT_FREE_BLOCK (inode,1 ); + goto out; + } + block_count--; + alloc_count++; + bit++; + block++; } - block_count--; - alloc_count++; - bit++; - block++; - } -mark_buffer_dirty (bh); -if (block_count >0 ) - goto repeat; +mark_buffer_dirty (bh); + }while (block_count >0 ); + out:if (udf_inc_free_space (sbi, partition, -alloc_count))mark_buffer_dirty (sbi->s_lvid_bh);
Signature · 1 line
1.5.3.7
Re: [PATCH 11/16] udf: replace loops coded with goto to real loops
Quoted 3 lines · On Thu 10-01-08 23:06:27, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 155 lines
--- fs/udf/balloc.c | 118 +++++++++++++++++++++++++++--------------------------- 1 files changed, 59 insertions(+), 59 deletions(-)fs/udf/balloc.c +59
-59@@ -183,46 +183,46 @@ static void udf_bitmap_free_blocks(struct super_block *sb, block = bloc.logicalBlockNum + offset + (sizeof (struct spaceBitmapDesc ) <<3 ); -do_more: - overflow =0 ; - block_group = block >> (sb->s_blocksize_bits +3 ); - bit = block % (sb->s_blocksize <<3 ); +do { + overflow =0 ; + block_group = block >> (sb->s_blocksize_bits +3 ); + bit = block % (sb->s_blocksize <<3 ); -/* -* Check to see if we are freeing blocks across a group boundary. -*/ -if (bit + count > (sb->s_blocksize <<3 )) { - overflow = bit + count - (sb->s_blocksize <<3 ); - count -= overflow; - } - bitmap_nr =load_block_bitmap (sb, bitmap, block_group); -if (bitmap_nr <0 ) - goto error_return; +/* +* Check to see if we are freeing blocks across a group boundary. +*/ +if (bit + count > (sb->s_blocksize <<3 )) { + overflow = bit + count - (sb->s_blocksize <<3 ); + count -= overflow; + } + bitmap_nr =load_block_bitmap (sb, bitmap, block_group); +if (bitmap_nr <0 ) + goto error_return; - bh = bitmap->s_block_bitmap[bitmap_nr]; -for (i =0 ; i < count; i++) { -if (udf_set_bit (bit + i, bh->b_data)) { -udf_debug ("bit %ld already set\n" , bit + i); -udf_debug ("byte=%2x\n" , - ((char *)bh->b_data)[(bit + i) >>3 ]); - }else { -if (inode) -DQUOT_FREE_BLOCK (inode,1 ); -udf_inc_free_space (sbi, sbi->s_partition,1 ); + bh = bitmap->s_block_bitmap[bitmap_nr]; +for (i =0 ; i < count; i++) { +if (udf_set_bit (bit + i, bh->b_data)) { +udf_debug ("bit %ld already set\n" , bit + i); +udf_debug ("byte=%2x\n" , + ((char *)bh->b_data)[(bit + i) >>3 ]); + }else { +if (inode) +DQUOT_FREE_BLOCK (inode,1 ); +udf_inc_free_space (sbi, sbi->s_partition,1 ); + } } - } -mark_buffer_dirty (bh); -if (overflow) { - block += count; - count = overflow; - goto do_more; - } +mark_buffer_dirty (bh); +if (overflow) { + block += count; + count = overflow; + } + }while (overflow); + error_return: sb->s_dirt =1 ;if (sbi->s_lvid_bh)mark_buffer_dirty (sbi->s_lvid_bh);mutex_unlock (&sbi->s_alloc_mutex); -return ; } static int udf_bitmap_prealloc_blocks(struct super_block *sb,@@ -246,37 +246,37 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,if (first_block + block_count > part_len) block_count = part_len - first_block; -repeat: - nr_groups =udf_compute_nr_groups (sb, partition); - block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); - block_group = block >> (sb->s_blocksize_bits +3 ); - group_start = block_group ?0 :sizeof (struct spaceBitmapDesc ); +do { + nr_groups =udf_compute_nr_groups (sb, partition); + block = first_block + (sizeof (struct spaceBitmapDesc ) <<3 ); + block_group = block >> (sb->s_blocksize_bits +3 ); + group_start = block_group ?0 :sizeof (struct spaceBitmapDesc ); - bitmap_nr =load_block_bitmap (sb, bitmap, block_group); -if (bitmap_nr <0 ) - goto out; - bh = bitmap->s_block_bitmap[bitmap_nr]; + bitmap_nr =load_block_bitmap (sb, bitmap, block_group); +if (bitmap_nr <0 ) + goto out; + bh = bitmap->s_block_bitmap[bitmap_nr]; - bit = block % (sb->s_blocksize <<3 ); + bit = block % (sb->s_blocksize <<3 ); -while (bit < (sb->s_blocksize <<3 ) && block_count >0 ) { -if (!udf_test_bit (bit, bh->b_data)) { - goto out; - }else if (DQUOT_PREALLOC_BLOCK (inode,1 )) { - goto out; - }else if (!udf_clear_bit (bit, bh->b_data)) { -udf_debug ("bit already cleared for block %d\n" , bit); -DQUOT_FREE_BLOCK (inode,1 ); - goto out; +while (bit < (sb->s_blocksize <<3 ) && block_count >0 ) { +if (!udf_test_bit (bit, bh->b_data)) + goto out; +else if (DQUOT_PREALLOC_BLOCK (inode,1 )) + goto out; +else if (!udf_clear_bit (bit, bh->b_data)) { +udf_debug ("bit already cleared for block %d\n" , bit); +DQUOT_FREE_BLOCK (inode,1 ); + goto out; + } + block_count--; + alloc_count++; + bit++; + block++; } - block_count--; - alloc_count++; - bit++; - block++; - } -mark_buffer_dirty (bh); -if (block_count >0 ) - goto repeat; +mark_buffer_dirty (bh); + }while (block_count >0 ); + out:if (udf_inc_free_space (sbi, partition, -alloc_count))mark_buffer_dirty (sbi->s_lvid_bh);Signature · 1 line
1.5.3.7
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 12/16 udf: convert byte order of constant instead of variable
In reply to [email protected]convert byte order of constant instead of variable, which can be done at compile time (vs run time)
--- fs/udf/directory.c | 4 ++-- fs/udf/inode.c | 16 ++++++++-------- fs/udf/misc.c | 12 ++++++------ fs/udf/super.c | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-)
fs/udf/directory.c +2 -2
@@ -225,7 +225,7 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)if ((*offset >0 ) && (*offset < bufsize)) ptr += *offset; fi = (struct fileIdentDesc *)ptr; -if (le16_to_cpu (fi->descTag.tagIdent) !=TAG_IDENT_FID ) { +if (fi->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_FID )) {udf_debug ("0x%x != TAG_IDENT_FID\n" ,le16_to_cpu (fi->descTag.tagIdent)); udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
@@ -262,7 +262,7 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) fe = (struct fileEntry *)buffer; -if (le16_to_cpu (fe->descTag.tagIdent) !=TAG_IDENT_FE ) { +if (fe->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_FE )) {udf_debug ("0x%x != TAG_IDENT_FE\n" ,le16_to_cpu (fe->descTag.tagIdent));return NULL ;
fs/udf/inode.c +8 -8
@@ -1103,7 +1103,7 @@ static void __udf_read_inode(struct inode *inode) fe = (struct fileEntry *)bh->b_data; -if (le16_to_cpu (fe->icbTag.strategyType) ==4096 ) { +if (fe->icbTag.strategyType ==cpu_to_le16 (4096 )) {struct buffer_head *ibh =NULL , *nbh =NULL ;struct indirectEntry *ie;
@@ -1140,7 +1140,7 @@ static void __udf_read_inode(struct inode *inode) }else {brelse (ibh); } - }else if (le16_to_cpu (fe->icbTag.strategyType) !=4 ) { + }else if (fe->icbTag.strategyType !=cpu_to_le16 (4 )) {printk (KERN_ERR "udf: unsupported strategy type: %d\n" ,le16_to_cpu (fe->icbTag.strategyType));brelse (bh);
@@ -1164,9 +1164,9 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) fe = (struct fileEntry *)bh->b_data; efe = (struct extendedFileEntry *)bh->b_data; -if (le16_to_cpu (fe->icbTag.strategyType) ==4 ) +if (fe->icbTag.strategyType ==cpu_to_le16 (4 ))UDF_I_STRAT4096 (inode) =0 ; -else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ +else /* if (fe->icbTag.strategyType == cpu_to_le16(4096)) */ UDF_I_STRAT4096 (inode) =1 ; UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) &
@@ -1177,7 +1177,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)UDF_I_LENALLOC (inode) =0 ;UDF_I_NEXT_ALLOC_BLOCK (inode) =0 ;UDF_I_NEXT_ALLOC_GOAL (inode) =0 ; -if (le16_to_cpu (fe->descTag.tagIdent) ==TAG_IDENT_EFE ) { +if (fe->descTag.tagIdent ==cpu_to_le16 (TAG_IDENT_EFE )) {UDF_I_EFE (inode) =1 ;UDF_I_USE (inode) =0 ; if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize -
@@ -1189,7 +1189,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) bh->b_data +sizeof (struct extendedFileEntry ), inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); - }else if (le16_to_cpu (fe->descTag.tagIdent) ==TAG_IDENT_FE ) { + }else if (fe->descTag.tagIdent ==cpu_to_le16 (TAG_IDENT_FE )) {UDF_I_EFE (inode) =0 ;UDF_I_USE (inode) =0 ; if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize -
@@ -1199,7 +1199,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) }memcpy (UDF_I_DATA (inode), bh->b_data +sizeof (struct fileEntry ), inode->i_sb->s_blocksize -sizeof (struct fileEntry )); - }else if (le16_to_cpu (fe->descTag.tagIdent) ==TAG_IDENT_USE ) { + }else if (fe->descTag.tagIdent ==cpu_to_le16 (TAG_IDENT_USE )) {UDF_I_EFE (inode) =0 ;UDF_I_USE (inode) =1 ; UDF_I_LENALLOC(inode) = le32_to_cpu(
@@ -1458,7 +1458,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) fe = (struct fileEntry *)bh->b_data; efe = (struct extendedFileEntry *)bh->b_data; -if (le16_to_cpu (fe->descTag.tagIdent) ==TAG_IDENT_USE ) { +if (fe->descTag.tagIdent ==cpu_to_le16 (TAG_IDENT_USE )) {struct unallocSpaceEntry *use = (struct unallocSpaceEntry *)bh->b_data;
fs/udf/misc.c +6 -6
@@ -74,8 +74,8 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,if (UDF_I_LENEATTR (inode)) {/* check checksum/crc */ -if (le16_to_cpu (eahd->descTag.tagIdent) != -TAG_IDENT_EAHD || +if (eahd->descTag.tagIdent != +cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) !=UDF_I_LOCATION (inode).logicalBlockNum)return NULL ;
@@ -161,8 +161,8 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, eahd = (struct extendedAttrHeaderDesc *)ea;/* check checksum/crc */ -if (le16_to_cpu (eahd->descTag.tagIdent) != -TAG_IDENT_EAHD || +if (eahd->descTag.tagIdent != +cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) !=UDF_I_LOCATION (inode).logicalBlockNum)return NULL ;
@@ -233,8 +233,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, }/* Verify the tag version */ -if (le16_to_cpu (tag_p->descVersion) !=0x0002U && -le16_to_cpu (tag_p->descVersion) !=0x0003U ) { +if (tag_p->descVersion !=cpu_to_le16 (0x0002U ) && + tag_p->descVersion !=cpu_to_le16 (0x0003U )) {udf_debug ("tag version 0x%04x != 0x0002 || 0x0003 block %d\n" ,le16_to_cpu (tag_p->descVersion), block); goto error_out;
fs/udf/super.c +8 -8
@@ -1014,20 +1014,20 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)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 ) +if (p->accessType == +cpu_to_le32 (PD_ACCESS_TYPE_READ_ONLY )) map->s_partition_flags |=UDF_PART_FLAG_READ_ONLY ; -if (le32_to_cpu (p->accessType) == -PD_ACCESS_TYPE_WRITE_ONCE ) +if (p->accessType == +cpu_to_le32 (PD_ACCESS_TYPE_WRITE_ONCE )) map->s_partition_flags |=UDF_PART_FLAG_WRITE_ONCE ; -if (le32_to_cpu (p->accessType) == -PD_ACCESS_TYPE_REWRITABLE ) +if (p->accessType == +cpu_to_le32 (PD_ACCESS_TYPE_REWRITABLE )) map->s_partition_flags |=UDF_PART_FLAG_REWRITABLE ; -if (le32_to_cpu (p->accessType) == -PD_ACCESS_TYPE_OVERWRITABLE ) +if (p->accessType == +cpu_to_le32 (PD_ACCESS_TYPE_OVERWRITABLE )) map->s_partition_flags |=UDF_PART_FLAG_OVERWRITABLE ;
Signature · 1 line
1.5.3.7
PATCH 13/16 udf: remove UDF_I_* macros and open code them
In reply to [email protected]--- fs/udf/balloc.c | 30 +++--- fs/udf/dir.c | 7 +- fs/udf/directory.c | 6 +- fs/udf/file.c | 24 +++-- fs/udf/ialloc.c | 50 +++++----- fs/udf/inode.c | 296 ++++++++++++++++++++++++++------------------------- fs/udf/misc.c | 38 ++++---- fs/udf/namei.c | 110 ++++++++++--------- fs/udf/partition.c | 4 +- fs/udf/super.c | 2 +- fs/udf/symlink.c | 4 +- fs/udf/truncate.c | 34 +++--- fs/udf/udf_i.h | 16 --- fs/udf/udfdecl.h | 8 +- 14 files changed, 315 insertions(+), 314 deletions(-)
fs/udf/balloc.c +16 -14
@@ -460,7 +460,7 @@ static void udf_table_free_blocks(struct super_block *sb, epos.offset = oepos.offset =sizeof (struct unallocSpaceEntry ); elen =0 ; - epos.block = oepos.block =UDF_I_LOCATION (table); + epos.block = oepos.block =UDF_I (table)->i_location; epos.bh = oepos.bh =NULL ; while (count &&
@@ -539,9 +539,9 @@ static void udf_table_free_blocks(struct super_block *sb, elen =EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits); -if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_SHORT ) { +if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) { adsize =sizeof (short_ad); - }else if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_LONG ) { + }else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) { adsize =sizeof (long_ad); }else {brelse (oepos.bh);
@@ -573,7 +573,8 @@ static void udf_table_free_blocks(struct super_block *sb,if (epos.offset + adsize > sb->s_blocksize) { loffset = epos.offset; aed->lengthAllocDescs =cpu_to_le32 (adsize); - sptr =UDF_I_DATA (table) + epos.offset - adsize; + sptr =UDF_I (table)->i_ext.i_data + epos.offset + - adsize; dptr = epos.bh->b_data +sizeof (struct allocExtDesc );memcpy (dptr, sptr, adsize);
@@ -591,8 +592,9 @@ static void udf_table_free_blocks(struct super_block *sb, aed->lengthAllocDescs) + adsize); }else { - sptr =UDF_I_DATA (table) + epos.offset; -UDF_I_LENALLOC (table) += adsize; + sptr =UDF_I (table)->i_ext.i_data + + epos.offset; +UDF_I (table)->i_lenAlloc += adsize;mark_inode_dirty (table); } epos.offset =sizeof (struct allocExtDesc );
@@ -606,7 +608,7 @@ static void udf_table_free_blocks(struct super_block *sb,2 ,1 , epos.block.logicalBlockNum, sizeof(tag)); -switch (UDF_I_ALLOCTYPE (table)) { +switch (UDF_I (table)->i_alloc_type) {case ICBTAG_FLAG_AD_SHORT : sad = (short_ad *)sptr; sad->extLength = cpu_to_le32(
@@ -637,7 +639,7 @@ static void udf_table_free_blocks(struct super_block *sb,udf_write_aext (table, &epos, eloc, elen,1 );if (!epos.bh) { -UDF_I_LENALLOC (table) += adsize; +UDF_I (table)->i_lenAlloc += adsize;mark_inode_dirty (table); }else { aed = (struct allocExtDesc *)epos.bh->b_data;
@@ -675,16 +677,16 @@ static int udf_table_prealloc_blocks(struct super_block *sb, first_block >= sbi->s_partmaps[partition].s_partition_len)return 0 ; -if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else return 0 ;mutex_lock (&sbi->s_alloc_mutex); epos.offset =sizeof (struct unallocSpaceEntry ); - epos.block =UDF_I_LOCATION (table); + epos.block =UDF_I (table)->i_location; epos.bh =NULL ; eloc.logicalBlockNum =0xFFFFFFFF ;
@@ -740,9 +742,9 @@ static int udf_table_new_block(struct super_block *sb, *err = -ENOSPC ; -if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (table) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else return newblock;
@@ -757,7 +759,7 @@ static int udf_table_new_block(struct super_block *sb,of the current closest match and use that when we are done. */ epos.offset =sizeof (struct unallocSpaceEntry ); - epos.block =UDF_I_LOCATION (table); + epos.block =UDF_I (table)->i_location; epos.bh = goal_epos.bh =NULL ; while (spread &&
fs/udf/dir.c +4 -3
@@ -69,16 +69,17 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, (nf_pos & ((dir->i_sb->s_blocksize -1 ) >>2 )) <<2 ; bits = dir->i_sb->s_blocksize_bits; -if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_IN_ICB ) +if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) fibh.sbh = fibh.ebh =NULL ;else if (inode_bmap (dir, nf_pos >> (bits -2 ), &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >>30 )) { block =udf_get_lb_pblock (dir->i_sb, eloc, offset);if ((++offset << bits) < elen) { -if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) epos.offset -=sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (dir)->i_alloc_type == +ICBTAG_FLAG_AD_LONG ) epos.offset -=sizeof (long_ad); }else offset =0 ;
fs/udf/directory.c +3 -3
@@ -84,9 +84,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, fibh->soffset = fibh->eoffset; -if (UDF_I_ALLOCTYPE (dir) ==ICBTAG_FLAG_AD_IN_ICB ) { - fi = udf_get_fileident(UDF_I_DATA(dir) - - (UDF_I_EFE(dir) ? +if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { + fi = udf_get_fileident(UDF_I(dir)->i_ext.i_data - + (UDF_I(dir)->i_efe ? sizeof(struct extendedFileEntry) : sizeof(struct fileEntry)), dir->i_sb->s_blocksize,
fs/udf/file.c +14 -10
@@ -50,7 +50,8 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) kaddr =kmap (page);memset (kaddr,0 ,PAGE_CACHE_SIZE ); -memcpy (kaddr,UDF_I_DATA (inode) +UDF_I_LENEATTR (inode), inode->i_size); +memcpy (kaddr,UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr, + inode->i_size);flush_dcache_page (page);SetPageUptodate (page);kunmap (page);
@@ -68,7 +69,8 @@ static int udf_adinicb_writepage(struct page *page,BUG_ON (!PageLocked (page)); kaddr =kmap (page); -memcpy (UDF_I_DATA (inode) +UDF_I_LENEATTR (inode), kaddr, inode->i_size); +memcpy (UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr, kaddr, + inode->i_size);mark_inode_dirty (inode);SetPageUptodate (page);kunmap (page);
@@ -87,7 +89,7 @@ static int udf_adinicb_write_end(struct file *file,char *kaddr; kaddr =kmap_atomic (page,KM_USER0 ); -memcpy (UDF_I_DATA (inode) +UDF_I_LENEATTR (inode) + offset, +memcpy (UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr + offset, kaddr + offset, copied);kunmap_atomic (kaddr,KM_USER0 );
@@ -111,7 +113,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,int err, pos;size_t count = iocb->ki_left; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_IN_ICB ) { +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) {if (file->f_flags &O_APPEND ) pos = inode->i_size;else
@@ -121,15 +123,16 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, (udf_file_entry_alloc_offset(inode) + pos + count)) {udf_expand_file_adinicb (inode, pos + count, &err); - if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { +if (UDF_I (inode)->i_alloc_type == +ICBTAG_FLAG_AD_IN_ICB ) {udf_debug ("udf_expand_adinicb: err=%d\n" , err);return err; } } else {if (pos + count > inode->i_size) -UDF_I_LENALLOC (inode) = pos + count; +UDF_I (inode)->i_lenAlloc = pos + count;else -UDF_I_LENALLOC (inode) = inode->i_size; +UDF_I (inode)->i_lenAlloc = inode->i_size; } }
@@ -209,11 +212,12 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, result =put_user (new_block, (long __user *)arg);return result;case UDF_GETEASIZE : - result =put_user (UDF_I_LENEATTR (inode), (int __user *)arg); + result =put_user (UDF_I (inode)->i_lenEAttr, (int __user *)arg);break ;case UDF_GETEABLOCK : - result =copy_to_user ((char __user *)arg,UDF_I_DATA (inode), -UDF_I_LENEATTR (inode)) ? -EFAULT :0 ; + result =copy_to_user ((char __user *)arg, +UDF_I (inode)->i_ext.i_data, +UDF_I (inode)->i_lenEAttr) ? -EFAULT :0 ;break ; }
fs/udf/ialloc.c +25 -25
101 lines not on this page · raw message
fs/udf/inode.c +151 -145
712 lines not on this page · raw message
fs/udf/misc.c +19 -19
@@ -52,16 +52,16 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,int offset;uint16_t crclen; - ea =UDF_I_DATA (inode); -if (UDF_I_LENEATTR (inode)) { - ad =UDF_I_DATA (inode) +UDF_I_LENEATTR (inode); + ea =UDF_I (inode)->i_ext.i_data; +if (UDF_I (inode)->i_lenEAttr) { + ad =UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr; }else { ad = ea; size +=sizeof (struct extendedAttrHeaderDesc ); } offset = inode->i_sb->s_blocksize -udf_file_entry_alloc_offset (inode) - -UDF_I_LENALLOC (inode); +UDF_I (inode)->i_lenAlloc;/* TODO - Check for FreeEASpace */
@@ -69,21 +69,21 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,struct extendedAttrHeaderDesc *eahd; eahd = (struct extendedAttrHeaderDesc *)ea; -if (UDF_I_LENALLOC (inode)) -memmove (&ad[size], ad,UDF_I_LENALLOC (inode)); +if (UDF_I (inode)->i_lenAlloc) +memmove (&ad[size], ad,UDF_I (inode)->i_lenAlloc); -if (UDF_I_LENEATTR (inode)) { +if (UDF_I (inode)->i_lenEAttr) {/* check checksum/crc */ if (eahd->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) != -UDF_I_LOCATION (inode).logicalBlockNum) +UDF_I (inode)->i_location.logicalBlockNum)return NULL ; }else {struct udf_sb_info *sbi =UDF_SB (inode->i_sb); size -=sizeof (struct extendedAttrHeaderDesc ); -UDF_I_LENEATTR (inode) += +UDF_I (inode)->i_lenEAttr +=sizeof (struct extendedAttrHeaderDesc ); eahd->descTag.tagIdent =cpu_to_le16 (TAG_IDENT_EAHD );if (sbi->s_udfrev >=0x0200 )
@@ -93,15 +93,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.tagSerialNum =cpu_to_le16 (sbi->s_serial_number); eahd->descTag.tagLocation =cpu_to_le32 ( -UDF_I_LOCATION (inode).logicalBlockNum); +UDF_I (inode)->i_location.logicalBlockNum); eahd->impAttrLocation =cpu_to_le32 (0xFFFFFFFF ); eahd->appAttrLocation =cpu_to_le32 (0xFFFFFFFF ); } - offset =UDF_I_LENEATTR (inode); + offset =UDF_I (inode)->i_lenEAttr;if (type <2048 ) {if (le32_to_cpu (eahd->appAttrLocation) < -UDF_I_LENEATTR (inode)) { +UDF_I (inode)->i_lenEAttr) {uint32_t aal =le32_to_cpu (eahd->appAttrLocation); memmove(&ea[offset - aal + size],
@@ -111,7 +111,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,cpu_to_le32 (aal + size); }if (le32_to_cpu (eahd->impAttrLocation) < -UDF_I_LENEATTR (inode)) { +UDF_I (inode)->i_lenEAttr) {uint32_t ial =le32_to_cpu (eahd->impAttrLocation); memmove(&ea[offset - ial + size],
@@ -122,7 +122,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, } }else if (type <65536 ) {if (le32_to_cpu (eahd->appAttrLocation) < -UDF_I_LENEATTR (inode)) { +UDF_I (inode)->i_lenEAttr) {uint32_t aal =le32_to_cpu (eahd->appAttrLocation); memmove(&ea[offset - aal + size],
@@ -138,7 +138,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)eahd +sizeof (tag), crclen,0 )); eahd->descTag.tagChecksum =udf_tag_checksum (&eahd->descTag); -UDF_I_LENEATTR (inode) += size; +UDF_I (inode)->i_lenEAttr += size;return (struct genericFormat *)&ea[offset]; }if (loc &0x02 )
@@ -154,9 +154,9 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,uint8_t *ea =NULL ;uint32_t offset; - ea =UDF_I_DATA (inode); + ea =UDF_I (inode)->i_ext.i_data; -if (UDF_I_LENEATTR (inode)) { +if (UDF_I (inode)->i_lenEAttr) {struct extendedAttrHeaderDesc *eahd; eahd = (struct extendedAttrHeaderDesc *)ea;
@@ -164,7 +164,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,if (eahd->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) != -UDF_I_LOCATION (inode).logicalBlockNum) +UDF_I (inode)->i_location.logicalBlockNum)return NULL ;if (type <2048 )
@@ -174,7 +174,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,else offset =le32_to_cpu (eahd->appAttrLocation); -while (offset <UDF_I_LENEATTR (inode)) { +while (offset <UDF_I (inode)->i_lenEAttr) { gaf = (struct genericFormat *)&ea[offset];if (le32_to_cpu (gaf->attrType) == type && gaf->attrSubtype == subtype)
fs/udf/namei.c +57 -53
303 lines not on this page · raw message
fs/udf/partition.c +2 -2
@@ -88,14 +88,14 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,brelse (bh); -if (UDF_I_LOCATION (sbi->s_vat_inode).partitionReferenceNum == +if (UDF_I (sbi->s_vat_inode)->i_location.partitionReferenceNum == partition) {udf_debug ("recursive call to udf_get_pblock!\n" );return 0xFFFFFFFF ; }return udf_get_pblock (sb, loc, -UDF_I_LOCATION (sbi->s_vat_inode). +UDF_I (sbi->s_vat_inode)->i_location. partitionReferenceNum, offset); }
fs/udf/super.c +1 -1
@@ -2046,7 +2046,7 @@ static unsigned int udf_count_free_table(struct super_block *sb,lock_kernel (); - epos.block =UDF_I_LOCATION (table); + epos.block =UDF_I (table)->i_location; epos.offset =sizeof (struct unallocSpaceEntry ); epos.bh =NULL ;
fs/udf/symlink.c +2 -2
@@ -81,8 +81,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)char *p =kmap (page);lock_kernel (); -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_IN_ICB ) { - symlink =UDF_I_DATA (inode) +UDF_I_LENEATTR (inode); +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { + symlink =UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr; }else { bh =sb_bread (inode->i_sb,udf_block_map (inode,0 ));
fs/udf/truncate.c +17 -17
@@ -75,16 +75,16 @@ void udf_truncate_tail_extent(struct inode *inode)int8_t etype =-1 , netype;int adsize; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_IN_ICB || - inode->i_size ==UDF_I_LENEXTENTS (inode)) +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || + inode->i_size ==UDF_I (inode)->i_lenExtents)return ;/* Are we going to delete the file anyway? */ if (inode->i_nlink ==0 )return ; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else BUG ();
@@ -117,7 +117,7 @@ void udf_truncate_tail_extent(struct inode *inode) }/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ -UDF_I_LENEXTENTS (inode) = inode->i_size; +UDF_I (inode)->i_lenExtents = inode->i_size;brelse (epos.bh); }
@@ -130,18 +130,18 @@ void udf_discard_prealloc(struct inode *inode)int8_t etype =-1 , netype;int adsize; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_IN_ICB || - inode->i_size ==UDF_I_LENEXTENTS (inode)) +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || + inode->i_size ==UDF_I (inode)->i_lenExtents)return ; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else adsize =0 ; - epos.block =UDF_I_LOCATION (inode); + epos.block =UDF_I (inode)->i_location;/* Find the last extent in the file */ while ((netype =udf_next_aext (inode, &epos, &eloc, &elen,1 )) !=-1 ) {
@@ -153,7 +153,7 @@ void udf_discard_prealloc(struct inode *inode) lbcount -= elen;extent_trunc (inode, &epos, eloc, etype, elen,0 );if (!epos.bh) { -UDF_I_LENALLOC (inode) = +UDF_I (inode)->i_lenAlloc = epos.offset -udf_file_entry_alloc_offset (inode);mark_inode_dirty (inode);
@@ -174,7 +174,7 @@ void udf_discard_prealloc(struct inode *inode) }/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ -UDF_I_LENEXTENTS (inode) = lbcount; +UDF_I (inode)->i_lenExtents = lbcount;brelse (epos.bh); }
@@ -190,9 +190,9 @@ void udf_truncate_extents(struct inode *inode)loff_t byte_offset;int adsize; -if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_SHORT ) +if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I_ALLOCTYPE (inode) ==ICBTAG_FLAG_AD_LONG ) +else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else BUG ();
@@ -227,7 +227,7 @@ void udf_truncate_extents(struct inode *inode) 0, indirect_ext_len); }else {if (!epos.bh) { -UDF_I_LENALLOC (inode) = +UDF_I (inode)->i_lenAlloc = lenalloc;mark_inode_dirty (inode); }else {
@@ -275,7 +275,7 @@ void udf_truncate_extents(struct inode *inode) indirect_ext_len); }else {if (!epos.bh) { -UDF_I_LENALLOC (inode) = lenalloc; +UDF_I (inode)->i_lenAlloc = lenalloc;mark_inode_dirty (inode); }else { struct allocExtDesc *aed =
@@ -325,7 +325,7 @@ void udf_truncate_extents(struct inode *inode) (sb->s_blocksize - 1)) != 0)); } } -UDF_I_LENEXTENTS (inode) = inode->i_size; +UDF_I (inode)->i_lenExtents = inode->i_size;brelse (epos.bh); }
fs/udf/udf_i.h +0 -16
@@ -7,20 +7,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode) return list_entry(inode, struct udf_inode_info, vfs_inode); } -#define UDF_I_LOCATION (X ) ( UDF_I(X)->i_location ) -#define UDF_I_LENEATTR (X ) ( UDF_I(X)->i_lenEAttr ) -#define UDF_I_LENALLOC (X ) ( UDF_I(X)->i_lenAlloc ) -#define UDF_I_LENEXTENTS (X ) ( UDF_I(X)->i_lenExtents ) -#define UDF_I_UNIQUE (X ) ( UDF_I(X)->i_unique ) -#define UDF_I_ALLOCTYPE (X ) ( UDF_I(X)->i_alloc_type ) -#define UDF_I_EFE (X ) ( UDF_I(X)->i_efe ) -#define UDF_I_USE (X ) ( UDF_I(X)->i_use ) -#define UDF_I_STRAT4096 (X ) ( UDF_I(X)->i_strat4096 ) -#define UDF_I_NEXT_ALLOC_BLOCK (X ) ( UDF_I(X)->i_next_alloc_block ) -#define UDF_I_NEXT_ALLOC_GOAL (X ) ( UDF_I(X)->i_next_alloc_goal ) -#define UDF_I_CRTIME (X ) ( UDF_I(X)->i_crtime ) -#define UDF_I_SAD (X ) ( UDF_I(X)->i_ext.i_sad ) -#define UDF_I_LAD (X ) ( UDF_I(X)->i_ext.i_lad ) -#define UDF_I_DATA (X ) ( UDF_I(X)->i_ext.i_data ) -#endif /* !defined(_LINUX_UDF_I_H) */
fs/udf/udfdecl.h +4 -4
@@ -24,14 +24,14 @@#define UDF_PATH_LEN 1023#define udf_file_entry_alloc_offset (inode)\ - (UDF_I_USE(inode) ?\ + (UDF_I(inode)->i_use ?\ sizeof(struct unallocSpaceEntry) :\ - ((UDF_I_EFE(inode) ?\ + ((UDF_I(inode)->i_efe ?\ sizeof(struct extendedFileEntry) :\ - sizeof(struct fileEntry)) + UDF_I_LENEATTR(inode))) + sizeof(struct fileEntry)) + UDF_I(inode)->i_lenEAttr))#define udf_ext0_offset (inode)\ - (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB ?\ + (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ?\ udf_file_entry_alloc_offset(inode) : 0)#define udf_get_lb_pblock (sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset))
Signature · 1 line
1.5.3.7
PATCH 14/16 udf: cache struct udf_inode_info
In reply to [email protected]cache UDF_I(struct inode *) return values when there are at least 2 uses in one function
--- fs/udf/balloc.c | 35 ++++--- fs/udf/dir.c | 9 +- fs/udf/directory.c | 7 +- fs/udf/file.c | 21 ++-- fs/udf/ialloc.c | 49 +++++---- fs/udf/inode.c | 305 ++++++++++++++++++++++++++++------------------------ fs/udf/misc.c | 40 ++++---- fs/udf/namei.c | 112 +++++++++++--------- fs/udf/partition.c | 8 +- fs/udf/symlink.c | 6 +- fs/udf/truncate.c | 37 ++++--- 11 files changed, 338 insertions(+), 291 deletions(-)
fs/udf/balloc.c +20 -15
@@ -436,6 +436,7 @@ static void udf_table_free_blocks(struct super_block *sb,struct extent_position oepos, epos;int8_t etype;int i; +struct udf_inode_info *iinfo;mutex_lock (&sbi->s_alloc_mutex); if (bloc.logicalBlockNum < 0 ||
@@ -448,6 +449,7 @@ static void udf_table_free_blocks(struct super_block *sb, goto error_return; } + iinfo =UDF_I (table);/* We do this up front - There are some error conditions that could occure, but.. oh well */ if (inode)
@@ -460,7 +462,7 @@ static void udf_table_free_blocks(struct super_block *sb, epos.offset = oepos.offset =sizeof (struct unallocSpaceEntry ); elen =0 ; - epos.block = oepos.block =UDF_I (table)->i_location; + epos.block = oepos.block = iinfo->i_location; epos.bh = oepos.bh =NULL ; while (count &&
@@ -539,11 +541,11 @@ static void udf_table_free_blocks(struct super_block *sb, elen =EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits); -if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) { +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); - }else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) { +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad); - }else { +else {brelse (oepos.bh);brelse (epos.bh); goto error_return;
@@ -573,7 +575,7 @@ static void udf_table_free_blocks(struct super_block *sb,if (epos.offset + adsize > sb->s_blocksize) { loffset = epos.offset; aed->lengthAllocDescs =cpu_to_le32 (adsize); - sptr =UDF_I (table)->i_ext.i_data + epos.offset + sptr = iinfo->i_ext.i_data + epos.offset - adsize; dptr = epos.bh->b_data +sizeof (struct allocExtDesc );
@@ -592,9 +594,9 @@ static void udf_table_free_blocks(struct super_block *sb, aed->lengthAllocDescs) + adsize); }else { - sptr =UDF_I (table)->i_ext.i_data + + sptr = iinfo->i_ext.i_data + epos.offset; -UDF_I (table)->i_lenAlloc += adsize; + iinfo->i_lenAlloc += adsize;mark_inode_dirty (table); } epos.offset =sizeof (struct allocExtDesc );
@@ -608,7 +610,7 @@ static void udf_table_free_blocks(struct super_block *sb,2 ,1 , epos.block.logicalBlockNum, sizeof(tag)); -switch (UDF_I (table)->i_alloc_type) { +switch (iinfo->i_alloc_type) {case ICBTAG_FLAG_AD_SHORT : sad = (short_ad *)sptr; sad->extLength = cpu_to_le32(
@@ -639,7 +641,7 @@ static void udf_table_free_blocks(struct super_block *sb,udf_write_aext (table, &epos, eloc, elen,1 );if (!epos.bh) { -UDF_I (table)->i_lenAlloc += adsize; + iinfo->i_lenAlloc += adsize;mark_inode_dirty (table); }else { aed = (struct allocExtDesc *)epos.bh->b_data;
@@ -672,21 +674,23 @@ static int udf_table_prealloc_blocks(struct super_block *sb,kernel_lb_addr eloc;struct extent_position epos;int8_t etype =-1 ; +struct udf_inode_info *iinfo;if (first_block <0 || first_block >= sbi->s_partmaps[partition].s_partition_len)return 0 ; -if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) + iinfo =UDF_I (table); +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else return 0 ;mutex_lock (&sbi->s_alloc_mutex); epos.offset =sizeof (struct unallocSpaceEntry ); - epos.block =UDF_I (table)->i_location; + epos.block = iinfo->i_location; epos.bh =NULL ; eloc.logicalBlockNum =0xFFFFFFFF ;
@@ -739,12 +743,13 @@ static int udf_table_new_block(struct super_block *sb,kernel_lb_addr eloc,uninitialized_var (goal_eloc );struct extent_position epos, goal_epos;int8_t etype; +struct udf_inode_info *iinfo =UDF_I (table); *err = -ENOSPC ; -if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I (table)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else return newblock;
@@ -759,7 +764,7 @@ static int udf_table_new_block(struct super_block *sb,of the current closest match and use that when we are done. */ epos.offset =sizeof (struct unallocSpaceEntry ); - epos.block =UDF_I (table)->i_location; + epos.block = iinfo->i_location; epos.bh = goal_epos.bh =NULL ; while (spread &&
fs/udf/dir.c +5 -4
@@ -58,6 +58,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,unsigned int dt_type;struct extent_position epos = {NULL ,0 , {0 ,0 } };unsigned char bits; +struct udf_inode_info *iinfo;if (nf_pos >= size)return 0 ;
@@ -69,17 +70,17 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, (nf_pos & ((dir->i_sb->s_blocksize -1 ) >>2 )) <<2 ; bits = dir->i_sb->s_blocksize_bits; -if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) + iinfo =UDF_I (dir); +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) fibh.sbh = fibh.ebh =NULL ;else if (inode_bmap (dir, nf_pos >> (bits -2 ), &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >>30 )) { block =udf_get_lb_pblock (dir->i_sb, eloc, offset);if ((++offset << bits) < elen) { -if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) epos.offset -=sizeof (short_ad); -else if (UDF_I (dir)->i_alloc_type == -ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) epos.offset -=sizeof (long_ad); }else offset =0 ;
fs/udf/directory.c +4 -3
@@ -81,12 +81,13 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,struct fileIdentDesc *fi;int i, num, block;struct buffer_head *tmp, *bha[16 ]; +struct udf_inode_info *iinfo =UDF_I (dir); fibh->soffset = fibh->eoffset; -if (UDF_I (dir)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { - fi = udf_get_fileident(UDF_I(dir)->i_ext.i_data - - (UDF_I(dir)->i_efe ? +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { + fi = udf_get_fileident(iinfo->i_ext.i_data - + (iinfo->i_efe ? sizeof(struct extendedFileEntry) : sizeof(struct fileEntry)), dir->i_sb->s_blocksize,
fs/udf/file.c +11 -10
@@ -45,13 +45,13 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) {struct inode *inode = page->mapping->host;char *kaddr; +struct udf_inode_info *iinfo =UDF_I (inode);BUG_ON (!PageLocked (page)); kaddr =kmap (page);memset (kaddr,0 ,PAGE_CACHE_SIZE ); -memcpy (kaddr,UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr, - inode->i_size); +memcpy (kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);flush_dcache_page (page);SetPageUptodate (page);kunmap (page);
@@ -65,12 +65,12 @@ static int udf_adinicb_writepage(struct page *page, {struct inode *inode = page->mapping->host;char *kaddr; +struct udf_inode_info *iinfo =UDF_I (inode);BUG_ON (!PageLocked (page)); kaddr =kmap (page); -memcpy (UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr, kaddr, - inode->i_size); +memcpy (iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);mark_inode_dirty (inode);SetPageUptodate (page);kunmap (page);
@@ -87,9 +87,10 @@ static int udf_adinicb_write_end(struct file *file,struct inode *inode = mapping->host;unsigned offset = pos & (PAGE_CACHE_SIZE -1 );char *kaddr; +struct udf_inode_info *iinfo =UDF_I (inode); kaddr =kmap_atomic (page,KM_USER0 ); -memcpy (UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr + offset, +memcpy (iinfo->i_ext.i_data + iinfo->i_lenEAttr + offset, kaddr + offset, copied);kunmap_atomic (kaddr,KM_USER0 );
@@ -112,8 +113,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,struct inode *inode = file->f_path.dentry->d_inode;int err, pos;size_t count = iocb->ki_left; +struct udf_inode_info *iinfo =UDF_I (inode); -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) {if (file->f_flags &O_APPEND ) pos = inode->i_size;else
@@ -123,16 +125,15 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, (udf_file_entry_alloc_offset(inode) + pos + count)) { udf_expand_file_adinicb(inode, pos + count, &err); -if (UDF_I (inode)->i_alloc_type == -ICBTAG_FLAG_AD_IN_ICB ) { + if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { udf_debug("udf_expand_adinicb: err=%d\n", err); return err; } } else {if (pos + count > inode->i_size) -UDF_I (inode)->i_lenAlloc = pos + count; + iinfo->i_lenAlloc = pos + count;else -UDF_I (inode)->i_lenAlloc = inode->i_size; + iinfo->i_lenAlloc = inode->i_size; } }
fs/udf/ialloc.c +26 -23
94 lines not on this page · raw message
fs/udf/inode.c +162 -143
783 lines not on this page · raw message
fs/udf/misc.c +21 -19
@@ -51,17 +51,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,uint8_t *ea =NULL , *ad =NULL ;int offset;uint16_t crclen; +struct udf_inode_info *iinfo =UDF_I (inode); - ea =UDF_I (inode)->i_ext.i_data; -if (UDF_I (inode)->i_lenEAttr) { - ad =UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr; + ea = iinfo->i_ext.i_data; +if (iinfo->i_lenEAttr) { + ad = iinfo->i_ext.i_data + iinfo->i_lenEAttr; }else { ad = ea; size +=sizeof (struct extendedAttrHeaderDesc ); } offset = inode->i_sb->s_blocksize -udf_file_entry_alloc_offset (inode) - -UDF_I (inode)->i_lenAlloc; + iinfo->i_lenAlloc;/* TODO - Check for FreeEASpace */
@@ -69,21 +70,21 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,struct extendedAttrHeaderDesc *eahd; eahd = (struct extendedAttrHeaderDesc *)ea; -if (UDF_I (inode)->i_lenAlloc) -memmove (&ad[size], ad,UDF_I (inode)->i_lenAlloc); +if (iinfo->i_lenAlloc) +memmove (&ad[size], ad, iinfo->i_lenAlloc); -if (UDF_I (inode)->i_lenEAttr) { +if (iinfo->i_lenEAttr) {/* check checksum/crc */ if (eahd->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) != -UDF_I (inode)->i_location.logicalBlockNum) + iinfo->i_location.logicalBlockNum)return NULL ; }else {struct udf_sb_info *sbi =UDF_SB (inode->i_sb); size -=sizeof (struct extendedAttrHeaderDesc ); -UDF_I (inode)->i_lenEAttr += + iinfo->i_lenEAttr +=sizeof (struct extendedAttrHeaderDesc ); eahd->descTag.tagIdent =cpu_to_le16 (TAG_IDENT_EAHD );if (sbi->s_udfrev >=0x0200 )
@@ -93,15 +94,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.tagSerialNum =cpu_to_le16 (sbi->s_serial_number); eahd->descTag.tagLocation =cpu_to_le32 ( -UDF_I (inode)->i_location.logicalBlockNum); + iinfo->i_location.logicalBlockNum); eahd->impAttrLocation =cpu_to_le32 (0xFFFFFFFF ); eahd->appAttrLocation =cpu_to_le32 (0xFFFFFFFF ); } - offset =UDF_I (inode)->i_lenEAttr; + offset = iinfo->i_lenEAttr;if (type <2048 ) {if (le32_to_cpu (eahd->appAttrLocation) < -UDF_I (inode)->i_lenEAttr) { + iinfo->i_lenEAttr) {uint32_t aal =le32_to_cpu (eahd->appAttrLocation); memmove(&ea[offset - aal + size],
@@ -111,7 +112,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,cpu_to_le32 (aal + size); }if (le32_to_cpu (eahd->impAttrLocation) < -UDF_I (inode)->i_lenEAttr) { + iinfo->i_lenEAttr) {uint32_t ial =le32_to_cpu (eahd->impAttrLocation); memmove(&ea[offset - ial + size],
@@ -122,7 +123,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, } }else if (type <65536 ) {if (le32_to_cpu (eahd->appAttrLocation) < -UDF_I (inode)->i_lenEAttr) { + iinfo->i_lenEAttr) {uint32_t aal =le32_to_cpu (eahd->appAttrLocation); memmove(&ea[offset - aal + size],
@@ -138,7 +139,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, eahd->descTag.descCRC =cpu_to_le16 (udf_crc ((char *)eahd +sizeof (tag), crclen,0 )); eahd->descTag.tagChecksum =udf_tag_checksum (&eahd->descTag); -UDF_I (inode)->i_lenEAttr += size; + iinfo->i_lenEAttr += size;return (struct genericFormat *)&ea[offset]; }if (loc &0x02 )
@@ -153,10 +154,11 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,struct genericFormat *gaf;uint8_t *ea =NULL ;uint32_t offset; +struct udf_inode_info *iinfo =UDF_I (inode); - ea =UDF_I (inode)->i_ext.i_data; + ea = iinfo->i_ext.i_data; -if (UDF_I (inode)->i_lenEAttr) { +if (iinfo->i_lenEAttr) {struct extendedAttrHeaderDesc *eahd; eahd = (struct extendedAttrHeaderDesc *)ea;
@@ -164,7 +166,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,if (eahd->descTag.tagIdent !=cpu_to_le16 (TAG_IDENT_EAHD ) ||le32_to_cpu (eahd->descTag.tagLocation) != -UDF_I (inode)->i_location.logicalBlockNum) + iinfo->i_location.logicalBlockNum)return NULL ;if (type <2048 )
@@ -174,7 +176,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,else offset =le32_to_cpu (eahd->appAttrLocation); -while (offset <UDF_I (inode)->i_lenEAttr) { +while (offset < iinfo->i_lenEAttr) { gaf = (struct genericFormat *)&ea[offset];if (le32_to_cpu (gaf->attrType) == type && gaf->attrSubtype == subtype)
fs/udf/namei.c +61 -51
341 lines not on this page · raw message
fs/udf/partition.c +4 -4
@@ -55,6 +55,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,struct udf_sb_info *sbi =UDF_SB (sb);struct udf_part_map *map;struct udf_virtual_data *vdata; +struct udf_inode_info *iinfo; map = &sbi->s_partmaps[partition]; vdata = &map->s_type_specific.s_virtual;
@@ -88,15 +89,14 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,brelse (bh); -if (UDF_I (sbi->s_vat_inode)->i_location.partitionReferenceNum == - partition) { + iinfo =UDF_I (sbi->s_vat_inode); +if (iinfo->i_location.partitionReferenceNum == partition) {udf_debug ("recursive call to udf_get_pblock!\n" );return 0xFFFFFFFF ; }return udf_get_pblock (sb, loc, -UDF_I (sbi->s_vat_inode)->i_location. - partitionReferenceNum, + iinfo->i_location.partitionReferenceNum, offset); }
fs/udf/symlink.c +4 -2
@@ -79,10 +79,12 @@ static int udf_symlink_filler(struct file *file, struct page *page)char *symlink;int err = -EIO ;char *p =kmap (page); +struct udf_inode_info *iinfo;lock_kernel (); -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { - symlink =UDF_I (inode)->i_ext.i_data +UDF_I (inode)->i_lenEAttr; + iinfo =UDF_I (inode); +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) { + symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr; }else { bh =sb_bread (inode->i_sb,udf_block_map (inode,0 ));
fs/udf/truncate.c +20 -17
@@ -74,17 +74,18 @@ void udf_truncate_tail_extent(struct inode *inode)uint64_t lbcount =0 ;int8_t etype =-1 , netype;int adsize; +struct udf_inode_info *iinfo =UDF_I (inode); -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || - inode->i_size ==UDF_I (inode)->i_lenExtents) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || + inode->i_size == iinfo->i_lenExtents)return ;/* Are we going to delete the file anyway? */ if (inode->i_nlink ==0 )return ; -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else BUG ();
@@ -117,7 +118,7 @@ void udf_truncate_tail_extent(struct inode *inode) }/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ -UDF_I (inode)->i_lenExtents = inode->i_size; + iinfo->i_lenExtents = inode->i_size;brelse (epos.bh); }
@@ -129,19 +130,20 @@ void udf_discard_prealloc(struct inode *inode)uint64_t lbcount =0 ;int8_t etype =-1 , netype;int adsize; +struct udf_inode_info *iinfo =UDF_I (inode); -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || - inode->i_size ==UDF_I (inode)->i_lenExtents) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB || + inode->i_size == iinfo->i_lenExtents)return ; -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else adsize =0 ; - epos.block =UDF_I (inode)->i_location; + epos.block = iinfo->i_location;/* Find the last extent in the file */ while ((netype =udf_next_aext (inode, &epos, &eloc, &elen,1 )) !=-1 ) {
@@ -153,7 +155,7 @@ void udf_discard_prealloc(struct inode *inode) lbcount -= elen;extent_trunc (inode, &epos, eloc, etype, elen,0 );if (!epos.bh) { -UDF_I (inode)->i_lenAlloc = + iinfo->i_lenAlloc = epos.offset -udf_file_entry_alloc_offset (inode);mark_inode_dirty (inode);
@@ -174,7 +176,7 @@ void udf_discard_prealloc(struct inode *inode) }/* This inode entry is in-memory only and thus we don't have to mark * the inode dirty */ -UDF_I (inode)->i_lenExtents = lbcount; + iinfo->i_lenExtents = lbcount;brelse (epos.bh); }
@@ -189,10 +191,11 @@ void udf_truncate_extents(struct inode *inode)sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;loff_t byte_offset;int adsize; +struct udf_inode_info *iinfo =UDF_I (inode); -if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) +if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_SHORT ) adsize =sizeof (short_ad); -else if (UDF_I (inode)->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) +else if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_LONG ) adsize =sizeof (long_ad);else BUG ();
@@ -227,7 +230,7 @@ void udf_truncate_extents(struct inode *inode) 0, indirect_ext_len); }else {if (!epos.bh) { -UDF_I (inode)->i_lenAlloc = + iinfo->i_lenAlloc = lenalloc;mark_inode_dirty (inode); }else {
@@ -275,7 +278,7 @@ void udf_truncate_extents(struct inode *inode) indirect_ext_len); }else {if (!epos.bh) { -UDF_I (inode)->i_lenAlloc = lenalloc; + iinfo->i_lenAlloc = lenalloc;mark_inode_dirty (inode); }else { struct allocExtDesc *aed =
@@ -325,7 +328,7 @@ void udf_truncate_extents(struct inode *inode) (sb->s_blocksize - 1)) != 0)); } } -UDF_I (inode)->i_lenExtents = inode->i_size; + iinfo->i_lenExtents = inode->i_size;brelse (epos.bh); }
Signature · 1 line
1.5.3.7
PATCH 15/16 udf: fix udf_debug macro
In reply to [email protected]udf_debug should be enclosed with do { } while (0) to be safely used in code like below:
if (something)
udf_debug(); else anything;
(Otherwise compiler will not compile it with:
"error: expected expression before 'else'")
--- include/linux/udf_fs.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/udf_fs.h +2 -2
@@ -39,11 +39,11 @@#ifdef UDFFS_DEBUG #define udf_debug(f, a...) \ - { \ + do { \ printk (KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \ __FILE__, __LINE__, __FUNCTION__); \ printk (f, ##a); \ - } + } while (0)#else #define udf_debug(f, a...) /**/#endif
Signature · 1 line
1.5.3.7
Re: [PATCH 15/16] udf: fix udf_debug macro
Quoted 23 lines · On Thu 10-01-08 23:06:31, [email protected] wrote:
udf_debugshould be enclosed with do { } while (0) to be safely used in code like below:
if (something)udf_debug(); else anything;(Otherwise compiler will not compile it with:
"error: expected expression before 'else'")Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>--- include/linux/udf_fs.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)include/linux/udf_fs.h +0
-0@@ -39,11 +39,11 @@#ifdef UDFFS_DEBUG #define udf_debug(f, a...) \
include/linux/udf_fs.h line 49
Quoted 10 lines
include/linux/udf_fs.h +2
-2- { \ +do { \printk (KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: " , \ __FILE__, __LINE__, __FUNCTION__); \ printk (f, ##a); \ - } + } while (0)#else #define udf_debug(f, a...) /**/#endif
Actually, in that case you should also change /**/ to do {} while (0)
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 16/16 udf: improve readability of udf_load_partition
In reply to [email protected]--- fs/udf/super.c | 59 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 30 insertions(+), 29 deletions(-)
fs/udf/super.c +30 -29
@@ -1447,44 +1447,45 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) sbi =UDF_SB (sb);for (i =0 ; i <ARRAY_SIZE (sbi->s_anchor); i++) { -if (sbi->s_anchor[i] && - (bh =udf_read_tagged (sb, sbi->s_anchor[i], - sbi->s_anchor[i], &ident))) { - anchor = (struct anchorVolDescPtr *)bh->b_data; - -/* Locate the main sequence */ - main_s =le32_to_cpu ( - anchor->mainVolDescSeqExt.extLocation); - main_e =le32_to_cpu ( - anchor->mainVolDescSeqExt.extLength); - main_e = main_e >> sb->s_blocksize_bits; - main_e += main_s; - -/* Locate the reserve sequence */ - reserve_s =le32_to_cpu ( +if (!sbi->s_anchor[i]) +continue ; + bh =udf_read_tagged (sb, sbi->s_anchor[i], sbi->s_anchor[i], + &ident); +if (!bh) +continue ; + + anchor = (struct anchorVolDescPtr *)bh->b_data; + +/* Locate the main sequence */ + main_s =le32_to_cpu (anchor->mainVolDescSeqExt.extLocation); + main_e =le32_to_cpu (anchor->mainVolDescSeqExt.extLength); + main_e = main_e >> sb->s_blocksize_bits; + main_e += main_s; + +/* Locate the reserve sequence */ + reserve_s =le32_to_cpu ( anchor->reserveVolDescSeqExt.extLocation); - reserve_e =le32_to_cpu ( + reserve_e =le32_to_cpu ( anchor->reserveVolDescSeqExt.extLength); - reserve_e = reserve_e >> sb->s_blocksize_bits; - reserve_e += reserve_s; + reserve_e = reserve_e >> sb->s_blocksize_bits; + reserve_e += reserve_s; -brelse (bh); +brelse (bh); -/* 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))) -break ; - } +/* 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))) +break ; }if (i ==ARRAY_SIZE (sbi->s_anchor)) {udf_debug ("No Anchor block found\n" );return 1 ; - }else -udf_debug ("Using anchor in block %d\n" , sbi->s_anchor[i]); + } +udf_debug ("Using anchor in block %d\n" , sbi->s_anchor[i]);for (i =0 ; i < sbi->s_partitions; i++) {kernel_lb_addr uninitialized_var (ino );
Signature · 1 line
1.5.3.7
Re: [PATCH 16/16] udf: improve readability of udf_load_partition
Quoted 3 lines · On Thu 10-01-08 23:06:32, [email protected] wrote:
Signed-off-by Marcin Slusarz <[email protected]>CC Jan Kara <[email protected]>CC Christoph Hellwig <[email protected]>
Quoted 86 lines
--- fs/udf/super.c | 59 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 30 insertions(+), 29 deletions(-)fs/udf/super.c +30
-29@@ -1447,44 +1447,45 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) sbi =UDF_SB (sb);for (i =0 ; i <ARRAY_SIZE (sbi->s_anchor); i++) { -if (sbi->s_anchor[i] && - (bh =udf_read_tagged (sb, sbi->s_anchor[i], - sbi->s_anchor[i], &ident))) { - anchor = (struct anchorVolDescPtr *)bh->b_data; - -/* Locate the main sequence */ - main_s =le32_to_cpu ( - anchor->mainVolDescSeqExt.extLocation); - main_e =le32_to_cpu ( - anchor->mainVolDescSeqExt.extLength); - main_e = main_e >> sb->s_blocksize_bits; - main_e += main_s; - -/* Locate the reserve sequence */ - reserve_s =le32_to_cpu ( +if (!sbi->s_anchor[i]) +continue ; + bh =udf_read_tagged (sb, sbi->s_anchor[i], sbi->s_anchor[i], + &ident); +if (!bh) +continue ; + + anchor = (struct anchorVolDescPtr *)bh->b_data; + +/* Locate the main sequence */ + main_s =le32_to_cpu (anchor->mainVolDescSeqExt.extLocation); + main_e =le32_to_cpu (anchor->mainVolDescSeqExt.extLength); + main_e = main_e >> sb->s_blocksize_bits; + main_e += main_s; + +/* Locate the reserve sequence */ + reserve_s =le32_to_cpu ( anchor->reserveVolDescSeqExt.extLocation); - reserve_e =le32_to_cpu ( + reserve_e =le32_to_cpu ( anchor->reserveVolDescSeqExt.extLength); - reserve_e = reserve_e >> sb->s_blocksize_bits; - reserve_e += reserve_s; + reserve_e = reserve_e >> sb->s_blocksize_bits; + reserve_e += reserve_s; -brelse (bh); +brelse (bh); -/* 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))) -break ; - } +/* 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))) +break ; }if (i ==ARRAY_SIZE (sbi->s_anchor)) {udf_debug ("No Anchor block found\n" );return 1 ; - }else -udf_debug ("Using anchor in block %d\n" , sbi->s_anchor[i]); + } +udf_debug ("Using anchor in block %d\n" , sbi->s_anchor[i]);for (i =0 ; i < sbi->s_partitions; i++) {kernel_lb_addr uninitialized_var (ino );Signature · 1 line
1.5.3.7
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 10 lines · On Thu, Jan 10, 2008 at 11:06:16PM +0100, [email protected] wrote:
Hi
This patchset contains various UDF fs cleanups.
It deprecates two patchsets I sent lately:http://lkml.org/lkml/2008/1/5/196 [PATCH 0/6] udf: improve code related to
super_blockv3
http://lkml.org/lkml/2008/1/5/211 [PATCH 0/7] udf: more cleanupsI hope I addressed all comments sent by Christoph Hellwig and Jan Kara. Thanks for review!
The whole patch series looks fine to me.