summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-09-24 18:19:10 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-03 16:07:32 -0800
commit622f28ae9ba4fa89b4ff0f4a6cf75d153ea838ce (patch)
treeb91404e9b6f9061fb0ab2b31cff1799bd71e7c52 /fs
parent201a05be9628ae58efe7638e0c7ae3937ec85273 (diff)
downloadblackbird-op-linux-622f28ae9ba4fa89b4ff0f4a6cf75d153ea838ce.tar.gz
blackbird-op-linux-622f28ae9ba4fa89b4ff0f4a6cf75d153ea838ce.zip
f2fs: enable inline dir handling
Add inline dir functions into normal dir ops' function to handle inline ops. Besides, we enable inline dir mode when a new dir inode is created if inline_data option is on. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/dir.c32
-rw-r--r--fs/f2fs/file.c2
-rw-r--r--fs/f2fs/inline.c2
-rw-r--r--fs/f2fs/namei.c34
-rw-r--r--fs/f2fs/recovery.c3
5 files changed, 58 insertions, 15 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 99e944e1dd01..cc6474a85d6c 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -201,6 +201,9 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
unsigned int max_depth;
unsigned int level;
+ if (f2fs_has_inline_dentry(dir))
+ return find_in_inline_dir(dir, child, res_page);
+
if (npages == 0)
return NULL;
@@ -227,6 +230,9 @@ struct f2fs_dir_entry *f2fs_parent_dir(struct inode *dir, struct page **p)
struct f2fs_dir_entry *de;
struct f2fs_dentry_block *dentry_blk;
+ if (f2fs_has_inline_dentry(dir))
+ return f2fs_parent_inline_dir(dir, p);
+
page = get_lock_data_page(dir, 0);
if (IS_ERR(page))
return NULL;
@@ -247,7 +253,8 @@ ino_t f2fs_inode_by_name(struct inode *dir, struct qstr *qstr)
de = f2fs_find_entry(dir, qstr, &page);
if (de) {
res = le32_to_cpu(de->ino);
- kunmap(page);
+ if (!f2fs_has_inline_dentry(dir))
+ kunmap(page);
f2fs_put_page(page, 0);
}
@@ -261,7 +268,8 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
f2fs_wait_on_page_writeback(page, DATA);
de->ino = cpu_to_le32(inode->i_ino);
set_de_type(de, inode);
- kunmap(page);
+ if (!f2fs_has_inline_dentry(dir))
+ kunmap(page);
set_page_dirty(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME;
mark_inode_dirty(dir);
@@ -303,6 +311,9 @@ static int make_empty_dir(struct inode *inode,
struct f2fs_dentry_block *dentry_blk;
struct f2fs_dir_entry *de;
+ if (f2fs_has_inline_dentry(inode))
+ return make_empty_inline_dir(inode, parent, page);
+
dentry_page = get_new_data_page(inode, page, 0, true);
if (IS_ERR(dentry_page))
return PTR_ERR(dentry_page);
@@ -462,6 +473,14 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
int err = 0;
int i;
+ if (f2fs_has_inline_dentry(dir)) {
+ err = f2fs_add_inline_entry(dir, name, inode);
+ if (!err || err != -EAGAIN)
+ return err;
+ else
+ err = 0;
+ }
+
dentry_hash = f2fs_dentry_hash(name);
level = 0;
current_depth = F2FS_I(dir)->i_current_depth;
@@ -600,6 +619,9 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
int i;
+ if (f2fs_has_inline_dentry(dir))
+ return f2fs_delete_inline_entry(dentry, page, dir, inode);
+
lock_page(page);
f2fs_wait_on_page_writeback(page, DATA);
@@ -637,6 +659,9 @@ bool f2fs_empty_dir(struct inode *dir)
struct f2fs_dentry_block *dentry_blk;
unsigned long nblock = dir_blocks(dir);
+ if (f2fs_has_inline_dentry(dir))
+ return f2fs_empty_inline_dir(dir);
+
for (bidx = 0; bidx < nblock; bidx++) {
dentry_page = get_lock_data_page(dir, bidx);
if (IS_ERR(dentry_page)) {
@@ -676,6 +701,9 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
unsigned char d_type = DT_UNKNOWN;
+ if (f2fs_has_inline_dentry(inode))
+ return f2fs_read_inline_dir(file, ctx);
+
bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
/* readahead for multi pages of dir */
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 80d9a0482e7d..d054e0ebfe24 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -314,7 +314,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
goto fail;
/* handle inline data case */
- if (f2fs_has_inline_data(inode)) {
+ if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode)) {
if (whence == SEEK_HOLE)
data_ofs = isize;
goto found;
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index b3be96ba585c..1fafc8561542 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -424,7 +424,7 @@ int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
/* clear inline dir and flag after data writeback */
zero_user_segment(ipage, INLINE_DATA_OFFSET,
INLINE_DATA_OFFSET + MAX_INLINE_DATA);
-
+ clear_inode_flag(F2FS_I(dir), FI_INLINE_DENTRY);
stat_dec_inline_inode(dir);
if (i_size_read(dir) < PAGE_CACHE_SIZE) {
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 6e67f2b6fce1..c8290da8e941 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -54,6 +54,10 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
nid_free = true;
goto out;
}
+
+ if (test_opt(sbi, INLINE_DENTRY) && S_ISDIR(inode->i_mode))
+ set_inode_flag(F2FS_I(inode), FI_INLINE_DENTRY);
+
trace_f2fs_new_inode(inode, 0);
mark_inode_dirty(inode);
return inode;
@@ -187,7 +191,8 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
de = f2fs_find_entry(dir, &dentry->d_name, &page);
if (de) {
nid_t ino = le32_to_cpu(de->ino);
- kunmap(page);
+ if (!f2fs_has_inline_dentry(dir))
+ kunmap(page);
f2fs_put_page(page, 0);
inode = f2fs_iget(dir->i_sb, ino);
@@ -219,7 +224,8 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
err = acquire_orphan_inode(sbi);
if (err) {
f2fs_unlock_op(sbi);
- kunmap(page);
+ if (!f2fs_has_inline_dentry(dir))
+ kunmap(page);
f2fs_put_page(page, 0);
goto fail;
}
@@ -443,7 +449,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
old_dir_page, new_dir);
update_inode_page(old_inode);
} else {
- kunmap(old_dir_page);
+ if (!f2fs_has_inline_dentry(old_inode))
+ kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0);
}
drop_nlink(old_dir);
@@ -456,15 +463,18 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
put_out_dir:
f2fs_unlock_op(sbi);
- kunmap(new_page);
+ if (!f2fs_has_inline_dentry(new_dir))
+ kunmap(new_page);
f2fs_put_page(new_page, 0);
out_dir:
if (old_dir_entry) {
- kunmap(old_dir_page);
+ if (!f2fs_has_inline_dentry(old_inode))
+ kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0);
}
out_old:
- kunmap(old_page);
+ if (!f2fs_has_inline_dentry(old_dir))
+ kunmap(old_page);
f2fs_put_page(old_page, 0);
out:
return err;
@@ -596,19 +606,23 @@ out_unlock:
f2fs_unlock_op(sbi);
out_new_dir:
if (new_dir_entry) {
- kunmap(new_dir_page);
+ if (!f2fs_has_inline_dentry(new_inode))
+ kunmap(new_dir_page);
f2fs_put_page(new_dir_page, 0);
}
out_old_dir:
if (old_dir_entry) {
- kunmap(old_dir_page);
+ if (!f2fs_has_inline_dentry(old_inode))
+ kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0);
}
out_new:
- kunmap(new_page);
+ if (!f2fs_has_inline_dentry(new_dir))
+ kunmap(new_page);
f2fs_put_page(new_page, 0);
out_old:
- kunmap(old_page);
+ if (!f2fs_has_inline_dentry(old_dir))
+ kunmap(old_page);
f2fs_put_page(old_page, 0);
out:
return err;
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 843da53ed7d5..4b180bbc3a21 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -129,7 +129,8 @@ retry:
goto out;
out_unmap_put:
- kunmap(page);
+ if (!f2fs_has_inline_dentry(dir))
+ kunmap(page);
f2fs_put_page(page, 0);
out_err:
iput(dir);
OpenPOWER on IntegriCloud