aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/file.c2
-rw-r--r--fs/f2fs/recovery.c26
3 files changed, 23 insertions, 6 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6594ce15a7bb..7b050298d6c9 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -900,6 +900,7 @@ void truncate_data_blocks(struct dnode_of_data *);
900void f2fs_truncate(struct inode *); 900void f2fs_truncate(struct inode *);
901int f2fs_setattr(struct dentry *, struct iattr *); 901int f2fs_setattr(struct dentry *, struct iattr *);
902int truncate_hole(struct inode *, pgoff_t, pgoff_t); 902int truncate_hole(struct inode *, pgoff_t, pgoff_t);
903int truncate_data_blocks_range(struct dnode_of_data *, int);
903long f2fs_ioctl(struct file *, unsigned int, unsigned long); 904long f2fs_ioctl(struct file *, unsigned int, unsigned long);
904long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); 905long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
905 906
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 316bcfe80448..deefd258b847 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -168,7 +168,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
168 return 0; 168 return 0;
169} 169}
170 170
171static int truncate_data_blocks_range(struct dnode_of_data *dn, int count) 171int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
172{ 172{
173 int nr_free = 0, ofs = dn->ofs_in_node; 173 int nr_free = 0, ofs = dn->ofs_in_node;
174 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 174 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 5148d90049b0..eceb6652532d 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -189,14 +189,14 @@ static void destroy_fsync_dnodes(struct f2fs_sb_info *sbi,
189} 189}
190 190
191static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi, 191static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
192 block_t blkaddr) 192 block_t blkaddr, struct dnode_of_data *dn)
193{ 193{
194 struct seg_entry *sentry; 194 struct seg_entry *sentry;
195 unsigned int segno = GET_SEGNO(sbi, blkaddr); 195 unsigned int segno = GET_SEGNO(sbi, blkaddr);
196 unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) & 196 unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) &
197 (sbi->blocks_per_seg - 1); 197 (sbi->blocks_per_seg - 1);
198 struct f2fs_summary sum; 198 struct f2fs_summary sum;
199 nid_t ino; 199 nid_t ino, nid;
200 void *kaddr; 200 void *kaddr;
201 struct inode *inode; 201 struct inode *inode;
202 struct page *node_page; 202 struct page *node_page;
@@ -224,10 +224,26 @@ static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
224 f2fs_put_page(sum_page, 1); 224 f2fs_put_page(sum_page, 1);
225 } 225 }
226 226
227 /* Use the locked dnode page and inode */
228 nid = le32_to_cpu(sum.nid);
229 if (dn->inode->i_ino == nid) {
230 struct dnode_of_data tdn = *dn;
231 tdn.nid = nid;
232 tdn.node_page = dn->inode_page;
233 tdn.ofs_in_node = sum.ofs_in_node;
234 truncate_data_blocks_range(&tdn, 1);
235 return;
236 } else if (dn->nid == nid) {
237 struct dnode_of_data tdn = *dn;
238 tdn.ofs_in_node = sum.ofs_in_node;
239 truncate_data_blocks_range(&tdn, 1);
240 return;
241 }
242
227 /* Get the node page */ 243 /* Get the node page */
228 node_page = get_node_page(sbi, le32_to_cpu(sum.nid)); 244 node_page = get_node_page(sbi, nid);
229 bidx = start_bidx_of_node(ofs_of_node(node_page)) + 245 bidx = start_bidx_of_node(ofs_of_node(node_page)) +
230 le16_to_cpu(sum.ofs_in_node); 246 le16_to_cpu(sum.ofs_in_node);
231 ino = ino_of_node(node_page); 247 ino = ino_of_node(node_page);
232 f2fs_put_page(node_page, 1); 248 f2fs_put_page(node_page, 1);
233 249
@@ -285,7 +301,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
285 } 301 }
286 302
287 /* Check the previous node page having this index */ 303 /* Check the previous node page having this index */
288 check_index_in_prev_nodes(sbi, dest); 304 check_index_in_prev_nodes(sbi, dest, &dn);
289 305
290 set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version); 306 set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
291 307