aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-10-19 02:06:41 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-03 19:07:34 -0500
commit062a3e7ba7eebcd7d44e49e9510135f901f93f48 (patch)
treed3796be4f5bfe0169f182be8c3c83822926a7012 /fs/f2fs
parent7b3cd7d6f026784b1a2a74b6e207b26253d9d780 (diff)
f2fs: reuse make_empty_dir code for inline_dentry
This patch introduces do_make_empty_dir to mitigate code redundancy for inline_dentry. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/dir.c42
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/inline.c20
3 files changed, 31 insertions, 33 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 4f029a1b0cf0..4e62bdeb253d 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -323,12 +323,35 @@ int update_dent_inode(struct inode *inode, const struct qstr *name)
323 return 0; 323 return 0;
324} 324}
325 325
326void do_make_empty_dir(struct inode *inode, struct inode *parent,
327 struct f2fs_dentry_ptr *d)
328{
329 struct f2fs_dir_entry *de;
330
331 de = &d->dentry[0];
332 de->name_len = cpu_to_le16(1);
333 de->hash_code = 0;
334 de->ino = cpu_to_le32(inode->i_ino);
335 memcpy(d->filename[0], ".", 1);
336 set_de_type(de, inode);
337
338 de = &d->dentry[1];
339 de->hash_code = 0;
340 de->name_len = cpu_to_le16(2);
341 de->ino = cpu_to_le32(parent->i_ino);
342 memcpy(d->filename[1], "..", 2);
343 set_de_type(de, inode);
344
345 test_and_set_bit_le(0, (void *)d->bitmap);
346 test_and_set_bit_le(1, (void *)d->bitmap);
347}
348
326static int make_empty_dir(struct inode *inode, 349static int make_empty_dir(struct inode *inode,
327 struct inode *parent, struct page *page) 350 struct inode *parent, struct page *page)
328{ 351{
329 struct page *dentry_page; 352 struct page *dentry_page;
330 struct f2fs_dentry_block *dentry_blk; 353 struct f2fs_dentry_block *dentry_blk;
331 struct f2fs_dir_entry *de; 354 struct f2fs_dentry_ptr d;
332 355
333 if (f2fs_has_inline_dentry(inode)) 356 if (f2fs_has_inline_dentry(inode))
334 return make_empty_inline_dir(inode, parent, page); 357 return make_empty_inline_dir(inode, parent, page);
@@ -339,22 +362,9 @@ static int make_empty_dir(struct inode *inode,
339 362
340 dentry_blk = kmap_atomic(dentry_page); 363 dentry_blk = kmap_atomic(dentry_page);
341 364
342 de = &dentry_blk->dentry[0]; 365 make_dentry_ptr(&d, (void *)dentry_blk, 1);
343 de->name_len = cpu_to_le16(1); 366 do_make_empty_dir(inode, parent, &d);
344 de->hash_code = 0;
345 de->ino = cpu_to_le32(inode->i_ino);
346 memcpy(dentry_blk->filename[0], ".", 1);
347 set_de_type(de, inode);
348
349 de = &dentry_blk->dentry[1];
350 de->hash_code = 0;
351 de->name_len = cpu_to_le16(2);
352 de->ino = cpu_to_le32(parent->i_ino);
353 memcpy(dentry_blk->filename[1], "..", 2);
354 set_de_type(de, inode);
355 367
356 test_and_set_bit_le(0, &dentry_blk->dentry_bitmap);
357 test_and_set_bit_le(1, &dentry_blk->dentry_bitmap);
358 kunmap_atomic(dentry_blk); 368 kunmap_atomic(dentry_blk);
359 369
360 set_page_dirty(dentry_page); 370 set_page_dirty(dentry_page);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f7bbfc7d06b8..cb59ebbf0f38 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1275,6 +1275,8 @@ struct f2fs_dir_entry *find_target_dentry(struct qstr *, int *,
1275 struct f2fs_dentry_ptr *); 1275 struct f2fs_dentry_ptr *);
1276bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *, 1276bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *,
1277 unsigned int); 1277 unsigned int);
1278void do_make_empty_dir(struct inode *, struct inode *,
1279 struct f2fs_dentry_ptr *);
1278struct page *init_inode_metadata(struct inode *, struct inode *, 1280struct page *init_inode_metadata(struct inode *, struct inode *,
1279 const struct qstr *, struct page *); 1281 const struct qstr *, struct page *);
1280void update_parent_metadata(struct inode *, struct inode *, unsigned int); 1282void update_parent_metadata(struct inode *, struct inode *, unsigned int);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 445e99d6f6ee..a30984505f16 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -314,26 +314,12 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
314 struct page *ipage) 314 struct page *ipage)
315{ 315{
316 struct f2fs_inline_dentry *dentry_blk; 316 struct f2fs_inline_dentry *dentry_blk;
317 struct f2fs_dir_entry *de; 317 struct f2fs_dentry_ptr d;
318 318
319 dentry_blk = inline_data_addr(ipage); 319 dentry_blk = inline_data_addr(ipage);
320 320
321 de = &dentry_blk->dentry[0]; 321 make_dentry_ptr(&d, (void *)dentry_blk, 2);
322 de->name_len = cpu_to_le16(1); 322 do_make_empty_dir(inode, parent, &d);
323 de->hash_code = 0;
324 de->ino = cpu_to_le32(inode->i_ino);
325 memcpy(dentry_blk->filename[0], ".", 1);
326 set_de_type(de, inode);
327
328 de = &dentry_blk->dentry[1];
329 de->hash_code = 0;
330 de->name_len = cpu_to_le16(2);
331 de->ino = cpu_to_le32(parent->i_ino);
332 memcpy(dentry_blk->filename[1], "..", 2);
333 set_de_type(de, inode);
334
335 test_and_set_bit_le(0, &dentry_blk->dentry_bitmap);
336 test_and_set_bit_le(1, &dentry_blk->dentry_bitmap);
337 323
338 set_page_dirty(ipage); 324 set_page_dirty(ipage);
339 325