aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/ialloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/ialloc.c')
-rw-r--r--fs/udf/ialloc.c94
1 files changed, 56 insertions, 38 deletions
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 636d8f613929..84360315aca2 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -43,19 +43,21 @@ void udf_free_inode(struct inode *inode)
43 clear_inode(inode); 43 clear_inode(inode);
44 44
45 mutex_lock(&sbi->s_alloc_mutex); 45 mutex_lock(&sbi->s_alloc_mutex);
46 if (sbi->s_lvidbh) { 46 if (sbi->s_lvid_bh) {
47 struct logicalVolIntegrityDescImpUse *lvidiu =
48 udf_sb_lvidiu(sbi);
47 if (S_ISDIR(inode->i_mode)) 49 if (S_ISDIR(inode->i_mode))
48 UDF_SB_LVIDIU(sb)->numDirs = 50 lvidiu->numDirs =
49 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1); 51 cpu_to_le32(le32_to_cpu(lvidiu->numDirs) - 1);
50 else 52 else
51 UDF_SB_LVIDIU(sb)->numFiles = 53 lvidiu->numFiles =
52 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); 54 cpu_to_le32(le32_to_cpu(lvidiu->numFiles) - 1);
53 55
54 mark_buffer_dirty(sbi->s_lvidbh); 56 mark_buffer_dirty(sbi->s_lvid_bh);
55 } 57 }
56 mutex_unlock(&sbi->s_alloc_mutex); 58 mutex_unlock(&sbi->s_alloc_mutex);
57 59
58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1); 60 udf_free_blocks(sb, NULL, UDF_I(inode)->i_location, 0, 1);
59} 61}
60 62
61struct inode *udf_new_inode(struct inode *dir, int mode, int *err) 63struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
@@ -64,7 +66,9 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
64 struct udf_sb_info *sbi = UDF_SB(sb); 66 struct udf_sb_info *sbi = UDF_SB(sb);
65 struct inode *inode; 67 struct inode *inode;
66 int block; 68 int block;
67 uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum; 69 uint32_t start = UDF_I(dir)->i_location.logicalBlockNum;
70 struct udf_inode_info *iinfo;
71 struct udf_inode_info *dinfo = UDF_I(dir);
68 72
69 inode = new_inode(sb); 73 inode = new_inode(sb);
70 74
@@ -74,13 +78,15 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
74 } 78 }
75 *err = -ENOSPC; 79 *err = -ENOSPC;
76 80
77 UDF_I_UNIQUE(inode) = 0; 81 iinfo = UDF_I(inode);
78 UDF_I_LENEXTENTS(inode) = 0; 82 iinfo->i_unique = 0;
79 UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; 83 iinfo->i_lenExtents = 0;
80 UDF_I_NEXT_ALLOC_GOAL(inode) = 0; 84 iinfo->i_next_alloc_block = 0;
81 UDF_I_STRAT4096(inode) = 0; 85 iinfo->i_next_alloc_goal = 0;
86 iinfo->i_strat4096 = 0;
82 87
83 block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, 88 block = udf_new_block(dir->i_sb, NULL,
89 dinfo->i_location.partitionReferenceNum,
84 start, err); 90 start, err);
85 if (*err) { 91 if (*err) {
86 iput(inode); 92 iput(inode);
@@ -88,21 +94,27 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
88 } 94 }
89 95
90 mutex_lock(&sbi->s_alloc_mutex); 96 mutex_lock(&sbi->s_alloc_mutex);
91 if (UDF_SB_LVIDBH(sb)) { 97 if (sbi->s_lvid_bh) {
98 struct logicalVolIntegrityDesc *lvid =
99 (struct logicalVolIntegrityDesc *)
100 sbi->s_lvid_bh->b_data;
101 struct logicalVolIntegrityDescImpUse *lvidiu =
102 udf_sb_lvidiu(sbi);
92 struct logicalVolHeaderDesc *lvhd; 103 struct logicalVolHeaderDesc *lvhd;
93 uint64_t uniqueID; 104 uint64_t uniqueID;
94 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); 105 lvhd = (struct logicalVolHeaderDesc *)
106 (lvid->logicalVolContentsUse);
95 if (S_ISDIR(mode)) 107 if (S_ISDIR(mode))
96 UDF_SB_LVIDIU(sb)->numDirs = 108 lvidiu->numDirs =
97 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1); 109 cpu_to_le32(le32_to_cpu(lvidiu->numDirs) + 1);
98 else 110 else
99 UDF_SB_LVIDIU(sb)->numFiles = 111 lvidiu->numFiles =
100 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); 112 cpu_to_le32(le32_to_cpu(lvidiu->numFiles) + 1);
101 UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); 113 iinfo->i_unique = uniqueID = le64_to_cpu(lvhd->uniqueID);
102 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 114 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
103 uniqueID += 16; 115 uniqueID += 16;
104 lvhd->uniqueID = cpu_to_le64(uniqueID); 116 lvhd->uniqueID = cpu_to_le64(uniqueID);
105 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 117 mark_buffer_dirty(sbi->s_lvid_bh);
106 } 118 }
107 inode->i_mode = mode; 119 inode->i_mode = mode;
108 inode->i_uid = current->fsuid; 120 inode->i_uid = current->fsuid;
@@ -114,35 +126,41 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
114 inode->i_gid = current->fsgid; 126 inode->i_gid = current->fsgid;
115 } 127 }
116 128
117 UDF_I_LOCATION(inode).logicalBlockNum = block; 129 iinfo->i_location.logicalBlockNum = block;
118 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; 130 iinfo->i_location.partitionReferenceNum =
119 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); 131 dinfo->i_location.partitionReferenceNum;
132 inode->i_ino = udf_get_lb_pblock(sb, iinfo->i_location, 0);
120 inode->i_blocks = 0; 133 inode->i_blocks = 0;
121 UDF_I_LENEATTR(inode) = 0; 134 iinfo->i_lenEAttr = 0;
122 UDF_I_LENALLOC(inode) = 0; 135 iinfo->i_lenAlloc = 0;
123 UDF_I_USE(inode) = 0; 136 iinfo->i_use = 0;
124 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { 137 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
125 UDF_I_EFE(inode) = 1; 138 iinfo->i_efe = 1;
126 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); 139 if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
127 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); 140 sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
141 iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
142 sizeof(struct extendedFileEntry),
143 GFP_KERNEL);
128 } else { 144 } else {
129 UDF_I_EFE(inode) = 0; 145 iinfo->i_efe = 0;
130 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); 146 iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
147 sizeof(struct fileEntry),
148 GFP_KERNEL);
131 } 149 }
132 if (!UDF_I_DATA(inode)) { 150 if (!iinfo->i_ext.i_data) {
133 iput(inode); 151 iput(inode);
134 *err = -ENOMEM; 152 *err = -ENOMEM;
135 mutex_unlock(&sbi->s_alloc_mutex); 153 mutex_unlock(&sbi->s_alloc_mutex);
136 return NULL; 154 return NULL;
137 } 155 }
138 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 156 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
139 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 157 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
140 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) 158 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
141 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; 159 iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
142 else 160 else
143 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; 161 iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
144 inode->i_mtime = inode->i_atime = inode->i_ctime = 162 inode->i_mtime = inode->i_atime = inode->i_ctime =
145 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); 163 iinfo->i_crtime = current_fs_time(inode->i_sb);
146 insert_inode_hash(inode); 164 insert_inode_hash(inode);
147 mark_inode_dirty(inode); 165 mark_inode_dirty(inode);
148 mutex_unlock(&sbi->s_alloc_mutex); 166 mutex_unlock(&sbi->s_alloc_mutex);