aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 13:00:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 13:00:14 -0400
commit9a7259d5c8978bbeb5fdcf64b168f8470d8208a6 (patch)
tree5c255d4b18622de06c2637c0c4069a384e99466d /fs/udf
parente9c0f1529c9022afbab16a442382aa9a84a79c41 (diff)
parente703c206135acb458adb705ec44bcc5d2615b37d (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext3, UDF, and quota fixes from Jan Kara: "A couple of ext3 & UDF fixes and also one improvement in quota locking." * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: ext3: fix start and len arguments handling in ext3_trim_fs() udf: Fix deadlock in udf_release_file() udf: Fix file entry logicalBlocksRecorded udf: Fix handling of i_blocks quota: Make quota code not call tty layer with dqptr_sem held udf: Init/maintain file entry checkpoint field ext3: Update ctime in ext3_splice_branch() only when needed ext3: Don't call dquot_free_block() if we don't update anything udf: Remove unnecessary OOM messages
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/balloc.c84
-rw-r--r--fs/udf/ialloc.c1
-rw-r--r--fs/udf/inode.c20
-rw-r--r--fs/udf/super.c5
-rw-r--r--fs/udf/udf_i.h1
5 files changed, 63 insertions, 48 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 987585bb0a1d..1ba2baaf4367 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -105,7 +105,6 @@ static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt)
105} 105}
106 106
107static void udf_bitmap_free_blocks(struct super_block *sb, 107static void udf_bitmap_free_blocks(struct super_block *sb,
108 struct inode *inode,
109 struct udf_bitmap *bitmap, 108 struct udf_bitmap *bitmap,
110 struct kernel_lb_addr *bloc, 109 struct kernel_lb_addr *bloc,
111 uint32_t offset, 110 uint32_t offset,
@@ -172,7 +171,6 @@ error_return:
172} 171}
173 172
174static int udf_bitmap_prealloc_blocks(struct super_block *sb, 173static int udf_bitmap_prealloc_blocks(struct super_block *sb,
175 struct inode *inode,
176 struct udf_bitmap *bitmap, 174 struct udf_bitmap *bitmap,
177 uint16_t partition, uint32_t first_block, 175 uint16_t partition, uint32_t first_block,
178 uint32_t block_count) 176 uint32_t block_count)
@@ -223,7 +221,6 @@ out:
223} 221}
224 222
225static int udf_bitmap_new_block(struct super_block *sb, 223static int udf_bitmap_new_block(struct super_block *sb,
226 struct inode *inode,
227 struct udf_bitmap *bitmap, uint16_t partition, 224 struct udf_bitmap *bitmap, uint16_t partition,
228 uint32_t goal, int *err) 225 uint32_t goal, int *err)
229{ 226{
@@ -349,7 +346,6 @@ error_return:
349} 346}
350 347
351static void udf_table_free_blocks(struct super_block *sb, 348static void udf_table_free_blocks(struct super_block *sb,
352 struct inode *inode,
353 struct inode *table, 349 struct inode *table,
354 struct kernel_lb_addr *bloc, 350 struct kernel_lb_addr *bloc,
355 uint32_t offset, 351 uint32_t offset,
@@ -581,7 +577,6 @@ error_return:
581} 577}
582 578
583static int udf_table_prealloc_blocks(struct super_block *sb, 579static int udf_table_prealloc_blocks(struct super_block *sb,
584 struct inode *inode,
585 struct inode *table, uint16_t partition, 580 struct inode *table, uint16_t partition,
586 uint32_t first_block, uint32_t block_count) 581 uint32_t first_block, uint32_t block_count)
587{ 582{
@@ -643,7 +638,6 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
643} 638}
644 639
645static int udf_table_new_block(struct super_block *sb, 640static int udf_table_new_block(struct super_block *sb,
646 struct inode *inode,
647 struct inode *table, uint16_t partition, 641 struct inode *table, uint16_t partition,
648 uint32_t goal, int *err) 642 uint32_t goal, int *err)
649{ 643{
@@ -743,18 +737,23 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,
743 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 737 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
744 738
745 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { 739 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
746 udf_bitmap_free_blocks(sb, inode, map->s_uspace.s_bitmap, 740 udf_bitmap_free_blocks(sb, map->s_uspace.s_bitmap,
747 bloc, offset, count); 741 bloc, offset, count);
748 } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { 742 } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
749 udf_table_free_blocks(sb, inode, map->s_uspace.s_table, 743 udf_table_free_blocks(sb, map->s_uspace.s_table,
750 bloc, offset, count); 744 bloc, offset, count);
751 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { 745 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
752 udf_bitmap_free_blocks(sb, inode, map->s_fspace.s_bitmap, 746 udf_bitmap_free_blocks(sb, map->s_fspace.s_bitmap,
753 bloc, offset, count); 747 bloc, offset, count);
754 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { 748 } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
755 udf_table_free_blocks(sb, inode, map->s_fspace.s_table, 749 udf_table_free_blocks(sb, map->s_fspace.s_table,
756 bloc, offset, count); 750 bloc, offset, count);
757 } 751 }
752
753 if (inode) {
754 inode_sub_bytes(inode,
755 ((sector_t)count) << sb->s_blocksize_bits);
756 }
758} 757}
759 758
760inline int udf_prealloc_blocks(struct super_block *sb, 759inline int udf_prealloc_blocks(struct super_block *sb,
@@ -763,29 +762,34 @@ inline int udf_prealloc_blocks(struct super_block *sb,
763 uint32_t block_count) 762 uint32_t block_count)
764{ 763{
765 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 764 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
765 sector_t allocated;
766 766
767 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 767 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
768 return udf_bitmap_prealloc_blocks(sb, inode, 768 allocated = udf_bitmap_prealloc_blocks(sb,
769 map->s_uspace.s_bitmap, 769 map->s_uspace.s_bitmap,
770 partition, first_block, 770 partition, first_block,
771 block_count); 771 block_count);
772 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 772 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
773 return udf_table_prealloc_blocks(sb, inode, 773 allocated = udf_table_prealloc_blocks(sb,
774 map->s_uspace.s_table, 774 map->s_uspace.s_table,
775 partition, first_block, 775 partition, first_block,
776 block_count); 776 block_count);
777 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) 777 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
778 return udf_bitmap_prealloc_blocks(sb, inode, 778 allocated = udf_bitmap_prealloc_blocks(sb,
779 map->s_fspace.s_bitmap, 779 map->s_fspace.s_bitmap,
780 partition, first_block, 780 partition, first_block,
781 block_count); 781 block_count);
782 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 782 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
783 return udf_table_prealloc_blocks(sb, inode, 783 allocated = udf_table_prealloc_blocks(sb,
784 map->s_fspace.s_table, 784 map->s_fspace.s_table,
785 partition, first_block, 785 partition, first_block,
786 block_count); 786 block_count);
787 else 787 else
788 return 0; 788 return 0;
789
790 if (inode && allocated > 0)
791 inode_add_bytes(inode, allocated << sb->s_blocksize_bits);
792 return allocated;
789} 793}
790 794
791inline int udf_new_block(struct super_block *sb, 795inline int udf_new_block(struct super_block *sb,
@@ -793,25 +797,29 @@ inline int udf_new_block(struct super_block *sb,
793 uint16_t partition, uint32_t goal, int *err) 797 uint16_t partition, uint32_t goal, int *err)
794{ 798{
795 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; 799 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
800 int block;
796 801
797 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) 802 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
798 return udf_bitmap_new_block(sb, inode, 803 block = udf_bitmap_new_block(sb,
799 map->s_uspace.s_bitmap, 804 map->s_uspace.s_bitmap,
800 partition, goal, err); 805 partition, goal, err);
801 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) 806 else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
802 return udf_table_new_block(sb, inode, 807 block = udf_table_new_block(sb,
803 map->s_uspace.s_table, 808 map->s_uspace.s_table,
804 partition, goal, err);
805 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
806 return udf_bitmap_new_block(sb, inode,
807 map->s_fspace.s_bitmap,
808 partition, goal, err); 809 partition, goal, err);
810 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
811 block = udf_bitmap_new_block(sb,
812 map->s_fspace.s_bitmap,
813 partition, goal, err);
809 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) 814 else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
810 return udf_table_new_block(sb, inode, 815 block = udf_table_new_block(sb,
811 map->s_fspace.s_table, 816 map->s_fspace.s_table,
812 partition, goal, err); 817 partition, goal, err);
813 else { 818 else {
814 *err = -EIO; 819 *err = -EIO;
815 return 0; 820 return 0;
816 } 821 }
822 if (inode && block)
823 inode_add_bytes(inode, sb->s_blocksize);
824 return block;
817} 825}
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 05ab48195be9..7e5aae4bf46f 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -116,6 +116,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode, int *err)
116 iinfo->i_lenEAttr = 0; 116 iinfo->i_lenEAttr = 0;
117 iinfo->i_lenAlloc = 0; 117 iinfo->i_lenAlloc = 0;
118 iinfo->i_use = 0; 118 iinfo->i_use = 0;
119 iinfo->i_checkpoint = 1;
119 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 120 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
120 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; 121 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
121 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) 122 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 7699df7b3198..7d7528008359 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1358,6 +1358,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1358 iinfo->i_unique = le64_to_cpu(fe->uniqueID); 1358 iinfo->i_unique = le64_to_cpu(fe->uniqueID);
1359 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1359 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
1360 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); 1360 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs);
1361 iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint);
1361 offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr; 1362 offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr;
1362 } else { 1363 } else {
1363 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1364 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
@@ -1379,6 +1380,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1379 iinfo->i_unique = le64_to_cpu(efe->uniqueID); 1380 iinfo->i_unique = le64_to_cpu(efe->uniqueID);
1380 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1381 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
1381 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); 1382 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs);
1383 iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint);
1382 offset = sizeof(struct extendedFileEntry) + 1384 offset = sizeof(struct extendedFileEntry) +
1383 iinfo->i_lenEAttr; 1385 iinfo->i_lenEAttr;
1384 } 1386 }
@@ -1495,6 +1497,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1495 struct buffer_head *bh = NULL; 1497 struct buffer_head *bh = NULL;
1496 struct fileEntry *fe; 1498 struct fileEntry *fe;
1497 struct extendedFileEntry *efe; 1499 struct extendedFileEntry *efe;
1500 uint64_t lb_recorded;
1498 uint32_t udfperms; 1501 uint32_t udfperms;
1499 uint16_t icbflags; 1502 uint16_t icbflags;
1500 uint16_t crclen; 1503 uint16_t crclen;
@@ -1589,13 +1592,18 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1589 dsea->minorDeviceIdent = cpu_to_le32(iminor(inode)); 1592 dsea->minorDeviceIdent = cpu_to_le32(iminor(inode));
1590 } 1593 }
1591 1594
1595 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
1596 lb_recorded = 0; /* No extents => no blocks! */
1597 else
1598 lb_recorded =
1599 (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >>
1600 (blocksize_bits - 9);
1601
1592 if (iinfo->i_efe == 0) { 1602 if (iinfo->i_efe == 0) {
1593 memcpy(bh->b_data + sizeof(struct fileEntry), 1603 memcpy(bh->b_data + sizeof(struct fileEntry),
1594 iinfo->i_ext.i_data, 1604 iinfo->i_ext.i_data,
1595 inode->i_sb->s_blocksize - sizeof(struct fileEntry)); 1605 inode->i_sb->s_blocksize - sizeof(struct fileEntry));
1596 fe->logicalBlocksRecorded = cpu_to_le64( 1606 fe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
1597 (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >>
1598 (blocksize_bits - 9));
1599 1607
1600 udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime); 1608 udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
1601 udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime); 1609 udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
@@ -1607,6 +1615,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1607 fe->uniqueID = cpu_to_le64(iinfo->i_unique); 1615 fe->uniqueID = cpu_to_le64(iinfo->i_unique);
1608 fe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); 1616 fe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr);
1609 fe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); 1617 fe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc);
1618 fe->checkpoint = cpu_to_le32(iinfo->i_checkpoint);
1610 fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); 1619 fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE);
1611 crclen = sizeof(struct fileEntry); 1620 crclen = sizeof(struct fileEntry);
1612 } else { 1621 } else {
@@ -1615,9 +1624,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1615 inode->i_sb->s_blocksize - 1624 inode->i_sb->s_blocksize -
1616 sizeof(struct extendedFileEntry)); 1625 sizeof(struct extendedFileEntry));
1617 efe->objectSize = cpu_to_le64(inode->i_size); 1626 efe->objectSize = cpu_to_le64(inode->i_size);
1618 efe->logicalBlocksRecorded = cpu_to_le64( 1627 efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
1619 (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >>
1620 (blocksize_bits - 9));
1621 1628
1622 if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec || 1629 if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec ||
1623 (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec && 1630 (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec &&
@@ -1646,6 +1653,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1646 efe->uniqueID = cpu_to_le64(iinfo->i_unique); 1653 efe->uniqueID = cpu_to_le64(iinfo->i_unique);
1647 efe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); 1654 efe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr);
1648 efe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); 1655 efe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc);
1656 efe->checkpoint = cpu_to_le32(iinfo->i_checkpoint);
1649 efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE); 1657 efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE);
1650 crclen = sizeof(struct extendedFileEntry); 1658 crclen = sizeof(struct extendedFileEntry);
1651 } 1659 }
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 85067b4c7e14..ac8a348dcb69 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -950,11 +950,8 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
950 else 950 else
951 bitmap = vzalloc(size); /* TODO: get rid of vzalloc */ 951 bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
952 952
953 if (bitmap == NULL) { 953 if (bitmap == NULL)
954 udf_err(sb, "Unable to allocate space for bitmap and %d buffer_head pointers\n",
955 nr_groups);
956 return NULL; 954 return NULL;
957 }
958 955
959 bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1); 956 bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
960 bitmap->s_nr_groups = nr_groups; 957 bitmap->s_nr_groups = nr_groups;
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
index d1bd31ea724e..bb8309dcd5c1 100644
--- a/fs/udf/udf_i.h
+++ b/fs/udf/udf_i.h
@@ -23,6 +23,7 @@ struct udf_inode_info {
23 __u64 i_lenExtents; 23 __u64 i_lenExtents;
24 __u32 i_next_alloc_block; 24 __u32 i_next_alloc_block;
25 __u32 i_next_alloc_goal; 25 __u32 i_next_alloc_goal;
26 __u32 i_checkpoint;
26 unsigned i_alloc_type : 3; 27 unsigned i_alloc_type : 3;
27 unsigned i_efe : 1; /* extendedFileEntry */ 28 unsigned i_efe : 1; /* extendedFileEntry */
28 unsigned i_use : 1; /* unallocSpaceEntry */ 29 unsigned i_use : 1; /* unallocSpaceEntry */