From 6307d43c25ee624ae51cd5b56c85f9fa88af3b6a Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Wed, 29 May 2013 10:15:36 +0900 Subject: f2fs: support 3.4 Change-Id: I20b6a2877e072a4b9639001fa0198837cfa74aff Signed-off-by: Jaegeuk Kim --- fs/f2fs/acl.c | 24 ++++-------------------- fs/f2fs/data.c | 3 +-- fs/f2fs/dir.c | 40 +++++++++++++++++++++++++--------------- fs/f2fs/f2fs.h | 6 ++++++ fs/f2fs/file.c | 4 +--- fs/f2fs/gc.c | 2 +- fs/f2fs/gc.h | 2 +- fs/f2fs/inode.c | 12 +++++------- fs/f2fs/namei.c | 6 +++--- fs/f2fs/node.c | 3 +-- fs/f2fs/super.c | 3 +-- 11 files changed, 49 insertions(+), 56 deletions(-) (limited to 'fs') diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index d0fc287..ca393ae 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c @@ -87,16 +87,8 @@ static struct posix_acl *f2fs_acl_from_disk(const char *value, size_t size) break; case ACL_USER: - acl->a_entries[i].e_uid = - make_kuid(&init_user_ns, - le32_to_cpu(entry->e_id)); - entry = (struct f2fs_acl_entry *)((char *)entry + - sizeof(struct f2fs_acl_entry)); - break; case ACL_GROUP: - acl->a_entries[i].e_gid = - make_kgid(&init_user_ns, - le32_to_cpu(entry->e_id)); + acl->a_entries[i].e_id = le32_to_cpu(entry->e_id); entry = (struct f2fs_acl_entry *)((char *)entry + sizeof(struct f2fs_acl_entry)); break; @@ -133,16 +125,8 @@ static void *f2fs_acl_to_disk(const struct posix_acl *acl, size_t *size) switch (acl->a_entries[i].e_tag) { case ACL_USER: - entry->e_id = cpu_to_le32( - from_kuid(&init_user_ns, - acl->a_entries[i].e_uid)); - entry = (struct f2fs_acl_entry *)((char *)entry + - sizeof(struct f2fs_acl_entry)); - break; case ACL_GROUP: - entry->e_id = cpu_to_le32( - from_kgid(&init_user_ns, - acl->a_entries[i].e_gid)); + entry->e_id = cpu_to_le32(acl->a_entries[i].e_id); entry = (struct f2fs_acl_entry *)((char *)entry + sizeof(struct f2fs_acl_entry)); break; @@ -356,7 +340,7 @@ static int f2fs_xattr_get_acl(struct dentry *dentry, const char *name, return PTR_ERR(acl); if (!acl) return -ENODATA; - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); + error = posix_acl_to_xattr(acl, buffer, size); posix_acl_release(acl); return error; @@ -378,7 +362,7 @@ static int f2fs_xattr_set_acl(struct dentry *dentry, const char *name, return -EPERM; if (value) { - acl = posix_acl_from_xattr(&init_user_ns, value, size); + acl = posix_acl_from_xattr(value, size); if (IS_ERR(acl)) return PTR_ERR(acl); if (acl) { diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 63d1902..d73c37f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1032,8 +1032,7 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb, get_data_block); } -static void f2fs_invalidate_data_page(struct page *page, unsigned int offset, - unsigned int length) +static void f2fs_invalidate_data_page(struct page *page, unsigned long offset) { struct inode *inode = page->mapping->host; struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f815ca0..c7d0d6a 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -618,26 +618,34 @@ bool f2fs_empty_dir(struct inode *dir) return true; } -static int f2fs_readdir(struct file *file, struct dir_context *ctx) +static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) { + unsigned long pos = file->f_pos; + unsigned char *types = NULL; + unsigned int bit_pos = 0, start_bit_pos = 0; + int over = 0; struct inode *inode = file_inode(file); unsigned long npages = dir_blocks(inode); - unsigned int bit_pos = 0; struct f2fs_dentry_block *dentry_blk = NULL; struct f2fs_dir_entry *de = NULL; struct page *dentry_page = NULL; - unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK); + unsigned int n = 0; unsigned char d_type = DT_UNKNOWN; + int slots; - bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK); + types = f2fs_filetype_table; + bit_pos = (pos % NR_DENTRY_IN_BLOCK); + n = (pos / NR_DENTRY_IN_BLOCK); for ( ; n < npages; n++) { dentry_page = get_lock_data_page(inode, n); if (IS_ERR(dentry_page)) continue; + start_bit_pos = bit_pos; dentry_blk = kmap(dentry_page); while (bit_pos < NR_DENTRY_IN_BLOCK) { + d_type = DT_UNKNOWN; bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap, NR_DENTRY_IN_BLOCK, bit_pos); @@ -645,21 +653,23 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) break; de = &dentry_blk->dentry[bit_pos]; - if (de->file_type < F2FS_FT_MAX) - d_type = f2fs_filetype_table[de->file_type]; - else - d_type = DT_UNKNOWN; - if (!dir_emit(ctx, + if (types && de->file_type < F2FS_FT_MAX) + d_type = types[de->file_type]; + + over = filldir(dirent, dentry_blk->filename[bit_pos], le16_to_cpu(de->name_len), - le32_to_cpu(de->ino), d_type)) + (n * NR_DENTRY_IN_BLOCK) + bit_pos, + le32_to_cpu(de->ino), d_type); + if (over) { + file->f_pos += bit_pos - start_bit_pos; goto stop; - - bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); - ctx->pos = n * NR_DENTRY_IN_BLOCK + bit_pos; + } + slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); + bit_pos += slots; } bit_pos = 0; - ctx->pos = (n + 1) * NR_DENTRY_IN_BLOCK; + file->f_pos = (n + 1) * NR_DENTRY_IN_BLOCK; kunmap(dentry_page); f2fs_put_page(dentry_page, 1); dentry_page = NULL; @@ -676,7 +686,7 @@ stop: const struct file_operations f2fs_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, - .iterate = f2fs_readdir, + .readdir = f2fs_readdir, .fsync = f2fs_sync_file, .unlocked_ioctl = f2fs_ioctl, }; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 07a7ae0..ad47500 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -31,6 +31,7 @@ /* * For mount options */ +#define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */ #define F2FS_MOUNT_BG_GC 0x00000001 #define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002 #define F2FS_MOUNT_DISCARD 0x00000004 @@ -1010,6 +1011,11 @@ static inline int f2fs_readonly(struct super_block *sb) return sb->s_flags & MS_RDONLY; } +static inline struct inode *file_inode(struct file *f) +{ + return f->f_path.dentry->d_inode; +} + /* * file.c */ diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c77ad4d..24a363b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -38,7 +38,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma, f2fs_balance_fs(sbi); - sb_start_pagefault(inode->i_sb); + vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); /* block allocation */ f2fs_lock_op(sbi); @@ -78,14 +78,12 @@ mapped: /* fill the page */ wait_on_page_writeback(page); out: - sb_end_pagefault(inode->i_sb); return block_page_mkwrite_return(err); } static const struct vm_operations_struct f2fs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = f2fs_vm_page_mkwrite, - .remap_pages = generic_file_remap_pages, }; static int get_parent_ino(struct inode *inode, nid_t *pino) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 599f546..a627dea 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -45,7 +45,7 @@ static int gc_thread_func(void *data) if (kthread_should_stop()) break; - if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) { + if (sbi->sb->s_frozen >= SB_FREEZE_WRITE) { wait_ms = increase_sleep_time(gc_th, wait_ms); continue; } diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 507056d..aa1c2cc 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -105,6 +105,6 @@ static inline int is_idle(struct f2fs_sb_info *sbi) { struct block_device *bdev = sbi->sb->s_bdev; struct request_queue *q = bdev_get_queue(bdev); - struct request_list *rl = &q->root_rl; + struct request_list *rl = &q->rq; return !(rl->count[BLK_RW_SYNC]) && !(rl->count[BLK_RW_ASYNC]); } diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 915f9a8..624deaf 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -83,8 +83,8 @@ static int do_read_inode(struct inode *inode) ri = F2FS_INODE(node_page); inode->i_mode = le16_to_cpu(ri->i_mode); - i_uid_write(inode, le32_to_cpu(ri->i_uid)); - i_gid_write(inode, le32_to_cpu(ri->i_gid)); + inode->i_uid = le32_to_cpu(ri->i_uid); + inode->i_gid = le32_to_cpu(ri->i_gid); set_nlink(inode, le32_to_cpu(ri->i_links)); inode->i_size = le64_to_cpu(ri->i_size); inode->i_blocks = le64_to_cpu(ri->i_blocks); @@ -181,8 +181,8 @@ void update_inode(struct inode *inode, struct page *node_page) ri->i_mode = cpu_to_le16(inode->i_mode); ri->i_advise = F2FS_I(inode)->i_advise; - ri->i_uid = cpu_to_le32(i_uid_read(inode)); - ri->i_gid = cpu_to_le32(i_gid_read(inode)); + ri->i_uid = cpu_to_le32(inode->i_uid); + ri->i_gid = cpu_to_le32(inode->i_gid); ri->i_links = cpu_to_le32(inode->i_nlink); ri->i_size = cpu_to_le64(i_size_read(inode)); ri->i_blocks = cpu_to_le64(inode->i_blocks); @@ -268,7 +268,6 @@ void f2fs_evict_inode(struct inode *inode) if (inode->i_nlink || is_bad_inode(inode)) goto no_delete; - sb_start_intwrite(inode->i_sb); set_inode_flag(F2FS_I(inode), FI_NO_ALLOC); i_size_write(inode, 0); @@ -280,7 +279,6 @@ void f2fs_evict_inode(struct inode *inode) stat_dec_inline_inode(inode); f2fs_unlock_op(sbi); - sb_end_intwrite(inode->i_sb); no_delete: - clear_inode(inode); + end_writeback(inode); } diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index a68838d..06eacf3 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -109,7 +109,7 @@ static inline void set_cold_files(struct f2fs_sb_info *sbi, struct inode *inode, } static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, - bool excl) + struct nameidata *nd) { struct super_block *sb = dir->i_sb; struct f2fs_sb_info *sbi = F2FS_SB(sb); @@ -181,7 +181,7 @@ out: struct dentry *f2fs_get_parent(struct dentry *child) { - struct qstr dotdot = QSTR_INIT("..", 2); + struct qstr dotdot = {.len = 2, .name = ".."}; unsigned long ino = f2fs_inode_by_name(child->d_inode, &dotdot); if (!ino) return ERR_PTR(-ENOENT); @@ -189,7 +189,7 @@ struct dentry *f2fs_get_parent(struct dentry *child) } static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, - unsigned int flags) + struct nameidata *nd) { struct inode *inode = NULL; struct f2fs_dir_entry *de; diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 0230326..8d7b3fb 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1276,8 +1276,7 @@ static int f2fs_set_node_page_dirty(struct page *page) return 0; } -static void f2fs_invalidate_node_page(struct page *page, unsigned int offset, - unsigned int length) +static void f2fs_invalidate_node_page(struct page *page, unsigned long offset) { struct inode *inode = page->mapping->host; struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f16da92..aac3d3d 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -545,7 +545,7 @@ static int segment_info_seq_show(struct seq_file *seq, void *offset) static int segment_info_open_fs(struct inode *inode, struct file *file) { - return single_open(file, segment_info_seq_show, PDE_DATA(inode)); + return single_open(file, segment_info_seq_show, PDE(inode)->data); } static const struct file_operations f2fs_seq_segment_info_fops = { @@ -1069,7 +1069,6 @@ static struct file_system_type f2fs_fs_type = { .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV, }; -MODULE_ALIAS_FS("f2fs"); static int __init init_inodecache(void) { -- cgit v1.1