diff options
-rw-r--r-- | fs/ext2/ext2.h | 1 | ||||
-rw-r--r-- | fs/ext2/file.c | 1 | ||||
-rw-r--r-- | fs/ext2/ialloc.c | 2 | ||||
-rw-r--r-- | fs/ext2/inode.c | 30 | ||||
-rw-r--r-- | fs/ext2/namei.c | 2 | ||||
-rw-r--r-- | fs/ext2/super.c | 44 | ||||
-rw-r--r-- | fs/ext2/symlink.c | 2 | ||||
-rw-r--r-- | fs/ext2/xattr.c | 1 | ||||
-rw-r--r-- | fs/udf/super.c | 51 |
9 files changed, 97 insertions, 37 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 93fcfe7bbb3b..10ab238de9a6 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -758,6 +758,7 @@ extern int ext2_write_inode (struct inode *, struct writeback_control *); | |||
758 | extern void ext2_evict_inode(struct inode *); | 758 | extern void ext2_evict_inode(struct inode *); |
759 | extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); | 759 | extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); |
760 | extern int ext2_setattr (struct dentry *, struct iattr *); | 760 | extern int ext2_setattr (struct dentry *, struct iattr *); |
761 | extern int ext2_getattr (const struct path *, struct kstat *, u32, unsigned int); | ||
761 | extern void ext2_set_inode_flags(struct inode *inode); | 762 | extern void ext2_set_inode_flags(struct inode *inode); |
762 | extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | 763 | extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
763 | u64 start, u64 len); | 764 | u64 start, u64 len); |
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 28b2609f25c1..39c4772e96c9 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
@@ -199,6 +199,7 @@ const struct inode_operations ext2_file_inode_operations = { | |||
199 | #ifdef CONFIG_EXT2_FS_XATTR | 199 | #ifdef CONFIG_EXT2_FS_XATTR |
200 | .listxattr = ext2_listxattr, | 200 | .listxattr = ext2_listxattr, |
201 | #endif | 201 | #endif |
202 | .getattr = ext2_getattr, | ||
202 | .setattr = ext2_setattr, | 203 | .setattr = ext2_setattr, |
203 | .get_acl = ext2_get_acl, | 204 | .get_acl = ext2_get_acl, |
204 | .set_acl = ext2_set_acl, | 205 | .set_acl = ext2_set_acl, |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 5c3d7b7e4975..a0c5ea91fcd4 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -222,8 +222,6 @@ static int find_group_dir(struct super_block *sb, struct inode *parent) | |||
222 | best_desc = desc; | 222 | best_desc = desc; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | if (!best_desc) | ||
226 | return -1; | ||
227 | 225 | ||
228 | return best_group; | 226 | return best_group; |
229 | } | 227 | } |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index e4bb9386c045..c27c27300d95 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -717,7 +717,7 @@ static int ext2_get_blocks(struct inode *inode, | |||
717 | /* the number of blocks need to allocate for [d,t]indirect blocks */ | 717 | /* the number of blocks need to allocate for [d,t]indirect blocks */ |
718 | indirect_blks = (chain + depth) - partial - 1; | 718 | indirect_blks = (chain + depth) - partial - 1; |
719 | /* | 719 | /* |
720 | * Next look up the indirect map to count the totoal number of | 720 | * Next look up the indirect map to count the total number of |
721 | * direct blocks to allocate for this branch. | 721 | * direct blocks to allocate for this branch. |
722 | */ | 722 | */ |
723 | count = ext2_blks_to_allocate(partial, indirect_blks, | 723 | count = ext2_blks_to_allocate(partial, indirect_blks, |
@@ -1239,6 +1239,7 @@ do_indirects: | |||
1239 | mark_inode_dirty(inode); | 1239 | mark_inode_dirty(inode); |
1240 | ext2_free_branches(inode, &nr, &nr+1, 1); | 1240 | ext2_free_branches(inode, &nr, &nr+1, 1); |
1241 | } | 1241 | } |
1242 | /* fall through */ | ||
1242 | case EXT2_IND_BLOCK: | 1243 | case EXT2_IND_BLOCK: |
1243 | nr = i_data[EXT2_DIND_BLOCK]; | 1244 | nr = i_data[EXT2_DIND_BLOCK]; |
1244 | if (nr) { | 1245 | if (nr) { |
@@ -1246,6 +1247,7 @@ do_indirects: | |||
1246 | mark_inode_dirty(inode); | 1247 | mark_inode_dirty(inode); |
1247 | ext2_free_branches(inode, &nr, &nr+1, 2); | 1248 | ext2_free_branches(inode, &nr, &nr+1, 2); |
1248 | } | 1249 | } |
1250 | /* fall through */ | ||
1249 | case EXT2_DIND_BLOCK: | 1251 | case EXT2_DIND_BLOCK: |
1250 | nr = i_data[EXT2_TIND_BLOCK]; | 1252 | nr = i_data[EXT2_TIND_BLOCK]; |
1251 | if (nr) { | 1253 | if (nr) { |
@@ -1635,6 +1637,32 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
1635 | return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); | 1637 | return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); |
1636 | } | 1638 | } |
1637 | 1639 | ||
1640 | int ext2_getattr(const struct path *path, struct kstat *stat, | ||
1641 | u32 request_mask, unsigned int query_falgs) | ||
1642 | { | ||
1643 | struct inode *inode = d_inode(path->dentry); | ||
1644 | struct ext2_inode_info *ei = EXT2_I(inode); | ||
1645 | unsigned int flags; | ||
1646 | |||
1647 | flags = ei->i_flags & EXT2_FL_USER_VISIBLE; | ||
1648 | if (flags & EXT2_APPEND_FL) | ||
1649 | stat->attributes |= STATX_ATTR_APPEND; | ||
1650 | if (flags & EXT2_COMPR_FL) | ||
1651 | stat->attributes |= STATX_ATTR_COMPRESSED; | ||
1652 | if (flags & EXT2_IMMUTABLE_FL) | ||
1653 | stat->attributes |= STATX_ATTR_IMMUTABLE; | ||
1654 | if (flags & EXT2_NODUMP_FL) | ||
1655 | stat->attributes |= STATX_ATTR_NODUMP; | ||
1656 | stat->attributes_mask |= (STATX_ATTR_APPEND | | ||
1657 | STATX_ATTR_COMPRESSED | | ||
1658 | STATX_ATTR_ENCRYPTED | | ||
1659 | STATX_ATTR_IMMUTABLE | | ||
1660 | STATX_ATTR_NODUMP); | ||
1661 | |||
1662 | generic_fillattr(inode, stat); | ||
1663 | return 0; | ||
1664 | } | ||
1665 | |||
1638 | int ext2_setattr(struct dentry *dentry, struct iattr *iattr) | 1666 | int ext2_setattr(struct dentry *dentry, struct iattr *iattr) |
1639 | { | 1667 | { |
1640 | struct inode *inode = d_inode(dentry); | 1668 | struct inode *inode = d_inode(dentry); |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 0c26dcc5d850..ccfbbf59e2fc 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -416,6 +416,7 @@ const struct inode_operations ext2_dir_inode_operations = { | |||
416 | #ifdef CONFIG_EXT2_FS_XATTR | 416 | #ifdef CONFIG_EXT2_FS_XATTR |
417 | .listxattr = ext2_listxattr, | 417 | .listxattr = ext2_listxattr, |
418 | #endif | 418 | #endif |
419 | .getattr = ext2_getattr, | ||
419 | .setattr = ext2_setattr, | 420 | .setattr = ext2_setattr, |
420 | .get_acl = ext2_get_acl, | 421 | .get_acl = ext2_get_acl, |
421 | .set_acl = ext2_set_acl, | 422 | .set_acl = ext2_set_acl, |
@@ -426,6 +427,7 @@ const struct inode_operations ext2_special_inode_operations = { | |||
426 | #ifdef CONFIG_EXT2_FS_XATTR | 427 | #ifdef CONFIG_EXT2_FS_XATTR |
427 | .listxattr = ext2_listxattr, | 428 | .listxattr = ext2_listxattr, |
428 | #endif | 429 | #endif |
430 | .getattr = ext2_getattr, | ||
429 | .setattr = ext2_setattr, | 431 | .setattr = ext2_setattr, |
430 | .get_acl = ext2_get_acl, | 432 | .get_acl = ext2_get_acl, |
431 | .set_acl = ext2_set_acl, | 433 | .set_acl = ext2_set_acl, |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 73b2d528237f..0128010a0874 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -757,7 +757,8 @@ static loff_t ext2_max_size(int bits) | |||
757 | { | 757 | { |
758 | loff_t res = EXT2_NDIR_BLOCKS; | 758 | loff_t res = EXT2_NDIR_BLOCKS; |
759 | int meta_blocks; | 759 | int meta_blocks; |
760 | loff_t upper_limit; | 760 | unsigned int upper_limit; |
761 | unsigned int ppb = 1 << (bits-2); | ||
761 | 762 | ||
762 | /* This is calculated to be the largest file size for a | 763 | /* This is calculated to be the largest file size for a |
763 | * dense, file such that the total number of | 764 | * dense, file such that the total number of |
@@ -771,24 +772,34 @@ static loff_t ext2_max_size(int bits) | |||
771 | /* total blocks in file system block size */ | 772 | /* total blocks in file system block size */ |
772 | upper_limit >>= (bits - 9); | 773 | upper_limit >>= (bits - 9); |
773 | 774 | ||
775 | /* Compute how many blocks we can address by block tree */ | ||
776 | res += 1LL << (bits-2); | ||
777 | res += 1LL << (2*(bits-2)); | ||
778 | res += 1LL << (3*(bits-2)); | ||
779 | /* Does block tree limit file size? */ | ||
780 | if (res < upper_limit) | ||
781 | goto check_lfs; | ||
774 | 782 | ||
783 | res = upper_limit; | ||
784 | /* How many metadata blocks are needed for addressing upper_limit? */ | ||
785 | upper_limit -= EXT2_NDIR_BLOCKS; | ||
775 | /* indirect blocks */ | 786 | /* indirect blocks */ |
776 | meta_blocks = 1; | 787 | meta_blocks = 1; |
788 | upper_limit -= ppb; | ||
777 | /* double indirect blocks */ | 789 | /* double indirect blocks */ |
778 | meta_blocks += 1 + (1LL << (bits-2)); | 790 | if (upper_limit < ppb * ppb) { |
779 | /* tripple indirect blocks */ | 791 | meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb); |
780 | meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); | 792 | res -= meta_blocks; |
781 | 793 | goto check_lfs; | |
782 | upper_limit -= meta_blocks; | 794 | } |
783 | upper_limit <<= bits; | 795 | meta_blocks += 1 + ppb; |
784 | 796 | upper_limit -= ppb * ppb; | |
785 | res += 1LL << (bits-2); | 797 | /* tripple indirect blocks for the rest */ |
786 | res += 1LL << (2*(bits-2)); | 798 | meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) + |
787 | res += 1LL << (3*(bits-2)); | 799 | DIV_ROUND_UP(upper_limit, ppb*ppb); |
800 | res -= meta_blocks; | ||
801 | check_lfs: | ||
788 | res <<= bits; | 802 | res <<= bits; |
789 | if (res > upper_limit) | ||
790 | res = upper_limit; | ||
791 | |||
792 | if (res > MAX_LFS_FILESIZE) | 803 | if (res > MAX_LFS_FILESIZE) |
793 | res = MAX_LFS_FILESIZE; | 804 | res = MAX_LFS_FILESIZE; |
794 | 805 | ||
@@ -1024,8 +1035,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1024 | sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); | 1035 | sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); |
1025 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); | 1036 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); |
1026 | 1037 | ||
1027 | if (EXT2_INODE_SIZE(sb) == 0) | ||
1028 | goto cantfind_ext2; | ||
1029 | sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); | 1038 | sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); |
1030 | if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0) | 1039 | if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0) |
1031 | goto cantfind_ext2; | 1040 | goto cantfind_ext2; |
@@ -1087,12 +1096,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1087 | sizeof(struct buffer_head *), | 1096 | sizeof(struct buffer_head *), |
1088 | GFP_KERNEL); | 1097 | GFP_KERNEL); |
1089 | if (sbi->s_group_desc == NULL) { | 1098 | if (sbi->s_group_desc == NULL) { |
1099 | ret = -ENOMEM; | ||
1090 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); | 1100 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); |
1091 | goto failed_mount; | 1101 | goto failed_mount; |
1092 | } | 1102 | } |
1093 | bgl_lock_init(sbi->s_blockgroup_lock); | 1103 | bgl_lock_init(sbi->s_blockgroup_lock); |
1094 | sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); | 1104 | sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); |
1095 | if (!sbi->s_debts) { | 1105 | if (!sbi->s_debts) { |
1106 | ret = -ENOMEM; | ||
1096 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); | 1107 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); |
1097 | goto failed_mount_group_desc; | 1108 | goto failed_mount_group_desc; |
1098 | } | 1109 | } |
@@ -1148,6 +1159,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1148 | #ifdef CONFIG_EXT2_FS_XATTR | 1159 | #ifdef CONFIG_EXT2_FS_XATTR |
1149 | sbi->s_ea_block_cache = ext2_xattr_create_cache(); | 1160 | sbi->s_ea_block_cache = ext2_xattr_create_cache(); |
1150 | if (!sbi->s_ea_block_cache) { | 1161 | if (!sbi->s_ea_block_cache) { |
1162 | ret = -ENOMEM; | ||
1151 | ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache"); | 1163 | ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache"); |
1152 | goto failed_mount3; | 1164 | goto failed_mount3; |
1153 | } | 1165 | } |
diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c index d5589ddcc281..00cdb8679486 100644 --- a/fs/ext2/symlink.c +++ b/fs/ext2/symlink.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | const struct inode_operations ext2_symlink_inode_operations = { | 24 | const struct inode_operations ext2_symlink_inode_operations = { |
25 | .get_link = page_get_link, | 25 | .get_link = page_get_link, |
26 | .getattr = ext2_getattr, | ||
26 | .setattr = ext2_setattr, | 27 | .setattr = ext2_setattr, |
27 | #ifdef CONFIG_EXT2_FS_XATTR | 28 | #ifdef CONFIG_EXT2_FS_XATTR |
28 | .listxattr = ext2_listxattr, | 29 | .listxattr = ext2_listxattr, |
@@ -31,6 +32,7 @@ const struct inode_operations ext2_symlink_inode_operations = { | |||
31 | 32 | ||
32 | const struct inode_operations ext2_fast_symlink_inode_operations = { | 33 | const struct inode_operations ext2_fast_symlink_inode_operations = { |
33 | .get_link = simple_get_link, | 34 | .get_link = simple_get_link, |
35 | .getattr = ext2_getattr, | ||
34 | .setattr = ext2_setattr, | 36 | .setattr = ext2_setattr, |
35 | #ifdef CONFIG_EXT2_FS_XATTR | 37 | #ifdef CONFIG_EXT2_FS_XATTR |
36 | .listxattr = ext2_listxattr, | 38 | .listxattr = ext2_listxattr, |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 4f30876ee325..1e33e0ac8cf1 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -342,6 +342,7 @@ static void ext2_xattr_update_super_block(struct super_block *sb) | |||
342 | return; | 342 | return; |
343 | 343 | ||
344 | spin_lock(&EXT2_SB(sb)->s_lock); | 344 | spin_lock(&EXT2_SB(sb)->s_lock); |
345 | ext2_update_dynamic_rev(sb); | ||
345 | EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR); | 346 | EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR); |
346 | spin_unlock(&EXT2_SB(sb)->s_lock); | 347 | spin_unlock(&EXT2_SB(sb)->s_lock); |
347 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); | 348 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); |
diff --git a/fs/udf/super.c b/fs/udf/super.c index e3d684ea3203..ffd8038ff728 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -1474,6 +1474,17 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, | |||
1474 | if (lvd->integritySeqExt.extLength) | 1474 | if (lvd->integritySeqExt.extLength) |
1475 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); | 1475 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); |
1476 | ret = 0; | 1476 | ret = 0; |
1477 | |||
1478 | if (!sbi->s_lvid_bh) { | ||
1479 | /* We can't generate unique IDs without a valid LVID */ | ||
1480 | if (sb_rdonly(sb)) { | ||
1481 | UDF_SET_FLAG(sb, UDF_FLAG_RW_INCOMPAT); | ||
1482 | } else { | ||
1483 | udf_warn(sb, "Damaged or missing LVID, forcing " | ||
1484 | "readonly mount\n"); | ||
1485 | ret = -EACCES; | ||
1486 | } | ||
1487 | } | ||
1477 | out_bh: | 1488 | out_bh: |
1478 | brelse(bh); | 1489 | brelse(bh); |
1479 | return ret; | 1490 | return ret; |
@@ -1943,13 +1954,24 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, | |||
1943 | return 0; | 1954 | return 0; |
1944 | } | 1955 | } |
1945 | 1956 | ||
1957 | static void udf_finalize_lvid(struct logicalVolIntegrityDesc *lvid) | ||
1958 | { | ||
1959 | struct timespec64 ts; | ||
1960 | |||
1961 | ktime_get_real_ts64(&ts); | ||
1962 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); | ||
1963 | lvid->descTag.descCRC = cpu_to_le16( | ||
1964 | crc_itu_t(0, (char *)lvid + sizeof(struct tag), | ||
1965 | le16_to_cpu(lvid->descTag.descCRCLength))); | ||
1966 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | ||
1967 | } | ||
1968 | |||
1946 | static void udf_open_lvid(struct super_block *sb) | 1969 | static void udf_open_lvid(struct super_block *sb) |
1947 | { | 1970 | { |
1948 | struct udf_sb_info *sbi = UDF_SB(sb); | 1971 | struct udf_sb_info *sbi = UDF_SB(sb); |
1949 | struct buffer_head *bh = sbi->s_lvid_bh; | 1972 | struct buffer_head *bh = sbi->s_lvid_bh; |
1950 | struct logicalVolIntegrityDesc *lvid; | 1973 | struct logicalVolIntegrityDesc *lvid; |
1951 | struct logicalVolIntegrityDescImpUse *lvidiu; | 1974 | struct logicalVolIntegrityDescImpUse *lvidiu; |
1952 | struct timespec64 ts; | ||
1953 | 1975 | ||
1954 | if (!bh) | 1976 | if (!bh) |
1955 | return; | 1977 | return; |
@@ -1961,18 +1983,12 @@ static void udf_open_lvid(struct super_block *sb) | |||
1961 | mutex_lock(&sbi->s_alloc_mutex); | 1983 | mutex_lock(&sbi->s_alloc_mutex); |
1962 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1984 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1963 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1985 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1964 | ktime_get_real_ts64(&ts); | ||
1965 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); | ||
1966 | if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE) | 1986 | if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE) |
1967 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); | 1987 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); |
1968 | else | 1988 | else |
1969 | UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT); | 1989 | UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT); |
1970 | 1990 | ||
1971 | lvid->descTag.descCRC = cpu_to_le16( | 1991 | udf_finalize_lvid(lvid); |
1972 | crc_itu_t(0, (char *)lvid + sizeof(struct tag), | ||
1973 | le16_to_cpu(lvid->descTag.descCRCLength))); | ||
1974 | |||
1975 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | ||
1976 | mark_buffer_dirty(bh); | 1992 | mark_buffer_dirty(bh); |
1977 | sbi->s_lvid_dirty = 0; | 1993 | sbi->s_lvid_dirty = 0; |
1978 | mutex_unlock(&sbi->s_alloc_mutex); | 1994 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -1986,7 +2002,6 @@ static void udf_close_lvid(struct super_block *sb) | |||
1986 | struct buffer_head *bh = sbi->s_lvid_bh; | 2002 | struct buffer_head *bh = sbi->s_lvid_bh; |
1987 | struct logicalVolIntegrityDesc *lvid; | 2003 | struct logicalVolIntegrityDesc *lvid; |
1988 | struct logicalVolIntegrityDescImpUse *lvidiu; | 2004 | struct logicalVolIntegrityDescImpUse *lvidiu; |
1989 | struct timespec64 ts; | ||
1990 | 2005 | ||
1991 | if (!bh) | 2006 | if (!bh) |
1992 | return; | 2007 | return; |
@@ -1998,8 +2013,6 @@ static void udf_close_lvid(struct super_block *sb) | |||
1998 | mutex_lock(&sbi->s_alloc_mutex); | 2013 | mutex_lock(&sbi->s_alloc_mutex); |
1999 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 2014 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
2000 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 2015 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
2001 | ktime_get_real_ts64(&ts); | ||
2002 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); | ||
2003 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) | 2016 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) |
2004 | lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); | 2017 | lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); |
2005 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) | 2018 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) |
@@ -2009,17 +2022,13 @@ static void udf_close_lvid(struct super_block *sb) | |||
2009 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT)) | 2022 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT)) |
2010 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | 2023 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); |
2011 | 2024 | ||
2012 | lvid->descTag.descCRC = cpu_to_le16( | ||
2013 | crc_itu_t(0, (char *)lvid + sizeof(struct tag), | ||
2014 | le16_to_cpu(lvid->descTag.descCRCLength))); | ||
2015 | |||
2016 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | ||
2017 | /* | 2025 | /* |
2018 | * We set buffer uptodate unconditionally here to avoid spurious | 2026 | * We set buffer uptodate unconditionally here to avoid spurious |
2019 | * warnings from mark_buffer_dirty() when previous EIO has marked | 2027 | * warnings from mark_buffer_dirty() when previous EIO has marked |
2020 | * the buffer as !uptodate | 2028 | * the buffer as !uptodate |
2021 | */ | 2029 | */ |
2022 | set_buffer_uptodate(bh); | 2030 | set_buffer_uptodate(bh); |
2031 | udf_finalize_lvid(lvid); | ||
2023 | mark_buffer_dirty(bh); | 2032 | mark_buffer_dirty(bh); |
2024 | sbi->s_lvid_dirty = 0; | 2033 | sbi->s_lvid_dirty = 0; |
2025 | mutex_unlock(&sbi->s_alloc_mutex); | 2034 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -2048,8 +2057,8 @@ u64 lvid_get_unique_id(struct super_block *sb) | |||
2048 | if (!(++uniqueID & 0xFFFFFFFF)) | 2057 | if (!(++uniqueID & 0xFFFFFFFF)) |
2049 | uniqueID += 16; | 2058 | uniqueID += 16; |
2050 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 2059 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
2060 | udf_updated_lvid(sb); | ||
2051 | mutex_unlock(&sbi->s_alloc_mutex); | 2061 | mutex_unlock(&sbi->s_alloc_mutex); |
2052 | mark_buffer_dirty(bh); | ||
2053 | 2062 | ||
2054 | return ret; | 2063 | return ret; |
2055 | } | 2064 | } |
@@ -2320,11 +2329,17 @@ static int udf_sync_fs(struct super_block *sb, int wait) | |||
2320 | 2329 | ||
2321 | mutex_lock(&sbi->s_alloc_mutex); | 2330 | mutex_lock(&sbi->s_alloc_mutex); |
2322 | if (sbi->s_lvid_dirty) { | 2331 | if (sbi->s_lvid_dirty) { |
2332 | struct buffer_head *bh = sbi->s_lvid_bh; | ||
2333 | struct logicalVolIntegrityDesc *lvid; | ||
2334 | |||
2335 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
2336 | udf_finalize_lvid(lvid); | ||
2337 | |||
2323 | /* | 2338 | /* |
2324 | * Blockdevice will be synced later so we don't have to submit | 2339 | * Blockdevice will be synced later so we don't have to submit |
2325 | * the buffer for IO | 2340 | * the buffer for IO |
2326 | */ | 2341 | */ |
2327 | mark_buffer_dirty(sbi->s_lvid_bh); | 2342 | mark_buffer_dirty(bh); |
2328 | sbi->s_lvid_dirty = 0; | 2343 | sbi->s_lvid_dirty = 0; |
2329 | } | 2344 | } |
2330 | mutex_unlock(&sbi->s_alloc_mutex); | 2345 | mutex_unlock(&sbi->s_alloc_mutex); |