Merge tag 'imx-drm-fixes-2016-08-30' of git://git.pengutronix.de/git/pza/linux into...
[deliverable/linux.git] / fs / f2fs / f2fs.h
index d5892f56c44d1d3db35ab5b6a25b98e36699b3f2..14f5fe2b841e2e7d4e699072cc2aeb6e1c14c645 100644 (file)
@@ -164,7 +164,7 @@ enum {
 #define BATCHED_TRIM_BLOCKS(sbi)       \
                (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg)
 #define DEF_CP_INTERVAL                        60      /* 60 secs */
-#define DEF_IDLE_INTERVAL              120     /* 2 mins */
+#define DEF_IDLE_INTERVAL              5       /* 5 secs */
 
 struct cp_control {
        int reason;
@@ -268,6 +268,8 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
 #define F2FS_IOC_GARBAGE_COLLECT       _IO(F2FS_IOCTL_MAGIC, 6)
 #define F2FS_IOC_WRITE_CHECKPOINT      _IO(F2FS_IOCTL_MAGIC, 7)
 #define F2FS_IOC_DEFRAGMENT            _IO(F2FS_IOCTL_MAGIC, 8)
+#define F2FS_IOC_MOVE_RANGE            _IOWR(F2FS_IOCTL_MAGIC, 9,      \
+                                               struct f2fs_move_range)
 
 #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
 #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
@@ -297,6 +299,13 @@ struct f2fs_defragment {
        u64 len;
 };
 
+struct f2fs_move_range {
+       u32 dst_fd;             /* destination fd */
+       u64 pos_in;             /* start position in src_fd */
+       u64 pos_out;            /* start position in dst_fd */
+       u64 len;                /* size to move */
+};
+
 /*
  * For INODE and NODE manager
  */
@@ -454,6 +463,7 @@ struct f2fs_inode_info {
        struct list_head inmem_pages;   /* inmemory pages managed by f2fs */
        struct mutex inmem_lock;        /* lock for inmemory pages */
        struct extent_tree *extent_tree;        /* cached extent_tree entry */
+       struct rw_semaphore dio_rwsem[2];/* avoid racing between dio and gc */
 };
 
 static inline void get_extent_info(struct extent_info *ext,
@@ -506,12 +516,13 @@ static inline bool __is_front_mergeable(struct extent_info *cur,
        return __is_extent_mergeable(cur, front);
 }
 
+extern void f2fs_mark_inode_dirty_sync(struct inode *);
 static inline void __try_update_largest_extent(struct inode *inode,
                        struct extent_tree *et, struct extent_node *en)
 {
        if (en->ei.len > et->largest.len) {
                et->largest = en->ei;
-               mark_inode_dirty_sync(inode);
+               f2fs_mark_inode_dirty_sync(inode);
        }
 }
 
@@ -698,14 +709,15 @@ enum page_type {
 struct f2fs_io_info {
        struct f2fs_sb_info *sbi;       /* f2fs_sb_info pointer */
        enum page_type type;    /* contains DATA/NODE/META/META_FLUSH */
-       int rw;                 /* contains R/RS/W/WS with REQ_META/REQ_PRIO */
+       int op;                 /* contains REQ_OP_ */
+       int op_flags;           /* rq_flag_bits */
        block_t new_blkaddr;    /* new block address to be written */
        block_t old_blkaddr;    /* old block address before Cow */
        struct page *page;      /* page to be written */
        struct page *encrypted_page;    /* encrypted page */
 };
 
-#define is_read_io(rw) (((rw) & 1) == READ)
+#define is_read_io(rw) (rw == READ)
 struct f2fs_bio_info {
        struct f2fs_sb_info *sbi;       /* f2fs superblock */
        struct bio *bio;                /* bios to merge */
@@ -1136,24 +1148,33 @@ static inline void f2fs_i_blocks_write(struct inode *, blkcnt_t, bool);
 static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
                                 struct inode *inode, blkcnt_t *count)
 {
+       blkcnt_t diff;
+
 #ifdef CONFIG_F2FS_FAULT_INJECTION
        if (time_to_inject(FAULT_BLOCK))
                return false;
 #endif
+       /*
+        * let's increase this in prior to actual block count change in order
+        * for f2fs_sync_file to avoid data races when deciding checkpoint.
+        */
+       percpu_counter_add(&sbi->alloc_valid_block_count, (*count));
+
        spin_lock(&sbi->stat_lock);
        sbi->total_valid_block_count += (block_t)(*count);
        if (unlikely(sbi->total_valid_block_count > sbi->user_block_count)) {
-               *count -= sbi->total_valid_block_count - sbi->user_block_count;
+               diff = sbi->total_valid_block_count - sbi->user_block_count;
+               *count -= diff;
                sbi->total_valid_block_count = sbi->user_block_count;
                if (!*count) {
                        spin_unlock(&sbi->stat_lock);
+                       percpu_counter_sub(&sbi->alloc_valid_block_count, diff);
                        return false;
                }
        }
        spin_unlock(&sbi->stat_lock);
 
        f2fs_i_blocks_write(inode, *count, true);
-       percpu_counter_add(&sbi->alloc_valid_block_count, (*count));
        return true;
 }
 
@@ -1551,7 +1572,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,
                        return;
        case FI_DATA_EXIST:
        case FI_INLINE_DOTS:
-               mark_inode_dirty_sync(inode);
+               f2fs_mark_inode_dirty_sync(inode);
        }
 }
 
@@ -1578,7 +1599,7 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode)
 {
        F2FS_I(inode)->i_acl_mode = mode;
        set_inode_flag(inode, FI_ACL_MODE);
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void f2fs_i_links_write(struct inode *inode, bool inc)
@@ -1587,7 +1608,7 @@ static inline void f2fs_i_links_write(struct inode *inode, bool inc)
                inc_nlink(inode);
        else
                drop_nlink(inode);
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void f2fs_i_blocks_write(struct inode *inode,
@@ -1598,7 +1619,7 @@ static inline void f2fs_i_blocks_write(struct inode *inode,
 
        inode->i_blocks = add ? inode->i_blocks + diff :
                                inode->i_blocks - diff;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
        if (clean || recover)
                set_inode_flag(inode, FI_AUTO_RECOVER);
 }
@@ -1612,7 +1633,7 @@ static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size)
                return;
 
        i_size_write(inode, i_size);
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
        if (clean || recover)
                set_inode_flag(inode, FI_AUTO_RECOVER);
 }
@@ -1627,19 +1648,19 @@ static inline bool f2fs_skip_inode_update(struct inode *inode)
 static inline void f2fs_i_depth_write(struct inode *inode, unsigned int depth)
 {
        F2FS_I(inode)->i_current_depth = depth;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void f2fs_i_xnid_write(struct inode *inode, nid_t xnid)
 {
        F2FS_I(inode)->i_xattr_nid = xnid;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void f2fs_i_pino_write(struct inode *inode, nid_t pino)
 {
        F2FS_I(inode)->i_pino = pino;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)
@@ -1767,13 +1788,13 @@ static inline int is_file(struct inode *inode, int type)
 static inline void set_file(struct inode *inode, int type)
 {
        F2FS_I(inode)->i_advise |= type;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline void clear_file(struct inode *inode, int type)
 {
        F2FS_I(inode)->i_advise &= ~type;
-       mark_inode_dirty_sync(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 }
 
 static inline int f2fs_readonly(struct super_block *sb)
@@ -1893,10 +1914,10 @@ struct page *init_inode_metadata(struct inode *, struct inode *,
 void update_parent_metadata(struct inode *, struct inode *, unsigned int);
 int room_for_filename(const void *, int, int);
 void f2fs_drop_nlink(struct inode *, struct inode *);
-struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
+struct f2fs_dir_entry *f2fs_find_entry(struct inode *, const struct qstr *,
                                                        struct page **);
 struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
-ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
+ino_t f2fs_inode_by_name(struct inode *, const struct qstr *, struct page **);
 void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
                                struct page *, struct inode *);
 int update_dent_inode(struct inode *, struct inode *, const struct qstr *);
@@ -1920,6 +1941,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
 /*
  * super.c
  */
+int f2fs_inode_dirtied(struct inode *);
 void f2fs_inode_synced(struct inode *);
 int f2fs_commit_super(struct f2fs_sb_info *, bool);
 int f2fs_sync_fs(struct super_block *, int);
@@ -2295,6 +2317,7 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *);
  */
 unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *, int);
 bool f2fs_init_extent_tree(struct inode *, struct f2fs_extent *);
+void f2fs_drop_extent_tree(struct inode *);
 unsigned int f2fs_destroy_extent_node(struct inode *);
 void f2fs_destroy_extent_tree(struct inode *);
 bool f2fs_lookup_extent_cache(struct inode *, pgoff_t, struct extent_info *);
This page took 0.028018 seconds and 5 git commands to generate.